Francois Gouget : testbot/TestWTBS: Allow checking the content of patches.

Alexandre Julliard julliard at winehq.org
Tue Jan 26 15:53:01 CST 2021


Module: tools
Branch: master
Commit: 4565c96149b43ff1cba49c31dd4693f115946d1e
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=4565c96149b43ff1cba49c31dd4693f115946d1e

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Tue Jan 26 04:38:49 2021 +0100

testbot/TestWTBS: Allow checking the content of patches.

This is useful for checking that the TestBot assembled all the expected
parts of a patch series, particularly when multiple patch series are
pending.

For instance:
----- TestWTBS -----
a patch.Grep WTBS [12]/4
a patch.GrepV WTBS [34]/4
---- TestWTBS -----

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/tests/TestWTBS | 52 ++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 42 insertions(+), 10 deletions(-)

diff --git a/testbot/tests/TestWTBS b/testbot/tests/TestWTBS
index 58cbf30..d0e7cab 100755
--- a/testbot/tests/TestWTBS
+++ b/testbot/tests/TestWTBS
@@ -384,6 +384,12 @@ sub LoadTestInfo($)
         $TestInfo->{$TaskType}->{"$LogType.$GrepType"} = [ $Array ];
       }
     }
+
+    my $Array = $TestInfo->{patch}->{$GrepType};
+    next if (!defined $Array);
+    next if (ref($Array) eq "ARRAY");
+    fail("patch.$GrepType should be an array (a lines)");
+    $TestInfo->{patch}->{$GrepType} = [ $Array ];
   }
 
   # Automatically check webpatch.Status in simple cases
@@ -643,18 +649,18 @@ sub CheckLogErrors($$$)
   }
 }
 
-sub GrepTaskLog($$$$)
+sub GrepFile($$$$;$)
 {
-  my ($Task, $LogName, $TaskInfo, $LogType) = @_;
+  my ($Key, $Dir, $FileName, $GrepInfo, $GrepPrefix) = @_;
 
-  my @Grep = @{$TaskInfo->{"$LogType.Grep"} || []};
-  my @GrepV = @{$TaskInfo->{"$LogType.GrepV"} || []};
+  my @Grep = @{$GrepInfo->{"${GrepPrefix}Grep"} || []};
+  my @GrepV = @{$GrepInfo->{"${GrepPrefix}GrepV"} || []};
   return if (!@Grep and !@GrepV);
 
-  if (open(my $LogFile, "<", $Task->GetDir() ."/$LogName"))
+  if (open(my $Fh, "<", "$Dir/$FileName"))
   {
     my $LineNo;
-    foreach my $Line (<$LogFile>)
+    foreach my $Line (<$Fh>)
     {
       $LineNo++;
       my $i = 0;
@@ -662,7 +668,7 @@ sub GrepTaskLog($$$$)
       {
         if ($Line =~ /$GrepV[$i]/)
         {
-          fail(TaskKeyStr($Task) ."/$LogName:$LineNo should not match $GrepV[$i]");
+          fail("$Key/$FileName:$LineNo should not match $GrepV[$i]");
           splice @GrepV, $i, 1;
           next;
         }
@@ -680,14 +686,21 @@ sub GrepTaskLog($$$$)
       }
       last if (!@Grep and !@GrepV);
     }
-    close($LogFile);
+    close($Fh);
   }
   foreach my $RegExp (@Grep)
   {
-    fail(TaskKeyStr($Task) ."/$LogName should match $RegExp");
+    fail("$Key/$FileName should match $RegExp");
   }
 }
 
+sub GrepTaskLog($$$$)
+{
+  my ($Task, $LogName, $GrepInfo, $GrepPrefix) = @_;
+
+  return GrepFile(TaskKeyStr($Task), $Task->GetDir(), $LogName, $GrepInfo, $GrepPrefix);
+}
+
 =pod
 
 =item <job.Status>
@@ -769,7 +782,7 @@ sub CheckTask($$$$)
       CheckLogErrors($LogInfo, $TaskInfo->{"$LogType.errors"},
                      TaskKeyStr($Task) ."/$LogName");
     }
-    GrepTaskLog($Task, $LogName, $TaskInfo, $LogType);
+    GrepTaskLog($Task, $LogName, $TaskInfo, "$LogType.");
   }
   if ($Task->Status eq "completed" and CheckValue($TaskInfo->{TestFailures}))
   {
@@ -850,6 +863,21 @@ space-separated list on the VMs matching the specified category.
 For instance:
 p win.TestUnits cabinet:extract cabinet:fdi
 
+=item <patch.Grep>
+=item <patch.GrepV>
+
+Verifies the presence or absence of specific regular expressions in the
+job's patch file. Multiple regular expressions can be specified so this uses
+the array type of line ('a').
+
+For instance:
+a patch.Grep WTBS [12]/4
+a patch.GrepV WTBS [34]/4
+
+Assuming that the WTBS patch series contains specific strings that allow
+identifying each part, this checks that the job's patch contains parts 1 and 2
+but not parts 3 and 4.
+
 =cut
 
 sub CheckJobTree($;$)
@@ -876,6 +904,10 @@ sub CheckJobTree($;$)
 
       $TestInfo = LoadTestInfo($Step->GetFullFileName());
       return if (!$TestInfo);
+      if ($TestInfo->{patch})
+      {
+        GrepFile($Job->Id, $Job->GetDir(), "patch.diff", $TestInfo->{patch});
+      }
     }
 
     my $TaskType = $Step->Type eq "build" ? "build" :




More information about the wine-cvs mailing list