initial import of aus2 sanity tests

This commit is contained in:
mike.morgan%oregonstate.edu 2006-05-26 01:18:01 +00:00
Родитель 45ec9979b6
Коммит 9f89b2ddc0
84 изменённых файлов: 696 добавлений и 0 удалений

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<updates>
<update type="minor" version="1.4.1" extensionVersion="1.4.1" buildID="2005100606" >
<patch type="complete" URL="http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/1.5b2/update/complete/en-US/firefox-1.5b2.mac.mar" hashFunction="MD5" hashValue="18851d4672da119c1f77168f36031246" size="8775022"/>
<patch type="partial" URL="http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/1.5b2/update/partial/en-US/firefox-1.5b1-1.5b2.mac.mar" hashFunction="MD5" hashValue="1ec26f92ac972827082763ec1680602a" size="1112776"/>
</update>
</updates>

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<updates>
<update type="minor" version="1.4.1" extensionVersion="1.4.1" buildID="2005100604" >
<patch type="complete" URL="http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/1.5b2/update/complete/en-US/firefox-1.5b2.linux-i686.mar" hashFunction="SHA1" hashValue="57ce3fab1b25906a59d1962bdc4a3d56db5ca3e8" size="7948446"/>
<patch type="partial" URL="http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/1.5b2/update/partial/en-US/firefox-1.5b1-1.5b2.linux-i686.mar" hashFunction="SHA1" hashValue="f386ef102b7723f417ca7d250bd460321478ae21" size="781040"/>
</update>
</updates>

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<updates>
<update type="minor" version="1.4.1" extensionVersion="1.4.1" buildID="2005100614" >
<patch type="complete" URL="http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/1.5b2/update/complete/en-US/firefox-1.5b2.win32.mar" hashFunction="SHA1" hashValue="b7ed4485e991b2e19c5d57757ace4a5fd8311db9" size="6306511"/>
<patch type="partial" URL="http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/1.5b2/update/partial/en-US/firefox-1.5b1-1.5b2.win32.mar" hashFunction="SHA1" hashValue="e8c61fa7523a34cd8cb5b395e73f5c411ca1a941" size="801010"/>
</update>
</updates>

Просмотреть файл

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<updates>
</updates>

Просмотреть файл

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<updates>
</updates>

Просмотреть файл

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<updates>
</updates>

Просмотреть файл

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<updates>
</updates>

Просмотреть файл

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<updates>
</updates>

Просмотреть файл

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<updates>
</updates>

Просмотреть файл

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<updates>
</updates>

Просмотреть файл

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<updates>
</updates>

Просмотреть файл

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<updates>
</updates>

Просмотреть файл

@ -0,0 +1,241 @@
<?php
// ***** BEGIN LICENSE BLOCK *****
//
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is AUS.
//
// The Initial Developer of the Original Code is Mike Morgan.
//
// Portions created by the Initial Developer are Copyright (C) 2006
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
// Mike Morgan <morgamic@mozilla.com>
//
// Alternatively, the contents of this file may be used under the terms of
// either the GNU General Public License Version 2 or later (the "GPL"), or
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
// in which case the provisions of the GPL or the LGPL are applicable instead
// of those above. If you wish to allow use of your version of this file only
// under the terms of either the GPL or the LGPL, and not to allow others to
// use your version of this file under the terms of the MPL, indicate your
// decision by deleting the provisions above and replace them with the notice
// and other provisions required by the GPL or the LGPL. If you do not delete
// the provisions above, a recipient may use your version of this file under
// the terms of any one of the MPL, the GPL or the LGPL.
//
// ***** END LICENSE BLOCK *****
/**
* AUS sanity check intro page.
*
* @package aus
* @subpackage sanity
* @author Mike Morgan
*/
// Read .ini file for config options.
$config = parse_ini_file('./sanity.ini',true);
// Include common functions.
require_once('./sanity.inc.php');
/**
* Redirect to log or reports if they have been requested.
*/
if (!empty($_POST['redirect'])) {
$path = (isset($_POST['logs'])) ? './log/' : './reports/';
header('Location: '.$path.$_POST['redirect']);
exit;
}
/**
* Regenerate control files.
*/
if (!empty($_POST['control']) && !empty($_POST['controlName'])) {
// Set destination directory.
$dir = $config['sources']['controlFiles'].str_replace(' ','_',$_POST['controlName']);
// If this directory does not exist, create it.
if (!is_dir($dir)) {
mkdir($dir);
}
$msg = array('Added control files successfully...');
// For each test case, grab and store results.
foreach ($config['testCases'] as $name=>$url) {
$result = trim(file_get_contents($_POST['control'].$url));
$file = $dir.'/'.str_replace(' ','_',$name).'.xml';
write($file,$result);
$msg[] = $file;
}
}
/**
* Read log and reports directories.
*/
// Gather possible options for controls.
$controls_select = '';
$controls = ls($config['sources']['controlFiles'],'/^[^.].*/');
foreach ($controls as $dir) {
$controls_select .= '<option value="'.$dir.'">'.$dir.'</option>'."\n";
}
// Gather possible targets for select list.
$targets_select = '';
if (!empty($config['targets']) && is_array($config['targets'])) {
foreach ($config['targets'] as $name=>$val) {
$targets_select .= '<option value="'.$val.'">'.$name.'</option>';
}
}
// Log files from the log directory defined in our config.
$logs_select = '';
$logs = ls($config['sources']['log'],'/^.*log$/','asc');
foreach ($logs as $filename) {
$buf = explode('.',$filename);
$readable = timify($buf[0]);
$logs_select .= '<option value="'.$filename.'">'.$readable.'</option>'."\n";
}
// HTML Reports from the reports directory defined in our config.
$reports_select = '';
$reports = ls($config['sources']['reports'],'/^.*html$/','asc');
foreach ($reports as $filename) {
$buf = explode('.',$filename);
$readable = timify($buf[0],false);
$reports_select .= '<option value="'.$filename.'">'.$readable.'</option>'."\n";
}
/**
* Generate HTML.
*/
$html = '';
$html .= <<<HEADER
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>AUS Regression Tests :: mozilla.org</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="rating" content="General"/>
<meta name="robots" content="All"/>
<style type="text/css">
.control { display: block; float: left; width: 15em; }
.test { display: block; float: left; width: 8em; }
.msg { color: green; }
</style>
</head>
<body>
<h1>AUS Regression Testing</h1>
<p>All tests use the defined test cases in <kbd>sanity.ini</kbd>.</p>
HEADER;
// Messages, if any.
if (!empty($msg) && is_array($msg)) {
$html .= '<ul class="msg">'."\n";
foreach ($msg as $li) {
$html .= '<li>'.$li.'</li>'."\n";
}
$html .= '</ul>'."\n";
}
$html .= <<<PAGE
<h2>Run a New Test</h2>
<p>To begin a test, choose a <kbd>Control</kbd> and a <kbd>Target</kbd> then hit
<kbd>Begin Test</kbd>. You will be redirected to a static HTML report.</p>
<form action="./sanity.php" method="post">
<div>
<label for="testControl" class="test">Control</label>
<select name="testControl" id="testControl">
{$controls_select}
</select>
</div><br/>
<fieldset>
<legend>Target</legend>
<div>
<label for="testTarget" class="test">Defined Target</label>
<select name="testTarget" id="testTarget">
{$targets_select}
</select>
</div>
<p>-- OR --</p>
<div>
<label for="testTargetOverride" class="test">Custom Target</label>
<input type="text" name="testTargetOverride" id="testTargetOverride" value="" size="77"/>
</div>
<p><em>Note:</em> If a <kbd>Custom Target</kbd> is defined, it will override any selected <kbd>Defined Targets</kbd>.</p>
</fieldset><br/>
<div>
<input type="submit" name="submit" value="Begin Test &raquo;"/>
</div>
</form>
<h2>Generate New Control Files</h2>
<form action="./" method="post">
<div>
<label for="controlName" class="control">Name of control source</label>
<input type="text" name="controlName" id="controlName" value="{$config['defaults']['controlName']}" size="77"/>
<input type="hidden" name="action" value="control" />
</div><br/>
<div>
<label for="control" class="control">Location of control source</label>
<input type="text" name="control" id="control" value="{$config['defaults']['control']}" size="77"/>
</div><br/>
<div>
<input type="submit" name="submit" value="Generate New Control Files &raquo;"/>
</div>
</form>
<h2>Logs &amp; Reports</h2>
<form action="./" method="post">
<h3>Logs</h3>
<div>
<select name="redirect" id="logs">
{$logs_select}
</select>
<input type="submit" name="logs" value="View Log &raquo;"/>
</div>
</form>
<h3>Reports</h3>
<form action="./" method="post">
<div>
<select name="redirect" id="reports">
{$reports_select}
</select>
<input type="submit" name="reports" value="View Report &raquo;"/>
</div>
</form>
PAGE;
$html .= <<<FOOTER
</body>
</html>
FOOTER;
echo $html;
?>

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,106 @@
<?php
// ***** BEGIN LICENSE BLOCK *****
//
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is AUS.
//
// The Initial Developer of the Original Code is Mike Morgan.
//
// Portions created by the Initial Developer are Copyright (C) 2006
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
// Mike Morgan <morgamic@mozilla.com>
//
// Alternatively, the contents of this file may be used under the terms of
// either the GNU General Public License Version 2 or later (the "GPL"), or
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
// in which case the provisions of the GPL or the LGPL are applicable instead
// of those above. If you wish to allow use of your version of this file only
// under the terms of either the GPL or the LGPL, and not to allow others to
// use your version of this file under the terms of the MPL, indicate your
// decision by deleting the provisions above and replace them with the notice
// and other provisions required by the GPL or the LGPL. If you do not delete
// the provisions above, a recipient may use your version of this file under
// the terms of any one of the MPL, the GPL or the LGPL.
//
// ***** END LICENSE BLOCK *****
/**
* Common functions
*
* @package aus
* @subpackage sanity
*/
/**
* Read a directory and return a sorted array of its contents.
* @string $dir path to directory
* @string $pattern pattern matching valid filenames
* @return array
*/
function ls($dir,$pattern, $sort='desc') {
$files = array();
$fp = opendir($dir);
while (false !== ($filename = readdir($fp))) {
if (preg_match($pattern,$filename)) {
$files[] = $filename;
}
}
closedir($fp);
if ($sort=='asc') {
rsort($files);
} else {
sort($files);
}
return $files;
}
/**
* Write a string to a file.
* @string $file file
* @string $string string
*/
function write($file,$string) {
if ($fp = fopen($file,'w')) {
fwrite($fp,$string);
fclose($fp);
}
}
/**
* Get date.
* @param string $datestring
* @param boolean $fuzzy
* @return string
*/
function timify($datestring,$fuzzy=true) {
$year = substr($datestring,0,4);
$month = substr($datestring,4,2);
$day = substr($datestring,6,2);
if (!$fuzzy) {
$hour = substr($datestring,8,2);
$minute = substr($datestring,10,2);
$second = substr($datestring,12,2);
return date( 'D F j, Y, g:i a', mktime($hour, $minute, $second, $month, $day, $year));
} else {
return date( 'D F j, Y', mktime(0, 0, 0, $month, $day, $year));
}
}
?>

