From: Stefano Lattarini Date: Sun, 17 Apr 2011 22:29:19 +0000 (+0200) Subject: tests: don't allow `$me' to be overridden from the environment X-Git-Tag: ng-0.5a~198^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b5a8552fec112499a527a8af8577a9b76144435;p=thirdparty%2Fautomake.git 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. --- diff --git a/ChangeLog b/ChangeLog index bdb49dbaa..b139a98d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-04-18 Stefano Lattarini + + 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 test defs: allow overriding of `$me' diff --git a/tests/Makefile.am b/tests/Makefile.am index b91a02597..cc25167ed 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 0cc68548a..9ccbdbd3f 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -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 \ diff --git a/tests/defs.in b/tests/defs.in index 38bb4e5b4..342e76d45 100644 --- a/tests/defs.in +++ b/tests/defs.in @@ -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 index 000000000..344a861b8 --- /dev/null +++ b/tests/self-check-me-in-env.test @@ -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 . + +# 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 + +: