automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FYI] {master} testsuite: more environment sanitization


From: Stefano Lattarini
Subject: [FYI] {master} testsuite: more environment sanitization
Date: Fri, 29 Apr 2011 20:29:08 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

* 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                          |   12 ++++++++++++
 tests/Makefile.am                  |    4 +++-
 tests/Makefile.in                  |    4 +++-
 tests/defs                         |   13 -------------
 tests/defs-static.in               |   12 ++++++++++++
 tests/self-check-env-sanitize.test |    4 ++--
 6 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 63a82fe..b52a375 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-04-29  Stefano Lattarini  <address@hidden>
+
+       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  <address@hidden>
 
        tests: fix spurious failure (non-renamed AM_TESTS_SETUP usage)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9b91fb1..0eba423 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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 \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 0fd70b5..308b2b2 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -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 \
diff --git a/tests/defs b/tests/defs
index 4f035f7..46ff08b 100644
--- a/tests/defs
+++ b/tests/defs
@@ -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
diff --git a/tests/defs-static.in b/tests/defs-static.in
index 9016207..45f08bf 100644
--- a/tests/defs-static.in
+++ b/tests/defs-static.in
@@ -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@'
diff --git a/tests/self-check-env-sanitize.test 
b/tests/self-check-env-sanitize.test
index 3a07c91..169f003 100755
--- a/tests/self-check-env-sanitize.test
+++ b/tests/self-check-env-sanitize.test
@@ -23,10 +23,10 @@
 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
 
 :
-- 
1.7.2.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]