Просмотреть файл

@ -0,0 +1,85 @@
; ***** BEGIN LICENSE BLOCK *****
;
; Version: MPL 1.1/GPL 2.0/LGPL 2.1
;
; The contents of this file are subject to the Mozilla Public License Version
; 1.1 (the "License"); you may not use this file except in compliance with
; the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS" basis,
; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
; for the specific language governing rights and limitations under the
; License.
;
; The Original Code is AUS.
;
; The Initial Developer of the Original Code is Mike Morgan.
;
; Portions created by the Initial Developer are Copyright (C) 2006
; the Initial Developer. All Rights Reserved.
;
; Contributor(s):
; Mike Morgan <morgamic@mozilla.com>
;
; Alternatively, the contents of this file may be used under the terms of
; either the GNU General Public License Version 2 or later (the "GPL"), or
; the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
; in which case the provisions of the GPL or the LGPL are applicable instead
; of those above. If you wish to allow use of your version of this file only
; under the terms of either the GPL or the LGPL, and not to allow others to
; use your version of this file under the terms of the MPL, indicate your
; decision by deleting the provisions above and replace them with the notice
; and other provisions required by the GPL or the LGPL. If you do not delete
; the provisions above, a recipient may use your version of this file under
; the terms of any one of the MPL, the GPL or the LGPL.
;
; ***** END LICENSE BLOCK *****
;
; This file defines test cases for AUS.
;
; Each test case is a URL. Examples:
; [testCases]
; FooBar = 1/Firefox/1.4/2005090806/Darwin_ppc-gcc3/en-US/beta/update.xml
; FOOTOO = 1/Firefox/1.4/2005090806/WINNT_x86-msvc/en-US/beta/update.xml
; Zoinks! = 1/Firefox/1.4/2005090805/Linux_x86-gcc3/en-US/beta/update.xml
;
; The test names lead the test script to look in [files]/testname.xml for the
; control source.
;
; NOTE: Test names with spaces will be written to files with '_'. Example:
; Foo Foo Test -> [files]/Foo_Foo_Test.xml
;
; The test script tests output between a control and a new version of AUS.
;
; By comparing output, we can test for regressions.
;
; Explanations for these test-case parameters can be found at:
; https://intranet.mozilla.org/AUS:Version2:Test_Cases
;
;
[defaults]
control = https://aus2.mozilla.org/update/
controlName = AUS2_Prod
target = https://aus2-staging.mozilla.org:8711/update/
[targets]
AUS2 Staging = https://aus2-staging.mozilla.org:8711/update/
AUS2 Dev = https://aus2-dev.mozilla.org:7777/update/
AUS2 Production = https://aus2.mozilla.org/update/
morgamic's Patch = "https://update-staging.mozilla.org/~morgamic/aus/update/"
[sources]
controlFiles = /home/morgamic/public_html/sanity/control/
reports = /home/morgamic/public_html/sanity/reports/
log = /home/morgamic/public_html/sanity/log/
[testCases]
Fx 1.5.0.3 Mac Univ = 1/Firefox/1.5.0.3/2006042618/Darwin_Universal-gcc3/en-US/releasetest/update.xml
Fx 3.0a1 Mac PPC 1-off = 1/Firefox/3.0a1/2006052405/Darwin_ppc-gcc3/en-US/nightly/update.xml
Fx 3.0a1 Win 1-off = 1/Firefox/3.0a1/2006052404/WINNT_x86-msvc/en-US/nightly/update.xml
Fx 3.0a1 Linux 1-off = 1/Firefox/3.0a1/2006052404/Linux_x86-gcc3/en-US/nightly/update.xml
Fx 3.0a1 Mac PPC 3-off = 1/Firefox/3.0a1/2006052204/Darwin_ppc-gcc3/en-US/nightly/update.xml
Fx 3.0a1 Win 3-off = 1/Firefox/3.0a1/2006052205/WINNT_x86-msvc/en-US/nightly/update.xml
Fx 3.0a1 Linux 3-off = 1/Firefox/3.0a1/2006052204/Linux_x86-gcc3/en-US/nightly/update.xml

