]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
testsuite: more environment sanitization
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 29 Apr 2011 17:45:40 +0000 (19:45 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 29 Apr 2011 18:25:03 +0000 (20:25 +0200)
* tests/defs: Move the checks verifying that the variables `me',
`parallel_tests' and `required' aren't set in the environment ...
* tests/defs-static.in: ... in here, with some optimizations to
avoid useless forks.  Also, do the same checks for the variables
`original_AUTOMAKE' and `original_ACLOCAL' too.
* tests/self-check-env-sanitize.test: Update.
* tests/Makefile.am (TESTS_ENVIRONMENT): Unset also variables
`original_AUTOMAKE' and `original_ACLOCAL'.

ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/defs
tests/defs-static.in
tests/self-check-env-sanitize.test

index 63a82feb3eb29f5123fe1e8d52697bd3daeb95e9..b52a375bc7967ca4b381b175b7c8d358e5705899 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-04-29  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       testsuite: more environment sanitization
+       * tests/defs: Move the checks verifying that the variables `me',
+       `parallel_tests' and `required' aren't set in the environment ...
+       * tests/defs-static.in: ... in here, with some optimizations to
+       avoid useless forks.  Also, do the same checks for the variables
+       `original_AUTOMAKE' and `original_ACLOCAL' too.
+       * tests/self-check-env-sanitize.test: Update.
+       * tests/Makefile.am (TESTS_ENVIRONMENT): Unset also variables
+       `original_AUTOMAKE' and `original_ACLOCAL'.
+
 2011-04-24  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        tests: fix spurious failure (non-renamed AM_TESTS_SETUP usage)
index 9b91fb1ac00e09b5a585c068e774ef7a338406b9..0eba42331bd1441e5534afbbdcd675b0f0faa484 100644 (file)
@@ -103,7 +103,9 @@ XFAIL_TESTS += $(instspc_xfail_tests)
 AM_TESTS_ENVIRONMENT = \
   test x"$$me" = x || unset me; \
   test x"$$required" = x || unset required; \
-  test x"$$parallel_tests" = x || unset parallel_tests;
+  test x"$$parallel_tests" = x || unset parallel_tests; \
+  test x"$$original_AUTOMAKE" = x || unset original_AUTOMAKE; \
+  test x"$$original_ACLOCAL" = x || unset original_ACLOCAL;
 
 TESTS = \
 aclocal.test \
index 0fd70b57e35b1e67a713e6a3bc133d12454a3b80..308b2b293eb241b9e81bd1502850ea823295feb8 100644 (file)
@@ -368,7 +368,9 @@ instspc_xfail_tests = instspc-squote-build.test \
 AM_TESTS_ENVIRONMENT = \
   test x"$$me" = x || unset me; \
   test x"$$required" = x || unset required; \
-  test x"$$parallel_tests" = x || unset parallel_tests;
+  test x"$$parallel_tests" = x || unset parallel_tests; \
+  test x"$$original_AUTOMAKE" = x || unset original_AUTOMAKE; \
+  test x"$$original_ACLOCAL" = x || unset original_ACLOCAL;
 
 TESTS = \
 aclocal.test \
index 4f035f73e625e8912a49326963082aa71efed6c8..46ff08b2ea954138de3b3b41c56bdd7c5f6fefa4 100644 (file)
@@ -40,9 +40,6 @@ if test -z "$me"; then
   me=`echo "$argv0" | sed -e 's,.*[\\/],,;s/\.test$//'` \
     && test -n "$me" \
     || { echo "$argv0: failed to define \$me" >&2; exit 99; }
-elif env | grep '^me=' >/dev/null; then
-  echo "$0: variable \`me' is set in the environment: this is unsafe" >&2
-  exit 99
 fi
 
 ## ---------------------------------------- ##
@@ -73,16 +70,6 @@ test -f "$testbuilddir/defs-static" || {
    exit 99
 }
 
-# Check that the environment is properly sanitized.
-for var in required parallel_tests; do
-  if env | grep "^$var=" >/dev/null; then
-    echo "$me: variable \`$var' is set in the environment:" \
-         "this is unsafe" >&2
-    exit 99
-  fi
-done
-unset var
-
 # Unset some MAKE... variables that may cause $MAKE to act like a
 # recursively invoked sub-make.  Any $MAKE invocation in a test is
 # conceptually an independent invocation, not part of the main
index 9016207121f454c4cfedf9d8e694d8cc97cd7906..45f08bfa87a98a58a1f0797ed63aa3494f7f5dc4 100644 (file)
@@ -63,6 +63,18 @@ else
   case `(set -o) 2>/dev/null || :` in *posix*) set -o posix;; esac
 fi
 
+# Check that the environment is properly sanitized.
+# Having variables exported to the empty string is OK, since our code
+# treats such variables as if they were unset.
+for var in me required parallel_tests original_AUTOMAKE original_ACLOCAL; do
+  if eval "test x\"\$$var\" != x" && env | grep "^$var=" >/dev/null; then
+    echo "$argv0: variable \`$var' is set in the environment:" \
+         "this is unsafe" >&2
+    exit 99
+  fi
+done
+unset var
+
 testsrcdir='@abs_srcdir@'
 top_testsrcdir='@abs_top_srcdir@'
 testbuilddir='@abs_builddir@'
index 3a07c912f24a53e6836d99620a169d5a7db5bc8f..169f00367c9885ef2d382a2ee4cffc82576d78bf 100755 (executable)
 set -x
 exec 5>&1
 
-for var in me parallel_tests required; do
+for var in me parallel_tests required original_AUTOMAKE original_ACLOCAL; do
   env "$var=foo" $SHELL -c '. ./defs' foo.test && exit 1
   env "$var=foo" $SHELL -c '. ./defs' foo.test 2>&1 1>&5 \
-    | grep "variable \`$var' is set in the environment.*unsafe" || exit 1
+    | grep "foo\.test:.* variable \`$var'.* in the environment.*unsafe" || exit 1
 done
 
 :