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
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 *****
42 my ($machinerecord, $excludeduniversefield) = @_;
47 dbg("getuniversekey: \$machinerecord=" . recordtostring($machinerecord) . ", \$excludeduniversefield=$excludeduniversefield");
50 for ($i = 0; $i < @universefields; $i++)
53 dbg("getuniversekey: \$universefields[$i]=$universefields[$i]");
56 if ($universefields[$i] ne $excludeduniversefield)
58 $key .= $machinerecord->{$universefields[$i]}
63 dbg("getuniversekey=$key");
71 my ($universekey, $excludeduniversefield) = @_;
76 my %universehash = ();
79 dbg("getuniverse: \$universekey=$universekey, \$excludeduniversefield=$excludeduniversefield");
82 for ($i = 0; $i < @testruns; $i++)
84 $testrun = $testruns[$i];
86 dbg("getuniverse: \$testruns[$i]=" . recordtostring($testrun));
88 $testrununiversekey = getuniversekey($testrun, $excludeduniversefield);
90 dbg("getuniverse: \$testrununiversekey=$testrununiversekey");
92 if ($testrununiversekey =~ /$universekey/)
95 dbg("getuniverse: matched \$testrununiversekey=$testrununiversekey to \$universekey=$universekey");
97 $value = $testrun->{$excludeduniversefield};
100 dbg("getuniverse: \$testrun->{$excludeduniversefield}=$value");
103 if (! $universehash{$value} )
106 dbg("getuniverse: pushing $value");
108 push @universe, ($value);
109 $universehash{$value} = 1;
113 @universe = sort @universe;
115 dbg("getuniverse=" . join(',', @universe));
127 for ($j = 0; $j < @recordfields - 1; $j++)
129 $field = $recordfields[$j];
131 dbg("recordtostring: \$field=$field, \$record->{$field}=$record->{$field}");
133 $line .= "$field=$record->{$field}, ";
135 $field = $recordfields[$#recordfields];
137 dbg("recordtodtring: \$field=$field, \$record->{$field}= $record->{$field}");
139 $line .= "$field=$record->{$field}";
152 dbg("dumping records");
155 # @records = sort sortrecords @records;
157 for ($i = 0; $i < @records; $i++)
159 $record = $records[$i];
160 $line = recordtostring($record);
161 if ($line eq $prevline)
163 dbg("DUPLICATE $line") if ($DEBUG);
175 return recordtostring($a) cmp recordtostring($b);
182 print STDERR "DEBUG: " . join(" ", @_) . "\n";
188 my ($fromreference) = @_;
189 my $toreference = {};
192 foreach $key (keys %{$fromreference})
194 $toreference->{$key} = $fromreference->{$key};
203 my $test_dir = $ENV{TEST_DIR} || "/work/mozilla/mozilla.com/test.mozilla.com/www";
205 $DEBUG = $ENV{DEBUG};
207 @recordfields = ('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');
208 @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_TIMEZONE', 'TEST_OPTIONS');
209 @universefields = ('TEST_BRANCH', 'TEST_REPO', 'TEST_BUILDTYPE', 'TEST_TYPE', 'TEST_OS', 'TEST_KERNEL', 'TEST_PROCESSORTYPE', 'TEST_MEMORY', 'TEST_TIMEZONE', 'TEST_OPTIONS');
215 my $UNIVERSE = $ENV{TEST_UNIVERSE} || "$test_dir/tests/mozilla.org/js/universe.data";
217 dbg "UNIVERSE=$UNIVERSE";
219 open TESTRUNS, "<$UNIVERSE" or die "$?";
225 dbg("BEGIN: \$_=$_\n");
229 my ($test_os, $test_kernel, $test_processortype, $test_memory, $test_timezone, $test_jsoptions, $test_branch, $test_repo, $test_buildtype, $test_type) = $_ =~
230 /^TEST_OS=([^,]*), TEST_KERNEL=([^,]*), TEST_PROCESSORTYPE=([^,]*), TEST_MEMORY=([^,]*), TEST_TIMEZONE=([^,]*), TEST_OPTIONS=([^,]*), TEST_BRANCH=([^,]*), TEST_REPO=([^,]*), TEST_BUILDTYPE=([^,]*), TEST_TYPE=([^,]*)/;
232 $record->{TEST_ID} = 'dummy';
233 $record->{TEST_RESULT} = 'dummy';
234 $record->{TEST_EXITSTATUS} = 'dummy';
235 $record->{TEST_DESCRIPTION} = 'dummy';
237 $record->{TEST_BRANCH} = $test_branch;
238 $record->{TEST_REPO} = $test_repo;
239 $record->{TEST_BUILDTYPE} = $test_buildtype;
240 $record->{TEST_TYPE} = $test_type;
241 $record->{TEST_OS} = $test_os;
242 $record->{TEST_KERNEL} = $test_kernel;
243 $record->{TEST_PROCESSORTYPE} = $test_processortype;
244 $record->{TEST_MEMORY} = $test_memory;
245 $record->{TEST_TIMEZONE} = $test_timezone;
246 $record->{TEST_OPTIONS} = $test_jsoptions;
248 dbg("BEGIN: testrun: " . recordtostring($record));
250 push @testruns, ($record);