Просмотреть файл

@ -0,0 +1,216 @@
<?php
// ***** BEGIN LICENSE BLOCK *****
//
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is AUS.
//
// The Initial Developer of the Original Code is Mike Morgan.
//
// Portions created by the Initial Developer are Copyright (C) 2006
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
// Mike Morgan <morgamic@mozilla.com>
//
// Alternatively, the contents of this file may be used under the terms of
// either the GNU General Public License Version 2 or later (the "GPL"), or
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
// in which case the provisions of the GPL or the LGPL are applicable instead
// of those above. If you wish to allow use of your version of this file only
// under the terms of either the GPL or the LGPL, and not to allow others to
// use your version of this file under the terms of the MPL, indicate your
// decision by deleting the provisions above and replace them with the notice
// and other provisions required by the GPL or the LGPL. If you do not delete
// the provisions above, a recipient may use your version of this file under
// the terms of any one of the MPL, the GPL or the LGPL.
//
// ***** END LICENSE BLOCK *****
/**
* AUS sanity check.
*
* @package aus
* @subpackage sanity
* @author Mike Morgan
*/
/**
* Process test cases and config file.
*/
$config = parse_ini_file('./sanity.ini',true);
// Variables.
$results = array(); // Results array.
$count = 1; // Test count.
$filename = date('YmdHis'); // Date-based filename for log and report file.
// For each test case, compare output and store results.
foreach ($config['testCases'] as $name=>$url) {
$time = date('r'); // Time of actual test.
$control = (!empty($_POST['testControl'])) ? $config['sources']['controlFiles'].$_POST['testControl'].'/'.str_replace(' ','_',$name).'.xml' : $config['sources']['controlFiles'].$config['defaults']['controlName'].'/'.str_replace(' ','_',$name).'.xml';
$target = (!empty($_POST['testTargetOverride'])) ? $_POST['testTargetOverride'].$url : ((!empty($_POST['testTarget'])) ? $_POST['testTarget'].$url : $config['defaults']['target'].$url);
$controlResult = trim(file_get_contents($control));
$targetResult = trim(file_get_contents($target));
// @TODO Would be nice to diff this instead.
// There is a PHP implementation of diff, might try that, time allowing:
// http://pear.php.net/package/Text_Diff
if ($controlResult == $targetResult) {
$result = 'OK';
} else {
$result = 'FAILED';
}
// Store results.
$results[] = array(
'count' => $count,
'name' => $name,
'result' => $result,
'controlResult' => $controlResult,
'controlURL' => $control,
'targetResult' => $targetResult,
'targetURL' => $target.$url,
'url' => $url,
'time' => $time
);
// If using the CLI, output to STDOUT.
if (empty($_SERVER['HTTP_HOST'])) {
if ($count == 1) {
echo 'AUS Regression Test Started '.date('YmdHis').' ...'."\n";
}
echo "{$count} {$name} {$time} {$result} {$url}\n";
}
$count++;
}
if (empty($_SERVER['HTTP_HOST'])) {
echo 'Test Completed. See ./log/'.date('Ymd').'.log for more information, or ./reports/'.date('YmdHis').'.html for an HTML report.'."\n\n";
}
/**
* Generate HTML for display/write.
*/
$html = '';
$html .= <<<HEADER
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>AUS Regression Tests :: mozilla.org</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="rating" content="General"/>
<meta name="robots" content="All"/>
<style type="text/css" media="all">
table { border: 1px solid #666; }
td { border: 1px solid #666; white-space: nowrap; }
td.xml { white-space: normal; }
th { font-weight: bold; background-color: #999; white-space: nowrap; }
.row1 { background-color: #ccc; }
.row2 { background-color: #eee; }
.OK { background-color: #9f9; }
.FAILED { background-color: #f99; }
</style>
</head>
<body>
<h1>Regression Test Results</h1>
HEADER;
$html .= <<<TABLETOP
<table>
<thead>
<tr>
<th>#</th>
<th nowrap="nowrap">Test Name</th>
<th nowrap="nowrap">Time</th>
<th nowrap="nowrap">Test Result</th>
<th nowrap="nowrap">Params</th>
<th nowrap="nowrap">Control ({$control})</th>
<th nowrap="nowrap">Result ({$target})</th>
</tr>
</thead>
<tbody>
TABLETOP;
foreach ($results as $row) {
$controlResultHTML = htmlentities($row['controlResult']);
$targetResultHTML = htmlentities($row['targetResult']);
$class = $row['count']%2;
$html .= <<<TABLEROW
<tr class="row{$class}">
<td>{$row['count']}</td>
<td>{$row['name']}</td>
<td>{$row['time']}</td>
<td class="{$row['result']}">{$row['result']}</td>
<td>{$row['url']}</td>
<td class="xml"><pre>{$controlResultHTML}</pre></td>
<td class="xml"><pre>{$targetResultHTML}</pre></td>
</tr>
TABLEROW;
}
$html .= <<<TABLEBOTTOM
</tbody>
</table>
TABLEBOTTOM;
$html .= <<<FOOTER
</body>
</html>
FOOTER;
// Write HTML report file.
$fp = fopen('./reports/'.$filename.'.html','w+');
fwrite($fp, $html);
fclose($fp);
/**
* Store all results to log file in ./log directory.
* Log filenames are date-based.
*/
$log = '';
foreach ($results as $row) {
$log .= <<<LINE
{$row['count']} {$row['name']} {$row['time']} {$row['result']} {$row['url']}
LINE;
}
// Write the log file.
// Log files will be written per-day.
$fp = fopen('./log/'.date('Ymd').'.log', 'a');
fwrite($fp, $log);
fclose($fp);
/**
* If the request is over HTTP, redirect to HTML report.
*/
if (!empty($_SERVER['HTTP_HOST']) && !empty($_POST['submit'])) {
header('Location: ./reports/'.$filename.'.html');
exit;
}
?>