Ejemplo n.º 1
0
function display_testsuites($distro_name, $new_table_caption, $testsuites_1, $testsuites_2, $files, $date_1, $date_2, $distro, $profile, &$total_array)
{
    if (count($testsuites_1) == 0 && count($testsuites_2) == 0) {
        return;
    }
    $new_table = "<table border=2>" . "<tr><b>" . "<th rowspan=2><center> Sl.No</center></th><th rowspan=2><center> Test Suite (Pass %)</center></th>";
    $new_table = $new_table . "<th colspan=4><center>{$date_1}</center></th><th colspan=4><center>{$date_2}</center></th><th rowspan=2><center>Regression</center></th>" . "<tr><th><center>  Pass</center></th><th><center> Fail</center></th><th><center> Not Run</center></th><th><center> Execution Time</center></th><th><center> Pass </center></th><th><center>Fail</center></th><th><center> Not Run</center></th><th><center>Execution Time</center></th>";
    $testsuites_1_count = 0;
    $testsuites_2_count = 0;
    $s_no = 1;
    print "<br><b>" . $new_table_caption . "</b><br><br>" . $new_table;
    $filename = "{$distro_name}-{$profile}.html";
    $regressed_count = 0;
    $total_passes = array();
    $total_failures = array();
    $total_notrun = array();
    $total_exec = array();
    $total_regresses = 0;
    while ($testsuites_1_count < count($testsuites_1) || $testsuites_2_count < count($testsuites_2)) {
        //Calculating pass percentage
        if ($testsuites_1[$testsuites_1_count]["name"] == null) {
            $recentsuite = $testsuites_2[$testsuites_2_count];
        } else {
            $recentsuite = $testsuites_1[$testsuites_1_count];
        }
        $total_tests = $recentsuite["pass"] + $recentsuite["fail"] + $recentsuite["notrun"];
        if ($total_tests != 0) {
            $percent = $recentsuite["pass"] * 100 / $total_tests;
        } else {
            $percent = 100;
        }
        $color = "ff3300";
        if ($percent > 90) {
            $color = "lightgreen";
        } else {
            if ($percent > 60) {
                $color = "yellow";
            }
        }
        if ($percent == 100) {
            $color = "30b323";
        }
        //Displaying result
        if ($testsuites_1[$testsuites_1_count]["name"] == $testsuites_2[$testsuites_2_count]["name"]) {
            //Testsuites that contain entries for both the recent and the previous run
            $regressed_count = 1;
            $total_passes[0] += $testsuites_1[$testsuites_1_count]["pass"];
            $total_passes[1] += $testsuites_2[$testsuites_2_count]["pass"];
            $total_failures[0] += $testsuites_1[$testsuites_1_count]["fail"];
            $total_failures[1] += $testsuites_2[$testsuites_2_count]["fail"];
            $total_notrun[0] += $testsuites_1[$testsuites_1_count]["notrun"];
            $total_notrun[1] += $testsuites_2[$testsuites_2_count]["notrun"];
            $total_exec[0] += $testsuites_1[$testsuites_1_count]["exectime"];
            $total_exec[1] += $testsuites_2[$testsuites_2_count]["exectime"];
            print "<tr><td>{$s_no}</td>\n";
            $testsuite_name = $testsuites_1[$testsuites_1_count]["name"] . " (" . ceil($percent) . " %)";
            $link = "displayDetails.php?image=1&testsuite=" . $testsuites_1[$testsuites_1_count]["name"] . "&profile={$profile}&distro={$distro}";
            print "<td bgcolor={$color}><a href={$link}>" . $testsuite_name . "</a></td>\n";
            if ($testsuites_1[$testsuites_1_count]["pass"] != 0) {
                print "<td><a href=displayDetails.php?&testsuite=" . $testsuites_1[$testsuites_1_count]["name"] . "&file=" . substr($files[0], -12, 8) . "&status=0&profile={$profile}&distro={$distro}>" . $testsuites_1[$testsuites_1_count]["pass"] . "</td>\n";
            } else {
                print "<td>" . $testsuites_1[$testsuites_1_count]["pass"] . "</td>\n";
            }
            if ($testsuites_1[$testsuites_1_count]["fail"] != 0) {
                print "<td><a href=displayDetails.php?&testsuite=" . $testsuites_1[$testsuites_1_count]["name"] . "&file=" . substr($files[0], -12, 8) . "&status=1&profile={$profile}&distro={$distro}>" . $testsuites_1[$testsuites_1_count]["fail"] . "</td>\n";
            } else {
                print "<td>" . $testsuites_1[$testsuites_1_count]["fail"] . "</td>\n";
            }
            if ($testsuites_1[$testsuites_1_count]["notrun"] != 0) {
                print "<td><a href=displayDetails.php?&testsuite=" . $testsuites_1[$testsuites_1_count]["name"] . "&file=" . substr($files[0], -12, 8) . "&status=2&profile={$profile}&distro={$distro}>" . $testsuites_1[$testsuites_1_count]["notrun"] . "</td>\n";
            } else {
                print "<td>" . $testsuites_1[$testsuites_1_count]["notrun"] . "</td>\n";
            }
            print "<td>" . $testsuites_1[$testsuites_1_count]["exectime"] . "</td>\n";
            $testsuites_1_count++;
            if ($testsuites_2[$testsuites_2_count]["pass"] != 0) {
                print "<td><a href=displayDetails.php?&testsuite=" . $testsuites_2[$testsuites_2_count]["name"] . "&file=" . substr($files[1], -12, 8) . "&status=0&profile={$profile}&distro={$distro}>" . $testsuites_2[$testsuites_2_count]["pass"] . "</td>\n";
            } else {
                print "<td>" . $testsuites_2[$testsuites_2_count]["pass"] . "</td>\n";
            }
            if ($testsuites_2[$testsuites_2_count]["fail"] != 0) {
                print "<td><a href=displayDetails.php?&testsuite=" . $testsuites_2[$testsuites_2_count]["name"] . "&file=" . substr($files[1], -12, 8) . "&status=1&profile={$profile}&distro={$distro}>" . $testsuites_2[$testsuites_2_count]["fail"] . "</td>\n";
            } else {
                print "<td>" . $testsuites_2[$testsuites_2_count]["fail"] . "</td>\n";
            }
            if ($testsuites_2[$testsuites_2_count]["notrun"] != 0) {
                print "<td><a href=displayDetails.php?&testsuite=" . $testsuites_2[$testsuites_2_count]["name"] . "&file=" . substr($files[1], -12, 8) . "&status=2&profile={$profile}&distro={$distro}>" . $testsuites_2[$testsuites_2_count]["notrun"] . "</td>\n";
            } else {
                print "<td>" . $testsuites_2[$testsuites_2_count]["notrun"] . "</td>\n";
            }
            print "<td>" . $testsuites_2[$testsuites_2_count]["exectime"] . "</td>\n";
            $testsuite_name = $testsuites_2[$testsuites_2_count]["name"];
            $testsuites_2_count++;
        } else {
            if ($testsuites_1[$testsuites_1_count]["name"] != null && ($testsuites_1[$testsuites_1_count]["name"] < $testsuites_2[$testsuites_2_count]["name"] || $testsuites_2[$testsuites_2_count]["name"] == null)) {
                #testsuites that contain an entry for recent run and no entry for previous run
                $regressed_count = 0;
                $total_passes[0] += $testsuites_1[$testsuites_1_count]["pass"];
                $total_failures[0] += $testsuites_1[$testsuites_1_count]["fail"];
                $total_notrun[0] += $testsuites_1[$testsuites_1_count]["notrun"];
                $total_exec[0] += $testsuites_1[$testsuites_1_count]["exectime"];
                print "<tr><td>{$s_no}</td>\n";
                print "<td bgcolor={$color}>" . $testsuites_1[$testsuites_1_count]["name"] . " (" . ceil($percent) . " %)" . "</td>\n";
                if ($testsuites_1[$testsuites_1_count]["pass"] != 0) {
                    print "<td><a href=displayDetails.php?&testsuite=" . $testsuites_1[$testsuites_1_count]["name"] . "&file=" . substr($files[0], -12, 8) . "&status=0&profile={$profile}&distro={$distro}>" . $testsuites_1[$testsuites_1_count]["pass"] . "</td>\n";
                } else {
                    print "<td>" . $testsuites_1[$testsuites_1_count]["pass"] . "</td>\n";
                }
                if ($testsuites_1[$testsuites_1_count]["fail"] != 0) {
                    print "<td><a href=displayDetails.php?&testsuite=" . $testsuites_1[$testsuites_1_count]["name"] . "&file=" . substr($files[0], -12, 8) . "&status=1&profile={$profile}&distro={$distro}>" . $testsuites_1[$testsuites_1_count]["fail"] . "</td>\n";
                } else {
                    print "<td>" . $testsuites_1[$testsuites_1_count]["fail"] . "</td>\n";
                }
                if ($testsuites_1[$testsuites_1_count]["notrun"] != 0) {
                    print "<td><a href=displayDetails.php?&testsuite=" . $testsuites_1[$testsuites_1_count]["name"] . "&file=" . substr($files[0], -12, 8) . "&status=2&profile={$profile}&distro={$distro}>" . $testsuites_1[$testsuites_1_count]["notrun"] . "</td>\n";
                } else {
                    print "<td>" . $testsuites_1[$testsuites_1_count]["notrun"] . "</td>\n";
                }
                print "<td>" . $testsuites_1[$testsuites_1_count]["exectime"] . "</td>\n";
                $testsuite_name = $testsuites_1[$testsuites_1_count]["name"];
                $testsuites_1_count++;
                print "<td>&nbsp;</td>\n";
                print "<td>&nbsp;</td>\n";
                print "<td>&nbsp</td>\n";
                print "<td>&nbsp;</td>\n";
            } else {
                if ($testsuites_2[$testsuites_2_count]["name"] != null && ($testsuites_1[$testsuites_1_count]["name"] > $testsuites_2[$testsuites_2_count]["name"] || $testsuites_1[$testsuites_1_count]["name"] == null)) {
                    #testsuites that contain an entry for previous run and no entry for the recent run
                    $regressed_count = 0;
                    $total_passes[1] += $testsuites_2[$testsuites_2_count]["pass"];
                    $total_failures[1] += $testsuites_2[$testsuites_2_count]["fail"];
                    $total_notrun[1] += $testsuites_2[$testsuites_2_count]["notrun"];
                    $total_exec[1] += $testsuites_2[$testsuites_2_count]["exectime"];
                    print "<tr><td>{$s_no}</td>\n";
                    print "<td bgcolor={$color}>" . $testsuites_2[$testsuites_2_count]["name"] . "</td>\n";
                    print "<td>&nbsp;</td>\n";
                    print "<td>&nbsp;</td>\n";
                    print "<td>&nbsp</td>\n";
                    print "<td>&nbsp;</td>\n";
                    if ($testsuites_2[$testsuites_2_count]["pass"] != 0) {
                        print "<td><a href=displayDetails.php?&testsuite=" . $testsuites_2[$testsuites_2_count]["name"] . "&file=" . substr($files[1], -12, 8) . "&status=0&profile={$profile}&distro={$distro}>" . $testsuites_2[$testsuites_2_count]["pass"] . "</td>\n";
                    } else {
                        print "<td>" . $testsuites_2[$testsuites_2_count]["pass"] . "</td>\n";
                    }
                    if ($testsuites_2[$testsuites_2_count]["fail"] != 0) {
                        print "<td><a href=displayDetails.php?&testsuite=" . $testsuites_2[$testsuites_2_count]["name"] . "&file=" . substr($files[1], -12, 8) . "&status=1&profile={$profile}&distro={$distro}>" . $testsuites_2[$testsuites_2_count]["fail"] . "</td>\n";
                    } else {
                        print "<td>" . $testsuites_2[$testsuites_2_count]["fail"] . "</td>";
                    }
                    if ($testsuites_2[$testsuites_2_count]["notrun"] != 0) {
                        print "<td><a href=displayDetails.php?&testsuite=" . $testsuites_2[$testsuites_2_count]["name"] . "&file=" . substr($files[1], -12, 8) . "&status=2&profile={$profile}&distro={$distro}>" . $testsuites_2[$testsuites_2_count]["notrun"] . "</td>\n";
                    } else {
                        print "<td>" . $testsuites_2[$testsuites_2_count]["notrun"] . "</td>\n";
                    }
                    print "<td>" . $testsuites_2[$testsuites_2_count]["exectime"] . "</td>\n";
                    $testsuite_name = $testsuites_2[$testsuites_2_count]["name"];
                    $testsuites_2_count++;
                }
            }
        }
        $s_no++;
        //Displaying number of regressed testcases
        $regressed_testcases = array();
        if ($regressed_count != 0) {
            //Checking for number of matches between the testcases that failed in the recent run and passed in the previous run
            $regressed_testcases = fetch_regressed_testcases($testsuites_1[$testsuites_1_count - 1]["testcases"], $testsuites_2[$testsuites_2_count - 1]["testcases"]);
            $regressed_count = count($regressed_testcases);
        }
        if ($regressed_count != 0) {
            print "<td><a href=displayDetails.php?&testsuite=" . $testsuite_name . "&file=" . substr($files[0], -12, 8) . "&file1=" . substr($files[1], -12, 8) . "&regression=1&status=4&profile={$profile}&distro={$distro}>" . $regressed_count . "</td></tr>\n";
        } else {
            print "<td>" . $regressed_count . "</td></tr>\n";
        }
        print "</tr>\n";
        $total_regresses += $regressed_count;
    }
    $total_array[0]["pass"] += $total_passes[0];
    $total_array[0]["fail"] += $total_failures[0];
    $total_array[0]["notrun"] += $total_notrun[0];
    $total_array[1]["pass"] += $total_passes[1];
    $total_array[1]["fail"] += $total_failures[1];
    $total_array[1]["notrun"] += $total_notrun[1];
    print "<tr><td>&nbsp</td><td>Total</td><td>" . $total_passes[0] . "</td><td>" . $total_failures[0] . "</td><td>" . $total_notrun[0] . "</td><td>" . $total_exec[0] . "</td>\n";
    print "<td>" . $total_passes[1] . "</td><td>" . $total_failures[1] . "</td><td>" . $total_notrun[1] . "</td><td>" . $total_exec[1] . "</td><td>" . $total_regresses . "</td>";
    print "</table>\n";
}
Ejemplo n.º 2
0
    $profilePath = "net_2_0";
}
#Checking whether the input file is correct
sanitize($file);
#Prepending the base directory and appending .xml to the input filename
$file = $dir . "testresults-{$profilePath}-" . $file . ".xml";
#Obtaining location of the recent chart for the particular testsuite
$chart_url = "displayDetails.php?image=1&testsuite={$testsuite_key}&profile={$profile}&distro={$distro}";
#Displaying regressed testcases
if ($_GET['regression'] == 1) {
    $file_1 = $_GET['file1'];
    sanitize($file_1);
    //Checking whether input file1 is correct
    $file_1 = $dir . "testresults-" . $profilePath . "-" . $file_1 . ".xml";
    print "<h1>Regressed testcases for " . $_GET['testsuite'] . "</h1>";
    $testcases = fetch_regressed_testcases($testsuite_key, $file, $file_1);
    print "<br><a href=\"{$chart_url}\"><b><font size=\"2\">&lt;View Progress Charts></b></font></a><br><br><table border=1><tr><th><center>Sl.No.</center></th><th><center>Test Case Name</center></th><th><center>Message</center></th></tr>";
    $count = 1;
    foreach ($testcases as $testcase) {
        print "<tr><td>{$count} </td><td bgcolor={$color}><a href=#" . $count . ">" . $testcase["name"] . "</a></td><td><pre>" . $testcase["message"] . "</pre></td><tr>";
        $count++;
    }
    print "</table>";
    $count = 1;
    foreach ($testcases as $testcase) {
        print "<p>" . $count . ".";
        print "<b id={$count}><font size=4>&nbsp;&nbsp;&nbsp;&nbsp;Test Case Name: " . $testcase["name"] . "</font></b><br><br>";
        if ($testcase["message"] != null) {
            print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Message:</b>&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<pre>" . $testcase["message"] . "</pre><br>";
        }
        if ($testcase["stacktrace"] != null) {