| 1 |
#!/usr/bin/perl |
| 2 |
# -*- Mode: Perl; tab-width: 4; indent-tabs-mode: nil; -*- |
| 3 |
|
| 4 |
# This Source Code Form is subject to the terms of the Mozilla Public |
| 5 |
# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 7 |
|
| 8 |
use strict; |
| 9 |
use Getopt::Mixed "nextOption"; |
| 10 |
|
| 11 |
# predeclarations |
| 12 |
sub debug; |
| 13 |
sub usage; |
| 14 |
sub parse_options; |
| 15 |
sub escape_string; |
| 16 |
sub escape_pattern; |
| 17 |
sub unescape_pattern; |
| 18 |
|
| 19 |
# option arguments |
| 20 |
|
| 21 |
my $option_desc = "b=s branch>b T=s buildtype>T R=s repo>R t=s testtype>t o=s os>o K=s kernel>K A=s arch>A M=s memory>M z=s timezone>z J=s jsoptions>J l=s rawlogfile>l f=s failurelogfile>f r=s patterns>r O=s outputprefix>O D debug>D"; |
| 22 |
|
| 23 |
my $testid; |
| 24 |
my $branch; |
| 25 |
my $repo; |
| 26 |
my $buildtype; |
| 27 |
my $testtype; |
| 28 |
my $rawlogfile; |
| 29 |
my $failurelogfile; |
| 30 |
my $os; |
| 31 |
my $patterns; |
| 32 |
my $timezone; |
| 33 |
my $jsoptions; |
| 34 |
my $outputprefix; |
| 35 |
my $arch; |
| 36 |
my $kernel; |
| 37 |
my $memory; |
| 38 |
my $debug = $ENV{DEBUG}; |
| 39 |
|
| 40 |
# pattern variables |
| 41 |
|
| 42 |
my $knownfailurebranchpattern; |
| 43 |
my $failurebranchpattern; |
| 44 |
my $knownfailureospattern; |
| 45 |
my $failureospattern; |
| 46 |
my $knownfailurerepopattern; |
| 47 |
my $failurerepopattern; |
| 48 |
my $knownfailurebuildtypepattern; |
| 49 |
my $failurebuildtypepattern; |
| 50 |
my $knownfailuretesttypepattern; |
| 51 |
my $failuretesttypepattern; |
| 52 |
my $knownfailuretimezonepattern; |
| 53 |
my $failuretimezonepattern; |
| 54 |
my $knownfailurejsoptionspattern; |
| 55 |
my $failurejsoptionspattern; |
| 56 |
my $knownfailurearchpattern; |
| 57 |
my $failurearchpattern; |
| 58 |
my $knownfailurekernelpattern; |
| 59 |
my $failurekernelpattern; |
| 60 |
my $knownfailurememorypattern; |
| 61 |
my $failurememorypattern; |
| 62 |
|
| 63 |
my @patterns; |
| 64 |
my $pattern; |
| 65 |
my @failures; |
| 66 |
my @fixes; |
| 67 |
my @excludedtests; |
| 68 |
my $excludedtest; |
| 69 |
my $excludedfile; |
| 70 |
my %includedtests = {}; |
| 71 |
my $includedfile; |
| 72 |
my @results; |
| 73 |
|
| 74 |
my $regchars = '\[\^\-\]\|\{\}\?\*\+\.\<\>\$\(\)'; |
| 75 |
|
| 76 |
|
| 77 |
&parse_options; |
| 78 |
|
| 79 |
my $jsdir = $ENV{TEST_JSDIR}; |
| 80 |
|
| 81 |
if (!defined($jsdir)) { |
| 82 |
$jsdir = "/work/mozilla/mozilla.com/test.mozilla.com/www/tests/mozilla.org/js"; |
| 83 |
} |
| 84 |
|
| 85 |
my @excludedfiles = ("excluded-$branch-$testtype-$buildtype.tests"); |
| 86 |
my @includedfiles = ("included-$branch-$testtype-$buildtype.tests"); |
| 87 |
|
| 88 |
# create working patterns file consisting of matches to users selection |
| 89 |
# and which has the test description patterns escaped |
| 90 |
|
| 91 |
# remove the excluded tests from the possible fixes log |
| 92 |
|
| 93 |
|
| 94 |
foreach $excludedfile ( @excludedfiles ) { |
| 95 |
open EXCLUDED, "<$jsdir/$excludedfile" or die "Unable to open excluded file $jsdir/$excludedfile: $!\n"; |
| 96 |
while (<EXCLUDED>) { |
| 97 |
chomp; |
| 98 |
|
| 99 |
next if ($_ =~ /^\#/); |
| 100 |
|
| 101 |
s/\s+$//; |
| 102 |
|
| 103 |
push @excludedtests, ($_); |
| 104 |
} |
| 105 |
close EXCLUDED; |
| 106 |
} |
| 107 |
|
| 108 |
@excludedtests = sort @excludedtests; |
| 109 |
|
| 110 |
foreach $includedfile ( @includedfiles ) { |
| 111 |
open INCLUDED, "<$jsdir/$includedfile" or die "Unable to open included file $jsdir/$includedfile: $!\n"; |
| 112 |
while (<INCLUDED>) { |
| 113 |
chomp; |
| 114 |
|
| 115 |
next if ($_ =~ /^\#/); |
| 116 |
|
| 117 |
s/\s+$//; |
| 118 |
|
| 119 |
$includedtests{$_} = 1; |
| 120 |
} |
| 121 |
close INCLUDED; |
| 122 |
} |
| 123 |
|
| 124 |
debug "loading patterns $patterns"; |
| 125 |
debug "pattern filter: ^TEST_ID=[^,]*, TEST_BRANCH=$knownfailurebranchpattern, TEST_REPO=$knownfailurerepopattern, TEST_BUILDTYPE=$knownfailurebuildtypepattern, TEST_TYPE=$knownfailuretesttypepattern, TEST_OS=$knownfailureospattern, TEST_KERNEL=$knownfailurekernelpattern, TEST_PROCESSORTYPE=$knownfailurearchpattern, TEST_MEMORY=$knownfailurememorypattern, TEST_TIMEZONE=$knownfailuretimezonepattern, TEST_OPTIONS=$knownfailurejsoptionspattern,"; |
| 126 |
|
| 127 |
open PATTERNS, "<$patterns" or die "Unable to open known failure patterns file $patterns: $!\n"; |
| 128 |
while (<PATTERNS>) { |
| 129 |
chomp; |
| 130 |
|
| 131 |
s/\s+$//; |
| 132 |
|
| 133 |
($testid) = $_ =~ /^TEST_ID=([^,]*),/; |
| 134 |
|
| 135 |
if (!$includedtests{$testid}) |
| 136 |
{ |
| 137 |
debug "test $testid was not included during this run"; |
| 138 |
} |
| 139 |
elsif ($_ =~ /^TEST_ID=[^,]*, TEST_BRANCH=$knownfailurebranchpattern, TEST_REPO=$knownfailurerepopattern, TEST_BUILDTYPE=$knownfailurebuildtypepattern, TEST_TYPE=$knownfailuretesttypepattern, TEST_OS=$knownfailureospattern, TEST_KERNEL=$knownfailurekernelpattern, TEST_PROCESSORTYPE=$knownfailurearchpattern, TEST_MEMORY=$knownfailurememorypattern, TEST_TIMEZONE=$knownfailuretimezonepattern, TEST_OPTIONS=$knownfailurejsoptionspattern,/) { |
| 140 |
debug "adding pattern : $_"; |
| 141 |
push @patterns, (escape_pattern($_)); |
| 142 |
} |
| 143 |
else { |
| 144 |
debug "skipping pattern: $_"; |
| 145 |
} |
| 146 |
|
| 147 |
} |
| 148 |
close PATTERNS; |
| 149 |
|
| 150 |
# create a working copy of the current failures which match the users selection |
| 151 |
|
| 152 |
debug "failure filter: ^TEST_ID=[^,]*, TEST_BRANCH=$failurebranchpattern, TEST_REPO=$failurerepopattern, TEST_BUILDTYPE=$failurebuildtypepattern, TEST_TYPE=$failuretesttypepattern, TEST_OS=$failureospattern, TEST_KERNEL=$failurekernelpattern, TEST_PROCESSORTYPE=$failurearchpattern, TEST_MEMORY=$failurememorypattern, TEST_TIMEZONE=$failuretimezonepattern, TEST_OPTIONS=$failurejsoptionspattern, TEST_RESULT=FAIL[^,]*,/"; |
| 153 |
|
| 154 |
if (defined($rawlogfile)) { |
| 155 |
|
| 156 |
$failurelogfile = "$outputprefix-results-failures.log"; |
| 157 |
my $alllog = "$outputprefix-results-all.log"; |
| 158 |
|
| 159 |
debug "writing failures $failurelogfile"; |
| 160 |
|
| 161 |
open INPUTLOG, "$jsdir/post-process-logs.pl $rawlogfile |" or die "Unable to open $rawlogfile $!\n"; |
| 162 |
open ALLLOG, ">$alllog" or die "Unable to open $alllog $!\n"; |
| 163 |
open FAILURELOG, ">$failurelogfile" or die "Unable to open $failurelogfile $!\n"; |
| 164 |
|
| 165 |
while (<INPUTLOG>) { |
| 166 |
chomp; |
| 167 |
|
| 168 |
print ALLLOG "$_\n"; |
| 169 |
|
| 170 |
if ($_ =~ /^TEST_ID=[^,]*, TEST_BRANCH=$failurebranchpattern, TEST_REPO=$failurerepopattern, TEST_BUILDTYPE=$failurebuildtypepattern, TEST_TYPE=$failuretesttypepattern, TEST_OS=$failureospattern, TEST_KERNEL=$failurekernelpattern, TEST_PROCESSORTYPE=$failurearchpattern, TEST_MEMORY=$failurememorypattern, TEST_TIMEZONE=$failuretimezonepattern, TEST_OPTIONS=$failurejsoptionspattern, TEST_RESULT=FAIL[^,]*,/) { |
| 171 |
debug "failure: $_"; |
| 172 |
push @failures, ($_); |
| 173 |
print FAILURELOG "$_\n"; |
| 174 |
} |
| 175 |
} |
| 176 |
close INPUTLOG; |
| 177 |
my $inputrc = $?; |
| 178 |
close ALLLOG; |
| 179 |
close FAILURELOG; |
| 180 |
|
| 181 |
die "FATAL ERROR in post-process-logs.pl" if $inputrc != 0; |
| 182 |
} |
| 183 |
else |
| 184 |
{ |
| 185 |
debug "loading failures $failurelogfile"; |
| 186 |
|
| 187 |
my $failurelogfilemode; |
| 188 |
|
| 189 |
if ($failurelogfile =~ /\.bz2$/) |
| 190 |
{ |
| 191 |
$failurelogfilemode = "bzcat $failurelogfile|"; |
| 192 |
} |
| 193 |
elsif ($failurelogfile =~ /\.gz$/) |
| 194 |
{ |
| 195 |
$failurelogfilemode = "zcat $failurelogfile|"; |
| 196 |
} |
| 197 |
else |
| 198 |
{ |
| 199 |
$failurelogfilemode = "<$failurelogfile"; |
| 200 |
} |
| 201 |
|
| 202 |
open FAILURES, "$failurelogfilemode" or die "Unable to open current failure log $failurelogfile: $!\n"; |
| 203 |
while (<FAILURES>) { |
| 204 |
chomp; |
| 205 |
|
| 206 |
if ($_ =~ /^TEST_ID=[^,]*, TEST_BRANCH=$failurebranchpattern, TEST_REPO=$failurerepopattern, TEST_BUILDTYPE=$failurebuildtypepattern, TEST_TYPE=$failuretesttypepattern, TEST_OS=$failureospattern, TEST_KERNEL=$failurekernelpattern, TEST_PROCESSORTYPE=$failurearchpattern, TEST_MEMORY=$failurememorypattern, TEST_TIMEZONE=$failuretimezonepattern, TEST_OPTIONS=$failurejsoptionspattern, TEST_RESULT=FAIL[^,]*,/) { |
| 207 |
debug "failure: $_"; |
| 208 |
push @failures, ($_); |
| 209 |
} |
| 210 |
} |
| 211 |
close FAILURES; |
| 212 |
} |
| 213 |
|
| 214 |
debug "finding fixed bugs"; |
| 215 |
|
| 216 |
unlink "$outputprefix-results-possible-fixes.log"; |
| 217 |
|
| 218 |
foreach $pattern (@patterns) { |
| 219 |
# look for known failure patterns that don't have matches in the |
| 220 |
# the current failures selected by the user. |
| 221 |
|
| 222 |
debug "searching for matches to $pattern\n"; |
| 223 |
|
| 224 |
@results = grep m@^$pattern@, @failures; |
| 225 |
|
| 226 |
if ($debug) { |
| 227 |
my $failure; |
| 228 |
foreach $failure (@failures) { |
| 229 |
if ($failure =~ $pattern) { |
| 230 |
debug "MATCH: $pattern - $failure\n"; |
| 231 |
} |
| 232 |
else { |
| 233 |
debug "NOMATCH: $pattern - $failure\n"; |
| 234 |
} |
| 235 |
} |
| 236 |
} |
| 237 |
if ($#results == -1) { |
| 238 |
debug "fix: '$pattern'"; |
| 239 |
push @fixes, ($pattern) |
| 240 |
} |
| 241 |
} |
| 242 |
|
| 243 |
foreach $excludedtest ( @excludedtests ) { |
| 244 |
# remove any potential fixes which are due to the test being excluded |
| 245 |
|
| 246 |
if ($debug) { |
| 247 |
@results = grep m@$excludedtest@, @fixes; |
| 248 |
if ($#results > -1) { |
| 249 |
print "excluding: " . (join ', ', @results) . "\n"; |
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
@results = grep !m@$excludedtest@, @fixes; |
| 254 |
|
| 255 |
@fixes = @results; |
| 256 |
} |
| 257 |
|
| 258 |
my $fix; |
| 259 |
open OUTPUT, ">$outputprefix-results-possible-fixes.log" or die "Unable to open $outputprefix-results-possible-fixes.log: $!"; |
| 260 |
foreach $fix (@fixes) { |
| 261 |
print OUTPUT unescape_pattern($fix) . "\n"; |
| 262 |
if ($debug) { |
| 263 |
debug "fix: $fix"; |
| 264 |
} |
| 265 |
} |
| 266 |
close OUTPUT; |
| 267 |
|
| 268 |
print STDOUT "log: $outputprefix-results-possible-fixes.log\n"; |
| 269 |
|
| 270 |
debug "finding regressions"; |
| 271 |
|
| 272 |
my $pass = 0; |
| 273 |
my $changed = ($#patterns != -1); |
| 274 |
|
| 275 |
debug "changed=$changed, \$#patterns=$#patterns, \$#failures=$#failures"; |
| 276 |
|
| 277 |
while ($changed) { |
| 278 |
|
| 279 |
$pass = $pass + 1; |
| 280 |
|
| 281 |
$changed = 0; |
| 282 |
|
| 283 |
debug "pass $pass"; |
| 284 |
|
| 285 |
foreach $pattern (@patterns) { |
| 286 |
|
| 287 |
debug "Pattern: $pattern"; |
| 288 |
|
| 289 |
my @nomatches = grep !m@^$pattern@, @failures; |
| 290 |
my @matches = grep m@^$pattern@, @failures; |
| 291 |
|
| 292 |
if ($debug) { |
| 293 |
my $temp = join ', ', @nomatches; |
| 294 |
debug "nomatches: $#nomatches $temp"; |
| 295 |
$temp = join ', ', @matches; |
| 296 |
debug "matches: $#matches $temp"; |
| 297 |
} |
| 298 |
|
| 299 |
@failures = @nomatches; |
| 300 |
|
| 301 |
if ($#matches > -1) { |
| 302 |
$changed = 1; |
| 303 |
} |
| 304 |
|
| 305 |
debug "*****************************************"; |
| 306 |
} |
| 307 |
|
| 308 |
} |
| 309 |
|
| 310 |
debug "\$#excludedtests=$#excludedtests, \$#failures=$#failures"; |
| 311 |
|
| 312 |
foreach $excludedtest ( @excludedtests ) { |
| 313 |
|
| 314 |
if ($debug) { |
| 315 |
@results = grep m@$excludedtest@, @failures; |
| 316 |
if ($#results > -1) { |
| 317 |
print "excluding: " . (join ', ', @results) . "\n"; |
| 318 |
} |
| 319 |
} |
| 320 |
|
| 321 |
@results = grep !m@$excludedtest@, @failures; |
| 322 |
|
| 323 |
debug "\$#results=$#results, \$excludedtest=$excludedtest, \$#failures=$#failures"; |
| 324 |
|
| 325 |
@failures = @results; |
| 326 |
} |
| 327 |
|
| 328 |
debug "possible regressions: \$#failures=$#failures"; |
| 329 |
|
| 330 |
open OUTPUT, ">$outputprefix-results-possible-regressions.log" or die "Unable to open $outputprefix-results-possible-regressions.log: $!"; |
| 331 |
|
| 332 |
my $failure; |
| 333 |
foreach $failure (@failures) { |
| 334 |
print OUTPUT "$failure\n"; |
| 335 |
if ($debug) { |
| 336 |
debug "regression: $failure"; |
| 337 |
} |
| 338 |
} |
| 339 |
close OUTPUT; |
| 340 |
|
| 341 |
print STDOUT "log: $outputprefix-results-possible-regressions.log\n"; |
| 342 |
|
| 343 |
|
| 344 |
sub debug { |
| 345 |
if ($debug) { |
| 346 |
my $msg = shift; |
| 347 |
print STDERR "DEBUG: $msg\n"; |
| 348 |
} |
| 349 |
} |
| 350 |
|
| 351 |
sub usage { |
| 352 |
|
| 353 |
my $msg = shift; |
| 354 |
|
| 355 |
print STDERR <<EOF; |
| 356 |
|
| 357 |
usage: $msg |
| 358 |
|
| 359 |
known-failures.pl [-b|--branch] branch |
| 360 |
[-T|--buildtype] buildtype |
| 361 |
[-t|--testtype] testtype |
| 362 |
[-o|--os] os |
| 363 |
[-K|--kernel] kernel |
| 364 |
[-A|--arch] arch |
| 365 |
[-M|--memory] memory |
| 366 |
[-z|--timezone] timezone |
| 367 |
[-J|--jsoptions] jsoptions |
| 368 |
[-r|--patterns] patterns |
| 369 |
([-f|--failurelogfile] failurelogfile|[-l|--logfile] rawlogfile]) |
| 370 |
[-O|--outputprefix] outputprefix |
| 371 |
[-D] |
| 372 |
|
| 373 |
variable description |
| 374 |
=============== ============================================================ |
| 375 |
-b branch branch 1.8.0, 1.8.1, 1.9.0, all |
| 376 |
-R repository CVS for 1.8.0, 1.8.1, 1.9.0 branches, |
| 377 |
mercurial repository name for 1.9.1 and later branches |
| 378 |
(\`basename http://hg.mozilla.org/repository\`) |
| 379 |
-T buildtype build type opt, debug, all |
| 380 |
-t testtype test type browser, shell, all |
| 381 |
-o os operating system nt, darwin, linux, all |
| 382 |
-K kernel kernel, all or a specific pattern |
| 383 |
-A arch architecture, all or a specific pattern |
| 384 |
-M memory memory in Gigabytes, all or a specific pattern |
| 385 |
-z timezone -0400, -0700, etc. default to user\'s zone |
| 386 |
-J jsoptions JavaScript options |
| 387 |
-l rawlogfile raw logfile |
| 388 |
-f failurelogfile failure logfile |
| 389 |
-r patterns known failure patterns |
| 390 |
-O outputprefix output files will be generated with this prefix |
| 391 |
-D turn on debugging output |
| 392 |
EOF |
| 393 |
|
| 394 |
exit(2); |
| 395 |
} |
| 396 |
|
| 397 |
sub parse_options { |
| 398 |
my ($option, $value); |
| 399 |
|
| 400 |
Getopt::Mixed::init ($option_desc); |
| 401 |
$Getopt::Mixed::order = $Getopt::Mixed::RETURN_IN_ORDER; |
| 402 |
|
| 403 |
while (($option, $value) = nextOption()) { |
| 404 |
|
| 405 |
if ($option eq "b") { |
| 406 |
$branch = $value; |
| 407 |
} |
| 408 |
elsif ($option eq "R") { |
| 409 |
$repo = $value; |
| 410 |
} |
| 411 |
elsif ($option eq "T") { |
| 412 |
$buildtype = $value; |
| 413 |
} |
| 414 |
elsif ($option eq "t") { |
| 415 |
$testtype = $value; |
| 416 |
} |
| 417 |
elsif ($option eq "o") { |
| 418 |
$os = $value; |
| 419 |
} |
| 420 |
elsif ($option eq "K") { |
| 421 |
$kernel = $value; |
| 422 |
} |
| 423 |
elsif ($option eq "A") { |
| 424 |
$arch = $value; |
| 425 |
} |
| 426 |
elsif ($option eq "M") { |
| 427 |
$memory = $value; |
| 428 |
} |
| 429 |
elsif ($option eq "z") { |
| 430 |
$timezone = $value; |
| 431 |
} |
| 432 |
elsif ($option eq "J") { |
| 433 |
my (@s, $j); |
| 434 |
|
| 435 |
if (! $value) { |
| 436 |
$jsoptions = 'none'; |
| 437 |
} |
| 438 |
else { |
| 439 |
$value =~ s/(-\w) (\w)/$1$2/g; |
| 440 |
@s = sort split / /, $value; |
| 441 |
$j = join(" ", @s); |
| 442 |
$j =~ s/(-\w)(\w)/$1 $2/g; |
| 443 |
$jsoptions = $j; |
| 444 |
} |
| 445 |
} |
| 446 |
elsif ($option eq "r") { |
| 447 |
$patterns = $value; |
| 448 |
} |
| 449 |
elsif ($option eq "l") { |
| 450 |
$rawlogfile = $value; |
| 451 |
} |
| 452 |
elsif ($option eq "f") { |
| 453 |
$failurelogfile = $value; |
| 454 |
} |
| 455 |
elsif ($option eq "O") { |
| 456 |
$outputprefix = $value; |
| 457 |
} |
| 458 |
elsif ($option eq "D") { |
| 459 |
$debug = 1; |
| 460 |
} |
| 461 |
|
| 462 |
} |
| 463 |
|
| 464 |
if ($debug) { |
| 465 |
print "branch=$branch, buildtype=$buildtype, testtype=$testtype, os=$os, kernel=$kernel, arch=$arch, memory=$memory, timezone=$timezone, jsoptions=$jsoptions, patterns=$patterns, rawlogfile=$rawlogfile failurelogfile=$failurelogfile, outputprefix=$outputprefix\n"; |
| 466 |
} |
| 467 |
Getopt::Mixed::cleanup(); |
| 468 |
|
| 469 |
if ( !defined($branch) ) { |
| 470 |
usage "missing branch"; |
| 471 |
} |
| 472 |
|
| 473 |
if (!defined($buildtype)) { |
| 474 |
usage "missing buildtype"; |
| 475 |
} |
| 476 |
|
| 477 |
if (!defined($testtype)) { |
| 478 |
usage "missing testtype"; |
| 479 |
} |
| 480 |
|
| 481 |
if (!defined($os)) { |
| 482 |
usage "missing os"; |
| 483 |
} |
| 484 |
|
| 485 |
if (!defined($memory)) { |
| 486 |
$memory = 'all'; |
| 487 |
} |
| 488 |
|
| 489 |
if (!defined($timezone)) { |
| 490 |
usage "missing timezone"; |
| 491 |
} |
| 492 |
|
| 493 |
if (!defined($jsoptions)) { |
| 494 |
$jsoptions = 'none'; |
| 495 |
} |
| 496 |
|
| 497 |
if (!defined($patterns)) { |
| 498 |
usage "missing patterns"; |
| 499 |
} |
| 500 |
|
| 501 |
if (!defined($rawlogfile) && !defined($failurelogfile)) { |
| 502 |
usage "missing logfile"; |
| 503 |
} |
| 504 |
|
| 505 |
if (!defined($outputprefix)) { |
| 506 |
usage "missing outputprefix"; |
| 507 |
} |
| 508 |
|
| 509 |
if ($branch eq "all") { |
| 510 |
$knownfailurebranchpattern = "[^,]*"; |
| 511 |
$failurebranchpattern = "[^,]*"; |
| 512 |
} |
| 513 |
else { |
| 514 |
$knownfailurebranchpattern = "($branch|.*)"; |
| 515 |
$knownfailurebranchpattern =~ s/\./\\./g; |
| 516 |
|
| 517 |
$failurebranchpattern = "$branch"; |
| 518 |
$failurebranchpattern =~ s/\./\\./g; |
| 519 |
} |
| 520 |
|
| 521 |
if ($repo eq "all" || $repo eq ".*") { |
| 522 |
$knownfailurerepopattern = "[^,]*"; |
| 523 |
$failurerepopattern = "[^,]*"; |
| 524 |
} |
| 525 |
else { |
| 526 |
$knownfailurerepopattern = "($repo|\\.\\*)"; |
| 527 |
$failurerepopattern = "$repo"; |
| 528 |
} |
| 529 |
|
| 530 |
if ($buildtype eq "opt") { |
| 531 |
$knownfailurebuildtypepattern = "(opt|\\.\\*)"; |
| 532 |
$failurebuildtypepattern = "opt"; |
| 533 |
} |
| 534 |
elsif ($buildtype eq "debug") { |
| 535 |
$knownfailurebuildtypepattern = "(debug|\\.\\*)"; |
| 536 |
$failurebuildtypepattern = "debug"; |
| 537 |
} |
| 538 |
elsif ($buildtype eq "all") { |
| 539 |
$knownfailurebuildtypepattern = "[^,]*"; |
| 540 |
$failurebuildtypepattern = "[^,]*"; |
| 541 |
} |
| 542 |
|
| 543 |
if ($testtype eq "shell") { |
| 544 |
$knownfailuretesttypepattern = "(shell|\\.\\*)"; |
| 545 |
$failuretesttypepattern = "shell"; |
| 546 |
} |
| 547 |
elsif ($testtype eq "browser") { |
| 548 |
$knownfailuretesttypepattern = "(browser|\\.\\*)"; |
| 549 |
$failuretesttypepattern = "browser"; |
| 550 |
} |
| 551 |
elsif ($testtype eq "all") { |
| 552 |
$knownfailuretesttypepattern = "[^,]*"; |
| 553 |
$failuretesttypepattern = "[^,]*"; |
| 554 |
} |
| 555 |
|
| 556 |
if ($os eq "nt") { |
| 557 |
$knownfailureospattern = "(nt|\\.\\*)"; |
| 558 |
$failureospattern = "nt"; |
| 559 |
} |
| 560 |
elsif ($os eq "darwin") { |
| 561 |
$knownfailureospattern = "(darwin|\\.\\*)"; |
| 562 |
$failureospattern = "darwin"; |
| 563 |
} |
| 564 |
elsif ($os eq "linux") { |
| 565 |
$knownfailureospattern = "(linux|\\.\\*)"; |
| 566 |
$failureospattern = "linux"; |
| 567 |
} |
| 568 |
elsif ($os eq "all") { |
| 569 |
$knownfailureospattern = "[^,]*"; |
| 570 |
$failureospattern = "[^,]*"; |
| 571 |
} |
| 572 |
|
| 573 |
if ($kernel ne "all") { |
| 574 |
$knownfailurekernelpattern = "(" . $kernel . "|\\.\\*)"; |
| 575 |
$failurekernelpattern = "$kernel"; |
| 576 |
} |
| 577 |
else { |
| 578 |
$knownfailurekernelpattern = "[^,]*"; |
| 579 |
$failurekernelpattern = "[^,]*"; |
| 580 |
} |
| 581 |
|
| 582 |
if ($arch ne "all") { |
| 583 |
$knownfailurearchpattern = "(" . $arch . "|\\.\\*)"; |
| 584 |
$failurearchpattern = "$arch"; |
| 585 |
} |
| 586 |
else { |
| 587 |
$knownfailurearchpattern = "[^,]*"; |
| 588 |
$failurearchpattern = "[^,]*"; |
| 589 |
} |
| 590 |
|
| 591 |
if ($memory ne "all") { |
| 592 |
$knownfailurememorypattern = "(" . $memory . "|\\.\\*)"; |
| 593 |
$failurememorypattern = "$memory"; |
| 594 |
} |
| 595 |
else { |
| 596 |
$knownfailurememorypattern = "[^,]*"; |
| 597 |
$failurememorypattern = "[^,]*"; |
| 598 |
} |
| 599 |
|
| 600 |
if ($timezone eq "all") { |
| 601 |
$knownfailuretimezonepattern = "[^,]*"; |
| 602 |
$failuretimezonepattern = "[^,]*"; |
| 603 |
} |
| 604 |
else { |
| 605 |
$knownfailuretimezonepattern = "(" . escape_string($timezone) . "|\\.\\*)"; |
| 606 |
$failuretimezonepattern = escape_string("$timezone"); |
| 607 |
} |
| 608 |
|
| 609 |
if ($jsoptions eq "all") { |
| 610 |
$knownfailurejsoptionspattern = "[^,]*"; |
| 611 |
$failurejsoptionspattern = "[^,]*"; |
| 612 |
} |
| 613 |
else { |
| 614 |
$knownfailurejsoptionspattern = "(" . escape_string($jsoptions) . "|\\.\\*)"; |
| 615 |
$failurejsoptionspattern = escape_string("$jsoptions"); |
| 616 |
} |
| 617 |
|
| 618 |
} |
| 619 |
|
| 620 |
sub escape_string { |
| 621 |
my $s = shift; |
| 622 |
|
| 623 |
# replace unescaped regular expression characters in the |
| 624 |
# string so they are not interpreted as regexp chars |
| 625 |
# when matching descriptions. leave the escaped regexp chars |
| 626 |
# `regexp` alone so they can be unescaped later and used in |
| 627 |
# pattern matching. |
| 628 |
|
| 629 |
# see perldoc perlre |
| 630 |
|
| 631 |
$s =~ s/\\/\\\\/g; |
| 632 |
|
| 633 |
# escape non word chars that aren't surrounded by `` |
| 634 |
$s =~ s/(?<!`)([$regchars])(?!`)/\\$1/g; |
| 635 |
$s =~ s/(?<!`)([$regchars])(?=`)/\\$1/g; |
| 636 |
$s =~ s/(?<=`)([$regchars])(?!`)/\\$1/g; |
| 637 |
|
| 638 |
# unquote the regchars |
| 639 |
$s =~ s/\`([^\`])\`/$1/g; |
| 640 |
|
| 641 |
debug "escape_string : $s"; |
| 642 |
|
| 643 |
return "$s"; |
| 644 |
|
| 645 |
} |
| 646 |
|
| 647 |
sub escape_pattern { |
| 648 |
|
| 649 |
my $line = shift; |
| 650 |
|
| 651 |
chomp; |
| 652 |
|
| 653 |
my ($leading, $trailing) = $line =~ /(.*TEST_DESCRIPTION=)(.*)/; |
| 654 |
|
| 655 |
# debug "escape_pattern: before: $leading$trailing"; |
| 656 |
|
| 657 |
$trailing = escape_string($trailing); |
| 658 |
|
| 659 |
debug "escape_pattern : $leading$trailing"; |
| 660 |
|
| 661 |
return "$leading$trailing"; |
| 662 |
|
| 663 |
} |
| 664 |
|
| 665 |
sub unescape_pattern { |
| 666 |
my $line = shift; |
| 667 |
|
| 668 |
chomp; |
| 669 |
|
| 670 |
my ($leading, $trailing) = $line =~ /(.*TEST_DESCRIPTION=)(.*)/; |
| 671 |
|
| 672 |
# quote the unescaped non word chars |
| 673 |
$trailing =~ s/(?<!\\)([$regchars])/`$1`/g; |
| 674 |
|
| 675 |
# unescape the escaped non word chars |
| 676 |
$trailing =~ s/\\([$regchars])/$1/g; |
| 677 |
|
| 678 |
$trailing =~ s/\\\\/\\/g; |
| 679 |
|
| 680 |
debug "unescape_pattern: after: $leading$trailing"; |
| 681 |
|
| 682 |
return "$leading$trailing"; |
| 683 |
} |
| 684 |
|
| 685 |
#### |
| 686 |
|
| 687 |
|
| 688 |
1; |