Add testcase for BZ 231357.
To do that a small enhancement to vg_regtest was needed:
(1) New declaration to allow specifying an environemnt variable
that is set prior to invoking valgrind.
eg: env: VAR=VAL
There can be more than one such declaration
(2) prog-asis: program_name
This is like prog: except the program name is not prefixed with
the testdir.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15064 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am
index fee4a78..7b346c6 100644
--- a/none/tests/Makefile.am
+++ b/none/tests/Makefile.am
@@ -71,6 +71,7 @@
bigcode.vgtest bigcode.stderr.exp bigcode.stdout.exp \
bitfield1.stderr.exp bitfield1.vgtest \
bug129866.vgtest bug129866.stderr.exp bug129866.stdout.exp \
+ bug231357.vgtest bug231357.stderr.exp bug231357.stdout.exp \
closeall.stderr.exp closeall.vgtest \
cmdline0.stderr.exp cmdline0.stdout.exp cmdline0.vgtest \
cmdline1.stderr.exp cmdline1.stdout.exp cmdline1.vgtest \
diff --git a/none/tests/bug231357.stderr.exp b/none/tests/bug231357.stderr.exp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/none/tests/bug231357.stderr.exp
diff --git a/none/tests/bug231357.stdout.exp b/none/tests/bug231357.stdout.exp
new file mode 100644
index 0000000..334beea
--- /dev/null
+++ b/none/tests/bug231357.stdout.exp
@@ -0,0 +1 @@
+/tmp/bruhaha/test.sh
diff --git a/none/tests/bug231357.vgtest b/none/tests/bug231357.vgtest
new file mode 100644
index 0000000..ad6427a
--- /dev/null
+++ b/none/tests/bug231357.vgtest
@@ -0,0 +1,5 @@
+prereq: rm -rf /tmp/bruhaha && mkdir /tmp/bruhaha && echo '#!/bin/echo' > /tmp/bruhaha/test.sh && chmod +x /tmp/bruhaha/test.sh
+env: PATH=/tmp/bruhaha:$PATH
+prog-asis: test.sh
+vgopts: -q
+cleanup: rm -rf /tmp/bruhaha
diff --git a/tests/vg_regtest.in b/tests/vg_regtest.in
index a3d0ce1..c8e1d2b 100755
--- a/tests/vg_regtest.in
+++ b/tests/vg_regtest.in
@@ -59,7 +59,9 @@
#
# Each test is defined in a file <test>.vgtest, containing one or more of the
# following lines, in any order:
-# - prog: <prog to run> (compulsory)
+# - prog: <prog to run>
+# - prog-asis: <prog to run>
+# - env: <environment variable for prog> (default: none)
# - args: <args for prog> (default: none)
# - vgopts: <Valgrind options> (default: none;
# multiple are allowed)
@@ -80,11 +82,16 @@
# - post: <post-test check command> (default: none)
# - cleanup: <post-test cleanup cmd> (default: none)
#
+# One of prog or prog-asis must be specified.
# If prog or probB is a relative path, it will be prefix with the test directory.
+# prog-asis will be taken as is, i.e. not prefixed with the test directory.
# Note that filters are necessary for stderr results to filter out things that
# always change, eg. process id numbers.
# Note that if a progB is specified, it is started in background (before prog).
#
+# There can be more than one env: declaration. Here is an example:
+# env: PATH=/opt/bin:$PATH
+#
# Expected stdout (filtered) is kept in <test>.stdout.exp* (can be more
# than one expected output). It can be missing if it would be empty. Expected
# stderr (filtered) is kept in <test>.stderr.exp*. There must be at least
@@ -154,6 +161,7 @@
my $prereq; # prerequisite test to satisfy before running test
my $post; # check command after running test
my $cleanup; # cleanup command to run
+my @env = (); # environment variable to set prior calling $prog
my @failures; # List of failed tests
@@ -302,6 +310,8 @@
$vgopts = $vgopts . " " . $addvgopts; # Nb: Make sure there's a space!
} elsif ($line =~ /^\s*prog:\s*(.*)$/) {
$prog = validate_program(".", $1, 0, 0);
+ } elsif ($line =~ /^\s*prog-asis:\s*(.*)$/) {
+ $prog = $1;
} elsif ($line =~ /^\s*args:\s*(.*)$/) {
$args = $1;
} elsif ($line =~ /^\s*stdout_filter:\s*(.*)$/) {
@@ -332,6 +342,8 @@
$post = $1;
} elsif ($line =~ /^\s*cleanup:\s*(.*)$/) {
$cleanup = $1;
+ } elsif ($line =~ /^\s*env:\s*(.*)$/) {
+ push @env,$1;
} else {
die "Bad line in $f: $line\n";
}
@@ -466,13 +478,19 @@
} else {
printf("%-16s valgrind $extraopts $vgopts $prog $args\n", "$name:");
}
-
+
+ # Collect environment variables, if any.
+ my $envvars = "";
+ foreach my $e (@env) {
+ $envvars = "$envvars $e";
+ }
+
# Pass the appropriate --tool option for the directory (can be overridden
# by an "args:" line, though).
my $tool=determine_tool();
if (defined $outer_valgrind ) {
# in an outer-inner setup, only set VALGRIND_LIB_INNER
- mysystem( "VALGRIND_LIB_INNER=$valgrind_lib "
+ mysystem( "$envvars VALGRIND_LIB_INNER=$valgrind_lib "
. "$outer_valgrind "
. "--tool=" . $outer_tool . " "
. "$outer_args "
@@ -484,7 +502,7 @@
} else {
# Set both VALGRIND_LIB and VALGRIND_LIB_INNER in case this Valgrind
# was configured with --enable-inner.
- mysystem( "VALGRIND_LIB=$valgrind_lib VALGRIND_LIB_INNER=$valgrind_lib "
+ mysystem( "$envvars VALGRIND_LIB=$valgrind_lib VALGRIND_LIB_INNER=$valgrind_lib "
. "$valgrind --command-line-only=yes --memcheck:leak-check=no "
. "--tool=$tool $extraopts $vgopts "
. "$prog $args > $name.stdout.out 2> $name.stderr.out");