]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: don't allow `$me' to be overridden from the environment
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 17 Apr 2011 22:29:19 +0000 (00:29 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 19 Apr 2011 20:36:34 +0000 (22:36 +0200)
* tests/defs.in: Sanity check: abort if $me is in the environment.
* tests/self-check-me-in-env.test: New test.
* tests/Makefile.am (TESTS_ENVIRONMENT): Unset variable `me'.
(TESTS): Update.

Suggestion by Ralf Wildenhues.

ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/defs.in
tests/self-check-me-in-env.test [new file with mode: 0755]

index bdb49dbaa03e7e06e589767e3717f11f983e972f..b139a98d003c0f26ff3409b23474402bdc534149 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-04-18  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       tests: don't allow `$me' to be overridden from the environment
+       * tests/defs.in: Sanity check: abort if $me is in the environment.
+       * tests/self-check-me-in-env.test: New test.
+       * tests/Makefile.am (TESTS_ENVIRONMENT): Unset variable `me'.
+       (TESTS): Update.
+       Suggestion by Ralf Wildenhues.
+
 2011-04-17  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        test defs: allow overriding of `$me'
index b91a02597706e01c7a4b66957a43576b44343fd0..cc25167ed6ffd2a20a6b63d9737a90a7beb0f51a 100644 (file)
@@ -38,7 +38,12 @@ $(parallel_tests): $(parallel_tests:-p.test=.test) Makefile.am
 
 MAINTAINERCLEANFILES = $(parallel_tests)
 
+# The testsuite variable `$me' should be overridable from the
+# test scripts, but not from the environment.
+TESTS_ENVIRONMENT = test x"$$me" = x || unset me;
+
 TESTS = \
+self-check-me-in-env.test \
 aclibobj.test \
 aclocal.test \
 aclocal3.test \
index 0cc68548ab0f314d8eee5cf9578088d9807b75d3..9ccbdbd3f2e8d99ed314cdfcbb2516655e89b78d 100644 (file)
@@ -308,7 +308,12 @@ pr401b-p.test \
 pr401c-p.test
 
 MAINTAINERCLEANFILES = $(parallel_tests)
+
+# The testsuite variable `$me' should be overridable from the
+# test scripts, but not from the environment.
+TESTS_ENVIRONMENT = test x"$$me" = x || unset me;
 TESTS = \
+self-check-me-in-env.test \
 aclibobj.test \
 aclocal.test \
 aclocal3.test \
index 38bb4e5b4b63e94a31715bd32606a28a28d080b4..342e76d451ac0704cd209d5e4344ffd3c2fab22b 100644 (file)
@@ -69,6 +69,9 @@ test -f "$srcdir/defs.in" || {
 # be done carefully, and *before* including ./defs).
 if test -z "$me"; then
   me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
+elif env | grep '^me=' >/dev/null; then
+  echo "$0: variable \`me' is set in the environment: this is unsafe" >&2
+  exit 99
 fi
 
 # This might be used in testcases checking distribution-related features.
diff --git a/tests/self-check-me-in-env.test b/tests/self-check-me-in-env.test
new file mode 100755 (executable)
index 0000000..344a861
--- /dev/null
@@ -0,0 +1,28 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Make sure that the testsuite initialization code complains when
+# $me is 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
+
+: