Re: [kvm-unit-tests RFC PATCH 1/5] lib: arm: Print test exit status on exit if chr-testdev is not av

Nadav Amit <[email protected]>
Newsgroups org.kernel.vger.kvm-ppc,dev.linux.lists.kvmarm,org.kernel.vger.kvm,org.kernel.vger.linux-s390
Message-ID <[email protected]>

> On Jul 12, 2021, at 10:07 AM, Andrew Jones <[email protected]> wrote:
> 
> On Mon, Jul 12, 2021 at 05:51:55PM +0100, Andre Przywara wrote:
>> On Fri,  2 Jul 2021 17:31:18 +0100
>> Alexandru Elisei <[email protected]> wrote:
>> 
>> Hi,
>> 
>>> The arm64 tests can be run under kvmtool, which doesn't emulate a
>>> chr-testdev device. In preparation for adding run script support for
>>> kvmtool, print the test exit status so the scripts can pick it up and
>>> correctly mark the test as pass or fail.
>>> 
>>> Signed-off-by: Alexandru Elisei <[email protected]>
>>> ---
>>> lib/chr-testdev.h |  1 +
>>> lib/arm/io.c      | 10 +++++++++-
>>> lib/chr-testdev.c |  5 +++++
>>> 3 files changed, 15 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/lib/chr-testdev.h b/lib/chr-testdev.h
>>> index ffd9a851aa9b..09b4b424670e 100644
>>> --- a/lib/chr-testdev.h
>>> +++ b/lib/chr-testdev.h
>>> @@ -11,4 +11,5 @@
>>>  */
>>> extern void chr_testdev_init(void);
>>> extern void chr_testdev_exit(int code);
>>> +extern bool chr_testdev_available(void);
>>> #endif
>>> diff --git a/lib/arm/io.c b/lib/arm/io.c
>>> index 343e10822263..9e62b571a91b 100644
>>> --- a/lib/arm/io.c
>>> +++ b/lib/arm/io.c
>>> @@ -125,7 +125,15 @@ extern void halt(int code);
>>> 
>>> void exit(int code)
>>> {
>>> -	chr_testdev_exit(code);
>>> +	if (chr_testdev_available()) {
>>> +		chr_testdev_exit(code);
>>> +	} else {
>>> +		/*
>>> +		 * Print the test return code in the format used by chr-testdev
>>> +		 * so the runner script can parse it.
>>> +		 */
>>> +		printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1);
>> 
>> It's more me being clueless here rather than a problem, but where does
>> this "EXIT: STATUS" line come from? In lib/chr-testdev.c I see "%dq",
>> so it this coming from QEMU (but I couldn't find it in there)?
>> 
>> But anyways the patch looks good and matches what PPC and s390 do.
> 
> I invented the 'EXIT: STATUS' format for PPC, which didn't/doesn't have an
> exit code testdev. Now that it has also been adopted by s390 I guess we've
> got a kvm-unit-tests standard to follow for arm :-)

I was unaware of this “standard” and I mistakenly used a different format
for x86, in case someone wants to fix it. [1]

[1] https://gitlab.com/kvm-unit-tests/kvm-unit-tests/-/commit/5747945371b47c51cb16187a26111d06f58f06b2
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEESJL3osl5Ymx/w9I1HaAqSabaD1oFAmDsd/0ACgkQHaAqSaba
D1qcGg//YR7HD5To5tLeXN8Sr9qEqR48YInrt1N2wDkBtgLyixAUA6PPVBfKGPA+
pbV06doi6bj9rF1eHSF/hz2XX3KFp2Z7pmn072Rg3uNMoX857kVJtv+mcPePLsEE
eQ7AZ2ofYf/Oo/xeQI14uoeHOLz276s962h6Vz5+dwfodFSOZ5Q4S2n3BZIkdSVJ
Y1ieWWIlMrerYnIUYJ5yF4yG+PtUFhE7KHoXOhoDFKXlZJ/c/fHZiuA43DlrrSEl
0ycMcKRzdgqyLE3Kd4mvi6A8kKr0piZCABGlrgGib4duoFGyUxkjgDWUqRrnebRr
f6OR57XzMAdnic8MbqdKIvC+Z8LYbE/vOBSrKj3yvjQvXvwbIgZr5tejIutIT7jD
EIVBbqemZ5eKPN3bqIHArNB4t+eO6kroSCgeQVQ0fcg06r/5mxow2qTSt9BQ+DdG
gnSbSugOfdBCnVw6ZC16oR8uxRUcF3UTAfG1SyDAMC9IX9ZbMPpOo9vNhizdUrrV
EU4sc2WVDH5qgr5LYTEm3G+iaBJd8P6JF/qa+2V6dq0UsZTB1OPTUA95zPLRubZ2
PjfZuoxVwx9g9yPDVQaCIicO461N0o92gxfU4pYAST3tNhO1/AcELzUsphDi8eQ8
nAOl4nmKoOVkWpEsy4YQ89o5C7R4zF1lhyfIAAcEM40rZjw8AKw=
=tyb3
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.