njn | 9fb16f5 | 2003-04-23 17:47:13 +0000 | [diff] [blame] | 1 | #! @PERL@ |
njn | a217f3d | 2002-09-27 08:26:27 +0000 | [diff] [blame] | 2 | ##--------------------------------------------------------------------## |
| 3 | ##--- Valgrind regression testing script vg_regtest ---## |
| 4 | ##--------------------------------------------------------------------## |
njn | c2e7f48 | 2002-09-27 08:44:17 +0000 | [diff] [blame] | 5 | |
njn | c953984 | 2002-10-02 13:26:35 +0000 | [diff] [blame] | 6 | # This file is part of Valgrind, an extensible x86 protected-mode |
| 7 | # emulator for monitoring program execution on x86-Unixes. |
njn | c2e7f48 | 2002-09-27 08:44:17 +0000 | [diff] [blame] | 8 | # |
njn | 0e1b514 | 2003-04-15 14:58:06 +0000 | [diff] [blame] | 9 | # Copyright (C) 2003 Nicholas Nethercote |
njn | c2e7f48 | 2002-09-27 08:44:17 +0000 | [diff] [blame] | 10 | # njn25@cam.ac.uk |
| 11 | # |
| 12 | # This program is free software; you can redistribute it and/or |
| 13 | # modify it under the terms of the GNU General Public License as |
| 14 | # published by the Free Software Foundation; either version 2 of the |
| 15 | # License, or (at your option) any later version. |
| 16 | # |
| 17 | # This program is distributed in the hope that it will be useful, but |
| 18 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 20 | # General Public License for more details. |
| 21 | # |
| 22 | # You should have received a copy of the GNU General Public License |
| 23 | # along with this program; if not, write to the Free Software |
| 24 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 25 | # 02111-1307, USA. |
| 26 | # |
| 27 | # The GNU General Public License is contained in the file COPYING. |
| 28 | |
| 29 | #---------------------------------------------------------------------------- |
njn | a217f3d | 2002-09-27 08:26:27 +0000 | [diff] [blame] | 30 | # usage: vg_regtest [options] <dirs | files> |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 31 | # |
njn | a217f3d | 2002-09-27 08:26:27 +0000 | [diff] [blame] | 32 | # Options: |
njn | a217f3d | 2002-09-27 08:26:27 +0000 | [diff] [blame] | 33 | # --all: run tests in all subdirs |
njn | c2e7f48 | 2002-09-27 08:44:17 +0000 | [diff] [blame] | 34 | # --valgrind: valgrind to use. Default is one built from this source tree. |
njn | a217f3d | 2002-09-27 08:26:27 +0000 | [diff] [blame] | 35 | # |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 36 | # The easiest way is to run all tests in valgrind/ with (assuming you installed |
| 37 | # in $PREFIX): |
| 38 | # |
| 39 | # $PREFIX/bin/vg_regtest --all |
| 40 | # |
njn | a217f3d | 2002-09-27 08:26:27 +0000 | [diff] [blame] | 41 | # You can specify individual files to test, or whole directories, or both. |
jsgf | 855d93d | 2003-10-13 22:26:55 +0000 | [diff] [blame] | 42 | # Directories are traversed recursively, except for ones named, for example, |
| 43 | # CVS/ or docs/. |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 44 | # |
| 45 | # Each test is defined in a file <test>.vgtest, containing one or more of the |
njn | a217f3d | 2002-09-27 08:26:27 +0000 | [diff] [blame] | 46 | # following lines, in any order: |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 47 | # - prog: <prog to run> (compulsory) |
| 48 | # - args: <args for prog> (default: none) |
| 49 | # - vgopts: <Valgrind options> (default: none) |
| 50 | # - stdout_filter: <filter to run stdout through> (default: none) |
njn | a217f3d | 2002-09-27 08:26:27 +0000 | [diff] [blame] | 51 | # - stderr_filter: <filter to run stderr through> (default: ./filter_stderr) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 52 | # |
njn | a217f3d | 2002-09-27 08:26:27 +0000 | [diff] [blame] | 53 | # Note that filters are necessary for stderr results to filter out things that |
| 54 | # always change, eg. process id numbers. |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 55 | # |
njn | a217f3d | 2002-09-27 08:26:27 +0000 | [diff] [blame] | 56 | # Expected stdout (filtered) is kept in <test>.stdout.exp. It can be missing |
njn | d8ced86 | 2003-04-08 00:47:05 +0000 | [diff] [blame] | 57 | # if it would be empty. Expected stderr (filtered) is kept in |
| 58 | # <test>.stderr.exp. |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 59 | # |
| 60 | # If results don't match, the output can be found in <test>.std<strm>.out, |
| 61 | # and the diff between expected and actual in <test>.std<strm>.diff. |
| 62 | # |
nethercote | 137bc55 | 2003-11-14 17:47:54 +0000 | [diff] [blame] | 63 | # Notes on adding regression tests for a new tool are in |
| 64 | # coregrind/docs/coregrind_tools.html. |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 65 | #---------------------------------------------------------------------------- |
| 66 | |
njn | 9fb16f5 | 2003-04-23 17:47:13 +0000 | [diff] [blame] | 67 | use warnings; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 68 | use strict; |
| 69 | |
| 70 | #---------------------------------------------------------------------------- |
| 71 | # Global vars |
| 72 | #---------------------------------------------------------------------------- |
njn | d8ced86 | 2003-04-08 00:47:05 +0000 | [diff] [blame] | 73 | my $usage="vg_regtest [--all, --valgrind]\n"; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 74 | |
| 75 | my $tmp="vg_regtest.tmp.$$"; |
| 76 | |
| 77 | # Test variables |
| 78 | my $vgopts; # valgrind options |
| 79 | my $prog; # test prog |
| 80 | my $args; # test prog args |
| 81 | my $stdout_filter; # filter program to run stdout results file through |
| 82 | my $stderr_filter; # filter program to run stderr results file through |
| 83 | |
| 84 | my @failures; # List of failed tests |
| 85 | |
njn | 9fb16f5 | 2003-04-23 17:47:13 +0000 | [diff] [blame] | 86 | my $num_tests_done = 0; |
| 87 | my %num_failures = (stderr => 0, stdout => 0); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 88 | |
njn | 71fe3e6 | 2003-04-23 21:48:20 +0000 | [diff] [blame] | 89 | # Default valgrind to use is this build tree's (uninstalled) one |
njn | c2e7f48 | 2002-09-27 08:44:17 +0000 | [diff] [blame] | 90 | my $prefix="@prefix@"; |
| 91 | my $exec_prefix="@exec_prefix@"; |
njn | 71fe3e6 | 2003-04-23 21:48:20 +0000 | [diff] [blame] | 92 | my $valgrind = "./coregrind/valgrind"; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 93 | |
| 94 | chomp(my $tests_dir = `pwd`); |
| 95 | |
| 96 | # default filter is the one named "filter_stderr" in the test's directory |
| 97 | my $default_stderr_filter = "filter_stderr"; |
| 98 | |
| 99 | |
| 100 | #---------------------------------------------------------------------------- |
| 101 | # Process command line, setup |
| 102 | #---------------------------------------------------------------------------- |
| 103 | |
| 104 | # If $prog is a relative path, it prepends $dir to it. Useful for two reasons: |
| 105 | # |
| 106 | # 1. Can prepend "." onto programs to avoid trouble with users who don't have |
| 107 | # "." in their path (by making $dir = ".") |
| 108 | # 2. Can prepend the current dir to make the command absolute to avoid |
| 109 | # subsequent trouble when we change directories. |
| 110 | # |
| 111 | # Also checks the program exists and is executable. |
njn | 71fe3e6 | 2003-04-23 21:48:20 +0000 | [diff] [blame] | 112 | sub validate_program ($$$) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 113 | { |
njn | 71fe3e6 | 2003-04-23 21:48:20 +0000 | [diff] [blame] | 114 | my ($dir, $prog, $must_be_executable) = @_; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 115 | |
| 116 | # If absolute path, leave it alone. If relative, make it |
| 117 | # absolute -- by prepending current dir -- so we can change |
| 118 | # dirs and still use it. |
| 119 | $prog = "$dir/$prog" if ($prog !~ /^\//); |
njn | 71fe3e6 | 2003-04-23 21:48:20 +0000 | [diff] [blame] | 120 | (-f $prog) or die "vg_regtest: `$prog' not found or not a file ($dir)\n"; |
| 121 | if ($must_be_executable) { |
| 122 | (-x $prog) or die "vg_regtest: `$prog' not executable ($dir)\n"; |
| 123 | } |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 124 | |
| 125 | return $prog; |
| 126 | } |
| 127 | |
| 128 | sub process_command_line() |
| 129 | { |
| 130 | my $alldirs = 0; |
| 131 | my @fs; |
| 132 | |
| 133 | for my $arg (@ARGV) { |
| 134 | if ($arg =~ /^-/) { |
njn | d8ced86 | 2003-04-08 00:47:05 +0000 | [diff] [blame] | 135 | if ($arg =~ /^--all$/) { |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 136 | $alldirs = 1; |
| 137 | } elsif ($arg =~ /^--valgrind=(.*)$/) { |
| 138 | $valgrind = $1; |
| 139 | } else { |
| 140 | die $usage; |
| 141 | } |
| 142 | } else { |
| 143 | push(@fs, $arg); |
| 144 | } |
| 145 | } |
njn | 71fe3e6 | 2003-04-23 21:48:20 +0000 | [diff] [blame] | 146 | $valgrind = validate_program($tests_dir, $valgrind, 0); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 147 | |
| 148 | if ($alldirs) { |
| 149 | @fs = (); |
| 150 | foreach my $f (glob "*") { |
| 151 | push(@fs, $f) if (-d $f); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | (0 != @fs) or die "No test files or directories specified\n"; |
| 156 | |
| 157 | return @fs; |
| 158 | } |
| 159 | |
| 160 | #---------------------------------------------------------------------------- |
| 161 | # Read a .vgtest file |
| 162 | #---------------------------------------------------------------------------- |
| 163 | sub read_vgtest_file($) |
| 164 | { |
| 165 | my ($f) = @_; |
| 166 | |
| 167 | # Defaults. |
| 168 | ($vgopts, $prog, $args, $stdout_filter, $stderr_filter) = |
| 169 | ("", undef, "", undef, undef); |
| 170 | |
| 171 | # Every test directory must have a "filter_stderr" |
njn | 71fe3e6 | 2003-04-23 21:48:20 +0000 | [diff] [blame] | 172 | $stderr_filter = validate_program(".", $default_stderr_filter, 1); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 173 | |
| 174 | open(INPUTFILE, "< $f") || die "File $f not openable\n"; |
| 175 | |
| 176 | while (my $line = <INPUTFILE>) { |
| 177 | if ($line =~ /^\s*vgopts:\s*(.*)$/) { |
| 178 | $vgopts = $1; |
| 179 | } elsif ($line =~ /^\s*prog:\s*(.*)$/) { |
njn | 71fe3e6 | 2003-04-23 21:48:20 +0000 | [diff] [blame] | 180 | $prog = validate_program(".", $1, 1); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 181 | } elsif ($line =~ /^\s*args:\s*(.*)$/) { |
| 182 | $args = $1; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 183 | } elsif ($line =~ /^\s*stdout_filter:\s*(.*)$/) { |
njn | 71fe3e6 | 2003-04-23 21:48:20 +0000 | [diff] [blame] | 184 | $stdout_filter = validate_program(".", $1, 1); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 185 | } elsif ($line =~ /^\s*stderr_filter:\s*(.*)$/) { |
njn | 71fe3e6 | 2003-04-23 21:48:20 +0000 | [diff] [blame] | 186 | $stderr_filter = validate_program(".", $1, 1); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 187 | } else { |
| 188 | die "Bad line in $f: $line\n"; |
| 189 | } |
| 190 | } |
| 191 | close(INPUTFILE); |
| 192 | |
| 193 | if (!defined $prog) { |
| 194 | die "no `prog:' line in `$f'\n"; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | #---------------------------------------------------------------------------- |
| 199 | # Do one test |
| 200 | #---------------------------------------------------------------------------- |
| 201 | # Since most of the program time is spent in system() calls, need this to |
| 202 | # propagate a Ctrl-C enabling us to quit. |
| 203 | sub mysystem($) |
| 204 | { |
| 205 | (system($_[0]) != 2) or exit 1; # 2 is SIGINT |
| 206 | } |
| 207 | |
nethercote | 137bc55 | 2003-11-14 17:47:54 +0000 | [diff] [blame] | 208 | # from a directory name like "/foo/cachesim/tests/" determine the tool name |
| 209 | sub determine_tool() |
njn25 | cac76cb | 2002-09-23 11:21:57 +0000 | [diff] [blame] | 210 | { |
| 211 | my $dir = `pwd`; |
nethercote | 137bc55 | 2003-11-14 17:47:54 +0000 | [diff] [blame] | 212 | $dir =~ /.*\/([^\/]+)\/tests.*/; # foo/tool_name/tests/foo |
njn25 | cac76cb | 2002-09-23 11:21:57 +0000 | [diff] [blame] | 213 | return $1; |
| 214 | } |
| 215 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 216 | sub do_one_test($$) |
| 217 | { |
| 218 | my ($dir, $vgtest) = @_; |
| 219 | $vgtest =~ /^(.*)\.vgtest/; |
| 220 | my $name = $1; |
| 221 | my $fullname = "$dir/$name"; |
| 222 | |
| 223 | read_vgtest_file($vgtest); |
| 224 | |
njn | db3c469 | 2002-10-04 10:03:34 +0000 | [diff] [blame] | 225 | printf("%-16s valgrind $vgopts $prog $args\n", "$name:"); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 226 | |
nethercote | 137bc55 | 2003-11-14 17:47:54 +0000 | [diff] [blame] | 227 | # Pass the appropriate --tool option for the directory (can be overridden |
njn | 71fe3e6 | 2003-04-23 21:48:20 +0000 | [diff] [blame] | 228 | # by an "args:" or "args.dev:" line, though). |
nethercote | 137bc55 | 2003-11-14 17:47:54 +0000 | [diff] [blame] | 229 | my $tool=determine_tool(); |
fitzhardinge | 98abfc7 | 2003-12-16 02:05:15 +0000 | [diff] [blame^] | 230 | mysystem("VALGRINDLIB=$tests_dir/.in_place $valgrind --tool=$tool $vgopts $prog $args > $name.stdout.out 2> $name.stderr.out"); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 231 | |
| 232 | if (defined $stdout_filter) { |
| 233 | mysystem("$stdout_filter < $name.stdout.out > $tmp"); |
| 234 | rename($tmp, "$name.stdout.out"); |
| 235 | } |
| 236 | |
| 237 | mysystem("$stderr_filter < $name.stderr.out > $tmp"); |
| 238 | rename($tmp, "$name.stderr.out"); |
| 239 | |
| 240 | # If stdout expected empty, .exp file might be missing so diff with |
| 241 | # /dev/null |
| 242 | my $stdout_exp = ( -r "$name.stdout.exp" |
| 243 | ? "$name.stdout.exp" |
| 244 | : "/dev/null" ); |
| 245 | |
njn | d8ced86 | 2003-04-08 00:47:05 +0000 | [diff] [blame] | 246 | my $stderr_exp = "$name.stderr.exp"; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 247 | (-r $stderr_exp) or die "Could not read `$stderr_exp'\n"; |
| 248 | |
| 249 | mysystem("diff -C0 $stdout_exp $name.stdout.out > $name.stdout.diff"); |
| 250 | mysystem("diff -C0 $stderr_exp $name.stderr.out > $name.stderr.diff"); |
| 251 | |
| 252 | for my $ext ("stdout", "stderr") { |
| 253 | if (-s "$name.$ext.diff") { |
njn | db3c469 | 2002-10-04 10:03:34 +0000 | [diff] [blame] | 254 | print "*** $name failed ($ext) ***\n"; |
njn | 9fb16f5 | 2003-04-23 17:47:13 +0000 | [diff] [blame] | 255 | push(@failures, sprintf("%-40s ($ext)", "$fullname")); |
| 256 | $num_failures{$ext}++; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 257 | } else { |
| 258 | unlink("$name.$ext.out", "$name.$ext.diff"); |
| 259 | } |
| 260 | } |
njn | 9fb16f5 | 2003-04-23 17:47:13 +0000 | [diff] [blame] | 261 | $num_tests_done++; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | #---------------------------------------------------------------------------- |
njn25 | cac76cb | 2002-09-23 11:21:57 +0000 | [diff] [blame] | 265 | # Test one directory (and any subdirs) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 266 | #---------------------------------------------------------------------------- |
njn | db3c469 | 2002-10-04 10:03:34 +0000 | [diff] [blame] | 267 | sub test_one_dir($$); # forward declaration |
njn25 | cac76cb | 2002-09-23 11:21:57 +0000 | [diff] [blame] | 268 | |
njn | db3c469 | 2002-10-04 10:03:34 +0000 | [diff] [blame] | 269 | sub test_one_dir($$) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 270 | { |
njn | db3c469 | 2002-10-04 10:03:34 +0000 | [diff] [blame] | 271 | my ($dir, $prev_dirs) = @_; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 272 | $dir =~ s/\/$//; # trim a trailing '/' |
| 273 | |
jsgf | 855d93d | 2003-10-13 22:26:55 +0000 | [diff] [blame] | 274 | # ignore dirs into which we should not recurse |
mueller | 92f0b80 | 2003-11-19 00:55:32 +0000 | [diff] [blame] | 275 | if ($dir =~ /^(BitKeeper|CVS|SCCS|docs|doc)$/) { return; } |
njn25 | cac76cb | 2002-09-23 11:21:57 +0000 | [diff] [blame] | 276 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 277 | chdir($dir) or die "Could not change into $dir\n"; |
| 278 | |
njn | 584eaac | 2002-10-04 15:30:48 +0000 | [diff] [blame] | 279 | # Nb: Don't prepend a '/' to the base directory |
| 280 | my $full_dir = $prev_dirs . ($prev_dirs eq "" ? "" : "/") . $dir; |
njn | db3c469 | 2002-10-04 10:03:34 +0000 | [diff] [blame] | 281 | my $dashes = "-" x (50 - length $full_dir); |
njn25 | cac76cb | 2002-09-23 11:21:57 +0000 | [diff] [blame] | 282 | |
njn | db3c469 | 2002-10-04 10:03:34 +0000 | [diff] [blame] | 283 | my @fs = glob "*"; |
| 284 | my @vgtests = grep { $_ =~ /\.vgtest$/ } @fs; |
| 285 | my $found_tests = (0 != (grep { $_ =~ /\.vgtest$/ } @fs)); |
| 286 | |
| 287 | if ($found_tests) { |
| 288 | print "-- Running tests in $full_dir $dashes\n"; |
njn | db3c469 | 2002-10-04 10:03:34 +0000 | [diff] [blame] | 289 | } |
njn25 | cac76cb | 2002-09-23 11:21:57 +0000 | [diff] [blame] | 290 | foreach my $f (@fs) { |
| 291 | if (-d $f) { |
njn | db3c469 | 2002-10-04 10:03:34 +0000 | [diff] [blame] | 292 | test_one_dir($f, $full_dir); |
njn25 | cac76cb | 2002-09-23 11:21:57 +0000 | [diff] [blame] | 293 | } elsif ($f =~ /\.vgtest$/) { |
njn | db3c469 | 2002-10-04 10:03:34 +0000 | [diff] [blame] | 294 | do_one_test($full_dir, $f); |
njn25 | cac76cb | 2002-09-23 11:21:57 +0000 | [diff] [blame] | 295 | } |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 296 | } |
njn | db3c469 | 2002-10-04 10:03:34 +0000 | [diff] [blame] | 297 | if ($found_tests) { |
| 298 | print "-- Finished tests in $full_dir $dashes\n"; |
| 299 | } |
| 300 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 301 | chdir(".."); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | #---------------------------------------------------------------------------- |
| 305 | # Summarise results |
| 306 | #---------------------------------------------------------------------------- |
njn | 9fb16f5 | 2003-04-23 17:47:13 +0000 | [diff] [blame] | 307 | sub plural($) |
| 308 | { |
| 309 | return ( $_[0] == 1 ? "" : "s" ); |
| 310 | } |
| 311 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 312 | sub summarise_results |
| 313 | { |
njn | d8ced86 | 2003-04-08 00:47:05 +0000 | [diff] [blame] | 314 | my $x = ( $num_tests_done == 1 ? "test" : "tests" ); |
njn | d8ced86 | 2003-04-08 00:47:05 +0000 | [diff] [blame] | 315 | |
njn | 9fb16f5 | 2003-04-23 17:47:13 +0000 | [diff] [blame] | 316 | printf("\n== %d test%s, %d stderr failure%s, %d stdout failure%s =================\n", |
| 317 | $num_tests_done, plural($num_tests_done), |
| 318 | $num_failures{"stderr"}, plural($num_failures{"stderr"}), |
| 319 | $num_failures{"stdout"}, plural($num_failures{"stdout"})); |
| 320 | |
| 321 | foreach my $failure (@failures) { |
| 322 | print "$failure\n"; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 323 | } |
njn | 9fb16f5 | 2003-04-23 17:47:13 +0000 | [diff] [blame] | 324 | print "\n"; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | #---------------------------------------------------------------------------- |
| 328 | # main(), sort of |
| 329 | #---------------------------------------------------------------------------- |
| 330 | |
daywalker | bb93698 | 2003-04-23 16:52:06 +0000 | [diff] [blame] | 331 | # nuke VALGRIND_OPTS |
| 332 | $ENV{"VALGRIND_OPTS"} = ""; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 333 | |
| 334 | my @fs = process_command_line(); |
| 335 | foreach my $f (@fs) { |
| 336 | if (-d $f) { |
njn | 584eaac | 2002-10-04 15:30:48 +0000 | [diff] [blame] | 337 | test_one_dir($f, ""); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 338 | } else { |
| 339 | # Allow the .vgtest suffix to be given or omitted |
| 340 | if ($f =~ /.vgtest$/ && -r $f) { |
| 341 | # do nothing |
| 342 | } elsif (-r "$f.vgtest") { |
| 343 | $f = "$f.vgtest"; |
| 344 | } else { |
| 345 | die "`$f' neither a directory nor a readable test file/name\n" |
| 346 | } |
| 347 | my $dir = `dirname $f`; chomp $dir; |
| 348 | my $file = `basename $f`; chomp $file; |
| 349 | chdir($dir) or die "Could not change into $dir\n"; |
| 350 | do_one_test($dir, $file); |
| 351 | chdir($tests_dir); |
| 352 | } |
| 353 | } |
| 354 | summarise_results(); |
| 355 | |
njn | c2e7f48 | 2002-09-27 08:44:17 +0000 | [diff] [blame] | 356 | ##--------------------------------------------------------------------## |
| 357 | ##--- end vg_regtest ---## |
| 358 | ##--------------------------------------------------------------------## |