2008-06-25 22:14:01 +00:00
|
|
|
# -*- Mode: Perl; tab-width: 4; indent-tabs-mode: nil; -*-
|
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
|
|
|
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
# 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
# http://www.mozilla.org/MPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
# for the specific language governing rights and limitations under the
|
|
|
|
# License.
|
|
|
|
#
|
|
|
|
# The Original Code is Mozilla JavaScript Testing Utilities
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is
|
|
|
|
# Mozilla Corporation.
|
|
|
|
# Portions created by the Initial Developer are Copyright (C) 2008
|
|
|
|
# the Initial Developer. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s): Bob Clary <bclary@bclary.com>
|
|
|
|
#
|
|
|
|
# Alternatively, the contents of this file may be used under the terms of
|
|
|
|
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
# in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
# of those above. If you wish to allow use of your version of this file only
|
|
|
|
# under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
# use your version of this file under the terms of the MPL, indicate your
|
|
|
|
# decision by deleting the provisions above and replace them with the notice
|
|
|
|
# and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
# the provisions above, a recipient may use your version of this file under
|
|
|
|
# the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
#
|
|
|
|
# ***** END LICENSE BLOCK *****
|
|
|
|
|
|
|
|
package Patterns;
|
|
|
|
|
|
|
|
sub getuniversekey
|
|
|
|
{
|
|
|
|
my ($machinerecord, $excludeduniversefield) = @_;
|
|
|
|
my $i;
|
|
|
|
my $key = '';
|
|
|
|
|
2009-01-14 15:16:17 +00:00
|
|
|
if ($DEBUG) {
|
|
|
|
dbg("getuniversekey: \$machinerecord=" . recordtostring($machinerecord) . ", \$excludeduniversefield=$excludeduniversefield");
|
|
|
|
}
|
2008-06-25 22:14:01 +00:00
|
|
|
|
|
|
|
for ($i = 0; $i < @universefields; $i++)
|
|
|
|
{
|
2009-01-14 15:16:17 +00:00
|
|
|
if ($DEBUG) {
|
|
|
|
dbg("getuniversekey: \$universefields[$i]=$universefields[$i]");
|
|
|
|
}
|
2008-06-25 22:14:01 +00:00
|
|
|
|
|
|
|
if ($universefields[$i] ne $excludeduniversefield)
|
|
|
|
{
|
|
|
|
$key .= $machinerecord->{$universefields[$i]}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-14 15:16:17 +00:00
|
|
|
if ($DEBUG) {
|
|
|
|
dbg("getuniversekey=$key");
|
|
|
|
}
|
2008-06-25 22:14:01 +00:00
|
|
|
|
|
|
|
return $key;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub getuniverse
|
|
|
|
{
|
|
|
|
my ($universekey, $excludeduniversefield) = @_;
|
|
|
|
my $i;
|
|
|
|
my $value;
|
|
|
|
my $testrun;
|
|
|
|
my @universe = ();
|
|
|
|
my %universehash = ();
|
|
|
|
|
2009-01-14 15:16:17 +00:00
|
|
|
if ($DEBUG) {
|
|
|
|
dbg("getuniverse: \$universekey=$universekey, \$excludeduniversefield=$excludeduniversefield");
|
|
|
|
}
|
2008-06-25 22:14:01 +00:00
|
|
|
|
|
|
|
for ($i = 0; $i < @testruns; $i++)
|
|
|
|
{
|
|
|
|
$testrun = $testruns[$i];
|
2009-01-14 15:16:17 +00:00
|
|
|
if ($DEBUG) {
|
|
|
|
dbg("getuniverse: \$testruns[$i]=" . recordtostring($testrun));
|
|
|
|
}
|
2008-06-25 22:14:01 +00:00
|
|
|
$testrununiversekey = getuniversekey($testrun, $excludeduniversefield);
|
2009-01-14 15:16:17 +00:00
|
|
|
if ($DEBUG) {
|
|
|
|
dbg("getuniverse: \$testrununiversekey=$testrununiversekey");
|
|
|
|
}
|
2008-06-25 22:14:01 +00:00
|
|
|
if ($testrununiversekey =~ /$universekey/)
|
|
|
|
{
|
2009-01-14 15:16:17 +00:00
|
|
|
if ($DEBUG) {
|
|
|
|
dbg("getuniverse: matched \$testrununiversekey=$testrununiversekey to \$universekey=$universekey");
|
|
|
|
}
|
2008-06-25 22:14:01 +00:00
|
|
|
$value = $testrun->{$excludeduniversefield};
|
|
|
|
|
2009-01-14 15:16:17 +00:00
|
|
|
if ($DEBUG) {
|
|
|
|
dbg("getuniverse: \$testrun->{$excludeduniversefield}=$value");
|
|
|
|
}
|
2008-06-25 22:14:01 +00:00
|
|
|
|
|
|
|
if (! $universehash{$value} )
|
|
|
|
{
|
2009-01-14 15:16:17 +00:00
|
|
|
if ($DEBUG) {
|
|
|
|
dbg("getuniverse: pushing $value");
|
|
|
|
}
|
2008-06-25 22:14:01 +00:00
|
|
|
push @universe, ($value);
|
|
|
|
$universehash{$value} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@universe = sort @universe;
|
2009-01-14 15:16:17 +00:00
|
|
|
if ($DEBUG) {
|
|
|
|
dbg("getuniverse=" . join(',', @universe));
|
|
|
|
}
|
2008-06-25 22:14:01 +00:00
|
|
|
return @universe;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub recordtostring
|
|
|
|
{
|
|
|
|
my ($record) = @_;
|
|
|
|
my $j;
|
|
|
|
my $line = '';
|
|
|
|
my $field;
|
|
|
|
|
|
|
|
for ($j = 0; $j < @recordfields - 1; $j++)
|
|
|
|
{
|
|
|
|
$field = $recordfields[$j];
|
2009-01-14 15:16:17 +00:00
|
|
|
if ($DEBUG) {
|
|
|
|
dbg("recordtostring: \$field=$field, \$record->{$field}=$record->{$field}");
|
|
|
|
}
|
2008-06-25 22:14:01 +00:00
|
|
|
$line .= "$field=$record->{$field}, ";
|
|
|
|
}
|
|
|
|
$field = $recordfields[$#recordfields];
|
2009-01-14 15:16:17 +00:00
|
|
|
if ($DEBUG) {
|
|
|
|
dbg("recordtodtring: \$field=$field, \$record->{$field}= $record->{$field}");
|
|
|
|
}
|
2008-06-25 22:14:01 +00:00
|
|
|
$line .= "$field=$record->{$field}";
|
|
|
|
|
|
|
|
return $line;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub dumprecords
|
|
|
|
{
|
|
|
|
my $record;
|
|
|
|
my $line;
|
|
|
|
my $prevline = '';
|
|
|
|
my $i;
|
|
|
|
|
2009-01-14 15:16:17 +00:00
|
|
|
if ($DEBUG) {
|
|
|
|
dbg("dumping records");
|
|
|
|
}
|
2008-06-25 22:14:01 +00:00
|
|
|
|
|
|
|
# @records = sort sortrecords @records;
|
|
|
|
|
|
|
|
for ($i = 0; $i < @records; $i++)
|
|
|
|
{
|
|
|
|
$record = $records[$i];
|
|
|
|
$line = recordtostring($record);
|
|
|
|
if ($line eq $prevline)
|
|
|
|
{
|
2008-07-24 05:04:56 +00:00
|
|
|
dbg("DUPLICATE $line") if ($DEBUG);
|
2008-06-25 22:14:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print "$line\n";
|
|
|
|
$prevline = $line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub sortrecords
|
|
|
|
{
|
|
|
|
return recordtostring($a) cmp recordtostring($b);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub dbg
|
|
|
|
{
|
|
|
|
if ($DEBUG)
|
|
|
|
{
|
2008-07-24 05:04:56 +00:00
|
|
|
print STDERR "DEBUG: " . join(" ", @_) . "\n";
|
2008-06-25 22:14:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub copyreference
|
|
|
|
{
|
|
|
|
my ($fromreference) = @_;
|
|
|
|
my $toreference = {};
|
|
|
|
my $key;
|
|
|
|
|
|
|
|
foreach $key (keys %{$fromreference})
|
|
|
|
{
|
2008-07-24 05:04:56 +00:00
|
|
|
$toreference->{$key} = $fromreference->{$key};
|
2008-06-25 22:14:01 +00:00
|
|
|
}
|
|
|
|
return $toreference;
|
|
|
|
}
|
|
|
|
|
|
|
|
BEGIN
|
|
|
|
{
|
|
|
|
dbg("begin");
|
|
|
|
|
|
|
|
my $test_dir = $ENV{TEST_DIR} || "/work/mozilla/mozilla.com/test.mozilla.com/www";
|
|
|
|
|
|
|
|
$DEBUG = $ENV{DEBUG};
|
|
|
|
|
2009-02-21 00:57:11 +00:00
|
|
|
@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');
|
|
|
|
@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');
|
|
|
|
@universefields = ('TEST_BRANCH', 'TEST_REPO', 'TEST_BUILDTYPE', 'TEST_TYPE', 'TEST_OS', 'TEST_KERNEL', 'TEST_PROCESSORTYPE', 'TEST_MEMORY', 'TEST_TIMEZONE', 'TEST_OPTIONS');
|
2008-06-25 22:14:01 +00:00
|
|
|
|
|
|
|
@records = ();
|
|
|
|
|
|
|
|
@testruns = ();
|
|
|
|
|
2008-08-13 18:09:14 +00:00
|
|
|
my $UNIVERSE = $ENV{TEST_UNIVERSE} || "$test_dir/tests/mozilla.org/js/universe.data";
|
|
|
|
|
|
|
|
dbg "UNIVERSE=$UNIVERSE";
|
|
|
|
|
|
|
|
open TESTRUNS, "<$UNIVERSE" or die "$?";
|
2008-06-25 22:14:01 +00:00
|
|
|
|
|
|
|
while (<TESTRUNS>) {
|
|
|
|
|
|
|
|
chomp;
|
|
|
|
|
2008-07-24 05:04:56 +00:00
|
|
|
dbg("BEGIN: \$_=$_\n");
|
|
|
|
|
2008-06-25 22:14:01 +00:00
|
|
|
my $record = {};
|
|
|
|
|
2009-02-21 00:57:11 +00:00
|
|
|
my ($test_os, $test_kernel, $test_processortype, $test_memory, $test_timezone, $test_jsoptions, $test_branch, $test_repo, $test_buildtype, $test_type) = $_ =~
|
|
|
|
/^TEST_OS=([^,]*), TEST_KERNEL=([^,]*), TEST_PROCESSORTYPE=([^,]*), TEST_MEMORY=([^,]*), TEST_TIMEZONE=([^,]*), TEST_OPTIONS=([^,]*), TEST_BRANCH=([^,]*), TEST_REPO=([^,]*), TEST_BUILDTYPE=([^,]*), TEST_TYPE=([^,]*)/;
|
2008-07-24 05:04:56 +00:00
|
|
|
|
|
|
|
$record->{TEST_ID} = 'dummy';
|
|
|
|
$record->{TEST_RESULT} = 'dummy';
|
|
|
|
$record->{TEST_EXITSTATUS} = 'dummy';
|
|
|
|
$record->{TEST_DESCRIPTION} = 'dummy';
|
2008-06-25 22:14:01 +00:00
|
|
|
|
|
|
|
$record->{TEST_BRANCH} = $test_branch;
|
2008-07-24 05:04:56 +00:00
|
|
|
$record->{TEST_REPO} = $test_repo;
|
2008-06-25 22:14:01 +00:00
|
|
|
$record->{TEST_BUILDTYPE} = $test_buildtype;
|
|
|
|
$record->{TEST_TYPE} = $test_type;
|
|
|
|
$record->{TEST_OS} = $test_os;
|
|
|
|
$record->{TEST_KERNEL} = $test_kernel;
|
|
|
|
$record->{TEST_PROCESSORTYPE} = $test_processortype;
|
|
|
|
$record->{TEST_MEMORY} = $test_memory;
|
|
|
|
$record->{TEST_TIMEZONE} = $test_timezone;
|
2009-01-14 15:16:17 +00:00
|
|
|
$record->{TEST_OPTIONS} = $test_jsoptions;
|
2008-06-25 22:14:01 +00:00
|
|
|
|
2008-07-24 05:04:56 +00:00
|
|
|
dbg("BEGIN: testrun: " . recordtostring($record));
|
|
|
|
|
|
|
|
push @testruns, ($record);
|
2008-06-25 22:14:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
close TESTRUNS;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|