>From 97bc61135228ae02dd390086ad555bb839582ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?=
Date: Sat, 19 Nov 2016 11:14:49 +0000 Subject: [PATCH 1/3] tests: fix recent tail-2 test regressions * tests/tail-2/pipe-f.sh: Avoid issue with readable directories on BSD systems. * tests/tail-2/retry.sh: Likewise. Reported by Assaf Gordon --- tests/tail-2/pipe-f.sh | 5 +---- tests/tail-2/retry.sh | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/tail-2/pipe-f.sh b/tests/tail-2/pipe-f.sh index 82364da..3c98266 100755 --- a/tests/tail-2/pipe-f.sh +++ b/tests/tail-2/pipe-f.sh @@ -23,13 +23,10 @@ echo oo > exp || framework_failure_ echo foo | timeout 10 tail -f -c3 > out || fail=1 compare exp out || fail=1 -cat <<\EOF > exp +cat <<\EOF > exp || framework_failure_ ==> standard input <== ar - -==> missing <== EOF -mkdir missing || framework_failure_ echo bar | returns_ 1 timeout 10 tail -f -c3 - missing > out || fail=1 compare exp out || fail=1 diff --git a/tests/tail-2/retry.sh b/tests/tail-2/retry.sh index 7829923..1ab09dd 100755 --- a/tests/tail-2/retry.sh +++ b/tests/tail-2/retry.sh @@ -148,6 +148,7 @@ returns_ 1 tail $mode --follow=descriptor missing >out 2>&1 || fail=1 [ "$(countlines_)" = 2 ] || { fail=1; cat out; } grep -F 'cannot open' out || { fail=1; cat out; } grep -F 'no files remaining' out || { fail=1; cat out; } +rm -f out || framework_failure_ # === Test: # Likewise for --follow=name (without --retry). @@ -155,10 +156,12 @@ returns_ 1 tail $mode --follow=name missing >out 2>&1 || fail=1 [ "$(countlines_)" = 2 ] || { fail=1; cat out; } grep -F 'cannot open' out || { fail=1; cat out; } grep -F 'no files remaining' out || { fail=1; cat out; } +rm -f out || framework_failure_ # === Test: # Ensure that tail -F retries when the file is initially untailable. -mkdir untailable +if ! cat . >/dev/null; then +mkdir untailable || framework_failure_ timeout 10 \ tail $mode $fastpoll -F untailable >out 2>&1 & pid=$! # Wait for "cannot open" error. @@ -172,6 +175,7 @@ grep -F 'cannot follow' out || { fail=1; cat out; } grep -F 'has become accessible' out || { fail=1; cat out; } grep -F 'foo' out || { fail=1; cat out; } rm -fd untailable out || framework_failure_ +fi done -- 2.5.5 >From 9c69958c3f9f7b19935683cd481737a31267f282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Tue, 22 Nov 2016 01:23:22 +0000 Subject: [PATCH 2/3] tests: fix false fails due to passing env vars to returns_ On BSD /bin/sh it was seen that unexported env vars passed to returns_() would not be propagated to the wrapped command. * cfg.mk (sc_prohibit_env_returns): Add a syntax check to disallow. * tests/misc/csplit-io-err.sh: Rearrange to export vars in a subshell. * tests/rm/rm-readdir-fail.sh: Likewise. * tests/misc/nohup.sh: Check $? manually rather than using returns_. * tests/misc/printenv.sh: Likewise. Reported by Assaf Gordon --- cfg.mk | 8 ++++++++ tests/misc/csplit-io-err.sh | 6 +++--- tests/misc/nohup.sh | 3 ++- tests/misc/printenv.sh | 6 ++++-- tests/rm/rm-readdir-fail.sh | 3 ++- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/cfg.mk b/cfg.mk index a1ac6ed..b4e8ad8 100644 --- a/cfg.mk +++ b/cfg.mk @@ -507,6 +507,14 @@ sc_prohibit_and_fail_1: in_vc_files='^tests/' \ $(_sc_search_regexp) +# Ensure that env vars are not passed through returns_ as +# that was seen to fail on FreeBSD /bin/sh at least +sc_prohibit_env_returns: + @prohibit='=[^ ]* returns_ ' \ + halt='Passing env vars to returns_ is non portable' \ + in_vc_files='^tests/' \ + $(_sc_search_regexp) + # The mode part of a setfacl -m option argument must be three bytes long. # I.e., an argument of user:bin:rw or user:bin:r will make Solaris 10's # setfacl reject it with: "Unrecognized character found in mode field". diff --git a/tests/misc/csplit-io-err.sh b/tests/misc/csplit-io-err.sh index 982df16..900e38b 100755 --- a/tests/misc/csplit-io-err.sh +++ b/tests/misc/csplit-io-err.sh @@ -66,9 +66,9 @@ gcc_shared_ k.c k.so \ # Split the input, and force fwrite() failure - # the 'csplit' command should fail with exit code 1 # (checked with 'returns_ 1 ... || fail=1') -seq 10 \ - | LD_PRELOAD=$LD_PRELOAD:./k.so returns_ 1 csplit - 1 4 2>out \ - || fail=1 +seq 10 | +(export LD_PRELOAD=$LD_PRELOAD:./k.so + returns_ 1 csplit - 1 4 2>out) || fail=1 test -e preloaded || skip_ 'LD_PRELOAD interception failed' diff --git a/tests/misc/nohup.sh b/tests/misc/nohup.sh index e9c8c38..e25b5da 100755 --- a/tests/misc/nohup.sh +++ b/tests/misc/nohup.sh @@ -118,6 +118,7 @@ EOF # Make sure it fails with exit status of 125 when given too few arguments, # except that POSIX requires 127 in this case. returns_ 125 nohup >/dev/null 2>&1 || fail=1 -POSIXLY_CORRECT=1 returns_ 127 nohup >/dev/null 2>&1 || fail=1 +POSIXLY_CORRECT=1 nohup >/dev/null 2>&1 +test $? = 127 || fail=1 Exit $fail diff --git a/tests/misc/printenv.sh b/tests/misc/printenv.sh index 2017e5d..a16d90e 100755 --- a/tests/misc/printenv.sh +++ b/tests/misc/printenv.sh @@ -59,8 +59,10 @@ EOF compare exp out || fail=1 # Exit status reflects missing variable, but remaining arguments processed. -ENV_TEST1=a returns_ 1 env -- printenv ENV_TEST2 ENV_TEST1 > out || fail=1 -ENV_TEST1=a returns_ 1 env -- printenv ENV_TEST1 ENV_TEST2 >> out || fail=1 +ENV_TEST1=a env -- printenv ENV_TEST2 ENV_TEST1 > out +test $? = 1 || fail=1 +ENV_TEST1=a env -- printenv ENV_TEST1 ENV_TEST2 >> out +test $? = 1 || fail=1 cat <