From: Stefano Lattarini Date: Mon, 6 Jun 2011 09:32:19 +0000 (+0200) Subject: tests defs: better requirements for XSI shells X-Git-Tag: ng-0.5a~89^2~196^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fe3c3285ba595cf5ce585b61f9f423714a66d96;p=thirdparty%2Fautomake.git tests defs: better requirements for XSI shells This change avoids potential spurious failures with tests using the requirement 'xsi-shell' to mean that they want */bin/sh* (not $SHELL) to be XSI-conforming. This idiom used to work before commit `v1.11-874-g1321be7' (as back then the test scripts were unconditionally run with /bin/sh), but has become inconsistent now that the test scripts re-execute themselves with configure determined $SHELL. The described spurious failures have already occurred in practice, for examples on Solaris systems which also had GNU Bash installed. From a suggestion by Peter Rosin. See discussion at: * tests/defs (xsi-shell): Now check that $SHELL, rather than the shell currently running the test script, is an XSI shell. (xsi-bin-sh): New requirement, checking that /bin/sh (which can differ from $SHELL) is an XSI shell. (xsi-lib-shell): New requirement, checking that the shell that should be used to test the Automake-provided scripts from `lib/' is an XSI shell. For the moment, this is just an alias for `xsi-bin-sh'. (require_xsi): New subroutine, used to factor out code common to the requirements above. ($xsi_shell_code): New variable, contains shell code supposed to work only with XSI shells. Used by the new subroutine above. * tests/ar-lib.test ($required): Require 'xsi-lib-shell' instead of 'xsi-shell', since the script we test here is run with /bin/sh, not with $SHELL. * tests/compile3.test: Likewise. * tests/compile6.test: Likewise. --- diff --git a/ChangeLog b/ChangeLog index 569f44add..744a9939f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2011-06-07 Stefano Lattarini + + tests defs: better requirements for XSI shells + This change avoids potential spurious failures with tests using + the requirement 'xsi-shell' to mean that they want */bin/sh* (not + $SHELL) to be XSI-conforming. This idiom used to work before + commit `v1.11-874-g1321be7' (as back then the test scripts were + unconditionally run with /bin/sh), but has become inconsistent + now that the test scripts re-execute themselves with configure + determined $SHELL. + The described spurious failures have already occurred in practice, + for examples on Solaris systems which also had GNU Bash installed. + From a suggestion by Peter Rosin. See discussion at: + + * tests/defs (xsi-shell): Now check that $SHELL, rather than the + shell currently running the test script, is an XSI shell. + (xsi-bin-sh): New requirement, checking that /bin/sh (which can + differ from $SHELL) is an XSI shell. + (xsi-lib-shell): New requirement, checking that the shell that + should be used to test the Automake-provided scripts from `lib/' + is an XSI shell. For the moment, this is just an alias for + `xsi-bin-sh'. + (require_xsi): New subroutine, used to factor out code common to + the requirements above. + ($xsi_shell_code): New variable, contains shell code supposed to + work only with XSI shells. Used by the new subroutine above. + * tests/ar-lib.test ($required): Require 'xsi-lib-shell' instead + of 'xsi-shell', since the script we test here is run with /bin/sh, + not with $SHELL. + * tests/compile3.test: Likewise. + * tests/compile6.test: Likewise. + 2011-06-02 Stefano Lattarini self tests: fix another spurious failure diff --git a/tests/ar-lib.test b/tests/ar-lib.test index 7168ecd3a..9936c0e8d 100755 --- a/tests/ar-lib.test +++ b/tests/ar-lib.test @@ -16,7 +16,7 @@ # Make sure `ar-lib' wraps the Microsoft Library Manager (lib) correctly -required=xsi-shell +required=xsi-lib-shell . ./defs || Exit 1 cp "$top_testsrcdir/lib/ar-lib" . diff --git a/tests/compile3.test b/tests/compile3.test index f949d1c2d..61cde6bfb 100755 --- a/tests/compile3.test +++ b/tests/compile3.test @@ -16,7 +16,7 @@ # Make sure `compile' wraps the Microsoft C/C++ compiler (cl) correctly -required=xsi-shell +required=xsi-lib-shell . ./defs || Exit 1 cp "$top_testsrcdir/lib/compile" . diff --git a/tests/compile6.test b/tests/compile6.test index 02feb4b6d..ca1c67178 100755 --- a/tests/compile6.test +++ b/tests/compile6.test @@ -16,7 +16,7 @@ # Make sure `compile' searches libraries correctly -required=xsi-shell +required=xsi-lib-shell . ./defs || Exit 1 cp "$top_testsrcdir/lib/compile" . diff --git a/tests/defs b/tests/defs index ea036f87c..55596cf74 100644 --- a/tests/defs +++ b/tests/defs @@ -283,6 +283,24 @@ unindent () } sed_unindent_prog="" # Avoid interferences from the environment. +# require_xsi SHELL +# ----------------- +# Skip the test if the given shell fails to support common XSI constructs. +require_xsi () +{ + test $# -eq 1 || framework_failure_ "require_xsi needs exactly one arg" + echo "$me: trying some XSI constructs with $1" + $1 -c "$xsi_shell_code" || skip_ "$1 lacks XSI features" +} +# Shell code supposed to work only with XSI shells. Keep this in sync +# with libtool.m4:_LT_CHECK_SHELL_FEATURES. +xsi_shell_code=' + _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,b/c, \ + && eval '\''test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5'\' + ## ----------------------------------------------------------- ## ## Checks for required tools, and additional setups (if any) ## @@ -316,6 +334,12 @@ do test "$FC" = false && skip_ "no Fortran compiler available";; fortran77) test "$F77" = false && skip_ "no Fortran 77 compiler available";; + xsi-shell) + require_xsi "$SHELL";; + xsi-bin-sh) + require_xsi "/bin/sh";; + xsi-lib-shell) + require_xsi "/bin/sh";; bzip2) # Do not use --version, bzip2 still tries to compress stdin. echo "$me: running bzip2 --help" @@ -509,17 +533,6 @@ do texi2dvi -o /dev/null --version \ || skip_ "required program \`texi2dvi' not available" ;; - xsi-shell) - # Try some XSI features. - # Keep this in sync with libtool.m4:_LT_CHECK_SHELL_FEATURES. - echo "$me: trying some XSI constructs" - ( _am_dummy="a/b/c" - test "${_am_dummy##*/},${_am_dummy%/*},${_am_dummy#??}"${_am_dummy%"$_am_dummy"}, \ - = c,a/b,b/c, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_am_dummy}" -eq 5' ) \ - || skip_ "the shell lacks some required XSI features" - ;; flex) # Since flex is required, we pick LEX for ./configure. LEX=flex