automake-patches
[Top][All Lists]
Advanced

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

[PATCH] test defs: don't allow `$me' to be overridden from the environme


From: Stefano Lattarini
Subject: [PATCH] test defs: don't allow `$me' to be overridden from the environment (was: Re: [FYI] {maint, master} test defs: allow overriding of `$me')
Date: Mon, 18 Apr 2011 00:33:25 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

On Sunday 17 April 2011, Stefano Lattarini wrote:
> On Sunday 17 April 2011, Ralf Wildenhues wrote:
> > * Stefano Lattarini wrote on Sun, Apr 17, 2011 at 06:27:44PM CEST:
> > > Subject: [PATCH] test defs: allow overriding of `$me'
> > > 
> > > * tests/defs.in ($me): Allow overriding by the including test
> > > script.  Add some explicative comments.
> > 
> > What if the user environment contains $me?
> >
> I thought that was very unlikely.  But I might be wrong, and I prefer to
> err on the safe side after all ...
> 
> > Will that be overridden still by the testsuite?
> >
> No.
> 
> > Otherwise you will have spurious failures (and to some extent
> > "arbitrary code execution" upon a testsuite run).
> >
> What about initilizing me from `$am_test_name' then?  On the line of:
> 
>  if test -z "$am_test_name"; then
>    me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
>  else
>    me=$am_test_name
>  fi
> 
> I'll prepare a patch tomorrow if you are OK with this proposal.
> 
Done with the attached patch.  I'll push by tomorrow evening if there
is no objection.

Thanks,
  Stefano
From 1bcc8133516634d974df06e57ae034f8a15c4735 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Mon, 18 Apr 2011 00:29:19 +0200
Subject: [PATCH] test defs: don't allow `$me' to be overridden from the 
environment

* tests/defs.in ($me): Use the namespace-safe `$am_test_name' (if
it's nonempty) as the default for the initialization of `$me', so
that a (not unlikely) environment variable `me' won't wreak havoc
in the testsuite.

Suggestion by Ralf Wildenhues.
---
 ChangeLog     |    9 +++++++++
 tests/defs.in |    9 ++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bdb49db..4c0ad3e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-04-18  Stefano Lattarini  <address@hidden>
+
+       test defs: don't allow `$me' to be overridden from the environment
+       * tests/defs.in ($me): Use the namespace-safe `$am_test_name' (if
+       it's nonempty) as the default for the initialization of `$me', so
+       that a (not unlikely) environment variable `me' won't wreak havoc
+       in the testsuite.
+       Suggestion by Ralf Wildenhues.
+
 2011-04-17  Stefano Lattarini  <address@hidden>
 
        test defs: allow overriding of `$me'
diff --git a/tests/defs.in b/tests/defs.in
index 38bb4e5..910c9a3 100644
--- a/tests/defs.in
+++ b/tests/defs.in
@@ -65,10 +65,13 @@ test -f "$srcdir/defs.in" || {
 }
 
 # The name of the current test (without the `.test' suffix).
-# Test scripts can override it if they need to (but this should
-# be done carefully, and *before* including ./defs).
-if test -z "$me"; then
+# Test scripts can override it if they need to, through the use of
+# the namespace-safe variable `$am_test_name' (but this should be
+# done carefully, and *before* including ./defs).
+if test -z "$am_test_name"; then
   me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
+else
+  me=$am_test_name
 fi
 
 # This might be used in testcases checking distribution-related features.
-- 
1.7.2.3


reply via email to

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