summaryrefslogtreecommitdiffstats
path: root/meta-agl-profile-core/recipes-devtools/valgrind/valgrind/0005-Modify-vg_test-wrapper-to-support-PTEST-formats.patch
blob: 7985308e417a857e6d815e0824e6c68ed258b2e0 (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

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Bui
From f49f27f1bc67d07440b0ac9a7d767a8ea1589bfe Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Tue, 15 Dec 2015 15:50:44 +0200
Subject: [PATCH 5/5] Modify vg_test wrapper to support PTEST formats

Change 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.

Enforce 30 seconds limit for the test.
This resume execution of the remaining tests when valgrind hangs.

Upstream-Status: Pending

Signed-off-by: Dave Lerner <dave.lerner@windriver.com>
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
 tests/vg_regtest.in | 75 +++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 55 insertions(+), 20 deletions(-)

diff --git a/tests/vg_regtest.in b/tests/vg_regtest.in
index a441f42..cb05b52 100755
--- a/tests/vg_regtest.in
+++ b/tests/vg_regtest.in
@@ -47,6 +47,7 @@
 #   --loop-till-fail: loops on the test(s) till one fail, then exit
 #              This is useful to obtain detailed trace or --keep-unfiltered
 #              output of a non deterministic test failure
+#   --yocto-ptest: output in yocto ptest format
 #
 # The easiest way is to run all tests in valgrind/ with (assuming you installed
 # in $PREFIX):
@@ -139,7 +140,7 @@ my $usage="\n"
      . "Usage:\n"
      . "   vg_regtest [--all, --valgrind, --valgrind-lib, --keep-unfiltered\n"
      . "                 --outer-valgrind, --outer-tool, --outer-args\n"
-     . "                 --loop-till-fail]\n"
+     . "                 --loop-till-fail, --yocto-ptest]\n"
      . "   Use EXTRA_REGTEST_OPTS to supply extra args for all tests\n"
      . "\n";
 
@@ -186,6 +187,7 @@ my $outer_args;
 my $valgrind_lib = "$tests_dir/.in_place";
 my $keepunfiltered = 0;
 my $looptillfail = 0;
+my $yoctoptest = 0;
 
 # default filter is the one named "filter_stderr" in the test's directory
 my $default_stderr_filter = "filter_stderr";
@@ -244,6 +246,8 @@ sub process_command_line()
                 $keepunfiltered = 1;
             } elsif ($arg =~ /^--loop-till-fail$/) {
                 $looptillfail = 1;
+            } elsif ($arg =~ /^--yocto-ptest$/) {
+                $yoctoptest = 1;
             } else {
                 die $usage;
             }
@@ -365,13 +369,28 @@ sub read_vgtest_file($)
 #----------------------------------------------------------------------------
 # Since most of the program time is spent in system() calls, need this to
 # propagate a Ctrl-C enabling us to quit.
-sub mysystem($) 
+# Enforce 30 seconds limit for the test.
+# This resume execution of the remaining tests if valgrind hangs.
+sub mysystem($)
 {
-    my $exit_code = system($_[0]);
-    ($exit_code == 2) and exit 1;      # 2 is SIGINT
-    return $exit_code;
+    my $exit_code=0;
+    eval {
+        local $SIG{'ALRM'} = sub { die "timed out\n" };
+        alarm(30);
+        $exit_code = system($_[0]);
+        alarm (0);
+        ($exit_code == 2) and die "SIGINT\n";   # 2 is SIGINT
+    };
+    if ($@) {
+        if ($@ eq "timed out\n") {
+            print "timed out\n";
+            return 1;
+        }
+        if ($@ eq "SIGINT\n") {
+            exit 1;
+        }
+    }
 }
-
 # if $keepunfiltered, copies $1 to $1.unfiltered.out
 # renames $0 tp $1
 sub filtered_rename($$) 
@@ -419,23 +438,25 @@ 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}++;
     if ($looptillfail == 1) {
        print "Failure encountered, stopping to loop\n";
        exit 1
     }
+    return 1;
 }
 
 sub do_one_test($$) 
 {
     my ($dir, $vgtest) = @_;
+    my $diffStatus = 0;
     $vgtest =~ /^(.*)\.vgtest/;
     my $name = $1;
     my $fullname = "$dir/$name"; 
@@ -454,7 +475,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.
@@ -472,7 +497,7 @@ sub do_one_test($$)
         }
         # 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
@@ -488,7 +513,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);
     }
 
     # Collect environment variables, if any.
@@ -529,7 +555,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);
@@ -538,7 +564,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
@@ -562,7 +588,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);
@@ -571,7 +597,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
@@ -583,7 +609,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);
 	}
     }
  
@@ -592,6 +618,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++;
 }
 
@@ -631,7 +664,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) {
@@ -641,7 +674,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("..");
@@ -667,10 +700,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";
 }
-- 
2.6.2