$row_nbr |
$line[Testcase] |
$line[Passed] |
$line[Failed] |
$line[Total] |
END;
$page .= FormatDuration ($line[AvgRunTime]);
$page .= " | ";
$total_passed += $line["Passed"];
$total_failed += $line["Failed"];
$total_total += $line["Total"];
} // if
} // foreach
// Print total
if (empty ($testcase)) {
$page .= <<
Total |
$total_passed |
$total_failed |
$total_total |
|
END;
} // if
$page .= <<
END;
return $page;
} // createPage
function exportTestHistoryCSV ($testcase) {
global $historyFor;
if (isset ($testcase)) {
$title = "Test History for $historyFor";
$filename = "Test History." . $testcase . ".csv";
} else {
$title = "Test History for All Tests";
$filename = "Test History.All Tests.csv";
} // if
// Protect $filename from wildcards
$filename = preg_replace ("/\*/", "%", $filename);
header ("Content-Type: application/octect-stream");
header ("Content-Disposition: attachment; filename=\"$filename\"");
print exportCSV (getData ($testcase), $title);
exit;
} // exportTestHistoryCSV
function setTestcase () {
global $testcase, $build, $level, $DUT, $test;
if (empty ($testcase)) {
if (empty ($test)) {
$test = "*";
} // if
if ($build == "*" and
$level == "*" and
$DUT == "*" and
$test == "*") {
unset ($testcase);
return "All Tests";
} else {
$testcase = "${build}_${level}_${DUT}_${test}";
} // if
} // if
return $testcase;
} // setTestcase
function displayReport ($testcase, $message = "") {
print createHeader ();
print createPage ($testcase, false, $message);
copyright ();
} // displayReport
function mailTestHistoryReport ($testcase, $pnbr, $username) {
global $historyFor;
if (isset ($testcase)) {
$subject = "Test History for $historyFor";
$filename = "Test History." . $testcase . ".csv";
} else {
$subject = "Test History for All Tests";
$filename = "Test History.All Tests.csv";
} // if
// Protect $filename from wildcards
$filename = preg_replace ("/\*/", "%", $filename);
$body = createPage ($testcase, true);
$attachment = exportCSV (getData ($testcase, true), $subject);
return mailReport ($pnbr, $username, $subject, $body, $filename, $attachment);
} // mailTestHistoryReport
openDB ();
$historyFor = setTestcase ();
switch ($action) {
case "Export":
exportTestHistoryCSV ($testcase);
break;
case "Mail":
list ($pnbr, $username) = explode (":", $user);
displayReport ($testcase, mailTestHistoryReport ($testcase, $pnbr, $username));
break;
default:
displayReport ($testcase);
break;
} // switch
?>