From 1ba58ec955f5e2f265f68e9fd615e7e3e4fb74eb Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 2 Jul 2009 11:32:39 -0600 Subject: [PATCH] Avoid syntax error in ash. * lib/autotest/general.m4 (AT_INIT) : Avoid syntax errors on shells that don't recognize <>. * tests/autotest.at (AT_SKIP_PARALLEL_TESTS): Also skip parallel tests for this reason. Skip based on the shell to be tested, not the shell driving the testsuite. (parallel syntax error): Rearrange similar to previous patch. (parallel test execution): Defer skip until after serial tests. Signed-off-by: Eric Blake --- ChangeLog | 11 +++++++++++ doc/autoconf.texi | 12 ++++++++++++ lib/autotest/general.m4 | 7 ++++--- tests/autotest.at | 30 ++++++++++++++++++++---------- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4d5d5324f..68c44906e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-07-03 Eric Blake + + Avoid syntax error in ash. + * lib/autotest/general.m4 (AT_INIT) : Avoid syntax + errors on shells that don't recognize <>. + * tests/autotest.at (AT_SKIP_PARALLEL_TESTS): Also skip parallel + tests for this reason. Skip based on the shell to be tested, + not the shell driving the testsuite. + (parallel syntax error): Rearrange similar to previous patch. + (parallel test execution): Defer skip until after serial tests. + 2009-07-02 Eric Blake Skip test on shells that can't catch syntax failure. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 04e3b10cf..3528f5325 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -14187,6 +14187,18 @@ escape, while @samp{: `cd /zorglub 2>/dev/null`} works properly. It is worth noting that Zsh (but not Ash nor Bash) makes it possible in assignments though: @samp{foo=`cd /zorglub` 2>/dev/null}. +Some shells, like @command{ash}, don't recognize bi-directional +redirection (@samp{<>}). And even on shells that recognize it, it is +not portable to use on fifos: Posix does not require read-write support +for named pipes, and Cygwin does not support it: + +@example +$ @kbd{mkfifo fifo} +$ @kbd{exec 5<>fifo} +$ @kbd{echo hi >&5} +bash: echo: write error: Communication error on send +@end example + When catering to old systems, don't redirect the same file descriptor several times, as you are doomed to failure under Ultrix. diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index ddc2270a0..50c2ff70a 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -1296,8 +1296,9 @@ at_first=: if test $at_jobs -ne 1 && rm -f "$at_job_fifo" && test -n "$at_job_group" && - ( mkfifo "$at_job_fifo" && trap 'exit 1' PIPE STOP TSTP ) 2>/dev/null && - exec AT_JOB_FIFO_FD<> "$at_job_fifo" + ( mkfifo "$at_job_fifo" && eval 'exec AT_JOB_FIFO_FD<> "$at_job_fifo"' \ + && trap 'exit 1' PIPE STOP TSTP ) 2>/dev/null && + eval 'exec AT_JOB_FIFO_FD<> "$at_job_fifo"' then # FIFO job dispatcher. @@ -1352,7 +1353,7 @@ dnl optimize away the _AT_CHECK subshell, so normalize here. dnl Ignore PIPE signals that stem from writing back the token. trap "" PIPE echo stop > "$at_stop_file" - echo token >&6 + echo token >&AT_JOB_FIFO_FD dnl Do not reraise the default PIPE handler. dnl It wreaks havoc with ksh, see above. dnl trap - 13 diff --git a/tests/autotest.at b/tests/autotest.at index 6f0bd1d5a..e83b32979 100644 --- a/tests/autotest.at +++ b/tests/autotest.at @@ -990,8 +990,11 @@ m4_define([AT_SKIP_PARALLEL_TESTS], [# Per BUGS, we have not yet figured out how to run parallel tests cleanly # under dash and some ksh variants. For now, only run this test under # limited conditions; help is appreciated in widening this test base. -AT_CHECK([test -n "${BASH_VERSION+set}${ZSH_VERSION+set}]]dnl -[[${TEST_PARALLEL_AUTOTEST+set}" || exit 77]) +AT_CHECK([${CONFIG_SHELL-$SHELL} -c 'test -n "${BASH_VERSION+set}]]dnl +[[${ZSH_VERSION+set}${TEST_PARALLEL_AUTOTEST+set}"' || exit 77]) +# The parallel scheduler requires mkfifo and bidirectional redirection to work. +AT_CHECK([mkfifo fifo || exit 77]) +AT_CHECK([${CONFIG_SHELL-$SHELL} -c 'eval "exec 5<>fifo"' || exit 77]) ]) @@ -1001,8 +1004,6 @@ AT_CHECK([test -n "${BASH_VERSION+set}${ZSH_VERSION+set}]]dnl AT_SETUP([parallel test execution]) -AT_SKIP_PARALLEL_TESTS - # This test tries to ensure that -j runs tests in parallel. # Such a test is inherently racy, because there are no real-time # guarantees about scheduling delays. So we try to minimize @@ -1053,13 +1054,17 @@ m4_for([count], [1], ]]AT_PARALLEL_NTESTS[[, [], ]) ]]) +# Even if parallel jobs are not supported, the command line must work. AT_CHECK([$CONFIG_SHELL ./micro-suite --help | grep " --jobs"], [0], [ignore]) AT_CHECK([$CONFIG_SHELL ./micro-suite -j2foo], [1], [], [stderr]) AT_CHECK([grep 'non-numeric argument' stderr], [], [ignore]) AT_CHECK([$CONFIG_SHELL ./micro-suite --jobs=foo], [1], [], [stderr]) AT_CHECK([grep 'non-numeric argument' stderr], [], [ignore]) -AT_CHECK([$CONFIG_SHELL ./micro-suite -j[]AT_PARALLEL_NJOBS], [], [stdout]) + +AT_SKIP_PARALLEL_TESTS + # Ensure that all tests run, and lines are not split. +AT_CHECK([$CONFIG_SHELL ./micro-suite -j[]AT_PARALLEL_NJOBS], [], [stdout]) AT_CHECK([grep -c '^.\{53\}ok' stdout], [], [AT_PARALLEL_NTESTS ]) # Running one test with -j should produce correctly formatted output: @@ -1074,8 +1079,6 @@ AT_CHECK([grep -c '^.\{53\}ok' stdout], [], [1 AT_CHECK([$CONFIG_SHELL ./micro-suite -j -k nomatch], [], [ignore]) AT_CHECK([$CONFIG_SHELL ./micro-suite -j3 -k nomatch], [], [ignore]) -# The parallel scheduler requires mkfifo to work. -AT_CHECK([mkfifo fifo || exit 77]) mkdir serial # Unfortunately, the return value of wait is unreliable, @@ -1113,9 +1116,16 @@ AT_CHECK_AT_TEST([parallel syntax error], AT_CLEANUP AT_SETUP([another test]) AT_CHECK([:])], - [], [1], [], [stderr], [AT_SKIP_PARALLEL_TESTS], - [AT_CHECK([grep "unable to parse test group: 2" stderr], [0], [ignore]) - AT_CHECK([$CONFIG_SHELL ./micro-suite -j 3], [0], [ignore])], [-j]) + [], [0], [], [], [AT_SKIP_PARALLEL_TESTS], + [dnl Until we can find a way to avoid catastrophic failure (ash) or + dnl lack of failure (zsh), skip the rest of this test on such shells. + echo 'if' > syntax + AT_CHECK([${CONFIG_SHELL-$SHELL} -c 'case `. ./syntax; echo $?` in + 0|"") exit 77;; + esac'], [0], [ignore], [ignore]) + AT_CHECK([$CONFIG_SHELL ./micro-suite -j], [1], [ignore], [stderr]) + AT_CHECK([grep "unable to parse test group: 2" stderr], [0], [ignore])], + [-j2 1 3]) AT_CHECK_AT_TEST([parallel errexit], [AT_CHECK([false]) -- 2.47.3