--- a/common/tools/ats/update_brag_status.pl Tue Oct 05 11:37:00 2010 +0100
+++ b/common/tools/ats/update_brag_status.pl Mon Oct 11 14:51:10 2010 +0100
@@ -24,14 +24,17 @@
my $test_report;
my $help;
my $line;
-my $auto_tests_total;
-my $auto_tests_passed;
-my $auto_tests_failed;
-my $auto_tests_notrun;
-my $man_tests_total;
-my $man_tests_passed;
-my $man_tests_failed;
-my $man_tests_notrun;
+my $auto_tests_total = 0;
+my $auto_tests_passed = 0;
+my $auto_tests_failed = 0;
+my $auto_tests_skipped = 0;
+my $auto_tests_noresult = 0;
+my $auto_tests_notrun = 0;
+my $auto_tests_disabled = 0;
+my $man_tests_total = 0;
+my $man_tests_passed = 0;
+my $man_tests_failed = 0;
+my $man_tests_notrun = 0;
my $temp_path;
my $detailshref;
my $xml_report;
@@ -42,6 +45,26 @@
my $m;
my @lines;
my $man_detailshref;
+my $build_id;
+my $name;
+my $type = "smoke"; # Currently hard-coded.
+my $start_time;
+my $end_time;
+my $time_stamp;
+my ($date, $time);
+my ($day, $month, $year);
+my $cases_total;
+my $cases_passed;
+my $cases_failed;
+my $cases_not_run;
+my $cases_not_available;
+my $fail_rate;
+my $auto_pass_rate;
+my $test_brag_status;
+my $test_target = "winscw"; # Currently hard-coded.
+my $report_url;
+my $bit_file = "bitinfo_smoketest.txt";
+my $bitops_path = "\.\.\\bitops.pl"; # Location of the bitops script (to update BIT db).
sub usage($);
sub help();
@@ -51,6 +74,7 @@
'ats3-report' => \$ats3_report,
'ats4-report' => \$ats4_report,
'test-report' => \$test_report,
+ 'build-id' => \$build_id,
'help' => \$help);
GetOptions(\%optmap,
@@ -58,6 +82,7 @@
'ats3-report=s',
'ats4-report=s',
'test-report=s',
+ 'build-id=i',
'help!')
or usage_error();
@@ -84,6 +109,10 @@
$auto_tests_total =~ s/^.*\">//;
$auto_tests_total =~ s/<.*//;
}
+ if ($read_flag == 3) { # Get number of Disabled tests.
+ ($auto_tests_disabled) = split /\//,$line;
+ $auto_tests_disabled =~ s/^.*\">//; # Remove opening td tag.
+ }
if ($read_flag == 4) { # Get number of Passed tests.
($auto_tests_passed) = split /\//,$line;
$auto_tests_passed =~ s/^.*\">//; # Remove opening td tag.
@@ -92,9 +121,13 @@
($auto_tests_failed) = split /\//,$line;
$auto_tests_failed =~ s/^.*\">//; # Remove opening td tag.
}
- if ($read_flag == 7) { # Get number of Not run tests.
- ($auto_tests_notrun) = split /\//,$line;
- $auto_tests_notrun =~ s/^.*\">//; # Remove opening td tag.
+ if ($read_flag == 6) { # Get number of Skipped tests.
+ ($auto_tests_skipped) = split /\//,$line;
+ $auto_tests_skipped =~ s/^.*\">//; # Remove opening td tag.
+ }
+ if ($read_flag == 7) { # Get number of No result tests.
+ ($auto_tests_noresult) = split /\//,$line;
+ $auto_tests_noresult =~ s/^.*\">//; # Remove opening td tag.
}
if ($line eq "<td class=\"tableData\">Nested tests<\/td>") { # Set flag for reading results.
$read_flag = 0;
@@ -104,12 +137,33 @@
};
}
close FILE;
+ # Set number of No run tests.
+ $auto_tests_notrun = $auto_tests_skipped + $auto_tests_noresult;
+
+ # Get additional info
+ open (FILE, "<$ats3_report") or die ("Couldn't open $ats3_report for reading: $!\n");
+ while ($line = <FILE>) {
+ chomp $line;
+ if ($line =~ "<b>Test run:") {
+ $name = $line;
+ $name =~ s/^.*<td>//;
+ $name =~ s/<\/td>.*//;
+ }
+ if ($line =~ "<b>Start time:") {
+ $start_time = $line;
+ $start_time =~ s/^.*<td>//;
+ $start_time =~ s/<\/td>.*//;
+ }
+ if ($line =~ "<b>End time:") {
+ $end_time = $line;
+ $end_time =~ s/^.*<td>//;
+ $end_time =~ s/<\/td>.*//;
+ }
+ }
+ close FILE;
+
}
if (defined($ats4_report)) { # Get ATS4 Smoketest results.
- $auto_tests_total = 0;
- $auto_tests_passed = 0;
- $auto_tests_failed = 0;
- $auto_tests_notrun = 0;
open (FILE, "<$ats4_report") or die ("Couldn't open $ats4_report for reading: $!\n");
my $read_flag = -1;
print "Reading $ats4_report... ";
@@ -120,7 +174,8 @@
$auto_tests_total++;
if ($line =~ "PASSED") { $auto_tests_passed++ }
if ($line =~ "FAILED") { $auto_tests_failed++ }
- if (($line =~ "SKIPPED") || ($line =~ "NOT_AVAILABLE")) { $auto_tests_notrun++ }
+ if ($line =~ "SKIPPED") { $auto_tests_skipped++ }
+ if ($line =~ "NOT_AVAILABLE") { $auto_tests_notrun++ }
# Re-set flag.
$read_flag = -1;
}
@@ -129,21 +184,44 @@
}
}
close FILE;
+
+ # Get additional info
+ $name = "Smoketest"; # Name not available in ATS4 testreport.
+ open (FILE, "<$ats4_report") or die ("Couldn't open $ats4_report for reading: $!\n");
+ $start_time = "";
+ while ($line = <FILE>) {
+ chomp $line;
+ if ($line =~ "timeStamp=\"") {
+ $time_stamp = $line;
+ $time_stamp =~ s/^.*timeStamp=\"//;
+ $time_stamp =~ s/\..*//;
+ ($date,$time) = split /\s/,$time_stamp;
+ ($day, $month, $year) = split /-/,$date;
+ $time_stamp = "$year-$month-$day $time";
+ if ($start_time eq "") { $start_time = $time_stamp }
+ }
+ }
+ close FILE;
+ $end_time = $time_stamp; # Last entry becomes end_time.
}
print "complete\n";
-print "Total number of tests: $auto_tests_total\n";
-print "Passed tests: $auto_tests_passed\n";
-print "Failed tests: $auto_tests_failed\n";
-print "Not run tests: $auto_tests_notrun\n";
+#print "Total number of tests: $auto_tests_total\n";
+#print "Passed tests: $auto_tests_passed\n";
+#print "Failed tests: $auto_tests_failed\n";
+#print "Not run tests: $auto_tests_notrun\n";
-# Define detailshref attribute.
+# Define detailshref attribute and report_url.
$temp_path = $brag_file;
$temp_path =~ s/\\/\//g; # Replace \ with /
$temp_path =~ s/\/summary\/.*//;
if (defined($ats3_report)) { $detailshref = $ats3_report };
if (defined($ats4_report)) { $detailshref = $ats4_report };
$detailshref =~ s/\\/\//g; # Replace \ with /
+$report_url = lc($detailshref);
$detailshref =~ s/($temp_path)/../;
+#Replace "//v800020/publish" with "http://cdn.symbian.org" in report_url
+$report_url =~ s/^.*\/publish\//http:\/\/cdn.symbian.org\//;
+
if (defined($test_report)) {
$man_detailshref = $test_report;
$man_detailshref =~ s/\\/\//g; # Replace \ with /
@@ -154,20 +232,16 @@
print "Parsing " . $test_report . "... ";
$xml_report = XMLin("$test_report", keeproot => 1, forcearray => [ 'test-set', 'test-case' ], keyattr => [] );
print "complete \n";
- $man_tests_total = 0;
- $man_tests_passed = 0;
- $man_tests_failed = 0;
- $man_tests_notrun = 0;
foreach $test_case (@{$xml_report->{'test-report'}->{'test-set'}->[0]->{'test-case'}}) {
if (lc($test_case->{'result'}) eq "passed") { $man_tests_passed++ }
if (lc($test_case->{'result'}) eq "failed") { $man_tests_failed++ }
if (lc($test_case->{'result'}) eq "not run") { $man_tests_notrun++ }
$man_tests_total++;
}
- print "Total number of tests: $man_tests_total\n";
- print "Passed tests: $man_tests_passed\n";
- print "Failed tests: $man_tests_failed\n";
- print "Not run tests: $man_tests_notrun\n";
+# print "Total number of tests: $man_tests_total\n";
+# print "Passed tests: $man_tests_passed\n";
+# print "Failed tests: $man_tests_failed\n";
+# print "Not run tests: $man_tests_notrun\n";
}
# Check for Smoketest results in BRAG file.
@@ -253,6 +327,51 @@
close FILE;
print "$test_brag_xml saved\n";
+# Calculate Test BRAG Status (based on auto + manual)
+$cases_total = $man_tests_total + $auto_tests_total;
+$cases_passed = $man_tests_passed + $auto_tests_passed;
+$cases_failed = $man_tests_failed + $auto_tests_failed;
+$cases_not_run = $man_tests_notrun + $auto_tests_notrun;
+$cases_not_available = $auto_tests_disabled;
+if ($auto_tests_total > 0) {
+ $auto_pass_rate = ($auto_tests_passed / $auto_tests_total) * 100;
+} else {
+ $auto_pass_rate = 0;
+}
+if ($cases_total > 0) {
+ $fail_rate = ($cases_failed / $cases_total) * 100;
+} else {
+ $fail_rate = 0;
+}
+if ($cases_total == 0) {
+ $test_brag_status = "n/a";
+} elsif (($fail_rate > 0) && ($fail_rate <= 50)) {
+ $test_brag_status = "amber";
+} elsif ($fail_rate > 50) {
+ $test_brag_status = "red";
+} else {
+ $test_brag_status = "green";
+}
+$auto_pass_rate = sprintf("%.1f", $auto_pass_rate);
+# Generate bit file
+if (-e $bit_file) { # Delete the file if exists.
+ unlink($bit_file);
+ print "$bit_file deleted\n";
+}
+open (FILE, "> $bit_file") or die ("Couldn't open $bit_file for writing: $!\n");
+print FILE "test $name,$type,$test_target,$start_time,$end_time,$auto_tests_total,$auto_tests_passed,$auto_tests_failed,$auto_tests_notrun,$auto_tests_disabled,$auto_pass_rate\n";
+if ($test_brag_status ne "n/a") { print FILE "test_brag $test_brag_status\n"; }
+print FILE "report Smoke Test Report,$report_url,report";
+close FILE;
+print "$bit_file saved\n";
+
+if (defined($build_id)) {
+ print "Updating BIT db... ";
+ my @args = ("perl", $bitops_path, "-u", $build_id, "-a", "-f", $bit_file);
+ system(@args) == 0 or die "system @args failed: $?";
+ print "complete\n";
+}
+
exit 0;
sub usage($)
@@ -263,14 +382,15 @@
"Specify the BRAG xml file and ATS report\n" .
"synopsis:\n" .
" update_brag_status.pl --help\n" .
- " update_brag_status.pl [--brag-file=XML_FILE] [--ats3-report=HTML_REPORT] [--ats4-report=SIMPLELOGGER_REPORT] [--test-report=XML_REPORT] \n" .
+ " update_brag_status.pl [--brag-file=XML_FILE] [--ats3-report=HTML_REPORT] [--ats4-report=SIMPLELOGGER_REPORT] [--test-report=XML_REPORT] [--build-id=ID]\n" .
"options:\n" .
" --help Display this help and exit.\n" .
" --brag-file=XML_FILE XML_FILE is the full path to the file containing BRAG summary.\n" .
" --ats3-report=HTML_REPORT HTML_REPORT is the full path to the ATS3 report.\n" .
" --ats4-report=SIMPLELOGGER_REPORT SIMPLELOGGER_REPORT is the full path to the ATS4 report.\n" .
" --test-report=XML_REPORT XML_REPORT is the name of the test report for manually executed tests.\n" .
- " If not specified only automated tests results will be taken into account.\n";
+ " If not specified only automated tests results will be taken into account.\n" .
+ " --build-id=ID ID is the id of the build which will be updated with the test results.\n";
exit $error;
}
--- a/common/tools/bitops.pl Tue Oct 05 11:37:00 2010 +0100
+++ b/common/tools/bitops.pl Mon Oct 11 14:51:10 2010 +0100
@@ -10,34 +10,58 @@
my $help = 0;
my $create = 0;
+my $stringcheck = 0;
+my $file = '';
my $id = '';
-my $file = '';
+my $append = 0;
+my $delete = '';
+my $testingonly = 0;
my $verbose = 0;
my $dryrun = 0;
GetOptions((
'create!' => \$create,
+ 'stringcheck!' => \$stringcheck,
'file=s' => \$file,
- 'id=s' => \$id,
+ 'update=s' => \$id,
+ 'append!' => \$append,
+ 'remove=s' => \$delete,
+ 'testingonly!' => \$testingonly,
'help!' => \$help,
'verbose!' => \$verbose,
'dryrun!' => \$dryrun,
));
-if ($help||!$file)
+if ($help||(($create||$id)&&!$file)||(!$create&&!$id&&!$delete))
{
print <<_EOH;
bitops
Executes operations on the BIT db
-Usage: bitops.pl [-c|-i ID] -f FILE
+Usage:
+ bitops.pl -c [-n] -f FILE
+ bitops.pl -u ID [-a] [-t] -f FILE
+ bitops.pl -r ID
Options:
-h, --help Show this help message and exit
-c, --create Create entry for a new build then set the attributes to
the values provided in FILE. Returns the build id for
the newly created build.
- -i ID, --id ID Update entry for build number ID with the values
- provided in FILE.
+ -s, --stringcheck Check that the build_id_string is unique, otherwise do
+ not create build.
+ -u ID, --update ID Update entry for build number ID with the values
+ provided in FILE. For the update operation only the
+ entry in the BUILDS table will be actually updated, the
+ entries in the other tables will be deleted, then the
+ data supplied will be inserted (this behaviour can be
+ changed with the -a option)
+ -a, --append Do not delete entries in the tables different than
+ BUILDS before inserting the data supplied. This option
+ must be used in conjuntion with -u (see info for -u
+ option for more information)
+ -t, --testingonly Only update the TESTING table and use ID obtained by
+ match of build_id_string
+ -r, --remove Remove build ID (entries in all tables) from the db
-f FILE, --file FILE Use attributes in FILE to create/update the build info
See below for file format.
-v, --verbose Increase info level
@@ -47,24 +71,29 @@
File format:
File must be a list of attribute-value-pairs. One avp per line, on each line
attribute and value are separated by a tab.
- These are the supported attributes (in brackets the syntax of the value):
- - build_id_string
- - package (VALUE)
- - platform (VALUE)
- - started (VALUE)
- - finished (VALUE)
- - creator (VALUE)
- - machine (VALUE)
- - build_brag (VALUE)
- - test_brag (VALUE)
- - baseline_short (VALUE)
- - sources_short (VALUE)
- - envinfo (TOOL,VERSION)
- - failure (CATEGORY,COUNT)
- - report (NAME,URL,TYPE)
- - content (NAME,URL,REVISION)
- - baseline (TYPE,PATH)
- - label (VALUE)
+ These are the supported attributes (in brackets the syntax of the value) with
+ the table they belong to:
+ - build_id_string - BUILDS
+ - package (VALUE) - BUILDS
+ - platform (VALUE) - BUILDS
+ - started (VALUE) - BUILDS
+ - finished (VALUE) - BUILDS
+ - creator (VALUE) - BUILDS
+ - machine (VALUE) - BUILDS
+ - build_brag (VALUE) - BUILDS
+ - test_brag (VALUE) - BUILDS
+ - baseline_short (VALUE) - BUILDS
+ - sources_short (VALUE) - BUILDS
+ - envinfo (TOOL,VERSION) - ENVINFO
+ - failure (CATEGORY,COUNT) - FAILURES
+ - report (NAME,URL,TYPE) - REPORTS
+ - content (NAME,URL,REVISION) - CONTENT
+ - baseline (TYPE,PATH) - BASELINES
+ - label (VALUE) - LABELS
+ - test (NAME,TYPE,TARGET,STARTED,FINISHED,CASES_TOTAL,CASES_PASSED,
+ CASES_FAILED,CASES_NOT_RUN,CASES_NOT_AVAILABLE,PASS_RATE) - TESTING
+
+Note on the update operation:
_EOH
exit(0);
}
@@ -78,7 +107,7 @@
my $content = [];
my $baselines = [];
my $labels = [];
-my $testing_entry = {};
+my $testing = [];
sub ConnectToDB()
{
@@ -112,7 +141,7 @@
my $attr = $1;
my $value = $2;
- if ($attr =~ /^(build_id_string|package|platform|started|finished|creator|machine|build_brag|test_brag|baseline_short|sources_short)$/i)
+ if ($attr =~ /^(build_id_string|package|platform|started|finished|creator|machine|build_brag|test_brag|baseline_short|sources_short|id)$/i)
{
$attr = lc($attr);
print " found ($attr,$value) for table 'build'\n" if ($verbose);
@@ -235,6 +264,45 @@
print " found ($attr,$value) for table 'labels'\n" if ($verbose);
push(@{$labels}, {label=>$value});
}
+ elsif ($attr =~ /^(test)$/i)
+ {
+ $attr = lc($attr);
+ if ($value =~ /([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*)/)
+ {
+ my $name=$1;
+ my $type=$2;
+ my $target=$3;
+ my $started=$4;
+ my $finished=$5;
+ my $cases_total=$6;
+ $cases_total=0 if (!$cases_total);
+ my $cases_passed=$7;
+ $cases_passed=0 if (!$cases_passed);
+ my $cases_failed=$8;
+ $cases_failed=0 if (!$cases_failed);
+ my $cases_not_run=$9;
+ $cases_not_run=0 if (!$cases_not_run);
+ my $cases_not_available=$10;
+ $cases_not_available=0 if (!$cases_not_available);
+ my $pass_rate=$11;
+ $pass_rate="0.0" if (!$pass_rate);
+
+ if (!$name)
+ {
+ print "ERROR: Name is empty: \"$value\"\n";
+ return 1;
+ }
+ print " found ($name,$type,$target,$started,$finished,$cases_total,$cases_passed,$cases_failed,$cases_not_run,$cases_not_available,$pass_rate) for table 'testing'\n" if ($verbose);
+ push(@{$testing}, {name=>$name,type=>$type,target=>$target,started=>$started,finished=>$finished,
+ cases_total=>$cases_total,cases_passed=>$cases_passed,cases_failed=>$cases_failed,cases_not_run=>$cases_not_run,
+ cases_not_available=>$cases_not_available,pass_rate=>$pass_rate});
+ }
+ else
+ {
+ print "ERROR: Could not understand value of envinfo: \"$value\"\n";
+ return 1;
+ }
+ }
else
{
print "ERROR: Could not understand avp: \"$line\"\n";
@@ -254,8 +322,8 @@
}
# MAIN PROGRAM
-
-my $r=parse_file($file);
+my $r=0;
+$r=parse_file($file) if ($create||$id);
if ($r)
{
print "Error while parsing file $file\n";
@@ -268,6 +336,25 @@
my $newbuildid = -1;
if ($create)
{
+ if ($stringcheck && defined $builds_entry->{build_id_string} && !$dryrun)
+ {
+ print "Check that the build_id_string is unique\n" if ($verbose);
+ my $query=$db->prepare("select id from builds where build_id_string='$builds_entry->{build_id_string}';");
+ $query->execute();
+ my @ids_existing=();
+ my $id_existing=-1;
+ $query->bind_columns(\$id_existing);
+ while($query->fetch())
+ {
+ push(@ids_existing, $id_existing);
+ }
+ if (scalar(@ids_existing))
+ {
+ print "ERROR: The supplied build_id_string already exists for build id: @ids_existing. Not creating build.\n";
+ exit(1);
+ }
+ }
+
if (keys %{$builds_entry})
{
my $field_list = '';
@@ -286,7 +373,7 @@
or die("Couldn't prepare query insert into builds: " . $db->errstr()) if (!$dryrun);
$query->execute(@fields)
- or print "WARNING: Couldn't execute insert into builds (@fields): " . $db->errstr() . "\n" if (!$dryrun);
+ or print "WARNING: Couldn't execute insert into builds ($field_list) values (@fields): " . $db->errstr() . "\n" if (!$dryrun);
$newbuildid = $db->last_insert_id(undef, undef, undef, undef) if (!$dryrun);
}
@@ -385,13 +472,66 @@
or print "WARNING: Couldn't execute insert into revision ($label): " . $db->errstr() . "\n" if (!$dryrun);
}
}
+
+ if (@{$testing})
+ {
+ print " prepare_cached 'insert into testing (build_id,name,type,target,started,finished,cases_total,cases_passed,cases_failed,cases_not_run,cases_not_available,pass_rate) values ($newbuildid,?,?,?,?,?,?,?,?,?,?,?)'\n" if ($verbose);
+ my $query = $db->prepare_cached("insert into testing (build_id,name,type,target,started,finished,cases_total,cases_passed,cases_failed,cases_not_run,cases_not_available,pass_rate) values ($newbuildid,?,?,?,?,?,?,?,?,?,?,?)")
+ or die("Couldn't prepare query insert into testing: " . $db->errstr()) if (!$dryrun);
+
+ for my $entry (@{$testing})
+ {
+ my $name = $entry->{name};
+ my $type = $entry->{type};
+ my $target = $entry->{target};
+ my $started = $entry->{started};
+ my $finished = $entry->{finished};
+ my $cases_total = $entry->{cases_total};
+ my $cases_passed = $entry->{cases_passed};
+ my $cases_failed = $entry->{cases_failed};
+ my $cases_not_run = $entry->{cases_not_run};
+ my $cases_not_available = $entry->{cases_not_available};
+ my $pass_rate = $entry->{pass_rate};
+
+ print " execute '$name,$type,$target,$started,$finished,$cases_total,$cases_passed,$cases_failed,$cases_not_run,$cases_not_available,$pass_rate'\n" if ($verbose);
+ $query->execute($name,$type,$target,$started,$finished,$cases_total,$cases_passed,$cases_failed,$cases_not_run,$cases_not_available,$pass_rate)
+ or print "WARNING: Couldn't execute insert into testing ($name,$type,$target,$started,$finished,$cases_total,$cases_passed,$cases_failed,$cases_not_run,$cases_not_available,$pass_rate): " . $db->errstr() . "\n" if (!$dryrun);
+ }
+ }
print "new build id: $newbuildid\n";
}
-else
+elsif ($id)
{
- print "Updating build $id\n";
+ my $extra = '';
+ $extra="for TESTING table only" if ($testingonly);
+ print "Updating build $id $extra\n";
+
+ if (defined $builds_entry->{id} && $id != $builds_entry->{id} && !$testingonly)
+ {
+ print "ERROR: The build id specified in the input file is different than the one on the command line. Not updating build.\n";
+ exit(1);
+ }
- if (keys %{$builds_entry})
+ if ($testingonly)
+ {
+ die "build_id_string must be provided" if (!defined $builds_entry->{build_id_string});
+ print "Search for matching build_id_string\n" if ($verbose);
+ my $query=$db->prepare("select id from builds where build_id_string='$builds_entry->{build_id_string}';");
+ $query->execute();
+ my @ids_existing=();
+ my $id_existing=-1;
+ $query->bind_columns(\$id_existing);
+ while($query->fetch())
+ {
+ push(@ids_existing, $id_existing);
+ }
+ die "More than 1 id matching: @ids_existing" if (scalar(@ids_existing)>1);
+ $id=shift @ids_existing;
+ $builds_entry->{id}=$id;
+ print "Now changing id to $id\n";
+ }
+
+ if (keys %{$builds_entry} && !$testingonly)
{
my $field_list = '';
my @fields = ();
@@ -410,15 +550,18 @@
$query->execute(@fields)
or print "WARNING: Couldn't execute update builds (@fields): " . $db->errstr() . "\n" if (!$dryrun);
}
- if (@{$envinfo})
+ if (@{$envinfo} && !$testingonly)
{
- print " prepare 'delete from envinfo where build_id=$id'\n" if ($verbose);
- my $delete_query = $db->prepare("delete from envinfo where build_id=$id")
- or die("Couldn't prepare query delete from envinfo: " . $db->errstr()) if (!$dryrun);
+ if (!$append)
+ {
+ print " prepare 'delete from envinfo where build_id=$id'\n" if ($verbose);
+ my $delete_query = $db->prepare("delete from envinfo where build_id=$id")
+ or die("Couldn't prepare query delete from envinfo: " . $db->errstr()) if (!$dryrun);
- print " execute ''\n" if ($verbose);
- $delete_query->execute()
- or print "WARNING: Couldn't execute delete from envinfo: " . $db->errstr() . "\n" if (!$dryrun);
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from envinfo: " . $db->errstr() . "\n" if (!$dryrun);
+ }
print " prepare 'insert into envinfo (build_id,tool,version) values ($id,?,?)'\n" if ($verbose);
my $query = $db->prepare_cached("insert into envinfo (build_id,tool,version) values ($id,?,?)")
@@ -434,16 +577,19 @@
or print "WARNING: Couldn't execute insert into envinfo ($tool,$version): " . $db->errstr() . "\n" if (!$dryrun);
}
}
- if (@{$failures})
+ if (@{$failures} && !$testingonly)
{
- print " prepare 'delete from failures where build_id=$id'\n" if ($verbose);
- my $delete_query = $db->prepare("delete from failures where build_id=$id")
- or die("Couldn't prepare query delete from failures: " . $db->errstr()) if (!$dryrun);
+ if (!$append)
+ {
+ print " prepare 'delete from failures where build_id=$id'\n" if ($verbose);
+ my $delete_query = $db->prepare("delete from failures where build_id=$id")
+ or die("Couldn't prepare query delete from failures: " . $db->errstr()) if (!$dryrun);
- print " execute ''\n" if ($verbose);
- $delete_query->execute()
- or print "WARNING: Couldn't execute delete from failures: " . $db->errstr() . "\n" if (!$dryrun);
-
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from failures: " . $db->errstr() . "\n" if (!$dryrun);
+ }
+
print " prepare 'insert into failures (build_id,category,count) values ($id,?,?)'\n" if ($verbose);
my $query = $db->prepare_cached("insert into failures (build_id,category,count) values ($id,?,?)")
or die("Couldn't prepare query insert into failures: " . $db->errstr()) if (!$dryrun);
@@ -458,19 +604,22 @@
or print "WARNING: Couldn't execute insert into failures ($category,$count): " . $db->errstr() . "\n" if (!$dryrun);
}
}
- if (@{$reports})
+ if (@{$reports} && !$testingonly)
{
- print " prepare 'delete from reports where build_id=$id'\n" if ($verbose);
- my $delete_query = $db->prepare("delete from reports where build_id=$id")
- or die("Couldn't prepare query delete from reports: " . $db->errstr()) if (!$dryrun);
+ if (!$append)
+ {
+ print " prepare 'delete from reports where build_id=$id'\n" if ($verbose);
+ my $delete_query = $db->prepare("delete from reports where build_id=$id")
+ or die("Couldn't prepare query delete from reports: " . $db->errstr()) if (!$dryrun);
- print " execute ''\n" if ($verbose);
- $delete_query->execute()
- or print "WARNING: Couldn't execute delete from reports: " . $db->errstr() . "\n";
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from reports: " . $db->errstr() . "\n";
+ }
print " prepare 'insert into reports (build_id,name,url,type) values ($id,?,?,?)'\n" if ($verbose);
my $query = $db->prepare_cached("insert into reports (build_id,name,url,type) values ($id,?,?,?)")
- or die("Couldn't prepare query insert into failures: " . $db->errstr()) if (!$dryrun);
+ or die("Couldn't prepare query insert into reports: " . $db->errstr()) if (!$dryrun);
for my $entry (@{$reports})
{
@@ -483,15 +632,18 @@
or print "WARNING: Couldn't execute insert into reports ($name,$url,$type): " . $db->errstr() . "\n" if (!$dryrun);
}
}
- if (@{$content})
+ if (@{$content} && !$testingonly)
{
- print " prepare 'delete from content where build_id=$id'\n" if ($verbose);
- my $delete_query = $db->prepare("delete from content where build_id=$id")
- or die("Couldn't prepare query delete from content: " . $db->errstr()) if (!$dryrun);
+ if (!$append)
+ {
+ print " prepare 'delete from content where build_id=$id'\n" if ($verbose);
+ my $delete_query = $db->prepare("delete from content where build_id=$id")
+ or die("Couldn't prepare query delete from content: " . $db->errstr()) if (!$dryrun);
- print " execute ''\n" if ($verbose);
- $delete_query->execute()
- or print "WARNING: Couldn't execute delete from content: " . $db->errstr() . "\n" if (!$dryrun);
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from content: " . $db->errstr() . "\n" if (!$dryrun);
+ }
print " prepare 'insert into content (build_id,name,url,revision) values ($id,?,?,?)'\n" if ($verbose);
my $query = $db->prepare_cached("insert into content (build_id,name,url,revision) values ($id,?,?,?)")
@@ -508,15 +660,18 @@
or print "WARNING: Couldn't execute insert into content ($name,$url,$revision): " . $db->errstr() . "\n" if (!$dryrun);
}
}
- if (@{$baselines})
+ if (@{$baselines} && !$testingonly)
{
- print " prepare 'delete from baselines where build_id=$id'\n" if ($verbose);
- my $delete_query = $db->prepare("delete from baselines where build_id=$id")
- or die("Couldn't prepare query delete from baselines: " . $db->errstr()) if (!$dryrun);
+ if (!$append)
+ {
+ print " prepare 'delete from baselines where build_id=$id'\n" if ($verbose);
+ my $delete_query = $db->prepare("delete from baselines where build_id=$id")
+ or die("Couldn't prepare query delete from baselines: " . $db->errstr()) if (!$dryrun);
- print " execute ''\n" if ($verbose);
- $delete_query->execute()
- or print "WARNING: Couldn't execute delete from baselines: " . $db->errstr() . "\n" if (!$dryrun);
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from baselines: " . $db->errstr() . "\n" if (!$dryrun);
+ }
print " prepare 'insert into baselines (build_id,type,path) values ($id,?,?)'\n" if ($verbose);
my $query = $db->prepare_cached("insert into baselines (build_id,type,path) values ($id,?,?)")
@@ -532,19 +687,23 @@
or print "WARNING: Couldn't execute insert into baselines ($type,$path): " . $db->errstr() . "\n" if (!$dryrun);
}
}
- if (@{$labels})
+ if (@{$labels} && !$testingonly)
{
- print " prepare 'delete from labels where build_id=$id'\n" if ($verbose);
- my $delete_query = $db->prepare("delete from labels where build_id=$id")
- or die("Couldn't prepare query delete from labels: " . $db->errstr()) if (!$dryrun);
+ if (!$append)
+ {
+ print " prepare 'delete from labels where build_id=$id'\n" if ($verbose);
+ my $delete_query = $db->prepare("delete from labels where build_id=$id")
+ or die("Couldn't prepare query delete from labels: " . $db->errstr()) if (!$dryrun);
- print " execute ''\n" if ($verbose);
- $delete_query->execute()
- or print "WARNING: Couldn't execute delete from labels: " . $db->errstr() . "\n" if (!$dryrun);
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from labels: " . $db->errstr() . "\n" if (!$dryrun);
+ }
print " prepare 'insert into labels (build_id,label) values ($id,?)'\n" if ($verbose);
my $query = $db->prepare_cached("insert into label (build_id,label) values ($id,?)")
or die("Couldn't prepare query insert into label: " . $db->errstr()) if (!$dryrun);
+
for my $entry (@{$labels})
{
@@ -555,6 +714,102 @@
or print "WARNING: Couldn't execute insert into labels ($label): " . $db->errstr() . "\n" if (!$dryrun);
}
}
+ if (@{$testing})
+ {
+ if (!$append)
+ {
+ print " prepare 'delete from testing where build_id=$id'\n" if ($verbose);
+ my $delete_query = $db->prepare("delete from testing where build_id=$id")
+ or die("Couldn't prepare query delete from testing: " . $db->errstr()) if (!$dryrun);
+
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from testing: " . $db->errstr() . "\n";
+ }
+
+ print " prepare 'insert into testing (build_id,name,type,target,started,finished,cases_total,cases_passed,cases_failed,cases_not_run,cases_not_available,pass_rate) values ($id,?,?,?,?,?,?,?,?,?,?,?)'\n" if ($verbose);
+ my $query = $db->prepare_cached("insert into testing (build_id,name,type,target,started,finished,cases_total,cases_passed,cases_failed,cases_not_run,cases_not_available,pass_rate) values ($id,?,?,?,?,?,?,?,?,?,?,?)")
+ or die("Couldn't prepare query insert into testing: " . $db->errstr()) if (!$dryrun);
+
+ for my $entry (@{$testing})
+ {
+ my $name = $entry->{name};
+ my $type = $entry->{type};
+ my $target = $entry->{target};
+ my $started = $entry->{started};
+ my $finished = $entry->{finished};
+ my $cases_total = $entry->{cases_total};
+ my $cases_passed = $entry->{cases_passed};
+ my $cases_failed = $entry->{cases_failed};
+ my $cases_not_run = $entry->{cases_not_run};
+ my $cases_not_available = $entry->{cases_not_available};
+ my $pass_rate = $entry->{pass_rate};
+
+ print " execute '$name,$type,$target,$started,$finished,$cases_total,$cases_passed,$cases_failed,$cases_not_run,$cases_not_available,$pass_rate'\n" if ($verbose);
+ $query->execute($name,$type,$target,$started,$finished,$cases_total,$cases_passed,$cases_failed,$cases_not_run,$cases_not_available,$pass_rate)
+ or print "WARNING: Couldn't execute insert into testing ($name,$type,$target,$started,$finished,$cases_total,$cases_passed,$cases_failed,$cases_not_run,$cases_not_available,$pass_rate): " . $db->errstr() . "\n" if (!$dryrun);
+ }
+ }
+}
+elsif ($delete)
+{
+ print "Removing build $delete\n";
+
+ print " prepare 'delete from builds where id=$delete'\n" if ($verbose);
+ my $delete_query = $db->prepare("delete from builds where id=$delete")
+ or die("Couldn't prepare query delete from builds: " . $db->errstr()) if (!$dryrun);
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from builds: " . $db->errstr() . "\n" if (!$dryrun);
+
+ print " prepare 'delete from envinfo where build_id=$delete'\n" if ($verbose);
+ $delete_query = $db->prepare("delete from envinfo where build_id=$delete")
+ or die("Couldn't prepare query delete from envinfo: " . $db->errstr()) if (!$dryrun);
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from envinfo: " . $db->errstr() . "\n" if (!$dryrun);
+
+ print " prepare 'delete from failures where build_id=$delete'\n" if ($verbose);
+ $delete_query = $db->prepare("delete from failures where build_id=$delete")
+ or die("Couldn't prepare query delete from failures: " . $db->errstr()) if (!$dryrun);
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from failures: " . $db->errstr() . "\n" if (!$dryrun);
+
+ print " prepare 'delete from reports where build_id=$delete'\n" if ($verbose);
+ $delete_query = $db->prepare("delete from reports where build_id=$delete")
+ or die("Couldn't prepare query delete from reports: " . $db->errstr()) if (!$dryrun);
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from reports: " . $db->errstr() . "\n" if (!$dryrun);
+
+ print " prepare 'delete from content where build_id=$delete'\n" if ($verbose);
+ $delete_query = $db->prepare("delete from content where build_id=$delete")
+ or die("Couldn't prepare query delete from content: " . $db->errstr()) if (!$dryrun);
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from content: " . $db->errstr() . "\n" if (!$dryrun);
+
+ print " prepare 'delete from baselines where build_id=$delete'\n" if ($verbose);
+ $delete_query = $db->prepare("delete from baselines where build_id=$delete")
+ or die("Couldn't prepare query delete from baselines: " . $db->errstr()) if (!$dryrun);
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from baselines: " . $db->errstr() . "\n" if (!$dryrun);
+
+ print " prepare 'delete from labels where build_id=$delete'\n" if ($verbose);
+ $delete_query = $db->prepare("delete from labels where build_id=$delete")
+ or die("Couldn't prepare query delete from labels: " . $db->errstr()) if (!$dryrun);
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from labels: " . $db->errstr() . "\n" if (!$dryrun);
+
+ print " prepare 'delete from testing where build_id=$delete'\n" if ($verbose);
+ $delete_query = $db->prepare("delete from testing where build_id=$delete")
+ or die("Couldn't prepare query delete from testing: " . $db->errstr()) if (!$dryrun);
+ print " execute ''\n" if ($verbose);
+ $delete_query->execute()
+ or print "WARNING: Couldn't execute delete from testing: " . $db->errstr() . "\n" if (!$dryrun);
}
DisconnectFromDB();