| Machine: | +[% result.machine_name | html %] | +
| Duration (s): | +[% result.duration_ms | html %] | +
| Exit Status: | +[% result.exit_status.name | html %] | +
diff --git a/mozilla/webtools/litmus/Litmus/DB/LogType.pm b/mozilla/webtools/litmus/Litmus/DB/LogType.pm
index 442ace2f5d6..08ca925e249 100755
--- a/mozilla/webtools/litmus/Litmus/DB/LogType.pm
+++ b/mozilla/webtools/litmus/Litmus/DB/LogType.pm
@@ -38,6 +38,7 @@ use base 'Litmus::DBI';
Litmus::DB::LogType->table('log_type_lookup');
Litmus::DB::LogType->columns(All => qw/log_type_id name/);
+Litmus::DB::LogType->columns(Essential => qw/log_type_id name/);
Litmus::DB::LogType->columns(TEMP => qw //);
Litmus::DB::LogType->has_many(test_result_logs => "Litmus::DB::Log");
diff --git a/mozilla/webtools/litmus/Litmus/DB/Testresult.pm b/mozilla/webtools/litmus/Litmus/DB/Testresult.pm
index 725404de710..85090d68a56 100755
--- a/mozilla/webtools/litmus/Litmus/DB/Testresult.pm
+++ b/mozilla/webtools/litmus/Litmus/DB/Testresult.pm
@@ -249,6 +249,11 @@ sub getTestResults($\@\@$) {
if ($criterion->{'value'} ne 'all') {
$where .= " AND tr.valid=";
$where .= $criterion->{'value'} == 1 ? '1' : '0';
+ }
+ } elsif ($criterion->{'field'} eq 'automated') {
+ if ($criterion->{'value'} ne 'all') {
+ $where .= " AND tr.is_automated_result=";
+ $where .= $criterion->{'value'} == 1 ? '1' : '0';
}
} elsif ($criterion->{'field'} eq 'user_id') {
if ($from !~ /users u/) {
diff --git a/mozilla/webtools/litmus/Litmus/XML.pm b/mozilla/webtools/litmus/Litmus/XML.pm
index 95bf4a0db2a..654b76ef027 100755
--- a/mozilla/webtools/litmus/Litmus/XML.pm
+++ b/mozilla/webtools/litmus/Litmus/XML.pm
@@ -43,6 +43,7 @@ use XML::XPath::XMLParser;
use Litmus::DB::User;
use Litmus::UserAgentDetect;
use Date::Manip;
+use Data::Dumper;
use CGI::Carp qw(set_message fatalsToBrowser);
@@ -57,363 +58,384 @@ no warnings;
no diagnostics;
sub new {
- my $self = {};
- bless($self);
- return $self;
+ my $self = {};
+ bless($self);
+ return $self;
}
# process XML test result data as described by
# the spec at http://wiki.mozilla.org/Litmus:Web_Services
sub processResults {
- my $self = shift;
- my $data = shift;
-
- $self->parseResultFile($data) ? 1 : return 0;
-
- unless ($self->authenticate()) { return 0} # login failure
-
- $self->validateResults() ? 1 : return 0;
-
- # at this point, everything is valid, so if we're just validating the
- # results, we can return an ok:
- if ($self->{'action'} eq 'validate') {
- unless ($self->{'response'}) { $self->respOk() }
- return 1;
+ my $self = shift;
+ my $data = shift;
+
+ $self->parseResultFile($data) ? 1 : return 0;
+
+ unless ($self->authenticate()) {
+ return 0;
+ } # login failure
+
+ $self->validateResults() ? 1 : return 0;
+
+ # at this point, everything is valid, so if we're just validating the
+ # results, we can return an ok:
+ if ($self->{'action'} eq 'validate') {
+ unless ($self->{'response'}) {
+ $self->respOk();
}
-
- # add so-called 'global logs' that apply to all the results
- # we save them in @globallogs so we can map them to the results later
- my @globallogs;
- foreach my $log (@{$self->{'logs'}}) {
- # the submission time is the timestamp of the first testresult:
- my $newlog = Litmus::DB::Log->create({
- submission_time => $self->{'results'}->[0]->{'timestamp'},
- log_type => $log->{'type'},
- log_text => $log->{'data'},
- });
- push(@globallogs, $newlog);
- }
-
- # now actually add the new results to the db:
- foreach my $result (@{$self->{'results'}}) {
- my $newres = Litmus::DB::Testresult->create({
- testcase => $result->{'testid'},
- user_agent => new Litmus::UserAgentDetect($self->{'useragent'}),
- user => $self->{'user'},
- opsys => $self->{'sysconfig'}->{'opsys'},
- branch => $self->{'sysconfig'}->{'branch'},
- locale => $self->{'sysconfig'}->{'locale'},
- build_id => $self->{'sysconfig'}->{'buildid'},
- machine_name => $self->{'machinename'},
- result_status => $result->{'resultstatus'},
- timestamp => $result->{'timestamp'},
- exit_status => $result->{'exitstatus'},
- duration_ms => $result->{'duration'},
- valid => 1,
- isAutomated => $result->{'isAutomated'},
- });
-
- if (!$newres) { $self->respErrResult($result->{'testid'}); next; }
-
- # add any bug ids:
- foreach my $bug (@{$result->{'bugs'}}) {
- my $newbug = Litmus::DB::Resultbug->create({
- test_result_id => $newres,
- bug_id => $bug,
- submission_time => $result->{'timestamp'},
- user => $self->{'user'},
- });
- }
-
- # add any comments:
- foreach my $comment (@{$result->{'comments'}}) {
- my $newcomment = Litmus::DB::Comment->create({
- test_result => $newres,
- submission_time => $result->{'timestamp'},
- user => $self->{'user'},
- comment => $comment,
- });
- }
-
- # add logs:
- my @resultlogs;
- push(@resultlogs, @globallogs); # all results get the global logs
- foreach my $log (@{$result->{'logs'}}) {
- my $newlog = Litmus::DB::Log->create({
- submission_time => $result->{'timestamp'},
- log_type => $log->{'type'},
- log_text => $log->{'data'},
- });
- push(@resultlogs, $newlog);
- }
-
- # now we map the logs to the current result:
- foreach my $log (@resultlogs) {
- Litmus::DB::LogTestresult->create({
- test_result => $newres,
- log_id => $log,
- });
- }
- }
-
- unless ($self->{'response'}) { $self->respOk() }
-
- #$self->{'response'} = $self->{'results'}->[0]->{'resultstatus'};
-
+ return 1;
+ }
+
+ # add so-called 'global logs' that apply to all the results
+ # we save them in @globallogs so we can map them to the results later
+ my @globallogs;
+ foreach my $log (@{$self->{'logs'}}) {
+ # the submission time is the timestamp of the first testresult:
+ my $newlog = Litmus::DB::Log->create({
+ submission_time => $self->{'results'}->[0]->{'timestamp'},
+ last_updated => $self->{'results'}->[0]->{'timestamp'},
+ log_type => $log->{'type'},
+ log_text => $log->{'data'},
+ });
+ push(@globallogs, $newlog);
+ }
+
+ # now actually add the new results to the db:
+ foreach my $result (@{$self->{'results'}}) {
+
+ my $ua = new Litmus::UserAgentDetect($self->{'useragent'});
+ my $newres = Litmus::DB::Testresult->create({
+ testcase_id => $result->{'testid'},
+ user_agent => $ua,
+ user_id => $self->{'user'}->{'user_id'},
+ opsys_id => $self->{'sysconfig'}->{'opsys'}->{'opsys_id'},
+ branch_id => $self->{'sysconfig'}->{'branch'}->{'branch_id'},
+ locale_abbrev => $self->{'sysconfig'}->{'locale'},
+ build_id => $self->{'sysconfig'}->{'buildid'},
+ machine_name => $self->{'machinename'},
+ result_status => $result->{'resultstatus'},
+ submission_time => $result->{'timestamp'},
+ last_updated => $result->{'timestamp'},
+ exit_status => $result->{'exitstatus'},
+ duration_ms => $result->{'duration'},
+ is_automated_result => $result->{'isAutomated'},
+ });
+
+ if (!$newres) {
+ $self->respErrResult($result->{'testid'});
+ next;
+ }
+
+ # add any bug ids:
+ foreach my $bug (@{$result->{'bugs'}}) {
+ my $newbug = Litmus::DB::Resultbug->create({
+ test_result_id => $newres,
+ bug_id => $bug,
+ submission_time => $result->{'timestamp'},
+ last_updated => $result->{'timestamp'},
+ user => $self->{'user'},
+ });
+ }
+
+ # add any comments:
+ foreach my $comment (@{$result->{'comments'}}) {
+ my $newcomment = Litmus::DB::Comment->create({
+ test_result => $newres,
+ submission_time => $result->{'timestamp'},
+ last_updated => $result->{'timestamp'},
+ user => $self->{'user'},
+ comment => $comment,
+ });
+ }
+
+ # add logs:
+ my @resultlogs;
+ push(@resultlogs, @globallogs); # all results get the global logs
+ foreach my $log (@{$result->{'logs'}}) {
+ my $newlog = Litmus::DB::Log->create({
+ submission_time => $result->{'timestamp'},
+ last_updated => $result->{'timestamp'},
+ log_type => $log->{'type'},
+ log_text => $log->{'data'},
+ });
+ push(@resultlogs, $newlog);
+ }
+
+ # now we map the logs to the current result:
+ foreach my $log (@resultlogs) {
+ Litmus::DB::LogTestresult->create({
+ test_result => $newres,
+ log_id => $log,
+ });
+ }
+
+ unless ($self->{'response'}) {
+ $self->respOk();
+ }
+
+ }
+
}
sub parseResultFile {
- my $self = shift;
- my $data = shift;
- my $x = XML::XPath->new(xml => $data, standalone => 1);
- $self->{'useragent'} = $x->findvalue('/litmusresults/@useragent');
- $self->{'machinename'} = $x->findvalue('litmusresults/@machinename');
- $self->{'action'} = $x->findvalue('/litmusresults/@action');
- $self->{'user'}->{'username'} = $x->findvalue(
- '/litmusresults/testresults/@username');
- $self->{'user'}->{'token'} = $x->findvalue(
- '/litmusresults/testresults/@authtoken');
-
- $self->{'sysconfig'}->{'product'} = $x->findvalue('/litmusresults/testresults/@product');
- $self->{'sysconfig'}->{'platform'} = $x->findvalue('/litmusresults/testresults/@platform');
- $self->{'sysconfig'}->{'opsys'} = $x->findvalue('/litmusresults/testresults/@opsys');
- $self->{'sysconfig'}->{'branch'} = $x->findvalue('/litmusresults/testresults/@branch');
- $self->{'sysconfig'}->{'buildid'} = $x->findvalue('/litmusresults/testresults/@buildid');
- $self->{'sysconfig'}->{'locale'} = $x->findvalue('/litmusresults/testresults/@locale');
-
- my @glogs = $x->find('/litmusresults/testresults/log')->get_nodelist();
- my $l_ct = 0;
- foreach my $log (@glogs) {
- my $type = $x->findvalue('@logtype', $log);
- my $logdata = stripWhitespace($log->string_value());
- $self->{'logs'}->[$l_ct]->{'type'} = $type;
- $self->{'logs'}->[$l_ct]->{'data'} = $logdata;
- $l_ct++;
- }
-
- my @results = $x->find('/litmusresults/testresults/result')->get_nodelist();
- my $c = 0;
- foreach my $result (@results) {
- $self->{'results'}->[$c]->{'testid'} = $x->findvalue('@testid', $result);
- $self->{'results'}->[$c]->{'isAutomated'} = $x->findvalue('@is_automated_result', $result);
- $self->{'results'}->[$c]->{'resultstatus'} = $x->findvalue('@resultstatus', $result);
- $self->{'results'}->[$c]->{'exitstatus'} = $x->findvalue('@exitstatus', $result);
- $self->{'results'}->[$c]->{'duration'} = $x->findvalue('@duration', $result);
- $self->{'results'}->[$c]->{'timestamp'} =
- &Date::Manip::UnixDate($x->findvalue('@timestamp', $result), "%q");
-
-
- my @comments = $x->find('comment', $result)->get_nodelist();
- my $com_ct = 0;
- foreach my $comment (@comments) {
- $comment = stripWhitespace($comment->string_value());
- $self->{'results'}->[$c]->{'comments'}->[$com_ct] = $comment;
- $com_ct++;
- }
-
- my @bugs = $x->find('bugnumber', $result)->get_nodelist();
- my $bug_ct = 0;
- foreach my $bug (@bugs) {
- $bug = stripWhitespace($bug->string_value());
- $self->{'results'}->[$c]->{'bugs'}->[$bug_ct];
- $bug_ct++;
- }
-
- my @logs = $x->find('log', $result)->get_nodelist();
- my $log_ct = 0;
- foreach my $log (@logs) {
- my $type = $x->findvalue('@logtype', $log);
- my $logdata = stripWhitespace($log->string_value());
- $self->{'results'}->[$c]->{'logs'}->[$log_ct]->{'type'} = $type;
- $self->{'results'}->[$c]->{'logs'}->[$log_ct]->{'data'} = $logdata;
- $log_ct++;
- }
- $c++;
- }
-
- $self->{'x'} = $x;
+ my $self = shift;
+ my $data = shift;
+
+ my $x = XML::XPath->new(xml => $data, standalone => 1);
+
+ $self->{'useragent'} = $x->findvalue('/litmusresults/@useragent');
+ $self->{'machinename'} = $x->findvalue('litmusresults/@machinename');
+ $self->{'action'} = $x->findvalue('/litmusresults/@action');
+ $self->{'user'}->{'username'} = $x->findvalue(
+ '/litmusresults/testresults/@username');
+ $self->{'user'}->{'token'} = $x->findvalue(
+ '/litmusresults/testresults/@authtoken');
+
+ $self->{'sysconfig'}->{'product'} = $x->findvalue('/litmusresults/testresults/@product');
+ $self->{'sysconfig'}->{'platform'} = $x->findvalue('/litmusresults/testresults/@platform');
+ $self->{'sysconfig'}->{'opsys'} = $x->findvalue('/litmusresults/testresults/@opsys');
+ $self->{'sysconfig'}->{'branch'} = $x->findvalue('/litmusresults/testresults/@branch');
+ $self->{'sysconfig'}->{'buildid'} = $x->findvalue('/litmusresults/testresults/@buildid');
+ $self->{'sysconfig'}->{'locale'} = $x->findvalue('/litmusresults/testresults/@locale');
+
+ my @glogs = $x->find('/litmusresults/testresults/log')->get_nodelist();
+ my $l_ct = 0;
+ foreach my $log (@glogs) {
+ my $type = $x->findvalue('@logtype', $log);
+ my $logdata = stripWhitespace($log->string_value());
+ $self->{'logs'}->[$l_ct]->{'type'} = $type;
+ $self->{'logs'}->[$l_ct]->{'data'} = $logdata;
+ $l_ct++;
+ }
+
+ my @results = $x->find('/litmusresults/testresults/result')->get_nodelist();
+ my $c = 0;
+ foreach my $result (@results) {
+ $self->{'results'}->[$c]->{'testid'} = $x->findvalue('@testid', $result);
+ $self->{'results'}->[$c]->{'isAutomated'} = $x->findvalue('@is_automated_result', $result);
+ $self->{'results'}->[$c]->{'resultstatus'} = $x->findvalue('@resultstatus', $result);
+ $self->{'results'}->[$c]->{'exitstatus'} = $x->findvalue('@exitstatus', $result) || 'Exited Normally';
+ $self->{'results'}->[$c]->{'duration'} = $x->findvalue('@duration', $result);
+ $self->{'results'}->[$c]->{'timestamp'} =
+ &Date::Manip::UnixDate($x->findvalue('@timestamp', $result), "%q");
+
+
+ my @comments = $x->find('comment', $result)->get_nodelist();
+ my $com_ct = 0;
+ foreach my $comment (@comments) {
+ $comment = stripWhitespace($comment->string_value());
+ $self->{'results'}->[$c]->{'comments'}->[$com_ct] = $comment;
+ $com_ct++;
+ }
+
+ my @bugs = $x->find('bugnumber', $result)->get_nodelist();
+ my $bug_ct = 0;
+ foreach my $bug (@bugs) {
+ $bug = stripWhitespace($bug->string_value());
+ $self->{'results'}->[$c]->{'bugs'}->[$bug_ct];
+ $bug_ct++;
+ }
+
+ my @logs = $x->find('log', $result)->get_nodelist();
+ my $log_ct = 0;
+ foreach my $log (@logs) {
+ my $type = $x->findvalue('@logtype', $log);
+ my $logdata = stripWhitespace($log->string_value());
+ $self->{'results'}->[$c]->{'logs'}->[$log_ct]->{'type'} = $type;
+ $self->{'results'}->[$c]->{'logs'}->[$log_ct]->{'data'} = $logdata;
+ $log_ct++;
+ }
+ $c++;
+ }
+
+ $self->{'x'} = $x;
}
# validate the result data, and resolve references to various tables
# the correct objects, looking up id numbers as needed
sub validateResults {
- my $self = shift;
+ my $self = shift;
- my $action = $self->{'action'};
- if ($action ne 'submit' && $action ne 'validate') {
- $self->respErrFatal("Action must be either 'submit' or 'validate'");
- return 0;
+ my $action = $self->{'action'};
+ if ($action ne 'submit' && $action ne 'validate') {
+ $self->respErrFatal("Action must be either 'submit' or 'validate'");
+ return 0;
+ }
+
+ my @users = Litmus::DB::User->search(email => $self->{'user'}->{'username'});
+ $self->{'user'} = $users[0];
+
+ unless ($self->{'useragent'}) {
+ $self->respErrFatal("You must specify a useragent");
+ return 0;
+ }
+
+ my @prods = Litmus::DB::Product->search(name => $self->{'sysconfig'}->{'product'});
+ unless ($prods[0]) {
+ $self->respErrFatal("Invalid product: ".$self->{'sysconfig'}->{'product'});
+ return 0;
+ }
+ $self->{'sysconfig'}->{'product'} = $prods[0];
+
+ my @platforms = Litmus::DB::Platform->search_ByProductAndName(
+ $self->{'sysconfig'}->{'product'},
+ $self->{'sysconfig'}->{'platform'});
+ unless ($platforms[0]) {
+ $self->respErrFatal("Invalid platform: ".$self->{'sysconfig'}->{'platform'});
+ return 0;
+ }
+ $self->{'sysconfig'}->{'platform'} = $platforms[0];
+
+ my @opsyses = Litmus::DB::Opsys->search(
+ name => $self->{'sysconfig'}->{'opsys'},
+ platform => $self->{'sysconfig'}->{'platform'});
+ unless ($opsyses[0]) {
+ $self->respErrFatal("Invalid opsys: ".$self->{'sysconfig'}->{'opsys'});
+ return 0;
+ }
+ $self->{'sysconfig'}->{'opsys'} = $opsyses[0];
+
+ my @branches = Litmus::DB::Branch->search(
+ name => $self->{'sysconfig'}->{'branch'},
+ product => $self->{'sysconfig'}->{'product'});
+ unless ($branches[0]) {
+ $self->respErrFatal("Invalid branch: ".$self->{'sysconfig'}->{'branch'});
+ return 0;
+ }
+ $self->{'sysconfig'}->{'branch'} = $branches[0];
+
+ unless ($self->{'sysconfig'}->{'buildid'}) {
+ $self->respErrFatal("Invalid build id: ".$self->{'sysconfig'}->{'buildid'});
+ return 0;
+ }
+
+ my @locales = Litmus::DB::Locale->search(
+ locale => $self->{'sysconfig'}->{'locale'});
+ unless ($locales[0]) {
+ $self->respErrFatal("Invalid locale: ".$self->{'sysconfig'}->{'locale'});
+ return 0;
+ }
+ $self->{'sysconfig'}->{'locale'} = $locales[0];
+
+ my %log_types;
+ my $log_types_iterator = Litmus::DB::LogType->retrieve_all;
+ while (my $log_type = $log_types_iterator->next) {
+ # ASSUMPTION: all logs types will have a unique name.
+ $log_types{$log_type->{'name'}} = $log_type;
+ }
+
+ foreach my $log (@{$self->{'logs'}}) {
+ my $found_log_type = 0;
+ if (exists $log_types{$log->{'type'}}) {
+ $log->{'type'} = $log_types{$log->{'type'}};
+ } else {
+ $self->respErrFatal("Invalid log type: ". $log->{'type'});
+ return 0;
}
-
- my @users = Litmus::DB::User->search(email => $self->{'user'}->{'username'});
- $self->{'user'} = $users[0];
-
-
- unless ($self->{'useragent'}) {
- $self->respErrFatal("You must specify a useragent");
- return 0;
+ }
+
+ foreach my $result (@{$self->{'results'}}) {
+ my @tests = Litmus::DB::Testcase->search(
+ test_id => $result->{'testid'});
+ unless ($tests[0]) {
+ $self->respErrResult('unknown', "Invalid test id");
+ next;
}
-
- my @prods = Litmus::DB::Product->search(name => $self->{'sysconfig'}->{'product'});
- unless ($prods[0]) {
- $self->respErrFatal("Invalid product: ".$self->{'sysconfig'}->{'product'});
- return 0;
- }
- $self->{'sysconfig'}->{'product'} = $prods[0];
-
- my @platforms = Litmus::DB::Platform->search_ByProductAndName(
- $self->{'sysconfig'}->{'product'},
- $self->{'sysconfig'}->{'platform'});
- unless ($platforms[0]) {
- $self->respErrFatal("Invalid platform: ".$self->{'sysconfig'}->{'platform'});
- return 0;
- }
- $self->{'sysconfig'}->{'platform'} = $platforms[0];
-
- my @opsyses = Litmus::DB::Opsys->search(
- name => $self->{'sysconfig'}->{'opsys'},
- platform => $self->{'sysconfig'}->{'platform'});
- unless ($opsyses[0]) {
- $self->respErrFatal("Invalid opsys: ".$self->{'sysconfig'}->{'opsys'});
- return 0;
- }
- $self->{'sysconfig'}->{'opsys'} = $opsyses[0];
-
- my @branches = Litmus::DB::Branch->search(
- name => $self->{'sysconfig'}->{'branch'},
- product => $self->{'sysconfig'}->{'product'});
- unless ($branches[0]) {
- $self->respErrFatal("Invalid branch: ".$self->{'sysconfig'}->{'branch'});
- return 0;
- }
- $self->{'sysconfig'}->{'branch'} = $branches[0];
-
- unless ($self->{'sysconfig'}->{'buildid'}) {
- $self->respErrFatal("Invalid build id: ".$self->{'sysconfig'}->{'buildid'});
- return 0;
- }
-
- my @locales = Litmus::DB::Locale->search(
- locale => $self->{'sysconfig'}->{'locale'});
- unless ($locales[0]) {
- $self->respErrFatal("Invalid locale: ".$self->{'sysconfig'}->{'locale'});
- return 0;
- }
- $self->{'sysconfig'}->{'locale'} = $locales[0];
-
- foreach my $log (@{$self->{'logs'}}) {
- my @types = Litmus::DB::LogType->search(name => $log->{'type'});
- unless ($types[0]) {
- $self->respErrFatal("Invalid log type: ".$log->{'type'});
- return 0;
- }
- $log->{'type'} = $types[0];
- }
-
- foreach my $result (@{$self->{'results'}}) {
- my @tests = Litmus::DB::Testcase->search(
- test_id => $result->{'testid'});
- unless ($tests[0]) {
- $self->respErrResult('unknown', "Invalid test id");
- next;
- }
- $result->{'testid'} = $tests[0];
+ $result->{'testid'} = $tests[0];
+
+ # assume it's an automated test result if not specified
+ ($result->{'isAutomated'} eq '0' || $result->{'isAutomated'} ne undef) ?
+ $result->{'isAutomated'} = 0 : $result->{'isAutomated'} = 1;
- # assume it's an automated test result if not specified
- ($result->{'isAutomated'} eq '0' || $result->{'isAutomated'} ne undef) ?
- $result->{'isAutomated'} = 0 : $result->{'isAutomated'} = 1;
-
- my @results = Litmus::DB::ResultStatus->search(
- name => $result->{'resultstatus'});
- unless ($results[0]) {
- $self->respErrResult($result->{'testid'}, "Invalid resultstatus");
- next;
- }
- $result->{'resultstatus'} = $results[0];
-
- my @es = Litmus::DB::ExitStatus->search(
- name => $result->{'exitstatus'});
- unless ($es[0]) {
- $self->respErrResult($result->{'testid'}, "Invalid exitstatus");
- next;
- }
- $result->{'exitstatus'} = $es[0];
-
- # if there's no duration, then it's just 0:
- unless ($result->{'duration'}) {
- $result->{'duration'} = 0;
- }
-
- # if there's no timestamp, then it's now:
- unless ($result->{'timestamp'}) {
- $result->{'timestamp'} = &Date::Manip::UnixDate("now","%q");
- }
-
- foreach my $log (@{$result->{'logs'}}) {
- my @types = Litmus::DB::LogType->search(name => $log->{'type'});
- unless ($types[0]) {
- $self->respErrResult($result->{'testid'},
- "Invalid log type: ".$log->{'type'});
- next;
- }
- $log->{'type'} = $types[0];
- }
+ my @results = Litmus::DB::ResultStatus->search(
+ name => $result->{'resultstatus'});
+ unless ($results[0]) {
+ $self->respErrResult($result->{'testid'}, "Invalid resultstatus");
+ next;
}
- return 1;
+ $result->{'resultstatus'} = $results[0];
+
+ my @es = Litmus::DB::ExitStatus->search(
+ name => $result->{'exitstatus'});
+ unless ($es[0]) {
+ $self->respErrResult($result->{'testid'}, "Invalid exitstatus");
+ next;
+ }
+ $result->{'exitstatus'} = $es[0];
+
+ # if there's no duration, then it's just 0:
+ if (!$result->{'duration'}) {
+ $result->{'duration'} = '0';
+ }
+
+ # if there's no timestamp, then it's now:
+ unless ($result->{'timestamp'}) {
+ $result->{'timestamp'} = &Date::Manip::UnixDate("now","%q");
+ }
+
+ foreach my $log (@{$result->{'logs'}}) {
+ my $found_log_type = 0;
+ if (exists $log_types{$log->{'type'}}) {
+ $log->{'type'} = $log_types{$log->{'type'}};
+ } else {
+ $self->respErrFatal("Invalid log type: ". $log->{'type'});
+ next;
+ }
+ }
+ }
+ return 1;
}
sub response {
- my $self = shift;
- return $self->{'response'};
+ my $self = shift;
+ return $self->{'response'};
}
# ONLY NON-PUBLIC API BELOW THIS POINT
sub authenticate {
- my $self = shift;
+ my $self = shift;
+
+ my @users = Litmus::DB::User->search(email => $self->{'user'}->{'username'});
+ my $user = $users[0];
- my @users = Litmus::DB::User->search(email => $self->{'user'}->{'username'});
- my $user = $users[0];
-
- unless ($user) { $self->respErrFatal("User does not exist"); return 0 }
-
- unless ($user->enabled()) { $self->respErrFatal("User disabled"); return 0 }
-
- if ($user->authtoken() ne $self->{'user'}->{'token'}) {
- respErrFatal("Invalid authentication token for user ".
- $self->{'user'}->{'username'});
- return 0;
- }
- return 1;
+ unless ($user) { $self->respErrFatal("User does not exist"); return 0 }
+
+ unless ($user->enabled()) { $self->respErrFatal("User disabled"); return 0 }
+
+ if ($user->authtoken() ne $self->{'user'}->{'token'}) {
+ $self->respErrFatal("Invalid authentication token for user " .
+ $self->{'user'}->{'username'});
+ return 0;
+ }
+ return 1;
}
sub respOk {
- my $self = shift;
- $self->{'response'} = 'ok';
+ my $self = shift;
+ $self->{'response'} = 'ok';
}
sub respErrFatal {
- my $self = shift;
- my $error = shift;
- $self->{'response'} = "Fatal error: $error\n";
+ my $self = shift;
+ my $error = shift;
+ $self->{'response'} = "Fatal error: $error\n";
}
sub respErrResult {
- my $self = shift;
- my $testid = shift;
- my $error = shift;
- $self->{'response'} .= "Error processing result for test $testid: $error\n";
+ my $self = shift;
+ my $testid = shift;
+ my $error = shift;
+ $self->{'response'} .= "Error processing result for test $testid: $error\n";
}
# remove leading and trailing whitespace from logs and comments
sub stripWhitespace {
- my $txt = shift;
- $txt =~ s/^\s+//;
- $txt =~ s/\s+$//;
- return $txt;
+ my $txt = shift;
+ $txt =~ s/^\s+//;
+ $txt =~ s/\s+$//;
+ return $txt;
}
-
-
1;
diff --git a/mozilla/webtools/litmus/advanced_search.cgi b/mozilla/webtools/litmus/advanced_search.cgi
index 802b3874d58..b557b9b3d35 100755
--- a/mozilla/webtools/litmus/advanced_search.cgi
+++ b/mozilla/webtools/litmus/advanced_search.cgi
@@ -159,6 +159,19 @@ if ($c->param) {
$limit_criteria .= "Display unvetted results only
";
}
}
+ } elsif ($param eq 'automated') {
+ my $value = $c->param($param);
+ if ($value ne 'all') {
+ if ($value eq '1') {
+ push @where, {field => 'automated',
+ value => 1};
+ $limit_criteria .= "Display automated results only
";
+ } else {
+ push @where, {field => 'automated',
+ value => '0E0'};
+ $limit_criteria .= "Display manual results only
";
+ }
+ }
} elsif ($param eq 'my_results_only') {
push @where, {field => 'user_id',
value => $cookie->{'user_id'}};
diff --git a/mozilla/webtools/litmus/process_test.cgi b/mozilla/webtools/litmus/process_test.cgi
index 8d9fc55ada2..8777d42b550 100755
--- a/mozilla/webtools/litmus/process_test.cgi
+++ b/mozilla/webtools/litmus/process_test.cgi
@@ -49,15 +49,15 @@ Litmus->init();
my $c = Litmus->cgi();
if ($c->param('data')) {
- # 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!
+ # 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!
}
Litmus::Auth::requireLogin("process_test.cgi");
diff --git a/mozilla/webtools/litmus/single_result.cgi b/mozilla/webtools/litmus/single_result.cgi
index 3ca546435d3..81edfa2be67 100755
--- a/mozilla/webtools/litmus/single_result.cgi
+++ b/mozilla/webtools/litmus/single_result.cgi
@@ -55,6 +55,10 @@ if ($c->param && $c->param('id')) {
internalError("There is no test result corresponding to id#: " . $c->param('id') . ".");
exit 1;
}
+
+ if ($result->is_automated_result) {
+ $vars->{'title'} = "Automated " . $title;
+ }
my $time = &Date::Manip::UnixDate("now","%q");
my $cookie = Litmus::Auth::getCookie();
diff --git a/mozilla/webtools/litmus/templates/en/default/reporting/advanced_search_form.tmpl b/mozilla/webtools/litmus/templates/en/default/reporting/advanced_search_form.tmpl
index 284fe34eeec..fdfdc94607d 100644
--- a/mozilla/webtools/litmus/templates/en/default/reporting/advanced_search_form.tmpl
+++ b/mozilla/webtools/litmus/templates/en/default/reporting/advanced_search_form.tmpl
@@ -231,6 +231,10 @@ Use this to limit the number of results displayed.