2 ////////////////////////////////////////////////////////////////////////////////
4 // File: VersionPerTestcase.php
6 // Description: Produce a report of versions per testcase
7 // Author: Andrew@ClearSCM.com
8 // Created: Mon Apr 28 15:20:06 MST 2008
12 // (c) Copyright 2008, General Dynamics, all rights reserved.
14 // All rights reserved except as subject to DFARS 252.227-7014 of contract
15 // number CP02H8901N issued under prime contract N00039-04-C-2009.
17 // Warning: This document contains technical data whose export is restricted
18 // by the Arms Export Control Act (Title 22, U.S.C., Sec 2751, et seq.) or the
19 // Export Administration Act of 1979, as amended, Title, 50, U.S.C., App. 2401
20 // et seq. Violations of these export laws are subject to severe criminal
21 // penalties. Disseminate in accordance with provisions of DoD Directive
24 ////////////////////////////////////////////////////////////////////////////////
25 $script = basename ($_SERVER["PHP_SELF"]);
27 include_once "$_SERVER[DOCUMENT_ROOT]/php/Utils.php";
28 include_once "$_SERVER[DOCUMENT_ROOT]/php/RantestDB.php";
30 $testcase = $_REQUEST["testcase"];
31 $user = $_REQUEST["user"];
33 $build = (empty ($_REQUEST["build"])) ? "*" : $_REQUEST["build"];
34 $level = (empty ($_REQUEST["level"])) ? "*" : $_REQUEST["level"];
35 $DUT = (empty ($_REQUEST["DUT"])) ? "*" : $_REQUEST["DUT"];
36 $test = (empty ($_REQUEST["test"])) ? "*" : $_REQUEST["test"];
38 $action = (empty ($_REQUEST["action"])) ? "Report" : $_REQUEST["action"];
39 $type = (empty ($_REQUEST["type"])) ? "All" : $_REQUEST["type"];
40 $sortBy = (empty ($_REQUEST["sortBy"])) ? "Date" : $_REQUEST["sortBy"];
41 $direction = (empty ($_REQUEST["direction"])) ? "descending" : $_REQUEST["direction"];
43 $historyFor = setTestcase ($testcase);
46 function sortVersion ($a, $b) {
49 return cmpStr ($a, $b, "Version", $direction);
52 function getData ($testcase) {
55 $data = getTestVersions ($testcase);
58 if ($sortBy == "Testcase") {
59 uasort ($data, "sortTestcase");
60 } elseif ($sortBy == "Unit") {
61 uasort ($data, "sortUnit");
62 } elseif ($sortBy == "Type") {
63 uasort ($data, "sortType");
64 } elseif ($sortBy == "Status") {
65 uasort ($data, "sortStatus");
66 } elseif ($sortBy == "Duration") {
67 uasort ($data, "sortDuration");
68 } elseif ($sortBy == "Version") {
69 uasort ($data, "sortVersion");
71 uasort ($data, "sortDate");
77 function createHeader () {
81 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
82 "http://www.w3.org/TR/html4/strict.dtd">
85 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
86 <link rel="stylesheet" type="text/css" media="screen" href="/css/Testing.css">
87 <link rel="stylesheet" type="text/css" media="screen" href="/css/Tables.css">
88 <title>Test Versions for $historyFor</title>
96 <h1 align="center">Test Versions for $historyFor</h1>
102 function createPage ($testcase, $forEmail = false, $message = "") {
103 global $webdir, $direction, $sortBy, $script;
104 global $build, $level, $DUT, $test;
106 $data = getData ($testcase);
109 $direction = ($direction == "ascending") ? "descending" : "ascending";
111 if (isset ($testcase)) {
112 $urlParms = "$script?testcase=$testcase&action=$action&direction=$direction&sortBy";
114 $urlParms = "$script?build=$build&level=$level&DUT=$DUT&test=$test&action=$action&direction=$direction&sortBy";
118 if ($sortBy == "Testcase") {
119 $testcaseDirection = ($direction == "ascending")
120 ? "<img src=/images/down.png border=0>"
121 : "<img src=/images/up.png border=0>";
122 } elseif ($sortBy == "Unit") {
123 $unitDirection = ($direction == "ascending")
124 ? "<img src=/images/down.png border=0>"
125 : "<img src=/images/up.png border=0>";
126 } elseif ($sortBy == "Type") {
127 $typeDirection = ($direction == "ascending")
128 ? "<img src=/images/down.png border=0>"
129 : "<img src=/images/up.png border=0>";
130 } elseif ($sortBy == "Status") {
131 $statusDirection = ($direction == "ascending")
132 ? "<img src=/images/down.png border=0>"
133 : "<img src=/images/up.png border=0>";
134 } elseif ($sortBy == "Duration") {
135 $durationDirection = ($direction == "ascending")
136 ? "<img src=/images/down.png border=0>"
137 : "<img src=/images/up.png border=0>";
138 } elseif ($sortBy == "Version") {
139 $versionDirection = ($direction == "ascending")
140 ? "<img src=/images/down.png border=0>"
141 : "<img src=/images/up.png border=0>";
143 $dateDirection = ($direction == "ascending")
144 ? "<img src=/images/down.png border=0>"
145 : "<img src=/images/up.png border=0>";
148 if (isset ($message)) {
149 $page .= "<div align=\"center\">$message</div>";
154 <table align="center" width="90%">
161 <th class=clear align="left" colspan="2"><a href="$script?action=Export&testcase=$testcase"><input type="submit" value="Export to CSV"></a></th>
162 <th class=clear align="right" colspan="6"><form action="$script?action=Mail&testcase=$testcase" method="post">
165 $page .= emailUsersDropdown ();
168 <input type="submit" value="Send"></form>
176 <th class=left>#</th>
177 <th><a href="$urlParms=Testcase">Testcase $testcaseDirection</a></th>
178 <th><a href="$urlParms=Date">Start Date/Time $dateDirection</a></th>
179 <th><a href="$urlParms=Unit">Unit $unitDirection</a></th>
180 <th><a href="$urlParms=Type">Type $typeDirection</a></th>
181 <th><a href="$urlParms=Status">Status $statusDirection</a></th>
182 <th><a href="$urlParms=Duration">Duration $durationDirection</a></th>
183 <th class=right><a href="$urlParms=Version">Version $versionDirection</a></th>
189 foreach ($data as $line) {
191 $row_color = setRowColor ($line["Status"]);
192 $line["Status"] = colorResult ($line["Status"]);
193 $duration = FormatDuration ($line["Duration"]);
197 <td align="center">$row_nbr</td>
198 <td><a href="rantest.php?testName=$line[Testcase]&runid=$line[_runid]&date=$reportDate">$line[Testcase]</a></td>
199 <td align="center">$line[Start]</td>
200 <td align="center">$line[Unit]</td>
201 <td align="center">$line[Type]</td>
202 <td align="center">$line[Status]</td>
203 <td align="right">$duration</td>
204 <td align="center">$line[Version]</td>
217 function exportTestVersionsCSV ($testcase) {
220 if (isset ($testcase)) {
221 $title = "Test Versions for $historyFor";
222 $filename = "Test Versions." . $testcase . ".csv";
224 $title = "Test Versions for All Tests";
225 $filename = "Test Versions for All Tests.csv";
228 // Protect $filename from wildcards
229 $filename = preg_replace ("/\*/", "%", $filename);
231 header ("Content-Type: application/octect-stream");
232 header ("Content-Disposition: attachment; filename=\"$filename\"");
234 print exportCSV (getData ($testcase), $title);
237 } // exportTestHistoryCSV
239 function setTestcase () {
240 global $testcase, $build, $level, $DUT, $test;
242 if (empty ($testcase)) {
247 if ($build == "*" and
254 $testcase = "${build}_${level}_${DUT}_${test}";
261 function displayReport ($testcase, $message = "") {
262 print createHeader ();
263 print createPage ($testcase, false, $message);
268 function mailTestVersionsReport ($testcase, $pnbr, $username) {
271 if (isset ($testcase)) {
272 $subject = "Test Versions for $historyFor";
273 $filename = "Test Versions." . $testcase . ".csv";
275 $subject = "Test Versions for All Tests";
276 $filename = "Test Versions for All Tests.csv";
279 // Protect $filename from wildcards
280 $filename = preg_replace ("/\*/", "%", $filename);
282 $body = createPage ($testcase, true);
283 $attachment = exportCSV (getData ($testcase, true), $subject);
285 return mailReport ($pnbr, $username, $subject, $body, $filename, $attachment);
286 } // mailTestVersionsReport
290 $historyFor = setTestcase ();
294 exportTestVersionsCSV ($testcase);
298 list ($pnbr, $username) = explode (":", $user);
299 displayReport ($testcase, mailTestVersionsReport ($testcase, $pnbr, $username));
303 displayReport ($testcase);