Skip to contentSkip to conversation

qemu-iotests: Fix core dump suppression in test 039

PATCH Applied Markus Armbruster 3 participants 4 messages May 14, 2014 – May 26, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-iotests: Fix core dump suppression in test 039

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...)

---
v2:
- Factor out core suppression into _no_dump_exec() [Fam]

 tests/qemu-iotests/039           | 20 ++++++++------------
 tests/qemu-iotests/039.out       |  3 +++
 tests/qemu-iotests/common.filter |  1 +
 3 files changed, 12 insertions(+), 12 deletions(-)
tests/qemu-iotests/039 +8 -12
index b9cbe99..27fe4bd 100755
@@ -47,6 +47,11 @@ _supported_os Linux
 _default_cache_mode "writethrough"
 _supported_cache_modes "writethrough"
 
+_no_dump_exec()
+{
+    (ulimit -c 0; exec "$@")
+}
+
 size=128M
 
 echo
@@ -67,10 +72,7 @@ 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"
+_no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" 2>&1 | _filter_qemu_io
 
 # The dirty bit must be set
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
@@ -103,10 +105,7 @@ echo "== Opening a dirty image read/write should repair it =="
 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"
+_no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" 2>&1 | _filter_qemu_io
 
 # The dirty bit must be set
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
@@ -122,10 +121,7 @@ echo "== Creating an image file with lazy_refcounts=off =="
 IMGOPTS="compat=1.1,lazy_refcounts=off"
 _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"
+_no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" 2>&1 | _filter_qemu_io
 
 # The dirty bit must not be set since lazy_refcounts=off
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
tests/qemu-iotests/039.out +3 -0
index fb31ae0..67e7744 100644
@@ -11,6 +11,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+./039: Aborted                 ( ulimit -c 0; exec "$@" )
 incompatible_features     0x1
 ERROR cluster 5 refcount=0 reference=1
 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0
@@ -42,6 +43,7 @@ read 512/512 bytes at offset 0
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+./039: Aborted                 ( ulimit -c 0; exec "$@" )
 incompatible_features     0x1
 Repairing cluster 5 refcount=0 reference=1
 wrote 512/512 bytes at offset 0
@@ -52,6 +54,7 @@ incompatible_features     0x0
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+./039: Aborted                 ( ulimit -c 0; exec "$@" )
 incompatible_features     0x0
 No errors were found on the image.
 
tests/qemu-iotests/common.filter +1 -0
index 776985d..a04df7f 100644
@@ -150,6 +150,7 @@ _filter_win32()
 _filter_qemu_io()
 {
     _filter_win32 | sed -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" \
+        -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\)/:\1/" \
         -e "s/qemu-io> //g"
 }
 
Signature · 1 line
1.8.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Markus Armbruster

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.

Quoted 7 lines

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...)
Applied
#2 lore raw

Am 14.05.2014 um 15:28 hat Fam Zheng geschrieben:

Quoted 17 lines · Markus Armbruster
Quoted 16 lines

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:

Quoted 5 lines
Quoted 3 lines
    (ulimit -c 0; exec $QEMU_IO arg...)

Thanks, applied to the block branch.

Kevin

#3 lore raw
Quoted 18 lines · Kevin Wolf

Am 14.05.2014 um 15:28 hat Fam Zheng geschrieben:

Quoted 17 lines · Markus Armbruster
Quoted 16 lines

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:

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
    (ulimit -c 0; exec $QEMU_IO arg...)

Thanks, applied to the block branch.

I just got this on a system with abrt installed:

039 3s ... - output mismatch (see 039.out.bad)

039.out.bad renamed from 039.out +1 -1
@@ -11,7 +11,7 @@
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./039: Aborted                 ( ulimit -c 0; exec "$@" )
+./039: Aborted                 (core dumped) ( ulimit -c 0; exec "$@" )
 incompatible_features     0x1
 ERROR cluster 5 refcount=0 reference=1
 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0

[...]

I immediately erased abrt, as I have no use for it.