diff options
Diffstat (limited to 'meta/recipes-devtools/valgrind/valgrind/add-ptest.patch')
-rw-r--r-- | meta/recipes-devtools/valgrind/valgrind/add-ptest.patch | 205 |
1 files changed, 205 insertions, 0 deletions
diff --git a/meta/recipes-devtools/valgrind/valgrind/add-ptest.patch b/meta/recipes-devtools/valgrind/valgrind/add-ptest.patch new file mode 100644 index 0000000000..fdc9cc0e83 --- /dev/null +++ b/meta/recipes-devtools/valgrind/valgrind/add-ptest.patch | |||
@@ -0,0 +1,205 @@ | |||
1 | Modify vg_test wrapper to support PTEST formats | ||
2 | |||
3 | This commit changes the valgrind regression test script vg_regtest to | ||
4 | support the yocto ptest stdout reporting format. The commit adds | ||
5 | '--yocto-ptest' as an optional argument to vg_regtest, which alters | ||
6 | the output to use the ptest infrastructure reporting format: | ||
7 | "[PASS|SKIP|FAIL]: testname" | ||
8 | instead of valgrind's internal test reporting format. Without the added | ||
9 | option, --yocto-ptest, the valgrind regression test output is unchanged. | ||
10 | |||
11 | Upstream-Status: Pending | ||
12 | |||
13 | Signed-off-by: Dave Lerner <dave.lerner@windriver.com> | ||
14 | |||
15 | diff --git a/tests/vg_regtest.in b/tests/vg_regtest.in | ||
16 | index 224385f..dbbd23d 100755 | ||
17 | --- a/tests/vg_regtest.in | ||
18 | +++ b/tests/vg_regtest.in | ||
19 | @@ -39,11 +39,11 @@ | ||
20 | # --valgrind.) | ||
21 | # --keep-unfiltered: keep a copy of the unfiltered output/error output | ||
22 | # of each test by adding an extension .unfiltered.out | ||
23 | -# | ||
24 | # --outer-valgrind: run this valgrind under the given outer valgrind. | ||
25 | # This valgrind must be configured with --enable-inner. | ||
26 | # --outer-tool: tool to use by the outer valgrind (default memcheck). | ||
27 | # --outer-args: use this as outer tool args. | ||
28 | +# --yocto-ptest: output in yocto ptest format | ||
29 | # | ||
30 | # The easiest way is to run all tests in valgrind/ with (assuming you installed | ||
31 | # in $PREFIX): | ||
32 | @@ -126,7 +126,7 @@ use strict; | ||
33 | my $usage="\n" | ||
34 | . "Usage:\n" | ||
35 | . " vg_regtest [--all, --valgrind, --valgrind-lib, --keep-unfiltered\n" | ||
36 | - . " --outer-valgrind, --outer-tool, --outer-args]\n" | ||
37 | + . " --outer-valgrind, --outer-tool, --outer-args, --yocto-ptest]\n" | ||
38 | . " Use EXTRA_REGTEST_OPTS to supply extra args for all tests\n" | ||
39 | . "\n"; | ||
40 | |||
41 | @@ -170,6 +170,7 @@ my $outer_args; | ||
42 | |||
43 | my $valgrind_lib = "$tests_dir/.in_place"; | ||
44 | my $keepunfiltered = 0; | ||
45 | +my $yoctoptest = 0; | ||
46 | |||
47 | # default filter is the one named "filter_stderr" in the test's directory | ||
48 | my $default_stderr_filter = "filter_stderr"; | ||
49 | @@ -226,6 +227,8 @@ sub process_command_line() | ||
50 | $valgrind_lib = $1; | ||
51 | } elsif ($arg =~ /^--keep-unfiltered$/) { | ||
52 | $keepunfiltered = 1; | ||
53 | + } elsif ($arg =~ /^--yocto-ptest$/) { | ||
54 | + $yoctoptest = 1; | ||
55 | } else { | ||
56 | die $usage; | ||
57 | } | ||
58 | @@ -394,19 +397,21 @@ sub do_diffs($$$$) | ||
59 | # A match; remove .out and any previously created .diff files. | ||
60 | unlink("$name.$mid.out"); | ||
61 | unlink(<$name.$mid.diff*>); | ||
62 | - return; | ||
63 | + return 0; | ||
64 | } | ||
65 | } | ||
66 | } | ||
67 | # If we reach here, none of the .exp files matched. | ||
68 | - print "*** $name failed ($mid) ***\n"; | ||
69 | + print "*** $name failed ($mid) ***\n" if ($yoctoptest == 0) ; | ||
70 | push(@failures, sprintf("%-40s ($mid)", "$fullname")); | ||
71 | $num_failures{$mid}++; | ||
72 | + return 1; | ||
73 | } | ||
74 | |||
75 | sub do_one_test($$) | ||
76 | { | ||
77 | my ($dir, $vgtest) = @_; | ||
78 | + my $diffStatus = 0; | ||
79 | $vgtest =~ /^(.*)\.vgtest/; | ||
80 | my $name = $1; | ||
81 | my $fullname = "$dir/$name"; | ||
82 | @@ -425,7 +430,11 @@ sub do_one_test($$) | ||
83 | } elsif (256 == $prereq_res) { | ||
84 | # Nb: weird Perl-ism -- exit code of '1' is seen by Perl as 256... | ||
85 | # Prereq failed, skip. | ||
86 | - printf("%-16s (skipping, prereq failed: $prereq)\n", "$name:"); | ||
87 | + if ($yoctoptest == 0) { | ||
88 | + printf("%-16s (skipping, prereq failed: $prereq)\n", "$name:"); | ||
89 | + } else { | ||
90 | + printf("SKIP: $fullname\n"); | ||
91 | + } | ||
92 | return; | ||
93 | } else { | ||
94 | # Bad prereq; abort. | ||
95 | @@ -438,7 +447,7 @@ sub do_one_test($$) | ||
96 | if (defined $progB) { | ||
97 | # If there is a progB, let's start it in background: | ||
98 | printf("%-16s valgrind $extraopts $vgopts $prog $args (progB: $progB $argsB)\n", | ||
99 | - "$name:"); | ||
100 | + "$name:") if ($yoctoptest == 0); | ||
101 | # progB.done used to detect child has finished. See below. | ||
102 | # Note: redirection of stdout and stderr is before $progB to allow argsB | ||
103 | # to e.g. redirect stdoutB to stderrB | ||
104 | @@ -452,7 +461,8 @@ sub do_one_test($$) | ||
105 | . "touch progB.done) &"); | ||
106 | } | ||
107 | } else { | ||
108 | - printf("%-16s valgrind $extraopts $vgopts $prog $args\n", "$name:"); | ||
109 | + printf("%-16s valgrind $extraopts $vgopts $prog $args\n", "$name:") | ||
110 | + if ($yoctoptest == 0); | ||
111 | } | ||
112 | |||
113 | # Pass the appropriate --tool option for the directory (can be overridden | ||
114 | @@ -487,7 +497,7 @@ sub do_one_test($$) | ||
115 | # Find all the .stdout.exp files. If none, use /dev/null. | ||
116 | my @stdout_exps = <$name.stdout.exp*>; | ||
117 | @stdout_exps = ( "/dev/null" ) if (0 == scalar @stdout_exps); | ||
118 | - do_diffs($fullname, $name, "stdout", \@stdout_exps); | ||
119 | + $diffStatus |= do_diffs($fullname, $name, "stdout", \@stdout_exps); | ||
120 | |||
121 | # Filter stderr | ||
122 | $stderr_filter_args = $name if (! defined $stderr_filter_args); | ||
123 | @@ -496,7 +506,7 @@ sub do_one_test($$) | ||
124 | # Find all the .stderr.exp files. At least one must exist. | ||
125 | my @stderr_exps = <$name.stderr.exp*>; | ||
126 | (0 != scalar @stderr_exps) or die "Could not find `$name.stderr.exp*'\n"; | ||
127 | - do_diffs($fullname, $name, "stderr", \@stderr_exps); | ||
128 | + $diffStatus |= do_diffs($fullname, $name, "stderr", \@stderr_exps); | ||
129 | |||
130 | if (defined $progB) { | ||
131 | # wait for the child to be finished | ||
132 | @@ -520,7 +530,7 @@ sub do_one_test($$) | ||
133 | # Find all the .stdoutB.exp files. If none, use /dev/null. | ||
134 | my @stdoutB_exps = <$name.stdoutB.exp*>; | ||
135 | @stdoutB_exps = ( "/dev/null" ) if (0 == scalar @stdoutB_exps); | ||
136 | - do_diffs($fullname, $name, "stdoutB", \@stdoutB_exps); | ||
137 | + $diffStatus |= do_diffs($fullname, $name, "stdoutB", \@stdoutB_exps); | ||
138 | |||
139 | # Filter stderr | ||
140 | $stderrB_filter_args = $name if (! defined $stderrB_filter_args); | ||
141 | @@ -529,7 +539,7 @@ sub do_one_test($$) | ||
142 | # Find all the .stderrB.exp files. At least one must exist. | ||
143 | my @stderrB_exps = <$name.stderrB.exp*>; | ||
144 | (0 != scalar @stderrB_exps) or die "Could not find `$name.stderrB.exp*'\n"; | ||
145 | - do_diffs($fullname, $name, "stderrB", \@stderrB_exps); | ||
146 | + $diffStatus |= do_diffs($fullname, $name, "stderrB", \@stderrB_exps); | ||
147 | } | ||
148 | |||
149 | # Maybe do post-test check | ||
150 | @@ -541,7 +551,7 @@ sub do_one_test($$) | ||
151 | # Find all the .post.exp files. If none, use /dev/null. | ||
152 | my @post_exps = <$name.post.exp*>; | ||
153 | @post_exps = ( "/dev/null" ) if (0 == scalar @post_exps); | ||
154 | - do_diffs($fullname, $name, "post", \@post_exps); | ||
155 | + $diffStatus |= do_diffs($fullname, $name, "post", \@post_exps); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | @@ -550,6 +560,13 @@ sub do_one_test($$) | ||
160 | print("(cleanup operation failed: $cleanup)\n"); | ||
161 | } | ||
162 | |||
163 | + if ($yoctoptest == 1) { | ||
164 | + if ($diffStatus == 0) { | ||
165 | + print("PASS: $fullname\n"); | ||
166 | + } else { | ||
167 | + print("FAIL: $fullname\n"); | ||
168 | + } | ||
169 | + } | ||
170 | $num_tests_done++; | ||
171 | } | ||
172 | |||
173 | @@ -589,7 +606,7 @@ sub test_one_dir($$) | ||
174 | my $found_tests = (0 != (grep { $_ =~ /\.vgtest$/ } @fs)); | ||
175 | |||
176 | if ($found_tests) { | ||
177 | - print "-- Running tests in $full_dir $dashes\n"; | ||
178 | + print "-- Running tests in $full_dir $dashes\n" if ($yoctoptest == 0); | ||
179 | } | ||
180 | foreach my $f (@fs) { | ||
181 | if (-d $f) { | ||
182 | @@ -599,7 +616,7 @@ sub test_one_dir($$) | ||
183 | } | ||
184 | } | ||
185 | if ($found_tests) { | ||
186 | - print "-- Finished tests in $full_dir $dashes\n"; | ||
187 | + print "-- Finished tests in $full_dir $dashes\n" if ($yoctoptest == 0); | ||
188 | } | ||
189 | |||
190 | chdir(".."); | ||
191 | @@ -625,10 +642,12 @@ sub summarise_results | ||
192 | $num_failures{"stdout"}, plural($num_failures{"stdout"}), | ||
193 | $num_failures{"stderrB"}, plural($num_failures{"stderrB"}), | ||
194 | $num_failures{"stdoutB"}, plural($num_failures{"stdoutB"}), | ||
195 | - $num_failures{"post"}, plural($num_failures{"post"})); | ||
196 | + $num_failures{"post"}, plural($num_failures{"post"})) | ||
197 | + if ($yoctoptest == 0); | ||
198 | |||
199 | foreach my $failure (@failures) { | ||
200 | - print "$failure\n"; | ||
201 | + print "$failure\n" | ||
202 | + if ($yoctoptest == 0); | ||
203 | } | ||
204 | print "\n"; | ||
205 | } | ||