From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [kvm-unit-tests PATCH 1/3] run_tests.sh: reduce return code ambiguity Date: Tue, 22 Dec 2015 18:29:33 +0100 Message-ID: <20151222172933.GA19037@potion.brq.redhat.com> References: <1450383054-9724-1-git-send-email-drjones@redhat.com> <1450383054-9724-2-git-send-email-drjones@redhat.com> <20151221163124.GA7061@potion.redhat.com> <20151221193510.GA5123@hawk.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org, pbonzini@redhat.com To: Andrew Jones Return-path: Received: from mx1.redhat.com ([209.132.183.28]:42555 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754792AbbLVR3h (ORCPT ); Tue, 22 Dec 2015 12:29:37 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 2631813A6A for ; Tue, 22 Dec 2015 17:29:37 +0000 (UTC) Content-Disposition: inline In-Reply-To: <20151221193510.GA5123@hawk.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: 2015-12-21 13:35-0600, Andrew Jones: > On Mon, Dec 21, 2015 at 05:31:24PM +0100, Radim Kr=C4=8Dm=C3=A1=C5=99= wrote: > > 2015-12-17 14:10-0600, Andrew Jones: >> > 128 =3D exited because of signal $? - 128 >> * =3D unit-test failed >>=20 >> (Signal 0 is not used, so we could map 128 to mean "debug-exit proba= bly >> wasn't called", but others might not understand our signal conventi= on. >=20 > I think we want 128 to be the beginning of signal space, which goes a= ll > the way up to 255, in order to allow exit code masking to work. >=20 >> Anyway, it'd be best for us to start at 200, for `case $? in 2??)` = =2E..) >=20 > Start what at 200? Signals, signal =3D $? - 200. Shell default to decimal representation = of numbers, so using binary steps doesn't give an advantage and 55 is stil= l a plenty of space. (I deplore elif cascade on the same variable, but w= e can always convert the $? to binary/octal/hex, for `case` decoding. :]) > I think we have everything covered above. The mapp= ing > looks like this >=20 > 0 =3D success > 1-63 =3D unit test failure code > 64-127 =3D test suite failure code 77 is not that easy to categorize -- we want to return it from both. > 128-255 =3D signal >=20 > which sounds good to me. To me as well. >> > Signed-off-by: Andrew Jones >> > --- >> > diff --git a/run_tests.sh b/run_tests.sh >> > @@ -54,10 +55,32 @@ function run() >> > =20 >> > # extra_params in the config file may contain backticks that = need to be >> > # expanded, so use eval to start qemu >> > - eval $cmdline >> test.log >> > + errlog=3D$(mktemp) >> > + eval $cmdline >> test.log 2> $errlog >> | [...] >> | cat $errlog >> test.log >>=20 >> This assumes that stderr is always after stdout, >=20 > True. I'm not sure that matters when the unit test, which only uses s= tdout > will always output stuff serially with qemu, which could output a mix= =2E But > your version below is fine by me if we want to pick up the need for t= he > pipe and tee. Yeah, I assume that QEMU can warn during the test, or interact with its own stdout in an ordered manner. I don't think it matter much, but there isn't a significant draw-back. >> eval $cmdline 2>&1 >> test.log | tee $errlog >> test.log >>=20 >> has a chance to print lines in wrong order too, but I think it's goi= ng >> to be closer to the original. >=20 > I'll play with it and send a v2 soon. Thanks, though I am quite distracted during the end of the year, so "soon" won't be truly appreciated. :)