From: Florian Krohm Date: Thu, 2 Apr 2015 22:02:24 +0000 (+0000) Subject: Add testcase for BZ 231357. X-Git-Tag: svn/VALGRIND_3_11_0~529 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1096d55baaf1e2be69c7a42a63a21802d5057a74;p=thirdparty%2Fvalgrind.git 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 --- diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index fee4a782f8..7b346c6c9d 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -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 index 0000000000..e69de29bb2 diff --git a/none/tests/bug231357.stdout.exp b/none/tests/bug231357.stdout.exp new file mode 100644 index 0000000000..334beea0b2 --- /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 0000000000..ad6427a1fc --- /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 a3d0ce1c17..c8e1d2b71e 100755 --- a/tests/vg_regtest.in +++ b/tests/vg_regtest.in @@ -59,7 +59,9 @@ # # Each test is defined in a file .vgtest, containing one or more of the # following lines, in any order: -# - prog: (compulsory) +# - prog: +# - prog-asis: +# - env: (default: none) # - args: (default: none) # - vgopts: (default: none; # multiple are allowed) @@ -80,11 +82,16 @@ # - post: (default: none) # - cleanup: (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 .stdout.exp* (can be more # than one expected output). It can be missing if it would be empty. Expected # stderr (filtered) is kept in .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");