44
44
# The prerequisite command, if present, must return 0 otherwise the test is
46
# Sometimes it is useful to run all the tests at a high sanity check
47
# level or with arbitrary other flags. To make this simple, extra
48
# options, applied to all tests run, are read from $EXTRA_REGTEST_OPTS,
49
# and handed to valgrind prior to any other flags specified by the
50
# .vgperf file. Note: the env var is the same as vg_regtest.
46
51
#----------------------------------------------------------------------------
58
63
-h --help show this message
59
64
--reps=<n> number of repeats for each program [1]
60
65
--tools=<t1,t2,t3> tools to run [Nulgrind and Memcheck]
61
--vg Valgrind(s) to measure (can be specified multiple
62
times). The "in-place" build is used.
63
[Valgrind in the current directory]
66
--vg Valgrind(s) to measure [Valgrind in the current directory]
67
(can be specified multiple times).
68
The "in-place" build is used.
70
--outer-valgrind: run these Valgrind(s) under the given outer valgrind.
71
These Valgrind(s) must be configured with --enable-inner.
72
--outer-tool: tool to use by the outer valgrind (default cachegrind).
73
--outer-args: use this as outer tool args.
65
75
Any tools named in --tools must be present in all directories specified
66
76
with --vg. (This is not checked.)
77
Use EXTRA_REGTEST_OPTS to supply extra args for all tests
79
90
my @vgdirs; # Dirs of the various Valgrinds being measured.
80
91
my @tools = ("none", "memcheck"); # tools being measured
93
# Outer valgrind to use, and args to use for it.
94
# If this is set, --valgrind should be set to the installed inner valgrind,
95
# and --valgrind-lib will be ignore
97
my $outer_tool = "cachegrind";
82
101
my $num_tests_done = 0;
83
102
my $num_timings_done = 0;
256
280
my $cmd = "$timecmd $prog $args";
257
281
my $tNative = time_prog($cmd, $n_reps);
283
if (defined $outer_valgrind) {
284
$outer_valgrind = validate_program($tests_dir, $outer_valgrind, 1, 1);
285
foreach my $vgdir (@vgdirs) {
286
validate_program($vgdir, "./coregrind/valgrind", 1, 1);
289
foreach my $vgdir (@vgdirs) {
290
validate_program($vgdir, "./coregrind/valgrind", 1, 1);
294
# Pull any extra options (for example, --sanity-level=4)
295
# from $EXTRA_REGTEST_OPTS.
296
my $maybe_extraopts = $ENV{"EXTRA_REGTEST_OPTS"};
297
my $extraopts = $maybe_extraopts ? $maybe_extraopts : "";
259
299
foreach my $vgdir (@vgdirs) {
261
301
printf("%-8s ", $name);
272
312
# First two chars of toolname for abbreviation
273
313
my $tool_abbrev = $tool;
274
314
$tool_abbrev =~ s/(..).*/$1/;
276
# Do the tool run(s). Set both VALGRIND_LIB and VALGRIND_LIB_INNER
277
# in case this Valgrind was configured with --enable-inner. And
278
# also VALGRINDLIB, which was the old name for the variable, to
279
# allow comparison against old Valgrind versions (eg. 2.4.X).
280
315
printf(" %s:", $tool_abbrev);
281
my $vgsetup = "VALGRINDLIB=$vgdir/.in_place "
282
. "VALGRIND_LIB=$vgdir/.in_place "
283
. "VALGRIND_LIB_INNER=$vgdir/.in_place ";
316
my $run_outer_args = "";
317
if (not defined $outer_args) {
319
" -v --command-line-only=yes"
320
. " --run-libc-freeres=no --sim-hints=enable-outer"
321
. " --smc-check=all-non-file"
322
. " --vgdb=no --trace-children=yes --read-var-info=no"
323
. " --suppressions=../tests/outer_inner.supp"
324
. " --memcheck:leak-check=full --memcheck:show-reachable=no"
325
. " --cachegrind:cache-sim=yes --cachegrind:branch-sim=yes"
326
. " --cachegrind:cachegrind-out-file=cachegrind.out.$vgdirname.$tool_abbrev.$name.%p"
327
. " --callgrind:cache-sim=yes --callgrind:branch-sim=yes"
328
. " --callgrind:dump-instr=yes --callgrind:collect-jumps=yes"
329
. " --callgrind:callgrind-out-file=callgrind.out.$vgdirname.$tool_abbrev.$name.%p"
332
$run_outer_args = $outer_args;
284
336
my $vgcmd = "$vgdir/coregrind/valgrind "
285
. "--command-line-only=yes --tool=$tool -q "
337
. "--command-line-only=yes --tool=$tool $extraopts -q "
286
338
. "--memcheck:leak-check=no "
287
339
. "--trace-children=yes "
341
# Do the tool run(s).
342
if (defined $outer_valgrind ) {
343
# in an outer-inner setup, only set VALGRIND_LIB_INNER
344
$vgsetup = "VALGRIND_LIB_INNER=$vgdir/.in_place ";
345
$vgcmd = "$outer_valgrind "
346
. "--tool=" . $outer_tool . " "
348
. "--log-file=" . "$outer_tool.outer.log.$vgdirname.$tool_abbrev.$name.%p "
351
# Set both VALGRIND_LIB and VALGRIND_LIB_INNER
352
# in case this Valgrind was configured with --enable-inner. And
353
# also VALGRINDLIB, which was the old name for the variable, to
354
# allow comparison against old Valgrind versions (eg. 2.4.X).
355
$vgsetup = "VALGRINDLIB=$vgdir/.in_place "
356
. "VALGRIND_LIB=$vgdir/.in_place "
357
. "VALGRIND_LIB_INNER=$vgdir/.in_place ";
289
359
my $cmd = "$vgsetup $timecmd $vgcmd $prog $args";
290
360
my $tTool = time_prog($cmd, $n_reps);
291
361
printf("%4.1fs (%4.1fx,", $tTool, $tTool/$tNative);
368
438
#----------------------------------------------------------------------------
370
440
#----------------------------------------------------------------------------
441
sub warn_about_EXTRA_REGTEST_OPTS()
443
print "WARNING: \$EXTRA_REGTEST_OPTS is set. You probably don't want\n";
444
print "to run the perf tests with it set, unless you are doing some\n";
445
print "strange experiment, and/or you really know what you are doing.\n";
372
449
# nuke VALGRIND_OPTS
373
450
$ENV{"VALGRIND_OPTS"} = "";
452
if ($ENV{"EXTRA_REGTEST_OPTS"}) {
454
warn_about_EXTRA_REGTEST_OPTS();
375
457
my @fs = process_command_line();
376
458
foreach my $f (@fs) {