//
// 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 .= ''."\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 .= '';
}
}
// 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 .= ''."\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 .= ''."\n";
}
/**
* Generate HTML.
*/
$html = '';
$html .= <<AUS Regression Tests :: mozilla.org
AUS Regression Testing
All tests use the defined test cases in sanity.ini.
HEADER;
// Messages, if any.
if (!empty($msg) && is_array($msg)) {
$html .= '
'."\n";
foreach ($msg as $li) {
$html .= '
'.$li.'
'."\n";
}
$html .= '
'."\n";
}
$html .= <<Run a New Test
To begin a test, choose a Control and a Target then hit
Begin Test. You will be redirected to a static HTML report.