| 1 |
#!/usr/bin/perl -w |
| 2 |
# -*- Mode: Perl; tab-width: 4; indent-tabs-mode: nil; -*- |
| 3 |
# This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 6 |
|
| 7 |
# usage: pattern-expander.pl knownfailures > knownfailures.expanded |
| 8 |
# |
| 9 |
# pattern-expander.pl reads the specified knownfailures file and |
| 10 |
# writes to stdout an expanded set of failures where the wildcards |
| 11 |
# ".*" are replaced with the set of possible values specified in the |
| 12 |
# universe.data file. |
| 13 |
|
| 14 |
use lib $ENV{TEST_DIR} . "/tests/mozilla.org/js"; |
| 15 |
|
| 16 |
use Patterns; |
| 17 |
|
| 18 |
package Patterns; |
| 19 |
|
| 20 |
processfile(); |
| 21 |
|
| 22 |
sub processfile |
| 23 |
{ |
| 24 |
my ($i, $j); |
| 25 |
|
| 26 |
while (<ARGV>) { |
| 27 |
|
| 28 |
chomp; |
| 29 |
|
| 30 |
$record = {}; |
| 31 |
|
| 32 |
my ($test_id, $test_branch, $test_repo, $test_buildtype, $test_type, $test_os, $test_kernel, $test_processortype, $test_memory, $test_timezone, $test_options, $test_result, $test_exitstatus, $test_description) = $_ =~ |
| 33 |
/TEST_ID=([^,]*), TEST_BRANCH=([^,]*), TEST_REPO=([^,]*), TEST_BUILDTYPE=([^,]*), TEST_TYPE=([^,]*), TEST_OS=([^,]*), TEST_KERNEL=([^,]*), TEST_PROCESSORTYPE=([^,]*), TEST_MEMORY=([^,]*), TEST_TIMEZONE=([^,]*), TEST_OPTIONS=([^,]*), TEST_RESULT=([^,]*), TEST_EXITSTATUS=([^,]*), TEST_DESCRIPTION=(.*)/; |
| 34 |
|
| 35 |
$record->{TEST_ID} = $test_id; |
| 36 |
$record->{TEST_BRANCH} = $test_branch; |
| 37 |
$record->{TEST_REPO} = $test_repo; |
| 38 |
$record->{TEST_BUILDTYPE} = $test_buildtype; |
| 39 |
$record->{TEST_TYPE} = $test_type; |
| 40 |
$record->{TEST_OS} = $test_os; |
| 41 |
$record->{TEST_KERNEL} = $test_kernel; |
| 42 |
$record->{TEST_PROCESSORTYPE} = $test_processortype; |
| 43 |
$record->{TEST_MEMORY} = $test_memory; |
| 44 |
$record->{TEST_TIMEZONE} = $test_timezone; |
| 45 |
$record->{TEST_OPTIONS} = $test_options; |
| 46 |
$record->{TEST_RESULT} = $test_result; |
| 47 |
$record->{TEST_EXITSTATUS} = $test_exitstatus; |
| 48 |
$record->{TEST_DESCRIPTION} = $test_description; |
| 49 |
|
| 50 |
if ($DEBUG) { |
| 51 |
dbg("processfile: \$_=$_"); |
| 52 |
} |
| 53 |
|
| 54 |
my @list1 = (); |
| 55 |
my @list2 = (); |
| 56 |
|
| 57 |
my $iuniversefield; |
| 58 |
my $universefield; |
| 59 |
|
| 60 |
$item1 = copyreference($record); |
| 61 |
if ($DEBUG) { |
| 62 |
dbg("processfile: check copyreference"); |
| 63 |
dbg("processfile: \$record=" . recordtostring($record)); |
| 64 |
dbg("processfile: \$item1=" . recordtostring($item1)); |
| 65 |
} |
| 66 |
push @list1, ($item1); |
| 67 |
|
| 68 |
for ($iuniversefield = 0; $iuniversefield < @universefields; $iuniversefield++) |
| 69 |
{ |
| 70 |
$universefield = $universefields[$iuniversefield]; |
| 71 |
|
| 72 |
if ($DEBUG) { |
| 73 |
dbg("processfile: \$universefields[$iuniversefield]=$universefield, \$record->{$universefield}=$record->{$universefield}"); |
| 74 |
} |
| 75 |
|
| 76 |
for ($j = 0; $j < @list1; $j++) |
| 77 |
{ |
| 78 |
$item1 = $list1[$j]; |
| 79 |
if ($DEBUG) { |
| 80 |
dbg("processfile: item1 \$list1[$j]=" . recordtostring($item1)); |
| 81 |
} |
| 82 |
# create a reference to a copy of the hash referenced by $item1 |
| 83 |
if ($item1->{$universefield} ne '.*') |
| 84 |
{ |
| 85 |
if ($DEBUG) { |
| 86 |
dbg("processfile: literal value"); |
| 87 |
} |
| 88 |
$item2 = copyreference($item1); |
| 89 |
if ($DEBUG) { |
| 90 |
dbg("processfile: check copyreference"); |
| 91 |
dbg("processfile: \$item1=" . recordtostring($item1)); |
| 92 |
dbg("processfile: \$item2=" . recordtostring($item2)); |
| 93 |
dbg("processfile: pushing existing record to list 2: " . recordtostring($item2)); |
| 94 |
} |
| 95 |
push @list2, ($item2); |
| 96 |
} |
| 97 |
else |
| 98 |
{ |
| 99 |
if ($DEBUG) { |
| 100 |
dbg("processfile: wildcard value"); |
| 101 |
} |
| 102 |
$keyfielduniversekey = getuniversekey($item1, $universefield); |
| 103 |
@keyfielduniverse = getuniverse($keyfielduniversekey, $universefield); |
| 104 |
|
| 105 |
if ($DEBUG) { |
| 106 |
dbg("processfile: \$keyfielduniversekey=$keyfielduniversekey, \@keyfielduniverse=" . join(',', @keyfielduniverse)); |
| 107 |
} |
| 108 |
|
| 109 |
for ($i = 0; $i < @keyfielduniverse; $i++) |
| 110 |
{ |
| 111 |
$item2 = copyreference($item1); |
| 112 |
if ($DEBUG) { |
| 113 |
dbg("processfile: check copyreference"); |
| 114 |
dbg("processfile: \$item1=" . recordtostring($item1)); |
| 115 |
dbg("processfile: \$item2=" . recordtostring($item2)); |
| 116 |
} |
| 117 |
$item2->{$universefield} = $keyfielduniverse[$i]; |
| 118 |
if ($DEBUG) { |
| 119 |
dbg("processfile: pushing new record to list 2 " . recordtostring($item2)); |
| 120 |
} |
| 121 |
push @list2, ($item2); |
| 122 |
} |
| 123 |
} |
| 124 |
if ($DEBUG) { |
| 125 |
for ($i = 0; $i < @list1; $i++) |
| 126 |
{ |
| 127 |
dbg("processfile: \$list1[$i]=" . recordtostring($list1[$i])); |
| 128 |
} |
| 129 |
for ($i = 0; $i < @list2; $i++) |
| 130 |
{ |
| 131 |
dbg("processfile: \$list2[$i]=" . recordtostring($list2[$i])); |
| 132 |
} |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
@list1 = @list2; |
| 137 |
@list2 = (); |
| 138 |
} |
| 139 |
for ($j = 0; $j < @list1; $j++) |
| 140 |
{ |
| 141 |
$item1 = $list1[$j]; |
| 142 |
push @records, ($item1); |
| 143 |
} |
| 144 |
} |
| 145 |
@records = sort sortrecords @records; |
| 146 |
|
| 147 |
dumprecords(); |
| 148 |
} |
| 149 |
|