X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=rantest%2Fweb%2FRantest%2Frantest.php;fp=rantest%2Fweb%2FRantest%2Frantest.php;h=90c0853453a2ab7da6f78b44f8fabbe1e28e0d3d;hb=8ec853edfd2e5666d8e76fb58bb95da7b4ccfbf6;hp=0000000000000000000000000000000000000000;hpb=b1f5fe3b3f099b5d0ffbf406dd4bee2c35522813;p=clearscm.git
diff --git a/rantest/web/Rantest/rantest.php b/rantest/web/Rantest/rantest.php
new file mode 100644
index 0000000..90c0853
--- /dev/null
+++ b/rantest/web/Rantest/rantest.php
@@ -0,0 +1,701 @@
+
+
+
+
+
+
+Test Steps for $testcase
+
+
+
+END;
+
+ $header .= banner ();
+ $header .= <<Test Steps for $testcase
+END;
+
+ return $header;
+} // createTestStepsHeader
+
+function createTestRunsHeader ($day) {
+ global $dateDropdown;
+
+ $header = <<
+
+
+
+
+
+Daily Test Report for $day
+
+
+END;
+
+ $header .= banner ();
+ $header .= <<
+Daily Test Report for $dateDropdown
+END;
+
+ return $header;
+} // createTestRunsHeader
+
+function createSuiteRunsHeader ($id) {
+ $suite = getName ("suite", $id);
+
+ $header = <<
+
+
+
+
+
+Suite Report for $suite
+
+
+
+END;
+
+ $header .= banner ();
+
+ return $header;
+} // createSuiteRunsHeader
+
+function createTestStepsPage ($testName, $forEmail = false, $message = "") {
+ global $runid, $date, $script;
+
+ $data = getTestSteps ($runid);
+
+ if (!$forEmail) {
+ if (isset ($message)) {
+ $page .= "$message
";
+ } // if
+ } // if
+
+ $page .= <<
+
+DUT: {$data[_header][DUTVersion]}
+EAST: {$data[_header][EASTVersion]}
+TM500: {$data[_header][TM500Version]}
+NMS: {$data[_header][NMSVersion]}
+RANTEST: {$data[_header][RANTESTVersion]}
+Date: $date
+
+
+END;
+
+ if (!$forEmail) {
+ $page .= <<
+ |
+
+ |
+
+END;
+ } // if
+
+ $page .= <<
+ Step |
+ Status |
+ Start |
+ End |
+ Duration |
+
+
+
+END;
+
+ foreach ($data["_steps"] as $line) {
+ $steps++;
+ $row_color = setRowColor ($line["Status"]);
+ $line["Status"] = colorResult ($line["Status"]);
+ $total_time += $line[Duration];
+ $startTime = substr ($line["Start"], 11, 8);
+ $endTime = substr ($line["End"], 11, 8);
+
+ $page .= <<
+ $line[Step] |
+ $line[Status] |
+ $startTime |
+ $endTime |
+
+END;
+ $page .= FormatDuration ($line[Duration]);
+ $page .= "";
+ } // foreach
+
+ $total_duration = FormatDuration ($total_time);
+
+ $logs = logs ($data["_header"]["_eastlogs"], $forEmail);
+
+ $username = getUserName ($data["_header"]["userid"]);
+
+ $page .= <<
+
+ Total steps run in $testName: $steps |
+ Run by: $username |
+ $logs |
+ $total_duration |
+
+
+ |
+
+END;
+
+ return $page;
+} // createTestStepsPage
+
+function createTestRunsPage ($day, $forEmail = false, $message = "") {
+ global $sortBy, $direction, $day, $type, $script, $testTypes;
+
+ if (!$forEmail) {
+ if ($sortBy == "Suite") {
+ $suiteDirection = ($direction == "ascending")
+ ? "
"
+ : "
";
+ } elseif ($sortBy == "Testcase") {
+ $testcaseDirection = ($direction == "ascending")
+ ? "
"
+ : "
";
+ } elseif ($sortBy == "Type") {
+ $typeDirection = ($direction == "ascending")
+ ? "
"
+ : "
";
+ } elseif ($sortBy == "Unit") {
+ $unitDirection = ($direction == "ascending")
+ ? "
"
+ : "
";
+ } elseif ($sortBy == "Status") {
+ $statusDirection = ($direction == "ascending")
+ ? "
"
+ : "
";
+ } elseif ($sortBy == "Start") {
+ $startDirection = ($direction == "ascending")
+ ? "
"
+ : "
";
+ } elseif ($sortBy == "End") {
+ $endDirection = ($direction == "ascending")
+ ? "
"
+ : "
";
+ } elseif ($sortBy == "Duration") {
+ $durationDirection = ($direction == "ascending")
+ ? "
"
+ : "
";
+ } // if
+
+ if (isset ($message)) {
+ $page .= "$message
";
+ } // if
+ } // if
+
+ $page .= <<
+
+END;
+
+ if (!$forEmail) {
+ $page .= <<
+
+
+
+ Type: |
+
+END;
+
+ $page .= <<Standalone";
+ } else {
+ $line["Suite"] = "$line[Suite]";
+ } // if
+
+ $row_color = setRowColor ($line["Status"]);
+ $testResult = colorResult ($line["Status"]);
+ $total_time += $line["Duration"];
+ $me = ($script == "index.php") ? "" : $script;
+ $logs = logs ($line["_eastlogs"], $forEmail);
+ $tests++;
+
+ $page .= <<
+ $tests |
+ $line[Suite] |
+ |
+ $line[Type] |
+
+END;
+ $page .= $line["Unit/Version"];
+ $page .= <<
+ $logs |
+ $testResult |
+ $line[Start] |
+ $line[End] |
+
+END;
+
+ $page .= FormatDuration ($line["Duration"]);
+ $page .= " | ";
+ } // while
+
+ $total_duration = FormatDuration ($total_time);
+
+ $page .= <<
+
+ $tests Run
+END;
+ $page .= stats ($day, $type);
+ $page .= <<
+ $total_duration |
+ |
+
+ |
+
+END;
+ return $page;
+} // createTestRunsPage
+
+function createSuiteRunsPage ($suiteid, $forEmail = false, $message = "") {
+ global $sortBy, $direction, $day;
+
+ $name = getName ("suite", $suiteid);
+ $page = "Test Suite Report for $name
";
+
+ if (!$forEmail) {
+ if ($sortBy == "Status") {
+ $statusDirection = ($direction == "ascending")
+ ? "
"
+ : "
";
+ } elseif ($sortBy == "Start") {
+ $startDirection = ($direction == "ascending")
+ ? "
"
+ : "
";
+ } elseif ($sortBy == "End") {
+ $endDirection = ($direction == "ascending")
+ ? "
"
+ : "
";
+ } elseif ($sortBy == "Duration") {
+ $durationDirection = ($direction == "ascending")
+ ? "
"
+ : "
";
+ } // if
+
+ if (isset ($message)) {
+ $page .= "$message
";
+ } // if
+ } // if
+
+ $page .= <<
+
+END;
+
+ if (!$forEmail) {
+ $page .= <<
+
+END;
+
+ $page .= <<
+
+ |
+
+END;
+ } // if
+
+ $direction = ($direction == "ascending") ? "descending" : "ascending";
+ $urlParms = "$script?suiteid=$suiteid&direction=$direction&&sortBy";
+
+ $data = getSuiteRuns ($suiteid);
+
+ $page .= <<
+ Status $statusDirection |
+ Start $startDirection |
+ End $endDirection |
+ Duration $durationDirection |
+
+ |
+
+END;
+
+ foreach ($data as $line) {
+ $row_color = setRowColor ($line["Status"]);
+ $status = colorResult ($line["Status"]);
+ $duration = FormatDuration ($line["Duration"]);
+
+ $suiteruns++;
+ $total_time += $line["Duration"];
+
+ $page .= <<
+ $status |
+ $line[Start] |
+ $line[End] |
+ $duration |
+
+END;
+ } // while
+
+ $total_duration = FormatDuration ($total_time);
+
+ $page .= <<
+
+ Total sutie runs for $name: $suiteruns |
+ $total_duration |
+
+
+
+
+END;
+
+ return $page;
+} // createSuiteRunsPage
+
+function displayStepRun ($testName, $message = "") {
+ print createTestStepsHeader ($testName);
+ print createTestStepsPage ($testName, false, $message);
+
+ copyright ();
+} // displayStepRun
+
+function displayTestRuns ($day, $message = "") {
+ print createTestRunsHeader ($day);
+ print createTestRunsPage ($day, false, $message);
+
+ copyright ();
+} // displayTestRuns
+
+function displaySuiteRun ($suiteid, $message = "") {
+ print createSuiteRunsHeader ($suiteid);
+ print createSuiteRunsPage ($suiteid, false, $message);
+
+ copyright ();
+} // displaySuiteRun
+
+// The $data structure for test steps is unique so handle exportion
+// here.
+function exportStepRunCSV ($data, $title) {
+ global $na;
+
+ $csv .= "$title\n";
+
+ // Put out header information
+ $csv .= "DUT, EAST, TM500, NMS, RANTEST, USER, DATE, LOGS\n";
+
+ $versions = array (
+ "DUTVersion",
+ "EASTVersion",
+ "TM500Version",
+ "NMSVersion",
+ "RANTESTVersion"
+ );
+
+ foreach ($versions as $version) {
+ if ($data["_header"][$version] == $na) {
+ $csv .= "N/A,";
+ } else {
+ $csv .= $data["_header"][$version] . ",";
+ } // if
+ } // foreach
+
+ $csv .= $data["_header"]["userid"] . ",";
+ $csv .= YMD2MDY ($data["_header"]["Date"]) . ",";
+ $csv .= logs ($data["_header"]["_eastlogs"], true) . "\n\n";
+
+ // Create header line
+ $firstTime = true;
+
+ foreach ($data["_steps"][0] as $key => $value) {
+ // Skip "hidden" fields - fields beginning with "_"
+ if (preg_match ("/^_/", $key) == 1) {
+ continue;
+ } // if
+
+ if (!$firstTime) {
+ $csv .= ",";
+ } else {
+ $firstTime = false;
+ } // if
+
+ $csv .= "\"$key\"";
+ } // foreach
+
+ $csv .= "\n";
+
+ foreach ($data["_steps"] as $entry) {
+ $firstTime = true;
+
+ foreach ($entry as $key => $value) {
+ // Skip "hidden" fields - fields beginning with "_"
+ if (preg_match ("/^_/", $key) == 1) {
+ continue;
+ } // if
+
+ if (!$firstTime) {
+ $csv .= ",";
+ } else {
+ $firstTime = false;
+ } // if
+
+ $csv .= "\"$value\"";
+ } // foreach
+
+ $csv .= "\n";
+ } // foreach
+
+ return $csv;
+} // exportStepRunCSV
+
+function exportStepRun ($testcase, $runid, $date) {
+ $timestamp = getTestRunTimestamp ($runid);
+ $filename = "Step Report." . $timestamp . ".csv";
+
+ header ("Content-Type: application/octect-stream");
+ header ("Content-Disposition: attachment; filename=\"$filename\"");
+
+ print exportStepRunCSV (getTestSteps ($runid), "Step Report for $testcase");
+
+ exit;
+} // exportStepRun
+
+function exportTestRuns ($day) {
+ global $type;
+
+ $filename = "Daily Test Report." . $day . ".csv";
+
+ header ("Content-Type: application/octect-stream");
+ header ("Content-Disposition: attachment; filename=\"$filename\"");
+
+ print exportCSV (getTestRuns (MDY2YMD ($day), $type, true), "Daily Test Report for $day");
+
+ exit;
+} // exportTestRuns
+
+function exportSuiteRun ($suiteid) {
+ $suite = getName ("suite", $suiteid);
+ $filename = "Suite Report." . $suite . ".csv";
+
+ header ("Content-Type: application/octect-stream");
+ header ("Content-Disposition: attachment; filename=\"$filename\"");
+
+ print exportCSV (getSuiteRuns ($suiteid), "Suite Report for $suite");
+
+ exit;
+} // exportSuiteRun
+
+function mailStepRunReport ($testName, $pnbr, $username) {
+ global $runid;
+
+ $subject = "Step Report for $testName";
+ $body = createTestStepsPage ($testName, true);
+ $timestamp = getTestRunTimestamp ($runid);
+ $filename = "Step Report." . $timestamp . ".csv";
+ $attachment = exportStepRunCSV (getTestSteps ($runid), $subject);
+
+ return mailReport ($pnbr, $username, $subject, $body, $filename, $attachment);
+} // mailStepReport
+
+function mailTestRunsReport ($day, $pnbr, $username) {
+ global $type;
+
+ $subject = "Daily Test Report for $day";
+ $body = createTestRunsPage ($day, true);
+ $filename = "TestRuns.$day.csv";
+ $attachment = exportCSV (getTestRuns (MDY2YMD ($day), $type, true), $subject);
+
+ return mailReport ($pnbr, $username, $subject, $body, $filename, $attachment);
+} // mailTestRunsReport
+
+function mailSuiteRunReport ($suiteid, $pnbr, $username) {
+ $subject = "Suite Report for $suitid";
+ $body = createSuiteRunsPage ($suiteid, true);
+ $filename = "Suite Runs.$suiteid.csv";
+
+ $attachment = exportCSV (getSuiteRuns ($suiteid, true), $subject);
+
+ return mailReport ($pnbr, $username, $subject, $body, $filename, $attachment);
+} // mailSuiteRunReport
+
+openDB ();
+
+$dateDropdown = reportDateDropdown ();
+
+switch ($action) {
+ case "Export":
+ if ($suiteid != 0) {
+ exportSuiteRun ($suiteid);
+ } elseif (isset ($testName)) {
+ exportStepRun ($testName, $runid, $date);
+ } else {
+ exportTestRuns ($day);
+ } // if
+
+ break;
+
+ case "Mail":
+ list ($pnbr, $username) = explode (":", $user);
+
+ if (isset ($suiteid)) {
+ $message = mailSuiteRunReport ($suiteid, $pnbr, $username);
+ displaySuiteRun ($suiteid, $message);
+ } elseif (isset ($testName)) {
+ $message = mailStepRunReport ($testName, $pnbr, $username);
+ displayStepRun ($testName, $message);
+ } else {
+ $message = mailTestRunsReport ($day, $pnbr, $username);
+
+ displayTestRuns ($day, $message);
+ } // if
+
+ break;
+
+ default:
+ if (isset ($suiteid)) {
+ displaySuiteRun ($suiteid);
+ } elseif (isset ($testName)) {
+ displayStepRun ($testName);
+ } else {
+ displayTestRuns ($day);
+ } // if
+
+ break;
+} // switch