9ae3a8
From 3d0fa39257aac5ee843c0f3e5e69703e299bb90c Mon Sep 17 00:00:00 2001
9ae3a8
From: Max Reitz <mreitz@redhat.com>
9ae3a8
Date: Mon, 13 Mar 2017 17:46:23 +0100
9ae3a8
Subject: [PATCH 12/24] qemu-iotests: Fix core dump suppression in test 039
9ae3a8
9ae3a8
RH-Author: Max Reitz <mreitz@redhat.com>
9ae3a8
Message-id: <20170313174629.28735-1-mreitz@redhat.com>
9ae3a8
Patchwork-id: 74281
9ae3a8
O-Subject: [RHEL-7.4 qemu-kvm PATCH 3/9] qemu-iotests: Fix core dump suppression in test 039
9ae3a8
Bugzilla: 1427176
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
9ae3a8
The shell script attempts to suppress core dumps like this:
9ae3a8
9ae3a8
    old_ulimit=$(ulimit -c)
9ae3a8
    ulimit -c 0
9ae3a8
    $QEMU_IO arg...
9ae3a8
    ulimit -c "$old_ulimit"
9ae3a8
9ae3a8
This breaks the test hard unless the limit was zero to begin with!
9ae3a8
ulimit sets both hard and soft limit by default, and (re-)raising the
9ae3a8
hard limit requires privileges.  Broken since it was added in commit
9ae3a8
dc68afe.
9ae3a8
9ae3a8
Could be fixed by adding -S to set only the soft limit, but I'm not
9ae3a8
sure how portable that is in practice.  Simply do it in a subshell
9ae3a8
instead, like this:
9ae3a8
9ae3a8
    (ulimit -c 0; exec $QEMU_IO arg...)
9ae3a8
9ae3a8
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
Reviewed-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit d530e342320d4db3c9522bfadc60a7bc8142343a)
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 tests/qemu-iotests/039           | 20 ++++++++------------
9ae3a8
 tests/qemu-iotests/039.out       |  3 +++
9ae3a8
 tests/qemu-iotests/common.filter |  1 +
9ae3a8
 3 files changed, 12 insertions(+), 12 deletions(-)
9ae3a8
9ae3a8
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
9ae3a8
index 8bade92..1e50651 100755
9ae3a8
--- a/tests/qemu-iotests/039
9ae3a8
+++ b/tests/qemu-iotests/039
9ae3a8
@@ -46,6 +46,11 @@ _supported_proto generic
9ae3a8
 _supported_os Linux
9ae3a8
 _unsupported_qemu_io_options --nocache
9ae3a8
 
9ae3a8
+_no_dump_exec()
9ae3a8
+{
9ae3a8
+    (ulimit -c 0; exec "$@")
9ae3a8
+}
9ae3a8
+
9ae3a8
 size=128M
9ae3a8
 
9ae3a8
 echo
9ae3a8
@@ -66,10 +71,7 @@ echo "== Creating a dirty image file =="
9ae3a8
 IMGOPTS="compat=1.1,lazy_refcounts=on"
9ae3a8
 _make_test_img $size
9ae3a8
 
9ae3a8
-old_ulimit=$(ulimit -c)
9ae3a8
-ulimit -c 0 # do not produce a core dump on abort(3)
9ae3a8
-$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
9ae3a8
-ulimit -c "$old_ulimit"
9ae3a8
+_no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" 2>&1 | _filter_qemu_io
9ae3a8
 
9ae3a8
 # The dirty bit must be set
9ae3a8
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
9ae3a8
@@ -102,10 +104,7 @@ echo "== Opening a dirty image read/write should repair it =="
9ae3a8
 IMGOPTS="compat=1.1,lazy_refcounts=on"
9ae3a8
 _make_test_img $size
9ae3a8
 
9ae3a8
-old_ulimit=$(ulimit -c)
9ae3a8
-ulimit -c 0 # do not produce a core dump on abort(3)
9ae3a8
-$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
9ae3a8
-ulimit -c "$old_ulimit"
9ae3a8
+_no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" 2>&1 | _filter_qemu_io
9ae3a8
 
9ae3a8
 # The dirty bit must be set
9ae3a8
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
9ae3a8
@@ -121,10 +120,7 @@ echo "== Creating an image file with lazy_refcounts=off =="
9ae3a8
 IMGOPTS="compat=1.1,lazy_refcounts=off"
9ae3a8
 _make_test_img $size
9ae3a8
 
9ae3a8
-old_ulimit=$(ulimit -c)
9ae3a8
-ulimit -c 0 # do not produce a core dump on abort(3)
9ae3a8
-$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
9ae3a8
-ulimit -c "$old_ulimit"
9ae3a8
+_no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" 2>&1 | _filter_qemu_io
9ae3a8
 
9ae3a8
 # The dirty bit must not be set since lazy_refcounts=off
9ae3a8
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
9ae3a8
diff --git a/tests/qemu-iotests/039.out b/tests/qemu-iotests/039.out
9ae3a8
index d25bf0b..af62da1 100644
9ae3a8
--- a/tests/qemu-iotests/039.out
9ae3a8
+++ b/tests/qemu-iotests/039.out
9ae3a8
@@ -11,6 +11,7 @@ No errors were found on the image.
9ae3a8
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 
9ae3a8
 wrote 512/512 bytes at offset 0
9ae3a8
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
9ae3a8
+./039: Aborted                 ( ulimit -c 0; exec "$@" )
9ae3a8
 incompatible_features     0x1
9ae3a8
 ERROR cluster 5 refcount=0 reference=1
9ae3a8
 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0
9ae3a8
@@ -45,6 +46,7 @@ read 512/512 bytes at offset 0
9ae3a8
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 
9ae3a8
 wrote 512/512 bytes at offset 0
9ae3a8
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
9ae3a8
+./039: Aborted                 ( ulimit -c 0; exec "$@" )
9ae3a8
 incompatible_features     0x1
9ae3a8
 ERROR cluster 5 refcount=0 reference=1
9ae3a8
 Rebuilding refcount structure
9ae3a8
@@ -58,6 +60,7 @@ incompatible_features     0x0
9ae3a8
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 
9ae3a8
 wrote 512/512 bytes at offset 0
9ae3a8
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
9ae3a8
+./039: Aborted                 ( ulimit -c 0; exec "$@" )
9ae3a8
 incompatible_features     0x0
9ae3a8
 No errors were found on the image.
9ae3a8
 *** done
9ae3a8
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
9ae3a8
index 9c82c77..dcd246d 100644
9ae3a8
--- a/tests/qemu-iotests/common.filter
9ae3a8
+++ b/tests/qemu-iotests/common.filter
9ae3a8
@@ -150,6 +150,7 @@ _filter_win32()
9ae3a8
 _filter_qemu_io()
9ae3a8
 {
9ae3a8
     _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)/" \
9ae3a8
+        -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\)/:\1/" \
9ae3a8
         -e "s/qemu-io> //g"
9ae3a8
 }
9ae3a8
 
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8