2005-07-30 00:21:01 +04:00
|
|
|
#!/usr/bin/perl -w
|
2005-10-11 22:44:16 +04:00
|
|
|
# -*- mode: cperl; c-basic-offset: 8; indent-tabs-mode: nil; -*-
|
|
|
|
|
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
|
|
|
# Version: MPL 1.1
|
2005-07-30 00:21:01 +04:00
|
|
|
#
|
2005-10-11 22:44:16 +04:00
|
|
|
# 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/
|
2005-07-30 00:21:01 +04:00
|
|
|
#
|
2005-10-11 22:44:16 +04:00
|
|
|
# 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.
|
2005-07-30 00:21:01 +04:00
|
|
|
#
|
|
|
|
# The Original Code is Litmus.
|
|
|
|
#
|
2005-10-11 22:44:16 +04:00
|
|
|
# The Initial Developer of the Original Code is
|
|
|
|
# the Mozilla Corporation.
|
2006-01-25 20:03:40 +03:00
|
|
|
# Portions created by the Initial Developer are Copyright (C) 2006
|
2005-10-11 22:44:16 +04:00
|
|
|
# the Initial Developer. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s):
|
|
|
|
# Chris Cooper <ccooper@deadsquid.com>
|
|
|
|
# Zach Lipton <zach@zachlipton.com>
|
2005-07-30 00:21:01 +04:00
|
|
|
#
|
2005-10-11 22:44:16 +04:00
|
|
|
# ***** END LICENSE BLOCK *****
|
2005-07-30 00:21:01 +04:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
2007-04-18 05:57:45 +04:00
|
|
|
use Time::HiRes qw( gettimeofday tv_interval );
|
|
|
|
our $t0 = [gettimeofday];
|
|
|
|
|
2005-07-30 00:21:01 +04:00
|
|
|
use Litmus;
|
|
|
|
use Litmus::Error;
|
|
|
|
use Litmus::DB::Product;
|
|
|
|
use Litmus::UserAgentDetect;
|
|
|
|
use Litmus::SysConfig;
|
|
|
|
use Litmus::Auth;
|
2005-08-04 04:59:29 +04:00
|
|
|
use Litmus::Utils;
|
2005-10-17 21:00:06 +04:00
|
|
|
use Litmus::DB::Resultbug;
|
2006-06-23 03:21:38 +04:00
|
|
|
use Litmus::XML;
|
2005-07-30 00:21:01 +04:00
|
|
|
|
|
|
|
use CGI;
|
2005-10-15 05:09:42 +04:00
|
|
|
use Date::Manip;
|
2005-07-30 00:21:01 +04:00
|
|
|
|
2006-08-02 00:50:15 +04:00
|
|
|
Litmus->init();
|
2006-01-08 06:56:10 +03:00
|
|
|
my $c = Litmus->cgi();
|
2005-07-30 00:21:01 +04:00
|
|
|
|
2006-06-23 03:21:38 +04:00
|
|
|
if ($c->param('data')) {
|
2007-05-14 23:17:08 +04:00
|
|
|
# we're getting XML result data from an automated testing provider,
|
|
|
|
# so pass that off to XML.pm for processing
|
|
|
|
my $x = Litmus::XML->new();
|
|
|
|
$x->processResults($c->param('data'));
|
|
|
|
|
|
|
|
# return whatever response was generated:
|
|
|
|
print $c->header('text/plain');
|
|
|
|
print $x->response();
|
|
|
|
exit; # that's all folks!
|
2006-06-23 03:21:38 +04:00
|
|
|
}
|
|
|
|
|
2007-04-18 05:57:45 +04:00
|
|
|
Litmus::Auth::requireLogin("process_test.cgi");
|
|
|
|
my $user || Litmus::Auth::getCurrentUser();
|
|
|
|
|
2006-06-23 19:35:30 +04:00
|
|
|
print $c->header();
|
2005-07-30 00:21:01 +04:00
|
|
|
|
2007-04-18 05:57:45 +04:00
|
|
|
my $test_run_id = $c->param("test_run_id");
|
|
|
|
|
|
|
|
if (!$test_run_id) {
|
|
|
|
invalidInputError("No Test Run selected!");
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $test_run = Litmus::DB::TestRun->getTestRunWithRefs($test_run_id);
|
|
|
|
my $sysconfig = Litmus::SysConfig->getCookieByTestRunId($test_run_id);
|
|
|
|
|
|
|
|
if (!$sysconfig) {
|
|
|
|
invalidInputError("No system configuration information found!");
|
|
|
|
exit 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
$c->storeCookie($sysconfig->setCookie());
|
|
|
|
|
|
|
|
$test_run->flagCriteriaInUse($sysconfig);
|
|
|
|
|
2005-07-30 00:21:01 +04:00
|
|
|
my @names = $c->param();
|
|
|
|
|
|
|
|
# find all the test numbers contained in this result submission
|
|
|
|
my @tests;
|
|
|
|
foreach my $curname (@names) {
|
2005-10-17 21:00:06 +04:00
|
|
|
if ($curname =~ /testresult_(\d*)/) {
|
|
|
|
push(@tests, $1);
|
|
|
|
}
|
2005-07-30 00:21:01 +04:00
|
|
|
}
|
|
|
|
|
2007-05-01 17:57:20 +04:00
|
|
|
if (scalar @tests < 1) {
|
2007-04-18 05:57:45 +04:00
|
|
|
invalidInputError("No test results found!");
|
2005-07-30 00:21:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
my $testcount;
|
|
|
|
my %resultcounts;
|
2005-08-23 09:22:14 +04:00
|
|
|
my $product;
|
2005-07-30 00:21:01 +04:00
|
|
|
foreach my $curtestid (@tests) {
|
2005-10-17 21:00:06 +04:00
|
|
|
unless ($c->param("testresult_".$curtestid)) {
|
|
|
|
# user didn't submit a result for this test so just skip
|
|
|
|
# it and move on...
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2006-06-05 08:07:29 +04:00
|
|
|
my $curtest = Litmus::DB::Testcase->retrieve($curtestid);
|
2005-10-17 21:00:06 +04:00
|
|
|
unless ($curtest) {
|
|
|
|
# oddly enough, the test doesn't exist
|
2007-04-18 05:57:45 +04:00
|
|
|
print STDERR "No testcase found for ID: $curtestid";
|
2005-10-17 21:00:06 +04:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
$testcount++;
|
2005-10-11 22:44:16 +04:00
|
|
|
|
2005-10-17 21:00:06 +04:00
|
|
|
my $ua = Litmus::UserAgentDetect->new();
|
|
|
|
|
2006-06-05 08:07:29 +04:00
|
|
|
my $result_status = Litmus::DB::ResultStatus->retrieve($c->param("testresult_".$curtestid));
|
|
|
|
$resultcounts{$result_status->name()}++;
|
2005-10-17 21:00:06 +04:00
|
|
|
|
|
|
|
my $note = $c->param("comment_".$curtestid);
|
|
|
|
my $bugs = $c->param("bugs_".$curtestid);
|
|
|
|
|
|
|
|
my $time = &Date::Manip::UnixDate("now","%q");
|
2007-04-18 05:57:45 +04:00
|
|
|
$user = $user || Litmus::Auth::getCookie()->user_id();
|
2005-10-17 21:00:06 +04:00
|
|
|
my $tr = Litmus::DB::Testresult->create({
|
2007-04-18 05:57:45 +04:00
|
|
|
user_id => $user,
|
|
|
|
testcase => $curtest,
|
|
|
|
timestamp => $time,
|
|
|
|
last_updated => $time,
|
|
|
|
useragent => $ua,
|
2006-06-05 08:07:29 +04:00
|
|
|
result_status => $result_status,
|
2007-04-18 05:57:45 +04:00
|
|
|
opsys_id => $sysconfig->{'opsys_id'},
|
|
|
|
branch_id => $test_run->branch_id,
|
|
|
|
build_id => $sysconfig->{'build_id'},
|
|
|
|
locale_abbrev => $sysconfig->{'locale'},
|
2005-10-17 21:00:06 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
# if there's a note, create an entry in the comments table for it
|
|
|
|
if ($note and
|
|
|
|
$note ne '') {
|
|
|
|
Litmus::DB::Comment->create({
|
|
|
|
testresult => $tr,
|
|
|
|
submission_time => $time,
|
|
|
|
last_updated => $time,
|
|
|
|
user => $user,
|
|
|
|
comment => $note
|
|
|
|
});
|
|
|
|
}
|
2007-04-18 05:57:45 +04:00
|
|
|
|
2005-10-17 21:00:06 +04:00
|
|
|
if ($bugs and
|
|
|
|
$bugs ne '') {
|
2005-12-14 01:12:22 +03:00
|
|
|
$bugs =~ s/[^0-9,]//g;
|
2005-10-17 21:00:06 +04:00
|
|
|
my @new_bugs = split(/,/,$bugs);
|
|
|
|
foreach my $new_bug (@new_bugs) {
|
2005-12-14 01:12:22 +03:00
|
|
|
next if ($new_bug eq '0');
|
2005-10-17 21:00:06 +04:00
|
|
|
my $bug = Litmus::DB::Resultbug->create({
|
|
|
|
testresult => $tr,
|
|
|
|
last_updated => $time,
|
|
|
|
submission_time => $time,
|
|
|
|
user => $user,
|
|
|
|
bug_id => $new_bug,
|
|
|
|
});
|
|
|
|
}
|
2005-10-11 22:44:16 +04:00
|
|
|
}
|
2005-07-30 00:21:01 +04:00
|
|
|
|
2005-10-17 21:00:06 +04:00
|
|
|
}
|
2006-06-05 09:53:10 +04:00
|
|
|
|
|
|
|
if (! $testcount) {
|
|
|
|
invalidInputError("No results submitted.");
|
|
|
|
}
|
2005-10-17 21:00:06 +04:00
|
|
|
|
2005-07-30 00:21:01 +04:00
|
|
|
my $testgroup;
|
|
|
|
if ($c->param("testgroup")) {
|
2006-06-05 09:53:10 +04:00
|
|
|
$testgroup = Litmus::DB::Testgroup->retrieve($c->param("testgroup"));
|
2005-07-30 00:21:01 +04:00
|
|
|
}
|
|
|
|
|
2005-10-11 22:44:16 +04:00
|
|
|
my $vars;
|
|
|
|
$vars->{'title'} = 'Run Tests';
|
|
|
|
|
|
|
|
my $cookie = Litmus::Auth::getCookie();
|
|
|
|
$vars->{"defaultemail"} = $cookie;
|
|
|
|
$vars->{"show_admin"} = Litmus::Auth::istrusted($cookie);
|
2007-04-18 05:57:45 +04:00
|
|
|
$vars->{"test_runs"} = [$test_run];
|
2006-02-07 21:20:53 +03:00
|
|
|
$vars->{'testcount'} = $testcount;
|
|
|
|
$vars->{'resultcounts'} = \%resultcounts || undef;
|
|
|
|
$vars->{'testgroup'} = $testgroup || undef;
|
|
|
|
$vars->{'return'} = $c->param("return") || undef;
|
|
|
|
|
|
|
|
Litmus->template()->process("process/process.html.tmpl", $vars) ||
|
|
|
|
internalError(Litmus->template()->error());
|
|
|
|
|
2007-04-18 05:57:45 +04:00
|
|
|
if ($Litmus::Config::DEBUG) {
|
|
|
|
my $elapsed = tv_interval ( $t0 );
|
|
|
|
printf "<div id='pageload'>Page took %f seconds to load.</div>", $elapsed;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit 0;
|
|
|
|
|
|
|
|
# END
|
|
|
|
|
|
|
|
#########################################################################
|
|
|
|
sub redirectToRunTests() {
|
|
|
|
my $c = Litmus->cgi();
|
|
|
|
print $c->redirect("http://127.0.0.1/run_tests.cgi");
|
|
|
|
}
|