1 From f49f27f1bc67d07440b0ac9a7d767a8ea1589bfe Mon Sep 17 00:00:00 2001
2 From: Alexander Kanavin <alex.kanavin@gmail.com>
3 Date: Tue, 15 Dec 2015 15:50:44 +0200
4 Subject: [PATCH 5/5] Modify vg_test wrapper to support PTEST formats
6 Change the valgrind regression test script vg_regtest to
7 support the yocto ptest stdout reporting format. The commit adds
8 '--yocto-ptest' as an optional argument to vg_regtest, which alters
9 the output to use the ptest infrastructure reporting format:
10 "[PASS|SKIP|FAIL]: testname"
11 instead of valgrind's internal test reporting format. Without the added
12 option, --yocto-ptest, the valgrind regression test output is unchanged.
14 Enforce 30 seconds limit for the test.
15 This resume execution of the remaining tests when valgrind hangs.
17 Upstream-Status: Pending
19 Signed-off-by: Dave Lerner <dave.lerner@windriver.com>
20 Signed-off-by: Tudor Florea <tudor.florea@enea.com>
21 Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
23 tests/vg_regtest.in | 75 +++++++++++++++++++++++++++++++++++++++--------------
24 1 file changed, 55 insertions(+), 20 deletions(-)
26 diff --git a/tests/vg_regtest.in b/tests/vg_regtest.in
27 index a441f42..cb05b52 100755
28 --- a/tests/vg_regtest.in
29 +++ b/tests/vg_regtest.in
31 # --loop-till-fail: loops on the test(s) till one fail, then exit
32 # This is useful to obtain detailed trace or --keep-unfiltered
33 # output of a non deterministic test failure
34 +# --yocto-ptest: output in yocto ptest format
36 # The easiest way is to run all tests in valgrind/ with (assuming you installed
38 @@ -139,7 +140,7 @@ my $usage="\n"
40 . " vg_regtest [--all, --valgrind, --valgrind-lib, --keep-unfiltered\n"
41 . " --outer-valgrind, --outer-tool, --outer-args\n"
42 - . " --loop-till-fail]\n"
43 + . " --loop-till-fail, --yocto-ptest]\n"
44 . " Use EXTRA_REGTEST_OPTS to supply extra args for all tests\n"
47 @@ -186,6 +187,7 @@ my $outer_args;
48 my $valgrind_lib = "$tests_dir/.in_place";
49 my $keepunfiltered = 0;
53 # default filter is the one named "filter_stderr" in the test's directory
54 my $default_stderr_filter = "filter_stderr";
55 @@ -244,6 +246,8 @@ sub process_command_line()
57 } elsif ($arg =~ /^--loop-till-fail$/) {
59 + } elsif ($arg =~ /^--yocto-ptest$/) {
64 @@ -365,13 +369,28 @@ sub read_vgtest_file($)
65 #----------------------------------------------------------------------------
66 # Since most of the program time is spent in system() calls, need this to
67 # propagate a Ctrl-C enabling us to quit.
69 +# Enforce 30 seconds limit for the test.
70 +# This resume execution of the remaining tests if valgrind hangs.
73 - my $exit_code = system($_[0]);
74 - ($exit_code == 2) and exit 1; # 2 is SIGINT
78 + local $SIG{'ALRM'} = sub { die "timed out\n" };
80 + $exit_code = system($_[0]);
82 + ($exit_code == 2) and die "SIGINT\n"; # 2 is SIGINT
85 + if ($@ eq "timed out\n") {
86 + print "timed out\n";
89 + if ($@ eq "SIGINT\n") {
95 # if $keepunfiltered, copies $1 to $1.unfiltered.out
97 sub filtered_rename($$)
98 @@ -419,23 +438,25 @@ sub do_diffs($$$$)
99 # A match; remove .out and any previously created .diff files.
100 unlink("$name.$mid.out");
101 unlink(<$name.$mid.diff*>);
107 # If we reach here, none of the .exp files matched.
108 - print "*** $name failed ($mid) ***\n";
109 + print "*** $name failed ($mid) ***\n" if ($yoctoptest == 0) ;
110 push(@failures, sprintf("%-40s ($mid)", "$fullname"));
111 $num_failures{$mid}++;
112 if ($looptillfail == 1) {
113 print "Failure encountered, stopping to loop\n";
121 my ($dir, $vgtest) = @_;
122 + my $diffStatus = 0;
123 $vgtest =~ /^(.*)\.vgtest/;
125 my $fullname = "$dir/$name";
126 @@ -454,7 +475,11 @@ sub do_one_test($$)
127 } elsif (256 == $prereq_res) {
128 # Nb: weird Perl-ism -- exit code of '1' is seen by Perl as 256...
129 # Prereq failed, skip.
130 - printf("%-16s (skipping, prereq failed: $prereq)\n", "$name:");
131 + if ($yoctoptest == 0) {
132 + printf("%-16s (skipping, prereq failed: $prereq)\n", "$name:");
134 + printf("SKIP: $fullname\n");
139 @@ -472,7 +497,7 @@ sub do_one_test($$)
141 # If there is a progB, let's start it in background:
142 printf("%-16s valgrind $extraopts $vgopts $prog $args (progB: $progB $argsB)\n",
144 + "$name:") if ($yoctoptest == 0);
145 # progB.done used to detect child has finished. See below.
146 # Note: redirection of stdout and stderr is before $progB to allow argsB
147 # to e.g. redirect stdoutB to stderrB
148 @@ -488,7 +513,8 @@ sub do_one_test($$)
149 . "touch progB.done) &");
152 - printf("%-16s valgrind $extraopts $vgopts $prog $args\n", "$name:");
153 + printf("%-16s valgrind $extraopts $vgopts $prog $args\n", "$name:")
154 + if ($yoctoptest == 0);
157 # Collect environment variables, if any.
158 @@ -529,7 +555,7 @@ sub do_one_test($$)
159 # Find all the .stdout.exp files. If none, use /dev/null.
160 my @stdout_exps = <$name.stdout.exp*>;
161 @stdout_exps = ( "/dev/null" ) if (0 == scalar @stdout_exps);
162 - do_diffs($fullname, $name, "stdout", \@stdout_exps);
163 + $diffStatus |= do_diffs($fullname, $name, "stdout", \@stdout_exps);
166 $stderr_filter_args = $name if (! defined $stderr_filter_args);
167 @@ -538,7 +564,7 @@ sub do_one_test($$)
168 # Find all the .stderr.exp files. At least one must exist.
169 my @stderr_exps = <$name.stderr.exp*>;
170 (0 != scalar @stderr_exps) or die "Could not find `$name.stderr.exp*'\n";
171 - do_diffs($fullname, $name, "stderr", \@stderr_exps);
172 + $diffStatus |= do_diffs($fullname, $name, "stderr", \@stderr_exps);
174 if (defined $progB) {
175 # wait for the child to be finished
176 @@ -562,7 +588,7 @@ sub do_one_test($$)
177 # Find all the .stdoutB.exp files. If none, use /dev/null.
178 my @stdoutB_exps = <$name.stdoutB.exp*>;
179 @stdoutB_exps = ( "/dev/null" ) if (0 == scalar @stdoutB_exps);
180 - do_diffs($fullname, $name, "stdoutB", \@stdoutB_exps);
181 + $diffStatus |= do_diffs($fullname, $name, "stdoutB", \@stdoutB_exps);
184 $stderrB_filter_args = $name if (! defined $stderrB_filter_args);
185 @@ -571,7 +597,7 @@ sub do_one_test($$)
186 # Find all the .stderrB.exp files. At least one must exist.
187 my @stderrB_exps = <$name.stderrB.exp*>;
188 (0 != scalar @stderrB_exps) or die "Could not find `$name.stderrB.exp*'\n";
189 - do_diffs($fullname, $name, "stderrB", \@stderrB_exps);
190 + $diffStatus |= do_diffs($fullname, $name, "stderrB", \@stderrB_exps);
193 # Maybe do post-test check
194 @@ -583,7 +609,7 @@ sub do_one_test($$)
195 # Find all the .post.exp files. If none, use /dev/null.
196 my @post_exps = <$name.post.exp*>;
197 @post_exps = ( "/dev/null" ) if (0 == scalar @post_exps);
198 - do_diffs($fullname, $name, "post", \@post_exps);
199 + $diffStatus |= do_diffs($fullname, $name, "post", \@post_exps);
203 @@ -592,6 +618,13 @@ sub do_one_test($$)
204 print("(cleanup operation failed: $cleanup)\n");
207 + if ($yoctoptest == 1) {
208 + if ($diffStatus == 0) {
209 + print("PASS: $fullname\n");
211 + print("FAIL: $fullname\n");
217 @@ -631,7 +664,7 @@ sub test_one_dir($$)
218 my $found_tests = (0 != (grep { $_ =~ /\.vgtest$/ } @fs));
221 - print "-- Running tests in $full_dir $dashes\n";
222 + print "-- Running tests in $full_dir $dashes\n" if ($yoctoptest == 0);
224 foreach my $f (@fs) {
226 @@ -641,7 +674,7 @@ sub test_one_dir($$)
230 - print "-- Finished tests in $full_dir $dashes\n";
231 + print "-- Finished tests in $full_dir $dashes\n" if ($yoctoptest == 0);
235 @@ -667,10 +700,12 @@ sub summarise_results
236 $num_failures{"stdout"}, plural($num_failures{"stdout"}),
237 $num_failures{"stderrB"}, plural($num_failures{"stderrB"}),
238 $num_failures{"stdoutB"}, plural($num_failures{"stdoutB"}),
239 - $num_failures{"post"}, plural($num_failures{"post"}));
240 + $num_failures{"post"}, plural($num_failures{"post"}))
241 + if ($yoctoptest == 0);
243 foreach my $failure (@failures) {
244 - print "$failure\n";
246 + if ($yoctoptest == 0);