Example #1
0
function SendTestsuiteMail($dailytest_id)
{
    # 按照模块分别发送mail
    Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $dailytest_id . "\n");
    $message .= PrintCss();
    //打印链接
    $message .= PrintDetailLink($dailytest_id);
    $message .= "<br/>\n";
    //打印每个模块的测试详细信息
    $message .= PrintTestsuiteTestDetail($dailytest_id);
    $sql = "select st_tester.testerdescription, st_tester.email,testdate,platform,branch,product,imageinfo\n        from\n        st_tester,st_dailytest\n        where\n        st_dailytest.tester=st_tester.tester and\n        st_dailytest.dailytest_id='{$dailytest_id}'";
    Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $sql . "\n");
    $testerresult = Dosql($sql);
    $num_tester = $testerresult->num_rows;
    for ($i = 0; $i < $num_tester; $i++) {
        $row = $testerresult->fetch_assoc();
        $testername = $row['testerdescription'];
        $testeremail = $row['email'];
        $reportdate = $row['testdate'];
        $platform = $row['platform'];
        $branch = $row['branch'];
        $product = $row['product'];
        $imageinfo = stripslashes($row['imageinfo']);
    }
    $testerresult->free();
    $sql = "select distinct st_testsuite.department_id ,department,department_email\n        from\n        st_testsuite,st_department\n        where\n        st_testsuite.department_id = st_department.department_id\n        and st_testsuite.testsuite_online = '1'\n        and st_department.department_online = '1'\n        order by department_id";
    Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $sql . "\n");
    $departmentresult = Dosql($sql);
    $num_depart = $departmentresult->num_rows;
    for ($depart = 0; $depart < $num_depart; $depart++) {
        $rowdepart = $departmentresult->fetch_assoc();
        //收件人//$to ="$testeremail,mamh@marvell.com";
        $to = "{$testeremail},mamh@marvell.com," . $rowdepart['department_email'];
        $sql = "select testsuite_id,testsuite from st_testsuite where testsuite_online = '1' and department_id = '" . $rowdepart['department_id'] . "'";
        Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $sql . "\n");
        $suiteresult = Dosql($sql);
        $num_suite = $suiteresult->num_rows;
        for ($suite = 0; $suite < $num_suite; $suite++) {
            $rowsuite = $suiteresult->fetch_assoc();
            $suitenewissueemessage .= PrintTestsuiteNewIssue($dailytest_id, $rowsuite['testsuite_id']);
            $suiteremainissuemessage .= PrintTestsuiteRemainIssue($dailytest_id, $rowsuite['testsuite_id']);
            //fail 状态的表
            $suitefailmessage .= "<h3 style=font-family:arial;>Fail Testcase <font style=color:blue>" . $rowsuite['testsuite'] . "</font></h3>\n";
            $suitefailmessage .= PrintFailStateTable($dailytest_id, $rowsuite['testsuite_id']);
            $suitefailmessage .= "<br/>\n";
            //统计各个状态的个数的表
            //$suitefailmessage .= PrintStateStatisticsTable($dailytest_id, $rowsuite['testsuite_id']);
            //所有状态的统计表
            $suitestatusmessage .= PrintTestsuiteTable($dailytest_id, $rowsuite['testsuite_id'], $rowsuite['testsuite']);
            $rowsuitestr .= " - " . $rowsuite['testsuite'];
        }
        $suiteresult->free();
        $messagetemp .= "<h3 style=font-family:arial;color:red>New Issues</h3>\n";
        $messagetemp .= $suitenewissueemessage;
        $messagetemp .= "<h3 style=font-family:arial;color:red>Remaining Issues</h3>\n";
        $messagetemp .= $suiteremainissuemessage;
        $messagetemp .= "<br/>\n";
        $messagetemp .= $suitefailmessage;
        $messagetemp .= "<h3 style=font-family:arial>Feature Status</h3>\n";
        $messagetemp .= $suitestatusmessage;
        $smoketest_imagedate = get_imageinfo_imagedate($imageinfo);
        if ($smoketest_imagedate) {
            $subject = "[Daily Smoke Test][" . stripslashes($product) . "][{$smoketest_imagedate}] " . $rowsuitestr;
        } else {
            $subject = "[Daily Smoke Test] - " . stripslashes($reportdate) . "_" . stripslashes($platform) . "_" . stripslashes($branch) . " _ " . stripslashes($product) . " " . $rowsuitestr;
        }
        Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $subject . "\n");
        $from = "{$testername}<{$testeremail}>";
        $headers = "Content-type:text/html; charset=utf-8\n";
        $headers .= "From:{$from}";
        //$to="*****@*****.**";
        $sendmailresult = mail($to, $subject, $message . $messagetemp, $headers);
        echo "SendTestsuiteMail:sendmailresult = {$sendmailresult}<br/>\n";
        echo "From = {$from}<br/>\n";
        echo "To = {$to}<br/>\n";
        Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $to . "\n");
        Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $from . "\n");
        $messagetemp = "";
        $suiteremainissuemessage = "";
        $suitenewissueemessage = "";
        $suitefailmessage = "";
        $suitestatusmessage = "";
        $rowsuitestr = "";
    }
    //end for()
    $departmentresult->free();
}
function PrintNoNoDetailandTable($platform, $branch, $testsuiteid, $testcasestateid, $date)
{
    #00**四种情况。platform和branch都是确定的。
    if ($date) {
        //如果填了日期
        $sql = "select testdate, st_tester.tester, testerdescription, email, imageinfo, boardno, hardware, note, newissue, remainissue, dailytest_id\n            from\n            st_dailytest,st_tester\n            where\n            platform = '{$platform}' and\n            branch = '{$branch}' and\n            testdate = '{$date}' and\n            st_tester.tester = st_dailytest.tester\n            limit 0,1";
    } else {
        //没有填写日期,就查找最新的
        $sql = "select testdate, st_tester.tester, testerdescription, email, imageinfo, boardno, hardware, note, newissue, remainissue, dailytest_id\n            from\n            st_dailytest,st_tester\n            where\n            platform = '{$platform}' and\n            branch = '{$branch}' and\n            st_tester.tester = st_dailytest.tester\n            order by testdate desc\n            limit 0,1";
    }
    $dailyresult = Dosql($sql);
    $num_daily = $dailyresult->num_rows;
    for ($i = 0; $i < $num_daily; $i++) {
        $row = $dailyresult->fetch_assoc();
        $dailytest_id = $row['dailytest_id'];
        $testdate = $row['testdate'];
        $imageinfo = $row['imageinfo'];
        $tester = $row['tester'];
        $testerdescription = $row['testerdescription'];
        $email = $row['email'];
        $boardno = $row['boardno'];
        $hardware = $row['hardware'];
        $note = $row['note'];
    }
    $dailyresult->free();
    echo "<h3 style=font-family:arial>{$platform} - {$branch} - {$product} - <font style=color:blue>" . get_imageinfo_imagedate($imageinfo) . "</font></h3>\n";
    echo "<h3 style=font-family:arial>Test Detail:</h3>\n";
    echo "<table class=\"altrowstable\" width=60%>\n";
    echo '<tr bgcolor="d2d2d2" align="center"><th colspan="2">Test Detail</th></tr>' . "\n";
    echo "<tr bgcolor=\"#ffffff\"><td width=\"15%\">Reportdate</td><td>" . htmlspecialchars(stripslashes($testdate)) . "</td></tr>\n";
    echo "<tr bgcolor=\"#ffffff\"><td>Imageinfo</td><td>" . htmlspecialchars(stripslashes($imageinfo)) . "</td></tr>\n";
    echo "<tr bgcolor=\"#ffffff\"><td>Tester</td><td><a href=\"mailto:" . $email . "\">" . htmlspecialchars(stripslashes($testerdescription)) . "</a>  {$email}</td></tr>\n";
    echo "<tr bgcolor=\"#ffffff\"><td>Boardno</td><td>" . htmlspecialchars(stripslashes($boardno)) . "</td></tr>\n";
    echo "<tr bgcolor=\"#ffffff\"><td>Hardware</td><td>" . htmlspecialchars(stripslashes($hardware)) . "</td></tr>\n";
    echo "<tr bgcolor=\"#ffffff\"><td>Note</td><td>" . htmlspecialchars(stripslashes($note)) . "</td></tr>\n";
    echo "</table>\n";
    PrintNewIssue($dailytest_id, $testsuiteid);
    PrintRemainIssue($dailytest_id, $testsuiteid);
    #分四种情况,11,10,01,00.
    if ($testsuiteid == -1) {
        if ($testcasestateid == -1) {
            #testsuite all. state all 11
            $sql = "select st_testsuite.testsuite_id as testsuite_id, st_testsuite.testsuite as testsuite\n                   from st_testsuite,st_stateresult,st_dailytest,st_testcase\n                where st_dailytest.dailytest_id=st_stateresult.dailytest_id and\n                st_stateresult.testcase_id=st_testcase.testcase_id and\n                st_testcase.testsuite_id=st_testsuite.testsuite_id and\n                st_testsuite.testsuite_online = '1' and\n                st_dailytest.dailytest_id='{$dailytest_id}'\n                group by st_testsuite.testsuite_id";
        } else {
            #testsuite all. state not all. 10
            $sql = "select st_testsuite.testsuite_id as testsuite_id, st_testsuite.testsuite as testsuite\n                   from st_testsuite,st_stateresult,st_dailytest,st_testcase\n                where st_dailytest.dailytest_id=st_stateresult.dailytest_id and\n                st_stateresult.testcase_id=st_testcase.testcase_id and\n                st_testcase.testsuite_id=st_testsuite.testsuite_id and\n                st_testsuite.testsuite_online = '1' and\n                st_dailytest.dailytest_id='{$dailytest_id}' and\n                st_stateresult.state_id = '{$testcasestateid}'\n                group by st_testsuite.testsuite_id";
        }
    } else {
        if ($testcasestateid == -1) {
            #testsuite not all. state all 01
            $sql = "select st_testsuite.testsuite_id as testsuite_id, st_testsuite.testsuite as testsuite\n                   from st_testsuite,st_stateresult,st_dailytest,st_testcase\n                where st_dailytest.dailytest_id=st_stateresult.dailytest_id and\n                st_stateresult.testcase_id=st_testcase.testcase_id and\n                st_testcase.testsuite_id=st_testsuite.testsuite_id and\n                st_testsuite.testsuite_online = '1' and\n                st_dailytest.dailytest_id='{$dailytest_id}' and\n                st_testsuite.testsuite_id = '{$testsuiteid}'\n                group by st_testsuite.testsuite_id";
        } else {
            #testsuite not all. state not all 00
            $sql = "select st_testsuite.testsuite_id as testsuite_id, st_testsuite.testsuite as testsuite\n                   from st_testsuite,st_stateresult,st_dailytest,st_testcase\n                where st_dailytest.dailytest_id=st_stateresult.dailytest_id and\n                st_stateresult.testcase_id=st_testcase.testcase_id and\n                st_testcase.testsuite_id=st_testsuite.testsuite_id and\n                st_testsuite.testsuite_online = '1' and\n                st_dailytest.dailytest_id='{$dailytest_id}' and\n                st_testsuite.testsuite_id = '{$testsuiteid}' and\n                st_stateresult.state_id = '{$testcasestateid}'\n                group by st_testsuite.testsuite_id";
        }
    }
    //end if()
    $testsuite = Dosql($sql);
    $num_suite = $testsuite->num_rows;
    for ($tables = 0; $tables < $num_suite; $tables++) {
        $row = $testsuite->fetch_assoc();
        PrintTestsuiteTable($dailytest_id, $row['testsuite_id'], $row['testsuite'], $testcasestateid);
    }
    $testsuite->free();
}