+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)
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 \
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 \
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
## ---------------------------------------- ##
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
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@'
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
: