nbdkit/0001-tests-test-captive.sh-Try-to-make-this-test-more-sta.patch

155 lines
4.2 KiB
Diff

From 376cda7c1ede6f03f8e922e7eae8f8b60cdf8e79 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 14 Nov 2019 11:11:22 +0000
Subject: [PATCH] tests/test-captive.sh: Try to make this test more stable on
slower machines.
This test relies on sending a signal to nbdkit which causes nbdkit to
exit before the captive subprocess. On slow machines (especially
armv7 and s390x in Fedora Koji) it appears that the captive subprocess
can still exit before nbdkit receives the signal, resulting in an
incorrect exit status and test failure.
There's not a lot we can do here except to increase the sleep.
Alternatives might be to try to inspect the status of the nbdkit
process to see if it has become a zombie yet, but that would be hard
to make portable.
Typical failure on armv7:
FAIL: test-captive.sh
=====================
+ fail=0
++ mktemp -u
+ sock=/tmp/tmp.bHGd8vKHxI
+ files='/tmp/tmp.bHGd8vKHxI captive.out captive.pid'
+ rm -f /tmp/tmp.bHGd8vKHxI captive.out captive.pid
+ cleanup_fn rm -f /tmp/tmp.bHGd8vKHxI captive.out captive.pid
+ _cleanup_hook[${#_cleanup_hook[@]}]='rm -f /tmp/tmp.bHGd8vKHxI captive.out captive.pid'
+ nbdkit -U /tmp/tmp.bHGd8vKHxI example1 --run '
echo nbd=$nbd; echo port=$port; echo socket=$unixsocket
'
++ cat captive.out
+ '[' 'nbd=nbd:unix:/tmp/tmp.bHGd8vKHxI
port=
socket=/tmp/tmp.bHGd8vKHxI' '!=' 'nbd=nbd:unix:/tmp/tmp.bHGd8vKHxI
port=
socket=/tmp/tmp.bHGd8vKHxI' ']'
+ status=0
+ nbdkit -U - example1 --run 'exit 2'
+ status=2
+ test 2 '!=' 2
+ test -s captive.out
+ status=0
+ nbdkit -U - -P captive.pid example1 --run '
for i in {1..60}; do
if test -s captive.pid; then break; fi
sleep 1
done
if ! test -s captive.pid; then
echo "$0: no pidfile yet"
exit 10
fi
kill -s ABRT $(cat captive.pid) || exit 10
sleep 5
'
++ kill -l ABRT
+ test 0 '!=' 134
+ echo './test-captive.sh: unexpected exit status 0'
./test-captive.sh: unexpected exit status 0
+ fail=1
+ test -s captive.out
+ exit 1
+ _run_cleanup_hooks
+ status=1
+ set +e
+ trap '' INT QUIT TERM EXIT ERR
+ echo ./test-captive.sh: run cleanup hooks: exit code 1
./test-captive.sh: run cleanup hooks: exit code 1
+ (( i = 0 ))
+ (( i < 1 ))
+ rm -f /tmp/tmp.bHGd8vKHxI captive.out captive.pid
+ (( ++i ))
+ (( i < 1 ))
+ exit 1
FAIL test-captive.sh (exit status: 1)
Typical failure on s390x:
FAIL: test-captive.sh
=====================
+ fail=0
++ mktemp -u
+ sock=/tmp/tmp.vTRXPPqeJR
+ files='/tmp/tmp.vTRXPPqeJR captive.out captive.pid'
+ rm -f /tmp/tmp.vTRXPPqeJR captive.out captive.pid
+ cleanup_fn rm -f /tmp/tmp.vTRXPPqeJR captive.out captive.pid
+ _cleanup_hook[${#_cleanup_hook[@]}]='rm -f /tmp/tmp.vTRXPPqeJR captive.out captive.pid'
+ nbdkit -U /tmp/tmp.vTRXPPqeJR example1 --run '
echo nbd=$nbd; echo port=$port; echo socket=$unixsocket
'
++ cat captive.out
+ '[' 'nbd=nbd:unix:/tmp/tmp.vTRXPPqeJR
port=
socket=/tmp/tmp.vTRXPPqeJR' '!=' 'nbd=nbd:unix:/tmp/tmp.vTRXPPqeJR
port=
socket=/tmp/tmp.vTRXPPqeJR' ']'
+ status=0
+ nbdkit -U - example1 --run 'exit 2'
+ status=2
+ test 2 '!=' 2
+ test -s captive.out
+ status=0
+ nbdkit -U - -P captive.pid example1 --run '
for i in {1..60}; do
if test -s captive.pid; then break; fi
sleep 1
done
if ! test -s captive.pid; then
echo "$0: no pidfile yet"
exit 10
fi
kill -s ABRT $(cat captive.pid) || exit 10
sleep 5
'
++ kill -l ABRT
+ test 0 '!=' 134
+ echo './test-captive.sh: unexpected exit status 0'
./test-captive.sh: unexpected exit status 0
+ fail=1
+ test -s captive.out
+ exit 1
+ _run_cleanup_hooks
+ status=1
+ set +e
+ trap '' INT QUIT TERM EXIT ERR
+ echo ./test-captive.sh: run cleanup hooks: exit code 1
./test-captive.sh: run cleanup hooks: exit code 1
+ (( i = 0 ))
+ (( i < 1 ))
+ rm -f /tmp/tmp.vTRXPPqeJR captive.out captive.pid
+ (( ++i ))
+ (( i < 1 ))
+ exit 1
FAIL test-captive.sh (exit status: 1)
---
tests/test-captive.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/test-captive.sh b/tests/test-captive.sh
index 82697a5..8762b86 100755
--- a/tests/test-captive.sh
+++ b/tests/test-captive.sh
@@ -81,7 +81,7 @@ if ! test -s captive.pid; then
exit 10
fi
kill -s ABRT $(cat captive.pid) || exit 10
-sleep 5
+sleep 10
' > captive.out || status=$?
if test $status != $(( 128 + $(kill -l ABRT) )); then
echo "$0: unexpected exit status $status"
--
2.23.0