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) = @_;
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");
65 my ($universekey, $excludeduniversefield) = @_;
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));
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}";
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);
149 return recordtostring
($a) cmp recordtostring
($b);
156 print STDERR
"DEBUG: " . join(" ", @_) . "\n";
162 my ($fromreference) = @_;
163 my $toreference = {};
166 foreach $key (keys %{$fromreference})
168 $toreference->{$key} = $fromreference->{$key};
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');
189 my $UNIVERSE = $ENV{TEST_UNIVERSE
} || "$test_dir/tests/mozilla.org/js/universe.data";
191 dbg
"UNIVERSE=$UNIVERSE";
193 open TESTRUNS
, "<$UNIVERSE" or die "$?";
199 dbg
("BEGIN: \$_=$_\n");
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);