]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add testcase for BZ 231357.
authorFlorian Krohm <florian@eich-krohm.de>
Thu, 2 Apr 2015 22:02:24 +0000 (22:02 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Thu, 2 Apr 2015 22:02:24 +0000 (22:02 +0000)
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

none/tests/Makefile.am
none/tests/bug231357.stderr.exp [new file with mode: 0644]
none/tests/bug231357.stdout.exp [new file with mode: 0644]
none/tests/bug231357.vgtest [new file with mode: 0644]
tests/vg_regtest.in

index fee4a782f8fd019ba5a96057eb7263bed040abca..7b346c6c9d517329cd5967a9943490822cb728b2 100644 (file)
@@ -71,6 +71,7 @@ EXTRA_DIST = \
        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 (file)
index 0000000..e69de29
diff --git a/none/tests/bug231357.stdout.exp b/none/tests/bug231357.stdout.exp
new file mode 100644 (file)
index 0000000..334beea
--- /dev/null
@@ -0,0 +1 @@
+/tmp/bruhaha/test.sh
diff --git a/none/tests/bug231357.vgtest b/none/tests/bug231357.vgtest
new file mode 100644 (file)
index 0000000..ad6427a
--- /dev/null
@@ -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
index a3d0ce1c173eea2cc5d8ad584b6114a63f084546..c8e1d2b71e0bef0306fd81a67f2cbcd5eb6a9b45 100755 (executable)
@@ -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)
 #   - 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 $stdinB;             # Input file for progB
 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 @@ sub read_vgtest_file($)
             $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 @@ sub read_vgtest_file($)
             $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 @@ sub do_one_test($$)
     } 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 @@ sub do_one_test($$)
     } 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");