+2011-04-22 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ testsuite: more environment sanitization
+ * tests/defs.in: Sanity check: abort if any of `parallel_tests'
+ or `required' is in the environment.
+ ($sed_unindent_prog): Initialize to empty, to avoid interferences
+ from the environment.
+ * tests/self-check-me-in-env.test: Renamed to ...
+ * tests/self-check-env-sanitize.test: ... this, and extended.
+ * tests/Makefile.am (TESTS): Update.
+ (TESTS_ENVIRONMENT): Unset variables `parallel_tests' and
+ `required'. Adjust comments.
+
2011-04-18 Stefano Lattarini <stefano.lattarini@gmail.com>
tests: don't allow `$me' to be overridden from the environment
MAINTAINERCLEANFILES = $(parallel_tests)
-# The testsuite variable `$me' should be overridable from the
+# Some testsuite-influential variables should be overridable from the
# test scripts, but not from the environment.
-TESTS_ENVIRONMENT = test x"$$me" = x || unset me;
+TESTS_ENVIRONMENT = \
+ test x"$$me" = x || unset me; \
+ test x"$$required" = x || unset required; \
+ test x"$$parallel_tests" = x || unset parallel_tests;
TESTS = \
-self-check-me-in-env.test \
+self-check-env-sanitize.test \
aclibobj.test \
aclocal.test \
aclocal3.test \
MAINTAINERCLEANFILES = $(parallel_tests)
-# The testsuite variable `$me' should be overridable from the
+# Some testsuite-influential variables should be overridable from the
# test scripts, but not from the environment.
-TESTS_ENVIRONMENT = test x"$$me" = x || unset me;
+TESTS_ENVIRONMENT = \
+ test x"$$me" = x || unset me; \
+ test x"$$required" = x || unset required; \
+ test x"$$parallel_tests" = x || unset parallel_tests;
+
TESTS = \
-self-check-me-in-env.test \
+self-check-env-sanitize.test \
aclibobj.test \
aclocal.test \
aclocal3.test \
exit 99
fi
+# 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
+
# This might be used in testcases checking distribution-related features.
# Test scripts are free to override this if they need to.
distdir=$me-1.0
fi
sed "$sed_unindent_prog" ${1+"$@"}
}
+sed_unindent_prog="" # Avoid interferences from the environment.
# Turn on shell traces.
set -x
# Sanity check for the automake testsuite.
# Make sure that the testsuite initialization code complains when
-# $me is set in the environment.
+# some testsuite-influential variables are set in the environment.
set -x
exec 5>&1
-env me=foo /bin/sh -c '. ./defs' foo.test && exit 1
-env me=foo /bin/sh -c '. ./defs' foo.test 2>&1 1>&5 \
- | grep "variable \`me' is set in the environment.*unsafe" || exit 1
+for var in me parallel_tests required; do
+ env "$var=foo" /bin/sh -c '. ./defs' foo.test && exit 1
+ env "$var=foo" /bin/sh -c '. ./defs' foo.test 2>&1 1>&5 \
+ | grep "variable \`$var' is set in the environment.*unsafe" || exit 1
+done
: