aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/valgrind/valgrind/add-ptest.patch
blob: fdc9cc0e83b77a93c23fb350290962f5eab5bc14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
Modify vg_test wrapper to support PTEST formats

This commit changes the valgrind regression test script vg_regtest to
support the yocto ptest stdout reporting format.  The commit adds
'--yocto-ptest' as an optional argument to vg_regtest, which alters
the output to use the ptest infrastructure reporting format:
    "[PASS|SKIP|FAIL]: testname"
instead of valgrind's internal test reporting format.  Without the added
option, --yocto-ptest, the valgrind regression test output is unchanged.

Upstream-Status: Pending

Signed-off-by: Dave Lerner <dave.lerner@windriver.com>

diff --git a/tests/vg_regtest.in b/tests/vg_regtest.in
index 224385f..dbbd23d 100755
--- a/tests/vg_regtest.in
+++ b/tests/vg_regtest.in
@@ -39,11 +39,11 @@
 #               --valgrind.)
 #   --keep-unfiltered: keep a copy of the unfiltered output/error output
 #     of each test by adding an extension .unfiltered.out
-#
 #   --outer-valgrind: run this valgrind under the given outer valgrind.
 #     This valgrind must be configured with --enable-inner.
 #   --outer-tool: tool to use by the outer valgrind (default memcheck).
 #   --outer-args: use this as outer tool args.
+#   --yocto-ptest: output in yocto ptest format
 #
 # The easiest way is to run all tests in valgrind/ with (assuming you installed
 # in $PREFIX):
@@ -126,7 +126,7 @@ use strict;
 my $usage="\n"
      . "Usage:\n"
      . "   vg_regtest [--all, --valgrind, --valgrind-lib, --keep-unfiltered\n"
-     . "                 --outer-valgrind, --outer-tool, --outer-args]\n"
+     . "                 --outer-valgrind, --outer-tool, --outer-args, --yocto-ptest]\n"
      . "   Use EXTRA_REGTEST_OPTS to supply extra args for all tests\n"
      . "\n";
 
@@ -170,6 +170,7 @@ my $outer_args;
 
 my $valgrind_lib = "$tests_dir/.in_place";
 my $keepunfiltered = 0;
+my $yoctoptest = 0;
 
 # default filter is the one named "filter_stderr" in the test's directory
 my $default_stderr_filter = "filter_stderr";
@@ -226,6 +227,8 @@ sub process_command_line()
                 $valgrind_lib = $1;
             } elsif ($arg =~ /^--keep-unfiltered$/) {
                 $keepunfiltered = 1;
+            } elsif ($arg =~ /^--yocto-ptest$/) {
+                $yoctoptest = 1;
             } else {
                 die $usage;
             }
@@ -394,19 +397,21 @@ sub do_diffs($$$$)
                 # A match;  remove .out and any previously created .diff files.
                 unlink("$name.$mid.out");
                 unlink(<$name.$mid.diff*>);
-                return;
+                return 0;
             }
         }
     }
     # If we reach here, none of the .exp files matched.
-    print "*** $name failed ($mid) ***\n";
+    print "*** $name failed ($mid) ***\n" if ($yoctoptest == 0) ;
     push(@failures, sprintf("%-40s ($mid)", "$fullname"));
     $num_failures{$mid}++;
+    return 1;
 }
 
 sub do_one_test($$) 
 {
     my ($dir, $vgtest) = @_;
+    my $diffStatus = 0;
     $vgtest =~ /^(.*)\.vgtest/;
     my $name = $1;
     my $fullname = "$dir/$name"; 
@@ -425,7 +430,11 @@ sub do_one_test($$)
         } elsif (256 == $prereq_res) {
             # Nb: weird Perl-ism -- exit code of '1' is seen by Perl as 256...
             # Prereq failed, skip.
-            printf("%-16s (skipping, prereq failed: $prereq)\n", "$name:");
+            if ($yoctoptest == 0) {
+                printf("%-16s (skipping, prereq failed: $prereq)\n", "$name:");
+            } else {
+                printf("SKIP: $fullname\n");
+            }
             return;
         } else {
             # Bad prereq; abort.
@@ -438,7 +447,7 @@ sub do_one_test($$)
     if (defined $progB) {
         # If there is a progB, let's start it in background:
         printf("%-16s valgrind $extraopts $vgopts $prog $args (progB: $progB $argsB)\n",
-               "$name:");
+               "$name:") if ($yoctoptest == 0);
         # progB.done used to detect child has finished. See below.
         # Note: redirection of stdout and stderr is before $progB to allow argsB
         # to e.g. redirect stdoutB to stderrB
@@ -452,7 +461,8 @@ sub do_one_test($$)
                      . "touch progB.done)  &");
         }
     } else {
-        printf("%-16s valgrind $extraopts $vgopts $prog $args\n", "$name:");
+        printf("%-16s valgrind $extraopts $vgopts $prog $args\n", "$name:")
+            if ($yoctoptest == 0);
     }
  
     # Pass the appropriate --tool option for the directory (can be overridden
@@ -487,7 +497,7 @@ sub do_one_test($$)
     # Find all the .stdout.exp files.  If none, use /dev/null.
     my @stdout_exps = <$name.stdout.exp*>;
     @stdout_exps = ( "/dev/null" ) if (0 == scalar @stdout_exps);
-    do_diffs($fullname, $name, "stdout", \@stdout_exps); 
+    $diffStatus |= do_diffs($fullname, $name, "stdout", \@stdout_exps);
 
     # Filter stderr
     $stderr_filter_args = $name if (! defined $stderr_filter_args);
@@ -496,7 +506,7 @@ sub do_one_test($$)
     # Find all the .stderr.exp files.  At least one must exist.
     my @stderr_exps = <$name.stderr.exp*>;
     (0 != scalar @stderr_exps) or die "Could not find `$name.stderr.exp*'\n";
-    do_diffs($fullname, $name, "stderr", \@stderr_exps); 
+    $diffStatus |= do_diffs($fullname, $name, "stderr", \@stderr_exps);
 
     if (defined $progB) {
         # wait for the child to be finished
@@ -520,7 +530,7 @@ sub do_one_test($$)
         # Find all the .stdoutB.exp files.  If none, use /dev/null.
         my @stdoutB_exps = <$name.stdoutB.exp*>;
         @stdoutB_exps = ( "/dev/null" ) if (0 == scalar @stdoutB_exps);
-        do_diffs($fullname, $name, "stdoutB", \@stdoutB_exps); 
+        $diffStatus |= do_diffs($fullname, $name, "stdoutB", \@stdoutB_exps);
         
         # Filter stderr
         $stderrB_filter_args = $name if (! defined $stderrB_filter_args);
@@ -529,7 +539,7 @@ sub do_one_test($$)
         # Find all the .stderrB.exp files.  At least one must exist.
         my @stderrB_exps = <$name.stderrB.exp*>;
         (0 != scalar @stderrB_exps) or die "Could not find `$name.stderrB.exp*'\n";
-        do_diffs($fullname, $name, "stderrB", \@stderrB_exps); 
+        $diffStatus |= do_diffs($fullname, $name, "stderrB", \@stderrB_exps);
     }
 
     # Maybe do post-test check
@@ -541,7 +551,7 @@ sub do_one_test($$)
 	    # Find all the .post.exp files.  If none, use /dev/null.
 	    my @post_exps = <$name.post.exp*>;
 	    @post_exps = ( "/dev/null" ) if (0 == scalar @post_exps);
-	    do_diffs($fullname, $name, "post", \@post_exps);
+	    $diffStatus |= do_diffs($fullname, $name, "post", \@post_exps);
 	}
     }
  
@@ -550,6 +560,13 @@ sub do_one_test($$)
             print("(cleanup operation failed: $cleanup)\n");
     }
 
+    if ($yoctoptest == 1) {
+        if ($diffStatus == 0) {
+            print("PASS: $fullname\n");
+        } else {
+            print("FAIL: $fullname\n");
+        }
+    }
     $num_tests_done++;
 }
 
@@ -589,7 +606,7 @@ sub test_one_dir($$)
     my $found_tests = (0 != (grep { $_ =~ /\.vgtest$/ } @fs));
 
     if ($found_tests) {
-        print "-- Running  tests in $full_dir $dashes\n";
+        print "-- Running  tests in $full_dir $dashes\n" if ($yoctoptest == 0);
     }
     foreach my $f (@fs) {
         if (-d $f) {
@@ -599,7 +616,7 @@ sub test_one_dir($$)
         }
     }
     if ($found_tests) {
-        print "-- Finished tests in $full_dir $dashes\n";
+        print "-- Finished tests in $full_dir $dashes\n" if ($yoctoptest == 0);
     }
 
     chdir("..");
@@ -625,10 +642,12 @@ sub summarise_results
            $num_failures{"stdout"},   plural($num_failures{"stdout"}),
            $num_failures{"stderrB"},  plural($num_failures{"stderrB"}),
            $num_failures{"stdoutB"},  plural($num_failures{"stdoutB"}),
-           $num_failures{"post"},     plural($num_failures{"post"}));
+           $num_failures{"post"},     plural($num_failures{"post"}))
+               if ($yoctoptest == 0);
 
     foreach my $failure (@failures) {
-        print "$failure\n";
+        print "$failure\n"
+           if ($yoctoptest == 0);
     }
     print "\n";
 }