9ae3a8
From 5eef8556fa85c070a242f93b675e7fb8e24a2fa0 Mon Sep 17 00:00:00 2001
9ae3a8
From: Max Reitz <mreitz@redhat.com>
9ae3a8
Date: Mon, 13 Mar 2017 17:46:56 +0100
9ae3a8
Subject: [PATCH 15/24] iotests: Fix test 039
9ae3a8
9ae3a8
RH-Author: Max Reitz <mreitz@redhat.com>
9ae3a8
Message-id: <20170313174659.29164-1-mreitz@redhat.com>
9ae3a8
Patchwork-id: 74277
9ae3a8
O-Subject: [RHEL-7.4 qemu-kvm PATCH 6/9] iotests: Fix 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
Test 039 used qemu-io -c abort for simulating a qemu crash; however,
9ae3a8
abort() generally results in a core dump and ulimit -c 0 is no reliable
9ae3a8
way of preventing that. Use "sigraise $(kill -l KILL)" instead to have
9ae3a8
it crash without a core dump.
9ae3a8
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Reviewed-by: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: 1418032092-16813-4-git-send-email-mreitz@redhat.com
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit 3f394472c5bca59de5cab9baafdff1984b0213a3)
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 tests/qemu-iotests/039     | 18 +++++++++++++-----
9ae3a8
 tests/qemu-iotests/039.out |  6 +++---
9ae3a8
 2 files changed, 16 insertions(+), 8 deletions(-)
9ae3a8
9ae3a8
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
9ae3a8
index 1e50651..ac85476 100755
9ae3a8
--- a/tests/qemu-iotests/039
9ae3a8
+++ b/tests/qemu-iotests/039
9ae3a8
@@ -46,9 +46,11 @@ _supported_proto generic
9ae3a8
 _supported_os Linux
9ae3a8
 _unsupported_qemu_io_options --nocache
9ae3a8
 
9ae3a8
-_no_dump_exec()
9ae3a8
+_subshell_exec()
9ae3a8
 {
9ae3a8
-    (ulimit -c 0; exec "$@")
9ae3a8
+    # Executing crashing commands in a subshell prevents information like the
9ae3a8
+    # "Killed" line from being lost
9ae3a8
+    (exec "$@")
9ae3a8
 }
9ae3a8
 
9ae3a8
 size=128M
9ae3a8
@@ -71,7 +73,9 @@ echo "== Creating a dirty image file =="
9ae3a8
 IMGOPTS="compat=1.1,lazy_refcounts=on"
9ae3a8
 _make_test_img $size
9ae3a8
 
9ae3a8
-_no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" 2>&1 | _filter_qemu_io
9ae3a8
+_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \
9ae3a8
+                        -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
9ae3a8
+    | _filter_qemu_io
9ae3a8
 
9ae3a8
 # The dirty bit must be set
9ae3a8
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
9ae3a8
@@ -104,7 +108,9 @@ 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
-_no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" 2>&1 | _filter_qemu_io
9ae3a8
+_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \
9ae3a8
+                        -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
9ae3a8
+    | _filter_qemu_io
9ae3a8
 
9ae3a8
 # The dirty bit must be set
9ae3a8
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
9ae3a8
@@ -120,7 +126,9 @@ echo "== Creating an image file with lazy_refcounts=off =="
9ae3a8
 IMGOPTS="compat=1.1,lazy_refcounts=off"
9ae3a8
 _make_test_img $size
9ae3a8
 
9ae3a8
-_no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" 2>&1 | _filter_qemu_io
9ae3a8
+_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \
9ae3a8
+                        -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
9ae3a8
+    | _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 af62da1..f3fe58b 100644
9ae3a8
--- a/tests/qemu-iotests/039.out
9ae3a8
+++ b/tests/qemu-iotests/039.out
9ae3a8
@@ -11,7 +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
+./039: Killed                  ( 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
@@ -46,7 +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
+./039: Killed                  ( exec "$@" )
9ae3a8
 incompatible_features     0x1
9ae3a8
 ERROR cluster 5 refcount=0 reference=1
9ae3a8
 Rebuilding refcount structure
9ae3a8
@@ -60,7 +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
+./039: Killed                  ( exec "$@" )
9ae3a8
 incompatible_features     0x0
9ae3a8
 No errors were found on the image.
9ae3a8
 *** done
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8