From cdf9779d17efa9ffc7ed14e206b6c64350591f2d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 14 Nov 2019 11:24:53 +0000 Subject: [PATCH] Add upstream patch to try to make test-captive more stable. --- ...ve.sh-Try-to-make-this-test-more-sta.patch | 154 ++++++++++++++++++ nbdkit.spec | 3 + 2 files changed, 157 insertions(+) create mode 100644 0001-tests-test-captive.sh-Try-to-make-this-test-more-sta.patch diff --git a/0001-tests-test-captive.sh-Try-to-make-this-test-more-sta.patch b/0001-tests-test-captive.sh-Try-to-make-this-test-more-sta.patch new file mode 100644 index 0000000..22d9ed2 --- /dev/null +++ b/0001-tests-test-captive.sh-Try-to-make-this-test-more-sta.patch @@ -0,0 +1,154 @@ +From 376cda7c1ede6f03f8e922e7eae8f8b60cdf8e79 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +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 + diff --git a/nbdkit.spec b/nbdkit.spec index b34f268..d6309bc 100644 --- a/nbdkit.spec +++ b/nbdkit.spec @@ -41,6 +41,9 @@ Source1: http://libguestfs.org/download/nbdkit/%{source_directory}/%{name Source2: libguestfs.keyring %endif +# Upstream patch to try to make test-captive more stable. +Patch1: 0001-tests-test-captive.sh-Try-to-make-this-test-more-sta.patch + %if 0%{patches_touch_autotools} BuildRequires: autoconf, automake, libtool %endif