Either for their presence or their absence. This is particularly useful to check that specific build actions were performed (or skipped) as expected.
For instance: ----- TestWTBS ----- a build.log.Grep ^Applying patch a build.log.GrepV ^Running make_requests a build.log.GrepV ^Running make_opengl ----- TestWTBS -----
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/tests/TestWTBS | 84 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-)
diff --git a/testbot/tests/TestWTBS b/testbot/tests/TestWTBS index 01f46bfde..58bf8a756 100755 --- a/testbot/tests/TestWTBS +++ b/testbot/tests/TestWTBS @@ -3,7 +3,7 @@ # # Automate checking the Wine TestBot test Suite results. # -# Copyright 2020 Francois Gouget +# Copyright 2020-2021 Francois Gouget # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -353,6 +353,22 @@ sub LoadTestInfo($) } }
+ # Validate and fix the Grep* fields + foreach my $GrepType ("Grep", "GrepV") + { + foreach my $TaskType ("tasks", "tests", "build", "win", "win32", "win64", "wine") + { + foreach my $LogType ("report", "log", "testbot") + { + my $Array = $TestInfo->{$TaskType}->{"$LogType.$GrepType"}; + next if (!defined $Array); + next if (ref($Array) eq "ARRAY"); + fail("$TaskType.$LogType.$GrepType should be an array (a lines)"); + $TestInfo->{$TaskType}->{"$LogType.$GrepType"} = [ $Array ]; + } + } + } + return $TestInfo; }
@@ -488,6 +504,51 @@ sub CheckLogErrors($$$) } }
+sub GrepTaskLog($$$$) +{ + my ($Task, $LogName, $TaskInfo, $LogType) = @_; + + my @Grep = @{$TaskInfo->{"$LogType.Grep"} || []}; + my @GrepV = @{$TaskInfo->{"$LogType.GrepV"} || []}; + return if (!@Grep and !@GrepV); + + if (open(my $LogFile, "<", $Task->GetDir() ."/$LogName")) + { + my $LineNo; + foreach my $Line (<$LogFile>) + { + $LineNo++; + my $i = 0; + while ($i < @GrepV) + { + if ($Line =~ /$GrepV[$i]/) + { + fail(TaskKeyStr($Task) ."/$LogName:$LineNo should not match $GrepV[$i]"); + splice @GrepV, $i, 1; + next; + } + $i++; + } + $i = 0; + while ($i < @Grep) + { + if ($Line =~ /$Grep[$i]/) + { + splice @Grep, $i, 1; + next; + } + $i++; + } + last if (!@Grep and !@GrepV); + } + close($LogFile); + } + foreach my $RegExp (@Grep) + { + fail(TaskKeyStr($Task) ."/$LogName should match $RegExp"); + } +} + =pod
=item <job.Status> @@ -503,6 +564,26 @@ By default the Status field should be 'completed'. Checks the value of the task's TestFailures field. By default the TestFailures field is not checked.
+=item <tasks.(report|log|testbot).Grep> +=item <tasks.(report|log|testbot).GrepV> + +Verifies the presence or absence of specific regular expressions in the +specified error log or reports of the tasks in the specified category. +Multiple regular expressions can be specified so this uses the array type of +line ('a'). + +For instance: +a build.log.Grep ^Applying patch +a build.log.GrepV ^Running make_requests +a build.log.GrepV ^Running make_opengl + +Checks that the TestBot applied the patch and did not find it necessary to +run make_requests and make_opengl. + +Finally, note that while the Grep* directives are inherited by subcategories, +they are not merged. So if if both win and win32 have Grep directives, win32 +will not inherit anything from the win category. + =cut
sub CheckTask($$$$) @@ -548,6 +629,7 @@ sub CheckTask($$$$) CheckLogErrors($LogInfo, $TaskInfo->{"$LogType.errors"}, TaskKeyStr($Task) ."/$LogName"); } + GrepTaskLog($Task, $LogName, $TaskInfo, $LogType); } if ($Task->Status eq "completed" and CheckValue($TaskInfo->{TestFailures})) {