From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkXaF-0001qi-Ae for qemu-devel@nongnu.org; Wed, 14 May 2014 07:42:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkXa9-0006Fx-3H for qemu-devel@nongnu.org; Wed, 14 May 2014 07:42:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53378) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkXa8-0006Fr-R9 for qemu-devel@nongnu.org; Wed, 14 May 2014 07:42:45 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4EBghn8015034 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 14 May 2014 07:42:43 -0400 Date: Wed, 14 May 2014 13:42:38 +0200 From: Kevin Wolf Message-ID: <20140514114238.GI3610@noname.redhat.com> References: <1399970763-8102-1-git-send-email-armbru@redhat.com> <20140513092211.GD26360@T430.nay.redhat.com> <87a9aly3nx.fsf@blackfin.pond.sub.org> <20140514075815.GD3610@noname.redhat.com> <87ha4shfv5.fsf@blackfin.pond.sub.org> <87egzwehkj.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87egzwehkj.fsf@blackfin.pond.sub.org> Subject: Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Fam Zheng , qemu-devel@nongnu.org, stefanha@redhat.com Am 14.05.2014 um 13:16 hat Markus Armbruster geschrieben: > Markus Armbruster writes: > > > Kevin Wolf writes: > > > >> Am 13.05.2014 um 19:44 hat Markus Armbruster geschrieben: > >>> Fam Zheng writes: > >>> > >>> > On Tue, 05/13 10:46, Markus Armbruster wrote: > >>> >> The shell script attempts to suppress core dumps like this: > >>> >> > >>> >> old_ulimit=$(ulimit -c) > >>> >> ulimit -c 0 > >>> >> $QEMU_IO arg... > >>> >> ulimit -c "$old_ulimit" > >>> >> > >>> >> This breaks the test hard unless the limit was zero to begin with! > >>> >> ulimit sets both hard and soft limit by default, and (re-)raising the > >>> >> hard limit requires privileges. Broken since it was added in commit > >>> >> dc68afe. > >>> >> > >>> >> Could be fixed by adding -S to set only the soft limit, but I'm not > >>> >> sure how portable that is in practice. Simply do it in a subshell > >>> >> instead, like this: > >>> >> > >>> >> (ulimit -c 0; exec $QEMU_IO arg...) > >>> >> > >>> >> Signed-off-by: Markus Armbruster > >>> >> --- > >>> >> tests/qemu-iotests/039 | 18 ++++++------------ > >>> >> 1 file changed, 6 insertions(+), 12 deletions(-) > >>> >> > >>> >> diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 > >>> >> index b9cbe99..182b0f0 100755 > >>> >> --- a/tests/qemu-iotests/039 > >>> >> +++ b/tests/qemu-iotests/039 > >>> >> @@ -67,10 +67,8 @@ echo "== Creating a dirty image file ==" > >>> >> IMGOPTS="compat=1.1,lazy_refcounts=on" > >>> >> _make_test_img $size > >>> >> > >>> >> -old_ulimit=$(ulimit -c) > >>> >> -ulimit -c 0 # do not produce a core dump on abort(3) > >>> >> -$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io > >>> >> -ulimit -c "$old_ulimit" > >>> >> +(ulimit -c 0 # do not produce a core dump on abort(3) > >>> >> +exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io > >>> > > >>> > This works well. > >>> > > >>> > But when I try to put this in a function to avoid repeating: > >>> > > >>> > function _no_dump_exec() > >>> > { > >>> > (ulimit -c 0; exec "$@") > >>> > } > >>> > > >>> > _no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io > >>> > > >>> > it doesn't work: > >>> > > >>> > 039 1s ... - output mismatch (see 039.out.bad) > >>> > --- 039.out 2014-05-13 12:10:39.248866480 +0800 > >>> > +++ 039.out.bad 2014-05-13 17:19:46.161986618 +0800 > >>> > @@ -9,6 +9,7 @@ > >>> > > >>> > == Creating a dirty image file == > >>> > Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 > >>> > +./039: line 51: 10517 Aborted "$@" > >>> > wrote 512/512 bytes at offset 0 > >>> > 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > >>> > incompatible_features 0x1 > >>> > > >>> > Any idea what the difference is here? > >>> > >>> This is qemu-io aborting, as instructed. The command is > >>> > >>> qemu-io --cache writeback --cache writethrough -c 'write -P 0x5a > >>> 0 512' -c abort scratch/t.qcow2 > >>> > >>> [...] > >>> > >>> The additional "Aborted" line appears as soon as I put pass the qemu-io > >>> command to a function that runs it using "$@". I don't need a subshell, > >>> exec or anything: > >> > >> So that looks fine, I'd even consider it a feature to have the abort > >> recorded explicitly. Let's just update the reference output. Another > >> reason why qemu-iotests is bash-only, but we already have the same kind > >> of output in other test cases, so this is not setting a precedence. > > > > Okay, I'll respin it that way. > > The message printed by the shell looks like: > > ./039: line : Aborted > > Need to filter out the PID. Okay to add that to the sed script in > _filter_qemu_io, or would you like to have it elsewhere? Fine with me in _filter_qemu_io. We may later need it elsewhere too, but we can still move it then. Kevin