On x86 compilers without fastcall, simulate it when invoking traces and un-simulate...
[wine-gecko.git] / js / tests / Patterns.pm
blob2ca29d4dfbf9425396bcb11a69c9462f1782ed50
1 # -*- Mode: Perl; tab-width: 4; indent-tabs-mode: nil; -*-
2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
13 # License.
15 # The Original Code is Mozilla JavaScript Testing Utilities
17 # The Initial Developer of the Original Code is
18 # Mozilla Corporation.
19 # Portions created by the Initial Developer are Copyright (C) 2008
20 # the Initial Developer. All Rights Reserved.
22 # Contributor(s): Bob Clary <bclary@bclary.com>
24 # Alternatively, the contents of this file may be used under the terms of
25 # either the GNU General Public License Version 2 or later (the "GPL"), or
26 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 # in which case the provisions of the GPL or the LGPL are applicable instead
28 # of those above. If you wish to allow use of your version of this file only
29 # under the terms of either the GPL or the LGPL, and not to allow others to
30 # use your version of this file under the terms of the MPL, indicate your
31 # decision by deleting the provisions above and replace them with the notice
32 # and other provisions required by the GPL or the LGPL. If you do not delete
33 # the provisions above, a recipient may use your version of this file under
34 # the terms of any one of the MPL, the GPL or the LGPL.
36 # ***** END LICENSE BLOCK *****
38 package Patterns;
40 sub getuniversekey
42 my ($machinerecord, $excludeduniversefield) = @_;
43 my $i;
44 my $key = '';
46 dbg("getuniversekey: \$machinerecord=" . recordtostring($machinerecord) . ", \$excludeduniversefield=$excludeduniversefield");
48 for ($i = 0; $i < @universefields; $i++)
50 dbg("getuniversekey: \$universefields[$i]=$universefields[$i]");
52 if ($universefields[$i] ne $excludeduniversefield)
54 $key .= $machinerecord->{$universefields[$i]}
58 dbg("getuniversekey=$key");
60 return $key;
63 sub getuniverse
65 my ($universekey, $excludeduniversefield) = @_;
66 my $i;
67 my $value;
68 my $testrun;
69 my @universe = ();
70 my %universehash = ();
72 dbg("getuniverse: \$universekey=$universekey, \$excludeduniversefield=$excludeduniversefield");
74 for ($i = 0; $i < @testruns; $i++)
76 $testrun = $testruns[$i];
77 dbg("getuniverse: \$testruns[$i]=" . recordtostring($testrun));
78 $testrununiversekey = getuniversekey($testrun, $excludeduniversefield);
79 dbg("getuniverse: \$testrununiversekey=$testrununiversekey");
80 if ($testrununiversekey =~ /$universekey/)
82 dbg("getuniverse: matched \$testrununiversekey=$testrununiversekey to \$universekey=$universekey");
83 $value = $testrun->{$excludeduniversefield};
85 dbg("getuniverse: \$testrun->{$excludeduniversefield}=$value");
87 if (! $universehash{$value} )
89 dbg("getuniverse: pushing $value");
90 push @universe, ($value);
91 $universehash{$value} = 1;
95 @universe = sort @universe;
96 dbg("getuniverse=" . join(',', @universe));
97 return @universe;
100 sub recordtostring
102 my ($record) = @_;
103 my $j;
104 my $line = '';
105 my $field;
107 for ($j = 0; $j < @recordfields - 1; $j++)
109 $field = $recordfields[$j];
110 dbg("recordtostring: \$field=$field, \$record->{$field}=$record->{$field}");
111 $line .= "$field=$record->{$field}, ";
113 $field = $recordfields[$#recordfields];
114 dbg("recordtodtring: \$field=$field, \$record->{$field}= $record->{$field}");
115 $line .= "$field=$record->{$field}";
117 return $line;
120 sub dumprecords
122 my $record;
123 my $line;
124 my $prevline = '';
125 my $i;
127 dbg("dumping records");
129 # @records = sort sortrecords @records;
131 for ($i = 0; $i < @records; $i++)
133 $record = $records[$i];
134 $line = recordtostring($record);
135 if ($line eq $prevline)
137 dbg("DUPLICATE $line") if ($DEBUG);
139 else
141 print "$line\n";
142 $prevline = $line;
147 sub sortrecords
149 return recordtostring($a) cmp recordtostring($b);
152 sub dbg
154 if ($DEBUG)
156 print STDERR "DEBUG: " . join(" ", @_) . "\n";
160 sub copyreference
162 my ($fromreference) = @_;
163 my $toreference = {};
164 my $key;
166 foreach $key (keys %{$fromreference})
168 $toreference->{$key} = $fromreference->{$key};
170 return $toreference;
173 BEGIN
175 dbg("begin");
177 my $test_dir = $ENV{TEST_DIR} || "/work/mozilla/mozilla.com/test.mozilla.com/www";
179 $DEBUG = $ENV{DEBUG};
181 @recordfields = ('TEST_ID', 'TEST_BRANCH', 'TEST_REPO', 'TEST_BUILDTYPE', 'TEST_TYPE', 'TEST_OS', 'TEST_KERNEL', 'TEST_PROCESSORTYPE', 'TEST_MEMORY', 'TEST_CPUSPEED', 'TEST_TIMEZONE', 'TEST_RESULT', 'TEST_EXITSTATUS', 'TEST_DESCRIPTION');
182 @sortkeyfields = ('TEST_ID', 'TEST_RESULT', 'TEST_EXITSTATUS', 'TEST_DESCRIPTION', 'TEST_BRANCH', 'TEST_REPO', 'TEST_BUILDTYPE', 'TEST_TYPE', 'TEST_OS', 'TEST_KERNEL', 'TEST_PROCESSORTYPE', 'TEST_MEMORY', 'TEST_CPUSPEED', 'TEST_TIMEZONE', );
183 @universefields = ('TEST_BRANCH', 'TEST_REPO', 'TEST_BUILDTYPE', 'TEST_TYPE', 'TEST_OS', 'TEST_KERNEL', 'TEST_PROCESSORTYPE', 'TEST_MEMORY', 'TEST_CPUSPEED', 'TEST_TIMEZONE');
185 @records = ();
187 @testruns = ();
189 my $UNIVERSE = $ENV{TEST_UNIVERSE} || "$test_dir/tests/mozilla.org/js/universe.data";
191 dbg "UNIVERSE=$UNIVERSE";
193 open TESTRUNS, "<$UNIVERSE" or die "$?";
195 while (<TESTRUNS>) {
197 chomp;
199 dbg("BEGIN: \$_=$_\n");
201 my $record = {};
203 my ($test_os, $test_kernel, $test_processortype, $test_memory, $test_cpuspeed, $test_timezone, $test_branch, $test_repo, $test_buildtype, $test_type) = $_ =~
204 /^TEST_OS=([^,]*), TEST_KERNEL=([^,]*), TEST_PROCESSORTYPE=([^,]*), TEST_MEMORY=([^,]*), TEST_CPUSPEED=([^,]*), TEST_TIMEZONE=([^,]*), TEST_BRANCH=([^,]*), TEST_REPO=([^,]*), TEST_BUILDTYPE=([^,]*), TEST_TYPE=([^,]*)/;
206 $record->{TEST_ID} = 'dummy';
207 $record->{TEST_RESULT} = 'dummy';
208 $record->{TEST_EXITSTATUS} = 'dummy';
209 $record->{TEST_DESCRIPTION} = 'dummy';
211 $record->{TEST_BRANCH} = $test_branch;
212 $record->{TEST_REPO} = $test_repo;
213 $record->{TEST_BUILDTYPE} = $test_buildtype;
214 $record->{TEST_TYPE} = $test_type;
215 $record->{TEST_OS} = $test_os;
216 $record->{TEST_KERNEL} = $test_kernel;
217 $record->{TEST_PROCESSORTYPE} = $test_processortype;
218 $record->{TEST_MEMORY} = $test_memory;
219 $record->{TEST_CPUSPEED} = $test_cpuspeed;
220 $record->{TEST_TIMEZONE} = $test_timezone;
222 dbg("BEGIN: testrun: " . recordtostring($record));
224 push @testruns, ($record);
227 close TESTRUNS;