blob: 52d2284f5f5eac1e23ed61ce049ba4dfbfa5f1bd [file] [log] [blame]
david_williams702bf682008-06-25 04:53:00 +00001
2 <?php
3
4function parse_testResults($filename)
5{
6 $junitFailures = 0;
7 if (is_file($filename)) {
8 $handle = @fopen($filename, "r");
9 if ($handle)
10 {
11 $size = filesize($filename);
12 $content = fread($handle, $size);
13 fclose($handle);
14 $junitStart = strpos($content, "Errors &amp; Failures");
15 $junitEnd = strpos($content, "</table>", $junitStart);
16 $junitInfo = substr($content, $junitStart, $junitEnd - $junitStart);
17 $start = strpos($junitInfo, "<td><b><font color=\"#ff0000\">");
18 while ($start !== false)
19 {
20 $start += 29;
21 $stop = strpos($junitInfo, "</font></b></td>", $start);
22 if ($stop !== false)
23 {
24 $result = substr($junitInfo, $start, $stop - $start);
25 if (is_numeric($result))
26 {
27 $junitFailures += $result;
28 }
29 else if (strcmp($result, "DNF") == 0)
30 {
31 $junitFailures++;
32 }
33 }
34 $start = strpos($junitInfo, "<td><b><font color=\"#ff0000\">", $stop);
35 }
36 $results = array($junitFailures);
37 return $results;
38 }
39 }
40}
41
42
43?>
44
45