cvs: php-gcov-web(SOC06) /cron config.php cron.php mailer.php template.php tests.php valgrind.php
| From: | Daniel Pronych | Date: | Sun, 13 Aug 2006 22:49:35 +0000 |
| Subject: | cvs: php-gcov-web(SOC06) /cron config.php cron.php mailer.php template.php tests.php valgrind.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-32155@lists.php.net to get a copy of this message | ||
pronych Sun Aug 13 22:49:35 2006 UTC
Modified files: (Branch: SOC06)
/php-gcov-web/cron config.php cron.php mailer.php template.php
tests.php valgrind.php
Log:
Added server/client capability to cron.php, fixed unicode for test failures in addition to XML
updates
http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/config.php?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-gcov-web/cron/config.php diff -u php-gcov-web/cron/config.php:1.1.2.1 php-gcov-web/cron/config.php:1.1.2.2 --- php-gcov-web/cron/config.php:1.1.2.1 Fri Aug 11 23:59:36 2006 +++ php-gcov-web/cron/config.php Sun Aug 13 22:49:35 2006 @@ -2,36 +2,53 @@ // Cron configuration file for the PHP scripts - // Todo: if possible integrate the website config to use this config for db +// Todo: if possible integrate the website config to use this config for db -// PHP Mailer configuration settings -$mail_from_name = 'GCOV Admin'; -$mail_from_email = 'pronych@php.net'; +// If is_master = true; after build, stores the outcome locally +// If is_master = false; after build, sends data to remote server +// Note: if is_master = false; a valid user and pass is required +$is_master = true; + +// Note: these options are specific to is_master = false +$server_submit_url = 'http://gcov.aristotle.dlitz.net/post.php'; +$server_submit_user = 'johndoe'; +$server_submit_pass = 'john'; -$mail_smtp_mode = 'disabled'; -$mail_smtp_host = null; -$mail_smtp_port = null; -$mail_smtp_user = null; - -// Database configuration definitions -$dbuser = 'phpgcov'; -$dbpass = 'phpfi'; -$dsn = 'mysql:host=localhost;dbname=phpqagcov'; +// PHP Mailer configuration settings +if($is_master) +{ + // PHP Mailer configuration settings + $mail_from_name = 'GCOV Admin'; + $mail_from_email = 'some.address@example.com'; + + $mail_smtp_mode = 'disabled'; + $mail_smtp_host = null; + $mail_smtp_port = null; + $mail_smtp_user = null; + + // Database configuration definitions + $dbuser = 'phpgcov'; + $dbpass = 'phpfi'; + $dsn = 'mysql:host=localhost;dbname=phpqagcov'; -// Sets up a persistent connection to the database -$dsn_attr = array( + // Sets up a persistent connection to the database + $dsn_attr = array( PDO::ATTR_PERSISTENT => true - ); - + ); -// Try to perform a database connection, on failure exit -try + // Try to perform a database connection, on failure exit + try + { + $mysqlconn = new PDO($dsn, $dbuser, $dbpass, $dsn_attr); + } + catch(PDOException $e) + { + // On failure we might want to output to a log + //echo 'Error: '.$e->getMessage().'<br />'; + exit; + } +} // End check if server is a master +else { - $mysqlconn = new PDO($dsn, $dbuser, $dbpass, $dsn_attr); -} -catch(PDOException $e) -{ - // On failure we might want to output to a log - //echo 'Error: '.$e->getMessage().'<br />'; - exit; + } http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/cron.php?r1=1.1.2.3&r2=1.1.2.4&diff_format=u Index: php-gcov-web/cron/cron.php diff -u php-gcov-web/cron/cron.php:1.1.2.3 php-gcov-web/cron/cron.php:1.1.2.4 --- php-gcov-web/cron/cron.php:1.1.2.3 Fri Aug 11 23:59:36 2006 +++ php-gcov-web/cron/cron.php Sun Aug 13 22:49:35 2006 @@ -7,12 +7,13 @@ define('CRON_PHP',true); -$tmpdir = $argv[1]; -$outdir = $argv[2]; -$phpdir = $argv[3]; -$makestatus = $argv[4]; // make status from bash script (fail or pass) -$phpver = $argv[5]; -$workdir = dirname(__FILE__); +$tmpdir = $argv[1]; // Temporary storage directory for this PHP version +$outdir = $argv[2]; // Output directory for this PHP version (set, but only used in master) +$phpdir = $argv[3]; // Directory where the PHP build source files are located +$makestatus = $argv[4]; // Make status from bash script (fail or pass) +$phpver = $argv[5]; // The version identifier for this PHP build (i.e. PHP_4_4) + +$workdir = dirname(__FILE__); // Get the working directory to simplify php file includes // Initialize core variables $build_time = -1; // Total time required for build (build_time.php) @@ -29,7 +30,7 @@ $codecoverage_percent = -1; // Information regarding the code coverage -$version_id = 0; +$version_id = 0; // Start by assuming the version_id is unknown $xmlarray = array(); @@ -47,233 +48,297 @@ require $workdir.'/system.php'; -// Get version ID for current version - -try -{ - $sql = 'SELECT version_id FROM versions WHERE version_name = ?'; - $stmt = $mysqlconn->prepare($sql); - $stmt->execute(array($phpver)); - $version_id = $stmt->fetchColumn(); -} -catch(PDOException $e) -{ - // if error occurs log, output and ensure the version_id is not legimate - $version_id = 0; -} - -if($version_id > 0) +// This section is required for either system configuration +if($makestatus == 'pass') { - // Add new build to the build tables - $build_date = date('Y-m-d'); - $build_datetime = date('Y-m-d H-i-s'); - $stmt = null; + // todo: summarize what variables each page modifies - $sql = 'INSERT INTO builds (version_id, build_date, build_datetime, build_numerrors, build_numwarnings, build_numfailures, build_numleaks, build_os_info, build_compiler_info, build_linker_info) '. -'VALUES (:version_id, :build_date, :build_datetime, :build_numerrors, :build_numwarnings, :build_numfailures, :build_numleaks, :build_os_info, :build_compiler_info, :build_linker_info) '; - $stmt = $mysqlconn->prepare($sql); - $stmt->bindParam(':version_id', $version_id); - $stmt->bindParam(':build_date', $build_date); - $stmt->bindParam(':build_datetime', $build_datetime); - $stmt->bindParam(':build_numerrors', $totalnumerrors); - $stmt->bindParam(':build_numwarnings', $totalnumwarnings); - $stmt->bindParam(':build_numfailures', $totalnumfailures); - $stmt->bindParam(':build_numleaks', $totalnumleaks); - $stmt->bindParam(':build_os_info', $osinfo); - $stmt->bindParam(':build_compiler_info', $compilerinfo); - $stmt->bindParam(':build_linker_info', $linkerinfo); - $stmt->execute(); - $stmt = null; + $data = file_get_contents("$tmpdir/php_test.log"); - if($makestatus == 'pass') + // If file could not be opened we should track the error + if($data === false) { + echo "unable to open log"."\n"; + } + else + { + // Check for unicode (is this sufficient for PHP > 6?) + if(preg_match('/UNICODE[ ]*:[ ]*ON[ ]?/', $data)) + { + // Easy way to track that unicode is enabled + $unicode = true; + } // Run the PHP tests - require $workdir.'/tests.php'; - + require $workdir.'/tests.php'; // Run the valgrind code require $workdir.'/valgrind.php'; - // Get the time it took to create the build - require $workdir.'/build_time.php'; - - // todo: if a Sunday, call graphs otherwise skip - if(date('D') == 'Sun') - { - require $workdir.'/graph.php'; - } - - // Do SQL updates for the specific PHP version + require $workdir.'/build_time.php'; + } +} - $sql = 'UPDATE versions SET version_last_build_time = ?, version_last_attempted_build_date = ?, version_last_successful_build_date = ? WHERE version_id = ?'; - $stmt_arr = array($build_time, $build_datetime, $build_datetime, $version_id); +// Start Master Only Section // +if($is_master) +{ + // Get version ID for the current PHP version + try + { + $sql = 'SELECT version_id FROM versions WHERE version_name = ?'; + $stmt = $mysqlconn->prepare($sql); + $stmt->execute(array($phpver)); + $version_id = $stmt->fetchColumn(); } - else + catch(PDOException $e) { - // If build fails only update the last attempted build date for the version - $sql = 'UPDATE versions SET version_last_attempted_build_date = ? WHERE version_id = ?'; - $stmt_arr = array($build_datetime, $version_id); + // if error occurs this might be good to log + $version_id = 0; } - $stmt = $mysqlconn->prepare($sql); - $stmt->execute($stmt_arr); - // Update the existing version information - echo 'Build Time: '.$build_time."\n"; - echo 'Code Coverage: '.$codecoverage_percent.'%'."\n"; + if($version_id > 0) + { + // Add new build to the build tables + $build_date = date('Y-m-d'); + $build_datetime = date('Y-m-d H-i-s'); + $stmt = null; -} -else -{ - // we may not want to log this as the PHP version may have been made up -} + $sql = 'INSERT INTO builds (version_id, build_date, build_datetime, build_numerrors, build_numwarnings, build_numfailures, build_numleaks, build_os_info, build_compiler_info, build_linker_info) '. +'VALUES (:version_id, :build_date, :build_datetime, :build_numerrors, :build_numwarnings, :build_numfailures, :build_numleaks, :build_os_info, :build_compiler_info, :build_linker_info) '; + $stmt = $mysqlconn->prepare($sql); -file_put_contents($outdir.DIRECTORY_SEPARATOR.'last_make_status.inc', $makestatus); -#todo: if write fails we need to do something about it + $stmt->bindParam(':version_id', $version_id); + $stmt->bindParam(':build_date', $build_date); + $stmt->bindParam(':build_datetime', $build_datetime); + $stmt->bindParam(':build_numerrors', $totalnumerrors); + $stmt->bindParam(':build_numwarnings', $totalnumwarnings); + $stmt->bindParam(':build_numfailures', $totalnumfailures); + $stmt->bindParam(':build_numleaks', $totalnumleaks); + $stmt->bindParam(':build_os_info', $osinfo); + $stmt->bindParam(':build_compiler_info', $compilerinfo); + $stmt->bindParam(':build_linker_info', $linkerinfo); + $stmt->execute(); + $stmt = null; -// todo: start of XML output + if($makestatus == 'pass') + { + + // todo:for weekly, if a Sunday, call graphs otherwise skip + if(date('D') == 'Sun') + { + require $workdir.'/graph.php'; + } -//$xml_array = array('php_build.log','php_test.log'); + // Do SQL updates for the specific PHP version -// start test log -$contents = file_get_contents($tmpdir.'/php_test.log'); - -$search_for = array($phpdir, $tmpdir, 'quadra23'); -$replace_with = array('/'.$phpver,'/'.$phpver, 'user'); - -$contents = str_replace($search_for, $replace_with, $contents); -file_put_contents($outdir.'/php_test.log.txt', $contents); -// end test log - -$xml_out = '<?xml version="1.0" encoding="UTF-8"?>'."\n" - .'<build>'."\n" - .'<buildinfo>'."\n" - .'<username>johndoe'.'</username>'."\n" - .'<version>'.$phpver.'</version>'."\n" - .'<buildstatus>'.$makestatus.'</buildstatus>'."\n" - .'<buildtime>'.$build_time.'</buildtime>'."\n" - .'<codecoverage>'.$codecoverage_percent.'</codecoverage>'."\n" - .'<compiler>'.$compilerinfo.'</compiler>'."\n" - .'<linker>'.$linkerinfo.'</linker>'."\n" - .'<os>'.$osinfo.'</os>'."\n" - .'</buildinfo>'."\n" - .'<builddata>'."\n"; + $sql = 'UPDATE versions SET version_last_build_time = ?, version_last_attempted_build_date = ?, version_last_successful_build_date = ? WHERE version_id = ?'; + $stmt_arr = array($build_time, $build_datetime, $build_datetime, $version_id); + } + else + { + // If build fails only update the last attempted build date for the version + $sql = 'UPDATE versions SET version_last_attempted_build_date = ? WHERE version_id = ?'; + $stmt_arr = array($build_datetime, $version_id); + } -$xml_search_for = array($phpdir); -$xml_replace_with = array(''); + $stmt = $mysqlconn->prepare($sql); + $stmt->execute($stmt_arr); -if(isset($xmlarray['compile_results'])) + // Update the existing version information + echo 'Build Time: '.$build_time."\n"; + echo 'Code Coverage: '.$codecoverage_percent.'%'."\n"; + + file_put_contents($outdir.DIRECTORY_SEPARATOR.'last_make_status.inc', $makestatus); + #todo: if write fails we need to do something about it + + } // End check for version > 0 + + if(file_put_contents($tmpdir.'/build.xml', $xml_out)) + { + echo 'XML file written'."\n"; + } + +} // End Master Only Section +else { - $xml_out .= '<compile_results>'."\n"; + // Start Slave Only Section // - foreach($xmlarray['compile_results'] as $res) - { - $xml_out .= '<message file="'.$res['file'].'" ' - .'function="'.$res['function'].'" ' - .'line="'.$res['line'].'" ' - .'type="'.$res['type'].'">' - .$res['msg'].'</message>'."\n"; - } + // todo: recode XML creation so its easier to maintain + + // load in the test log + $contents = file_get_contents($tmpdir.'/php_test.log'); + + $search_for = array($phpdir, $tmpdir); + $replace_with = array('/'.$phpver,'/'.$phpver); + + $contents = str_replace($search_for, $replace_with, $contents); + file_put_contents($outdir.'/php_test.log.txt', $contents); + // end test log + + $xml_out = '<?xml version="1.0" encoding="UTF-8"?>'; - $xml_out .= '</compile_results>'."\n"; -} // End check for compile results + $xml_out .= <<< XML +<build> +<buildinfo> +<username>johndoe</username> +<version>$phpver</version> +<buildstatus>$makestatus</buildstatus> +<buildtime>$build_time</buildtime> +<codecoverage>$codecoverage_percent</codecoverage> +<compiler>$compilerinfo</compiler> +<linker>$linkerinfo</linker> +<os>$osinfo</os> +</buildinfo> +<builddata> +XML; -if(isset($xmlarray['tests'])) -{ - $xml_out .= '<tests>'."\n"; + $xml_search_for = array($phpdir); + $xml_replace_with = array(''); - foreach($xmlarray['tests'] as $test) + // Ensure the section actually exists before appending to the XML + if(isset($xmlarray['compile_results'])) { - $xml_out .= '<test status="'.$test['status'].'" ' - .'file="'.$test['file'].'">'; + $xml_out .= <<< XML +<compile_results> +XML; - // Since more info is available for failed tests - if(strtolower($test['status']) == 'fail') + foreach($xmlarray['compile_results'] as $res) { - $xml_out .= "\n" - .'<expected>' - .'<![CDATA[' - .$test['expected'] - .']]>' - .'</expected>'."\n" - .'<output>' - .'<![CDATA[' - .$test['output'] - .']]>' - .'</output>'."\n" - .'<difference>'."\n" - .'<![CDATA[' - .$test['difference'] - .']]>' - .'</difference>'; + $xml_out .= <<< XML + +<message file="$res[file]" function="$res[function]" line="$res[line]" type="$res[type]">$res[msg]</message> +XML; } + + $xml_out .= <<< XML +</compile_results> +XML; + } // End check for compile results definition - $xml_out .= '</test>'."\n"; - } + // todo: output failure and pass type (i.e. native or unicode) + if(isset($xmlarray['tests'])) + { + $xml_out .= <<< XML +<tests> +XML; - $xml_out .= '</tests>'."\n"; + foreach($xmlarray['tests'] as $test) + { + $xml_out .= <<< XML +<test status="$test[status]" file="$test[file]" type="$test[testtype]"> +XML; + + // Since more info is available for failed tests + if(strtolower($test['status']) == 'fail') + { + $diff = base64_encode($test['difference']); + $exp = base64_encode($test['expected']); + $out = base64_encode($test['output']); + + $xml_out .= <<< XML +<difference>$diff</difference> +<expected>$exp</expected> +<output>$out</output> +XML; + + } + + $xml_out .= <<< XML +</test> +XML; + } -} // End check for tests + $xml_out .= <<< XML +</tests> +XML; -if(isset($xmlarray['valgrind'])) -{ - $xml_out .= '<valgrind>'."\n"; + } // End check for tests definition - foreach($xmlarray['valgrind'] as $valgrind) + // todo: output leak type (i.e. native or unicode) + if(isset($xmlarray['valgrind'])) { - $xml_out .= '<leak file="' - .$valgrind['file'].'">'."\n" - .'<script>' - .'<![CDATA[' + $xml_out .= <<< XML +<valgrind> +XML; + + foreach($xmlarray['valgrind'] as $valgrind) + { + + $xml_out .= <<< XML +<leak file="$valgrind[file]" type="$valgrind[testtype]"> +XML; + +/* + $xml_out .= <<< XML +<leak file="$valgrind[file]" type="$valgrind[testtype]"> +<script><![CDATA[' . $valgrind[script] . ']]></script> +<report><![CDATA[' . $valgrind[report] . ']]></report> + +XML; +*/ + + $xml_out .= + '<script>' + .'<![CDATA[' .$valgrind['script'] - .']]>' - .'</script>'."\n" - .'<report>' - .'<![CDATA[' + .']]>' + .'</script>'."\n" + .'<report>' + .'<![CDATA[' .$valgrind['report'] - .']]>' - .'</report>'."\n" - .'</leak>'."\n"; - } + .']]>' + .'</report>'."\n"; - $xml_out .= '</valgrind>'."\n"; -} + $xml_out .= <<< XML +</leak> +XML; + } -$xml_out .= '</builddata>'."\n" - .'</build>'."\n"; + $xml_out .= <<< XML +</valgrind> +XML; + } // End check for valgrind definition + + // End XML + $xml_out .= <<< XML +</builddata> +</build> +XML; -if(file_put_contents($tmpdir.'/build.xml', $xml_out)) -{ - echo 'XML file written'."\n"; -} + if(file_put_contents($tmpdir.'/build.xml', $xml_out)) + { + echo 'XML file written'."\n"; + } + // todo: this file would be gzipped and then sent to server + file_put_contents($outdir.'/build.xml', $xml_out); -// todo: this file would be gzipped and then sent to server -file_put_contents($outdir.'/build.xml', $xml_out); + // Get the array for output (testing only) + ob_start(); + print_r($xmlarray); -// Get the array for output (testing only) -ob_start(); + $contents = ob_get_clean(); -print_r($xmlarray); + file_put_contents($outdir.'/build.txt', $contents); -$contents = ob_get_clean(); + // Setup for data post to remote server + $contents = bzcompress($xml_out); + $contents = base64_encode($contents); -file_put_contents($outdir.'/build.txt', $contents); + // todo: only for testing the size of file, actual decompression needs to be into a string -// Setup for data post to remote server -$contents = bzcompress($xml_out); -$contents = base64_encode($contents); + file_put_contents($tmpdir.'/build.bz2', $contents); -$postdata = array('username' => 'johndoe', - 'password' => 'abcd', - 'contents' => $contents + // Set up the post data + $postdata = array('username' => $server_submit_user, + 'password' => $server_submit_pass, + 'contents' => $contents ); -$uri = 'http://gcov.aristotle.dlitz.net/post.php'; -$result = file_get_contents($uri, false, + $result = file_get_contents($server_submit_url, false, stream_context_create( array('http' => array( @@ -285,11 +350,11 @@ ) ); -if($result === false) - echo 'not posted'; -else - echo 'posted'; -echo "\n"; + if($result === false) + echo 'not posted'; + else + echo 'posted'; + echo "\n"; +} -//require $workdir.'/make-index.php'; // make the index file ?> http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/mailer.php?r1=1.1.2.2&r2=1.1.2.3&diff_format=u Index: php-gcov-web/cron/mailer.php diff -u php-gcov-web/cron/mailer.php:1.1.2.2 php-gcov-web/cron/mailer.php:1.1.2.3 --- php-gcov-web/cron/mailer.php:1.1.2.2 Fri Aug 11 23:59:36 2006 +++ php-gcov-web/cron/mailer.php Sun Aug 13 22:49:35 2006 @@ -7,10 +7,7 @@ var $CharSet = 'iso-8859-1'; var $ContentType = 'text/html'; -/* - var $From = 'someaddress@example.com'; - var $FromName = 'Some Address'; -*/ + var $From = 'some.address@example.com'; var $FromName = 'Some Address'; @@ -24,18 +21,4 @@ var $WordWrap = 75; - function MyMailer() - { - // Handles SMTPAuth (if enabled) - if($SMTPAuth == true) - { - $Username = 'username'; - $Password = 'password'; - } - - $From = 'pronych@php.net'; - $FromName = 'Daniel Pronych'; - - } - } http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/template.php?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-gcov-web/cron/template.php diff -u php-gcov-web/cron/template.php:1.1.2.1 php-gcov-web/cron/template.php:1.1.2.2 --- php-gcov-web/cron/template.php:1.1.2.1 Sat Jul 8 19:25:37 2006 +++ php-gcov-web/cron/template.php Sun Aug 13 22:49:35 2006 @@ -1,48 +1,57 @@ -<?php - -function html_header($title = '') { - - $h1 = $title ? $title : 'PHP Q&A Server'; - return <<< HTML - -<html> -<head> -<title> :: PHP Q&A server :: $title</title> -</head> -<body> -<h1 align="center">$h1</h1> - -HTML; -} - - -function html_footer() { - - date_default_timezone_set('UTC'); - $timestamp = time(); - $date = date('r', $timestamp); - - return <<< HTML -<?php -function time_diff() { - date_default_timezone_set('UTC'); - \$diff = time() - $timestamp; - - if (\$diff < 60) { - echo "\$diff seconds"; - } elseif(\$diff < 3600) { - echo intval(\$diff/60) ." minutes"; - } else { - echo intval(\$diff/3600) ." hours"; - } -} -?> - -<p> </p> -<p align="center"><small>Generated at $date (<?php time_diff() ?> ago)</small></p> -</body> -</html> - -HTML; -} -?> \ No newline at end of file +<?php + +function html_header($title = '') { + + $h1 = $title ? $title : 'PHP Q&A Server'; + return <<< HTML + +<html> +<head> +<title> :: PHP Q&A server :: $title</title> +</head> +<body> +<h1 align="center">$h1</h1> + +HTML; +} + + +function html_footer($closehtml=true) +{ + date_default_timezone_set('UTC'); + $timestamp = time(); + $date = date('r', $timestamp); + + return <<< HTML +<?php + function time_diff() + { + date_default_timezone_set('UTC'); + \$diff = time() - $timestamp; + + if (\$diff < 60) + { + echo "\$diff seconds"; + } + elseif(\$diff < 3600) + { + echo intval(\$diff/60) ." minutes"; + } else + { + echo intval(\$diff/3600) ." hours"; + } + } +?> + +<p> </p> +<p align="center"><small>Generated at $date (<?php time_diff(); ?> ago)</small></p> + +<?php if(\$closehtml) +{ + echo '</body>'."\n".'</html>'."\n"; +} +?> + +HTML; +} +?> http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/tests.php?r1=1.1.2.3&r2=1.1.2.4&diff_format=u Index: php-gcov-web/cron/tests.php diff -u php-gcov-web/cron/tests.php:1.1.2.3 php-gcov-web/cron/tests.php:1.1.2.4 --- php-gcov-web/cron/tests.php:1.1.2.3 Fri Aug 11 23:59:36 2006 +++ php-gcov-web/cron/tests.php Sun Aug 13 22:49:35 2006 @@ -1,5 +1,9 @@ <?php + +// data: contains the contents of $tmpdir/php_test.log +// unicode: true if unicode is included + if(!defined('CRON_PHP')) { echo basename($_SERVER['PHP_SELF']).': Sorry this file must be called by a cron script.'."\n"; @@ -9,43 +13,63 @@ // Ensure the write variable is empty before inserting content $write = ''; -$data = file_get_contents("$tmpdir/php_test.log"); -//$write = html_header('Test Failures'); +// Regular expression used to find a single failure +$fail_re = '/FAIL(:(?P<testtype>[a-z|A-Z]))?/'; -// Grab the results according to failure or pass -preg_match_all('/(?P<status>FAIL|PASS) (?P<title>.+) \[(?P<file>[^\]]+)\]/', $data, $tests, PREG_SET_ORDER); +// Regular expression to find all tests with a pass or failure +$tests_re = '/(?P<status>FAIL|PASS)(:(?P<testtype>[a-z|A-Z]))? (?P<title>.+) \[(?P<file>[^\]]+)\]/'; -// todo: do a count instead of a bloated get all failures -preg_match_all('/FAIL (?P<title>.+) \[(?P<file>[^\]]+)\]/', $data, $failed, PREG_SET_ORDER); +// Grab all tests that match the tests regular expression +preg_match_all($tests_re, $data, $tests, PREG_SET_ORDER); $old_dir = ''; -if (count($failed) < 1) { + +// A single failure is enough to verify that a failure occurred +if (preg_match($fail_re, $data) < 1) +{ $write .= "<p>Congratulations! Currently there are no test failures!</p>\n"; } else { - $totalnumfailures = count($failed); - $write .= <<< HTML <table border="1"> <tr> <td>File</td> + <td>Test Type</td> <td>Name</td> </tr> HTML; } +foreach ($tests as $test) +{ -foreach ($tests as $test) { - + $dir = dirname($test['file']); $file = basename($test['file']); - $status = $test['status']; + $status = $test['status']; // FAIL or PASS $title = $test['title']; - $dir = dirname($test['file']); - $hash = md5($test['file']); + // Note: that the following period is preserved $base = "$phpdir/".substr($test['file'],0,-4); $t = array(); + $t['script'] = file_get_contents($base.'php') + or $t['script'] = 'Script contents not available.'; + + if((isset($test['testtype'])) + && (strtolower($test['testtype']) == 'u')) + { + $t['testtype'] = 'Unicode'; + $base .= 'u.'; + } + else + { + $t['testtype'] = 'Native'; + } + + // Note: the hash reflects the exact filename for native + // i.e. unicode would be file.u.phpt and native file.phpt + $hash = md5($base.'phpt'); + if(strtolower($status) == 'fail') { $t['status'] = 'fail'; @@ -72,31 +96,36 @@ if ($old_dir != $dir) { $old_dir = $dir; - $write .= "<tr><td colspan='2' align='center'><b>$dir</b></td></tr>\n"; + $write .= "<tr><td colspan='3' align='center'><b>$dir</b></td></tr>\n"; } - $write .= "<tr><td><a href='viewer.php?version=$version&func=tests&file=$hash'>$file</a></td><td>$title</td></tr>\n"; + $write .= "<tr><td><a href='viewer.php?version=$version&func=tests&file=$hash'>$file</a></td><td>{$t['testtype']}</td><td>$title</td></tr>\n"; - $additional = - "<h2>Script</h2><pre>\n" . highlight_file($base.'php', true). - "\n</pre><h2>Expected</h2><pre>\n" . htmlspecialchars(file_get_contents($base.'exp')). - "\n</pre><h2>Output</h2><pre>\n" .htmlspecialchars(str_replace($phpdir,'',file_get_contents($base.'out'))). - "\n</pre><h2>Diff</h2><pre>\n".htmlspecialchars(str_replace($phpdir,'',file_get_contents($base.'diff')))."\n</pre>"; - - // now create the test's page - file_put_contents("$outdir/$hash.inc", - //html_header("Test Failure: $file"). - '<?php $filename="'.htmlspecialchars(basename($file)).'"; ?>'. + $additional = + "<h2>Script</h2><pre>\n" + .highlight_string($t['script'], true) + ."\n</pre><h2>Expected</h2><pre>\n" + .htmlspecialchars($t['expected']) + ."\n</pre><h2>Output</h2><pre>\n" + .htmlspecialchars(str_replace($phpdir,'',$t['output'])) + ."\n</pre><h2>Diff</h2><pre>\n" + .htmlspecialchars(str_replace($phpdir,'',$t['difference']))."\n</pre>"; + + // now create the Page for the test + file_put_contents("$outdir/$hash.inc", + '<?php $filename="'.htmlspecialchars(basename($file)).'"; ?>'. $additional. html_footer() ); + + $totalnumfailures += 1; } } -if (count($failed)) +if ($totalnumfailures > 0) $write .= "</table>\n"; -$write .= html_footer(); +$write .= html_footer(false); file_put_contents("$outdir/tests.inc", $write); ?> http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/valgrind.php?r1=1.1.2.4&r2=1.1.2.5&diff_format=u Index: php-gcov-web/cron/valgrind.php diff -u php-gcov-web/cron/valgrind.php:1.1.2.4 php-gcov-web/cron/valgrind.php:1.1.2.5 --- php-gcov-web/cron/valgrind.php:1.1.2.4 Fri Aug 11 23:59:36 2006 +++ php-gcov-web/cron/valgrind.php Sun Aug 13 22:49:35 2006 @@ -6,29 +6,17 @@ exit; } -$unicode = false; // assume unicode is disabled +// data: contains the contents of $tmpdir/php_test.log +// unicode: true if unicode is included in the log files $write = ''; require_once $workdir.'/template.php'; -// ----------------- -// fix filename after the others are fixed -$data = file_get_contents("$tmpdir/php_test.log"); - -// Check if unicode testing is enabled (is this sufficient for PHP > 6?) -if(preg_match('/UNICODE[ ]*:[ ]*ON[ ]?/', $data)) -{ - // Easy way to track that unicode is enabled - $unicode = true; -} - -///LEAK(:(?P<testtype>[a-z|A-Z]))? (?P<title>.+) \[(?P<file>[^\]]+)\]/ - $leak_re = '/LEAK(:(?P<testtype>[a-z|A-Z]))? (?P<title>.+) \[(?P<file>[^\]]+)\]/'; -// Check for Leaks +// Find memory leaks in the data preg_match_all($leak_re, $data, $leaks, PREG_SET_ORDER); $old_dir = ''; @@ -58,18 +46,19 @@ // If test mode is not unicode it is native if((isset($test['testtype'])) && (strtolower($test['testtype']) == 'u')) { - $testtype = 'Unicode'; + $t['testtype'] = 'Unicode'; $report_file = $base.'u.mem'; } else { - $testtype = 'Native'; + $t['testtype'] = 'Native'; $report_file = $base.'mem'; } $title = $test['title']; $dir = dirname($test['file']); - $hash = 'v' . md5($test['file']); + + $hash = 'v' . md5($report_file); if ($old_dir != $dir) { @@ -82,12 +71,10 @@ } // todo: urlencode - $write .= "<tr><td><a href='viewer.php?version=$phpver&func=valgrind&file=$hash'>$file</a></td><td>$testtype</td><td>$title</td></tr>\n"; + $write .= "<tr><td><a href='viewer.php?version=$phpver&func=valgrind&file=$hash'>$file</a></td><td>{$t['testtype']}</td><td>$title</td></tr>\n"; // todo: added str_replace to individual report output - $base = "$phpdir/".substr($test['file'],0,-4); - $script_php = highlight_file($base.'php', true); $script_text = '';
http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/config.php?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-gcov-web/cron/config.php diff -u php-gcov-web/cron/config.php:1.1.2.1 php-gcov-web/cron/config.php:1.1.2.2 --- php-gcov-web/cron/config.php:1.1.2.1 Fri Aug 11 23:59:36 2006 +++ php-gcov-web/cron/config.php Sun Aug 13 22:49:35 2006 @@ -2,36 +2,53 @@ // Cron configuration file for the PHP scripts - // Todo: if possible integrate the website config to use this config for db +// Todo: if possible integrate the website config to use this config for db -// PHP Mailer configuration settings -$mail_from_name = 'GCOV Admin'; -$mail_from_email = 'pronych@php.net'; +// If is_master = true; after build, stores the outcome locally +// If is_master = false; after build, sends data to remote server +// Note: if is_master = false; a valid user and pass is required +$is_master = true; + +// Note: these options are specific to is_master = false +$server_submit_url = 'http://gcov.aristotle.dlitz.net/post.php'; +$server_submit_user = 'johndoe'; +$server_submit_pass = 'john'; -$mail_smtp_mode = 'disabled'; -$mail_smtp_host = null; -$mail_smtp_port = null; -$mail_smtp_user = null; - -// Database configuration definitions -$dbuser = 'phpgcov'; -$dbpass = 'phpfi'; -$dsn = 'mysql:host=localhost;dbname=phpqagcov'; +// PHP Mailer configuration settings +if($is_master) +{ + // PHP Mailer configuration settings + $mail_from_name = 'GCOV Admin'; + $mail_from_email = 'some.address@example.com'; + + $mail_smtp_mode = 'disabled'; + $mail_smtp_host = null; + $mail_smtp_port = null; + $mail_smtp_user = null; + + // Database configuration definitions + $dbuser = 'phpgcov'; + $dbpass = 'phpfi'; + $dsn = 'mysql:host=localhost;dbname=phpqagcov'; -// Sets up a persistent connection to the database -$dsn_attr = array( + // Sets up a persistent connection to the database + $dsn_attr = array( PDO::ATTR_PERSISTENT => true - ); - + ); -// Try to perform a database connection, on failure exit -try + // Try to perform a database connection, on failure exit + try + { + $mysqlconn = new PDO($dsn, $dbuser, $dbpass, $dsn_attr); + } + catch(PDOException $e) + { + // On failure we might want to output to a log + //echo 'Error: '.$e->getMessage().'<br />'; + exit; + } +} // End check if server is a master +else { - $mysqlconn = new PDO($dsn, $dbuser, $dbpass, $dsn_attr); -} -catch(PDOException $e) -{ - // On failure we might want to output to a log - //echo 'Error: '.$e->getMessage().'<br />'; - exit; + } http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/cron.php?r1=1.1.2.3&r2=1.1.2.4&diff_format=u Index: php-gcov-web/cron/cron.php diff -u php-gcov-web/cron/cron.php:1.1.2.3 php-gcov-web/cron/cron.php:1.1.2.4 --- php-gcov-web/cron/cron.php:1.1.2.3 Fri Aug 11 23:59:36 2006 +++ php-gcov-web/cron/cron.php Sun Aug 13 22:49:35 2006 @@ -7,12 +7,13 @@ define('CRON_PHP',true); -$tmpdir = $argv[1]; -$outdir = $argv[2]; -$phpdir = $argv[3]; -$makestatus = $argv[4]; // make status from bash script (fail or pass) -$phpver = $argv[5]; -$workdir = dirname(__FILE__); +$tmpdir = $argv[1]; // Temporary storage directory for this PHP version +$outdir = $argv[2]; // Output directory for this PHP version (set, but only used in master) +$phpdir = $argv[3]; // Directory where the PHP build source files are located +$makestatus = $argv[4]; // Make status from bash script (fail or pass) +$phpver = $argv[5]; // The version identifier for this PHP build (i.e. PHP_4_4) + +$workdir = dirname(__FILE__); // Get the working directory to simplify php file includes // Initialize core variables $build_time = -1; // Total time required for build (build_time.php) @@ -29,7 +30,7 @@ $codecoverage_percent = -1; // Information regarding the code coverage -$version_id = 0; +$version_id = 0; // Start by assuming the version_id is unknown $xmlarray = array(); @@ -47,233 +48,297 @@ require $workdir.'/system.php'; -// Get version ID for current version - -try -{ - $sql = 'SELECT version_id FROM versions WHERE version_name = ?'; - $stmt = $mysqlconn->prepare($sql); - $stmt->execute(array($phpver)); - $version_id = $stmt->fetchColumn(); -} -catch(PDOException $e) -{ - // if error occurs log, output and ensure the version_id is not legimate - $version_id = 0; -} - -if($version_id > 0) +// This section is required for either system configuration +if($makestatus == 'pass') { - // Add new build to the build tables - $build_date = date('Y-m-d'); - $build_datetime = date('Y-m-d H-i-s'); - $stmt = null; + // todo: summarize what variables each page modifies - $sql = 'INSERT INTO builds (version_id, build_date, build_datetime, build_numerrors, build_numwarnings, build_numfailures, build_numleaks, build_os_info, build_compiler_info, build_linker_info) '. -'VALUES (:version_id, :build_date, :build_datetime, :build_numerrors, :build_numwarnings, :build_numfailures, :build_numleaks, :build_os_info, :build_compiler_info, :build_linker_info) '; - $stmt = $mysqlconn->prepare($sql); - $stmt->bindParam(':version_id', $version_id); - $stmt->bindParam(':build_date', $build_date); - $stmt->bindParam(':build_datetime', $build_datetime); - $stmt->bindParam(':build_numerrors', $totalnumerrors); - $stmt->bindParam(':build_numwarnings', $totalnumwarnings); - $stmt->bindParam(':build_numfailures', $totalnumfailures); - $stmt->bindParam(':build_numleaks', $totalnumleaks); - $stmt->bindParam(':build_os_info', $osinfo); - $stmt->bindParam(':build_compiler_info', $compilerinfo); - $stmt->bindParam(':build_linker_info', $linkerinfo); - $stmt->execute(); - $stmt = null; + $data = file_get_contents("$tmpdir/php_test.log"); - if($makestatus == 'pass') + // If file could not be opened we should track the error + if($data === false) { + echo "unable to open log"."\n"; + } + else + { + // Check for unicode (is this sufficient for PHP > 6?) + if(preg_match('/UNICODE[ ]*:[ ]*ON[ ]?/', $data)) + { + // Easy way to track that unicode is enabled + $unicode = true; + } // Run the PHP tests - require $workdir.'/tests.php'; - + require $workdir.'/tests.php'; // Run the valgrind code require $workdir.'/valgrind.php'; - // Get the time it took to create the build - require $workdir.'/build_time.php'; - - // todo: if a Sunday, call graphs otherwise skip - if(date('D') == 'Sun') - { - require $workdir.'/graph.php'; - } - - // Do SQL updates for the specific PHP version + require $workdir.'/build_time.php'; + } +} - $sql = 'UPDATE versions SET version_last_build_time = ?, version_last_attempted_build_date = ?, version_last_successful_build_date = ? WHERE version_id = ?'; - $stmt_arr = array($build_time, $build_datetime, $build_datetime, $version_id); +// Start Master Only Section // +if($is_master) +{ + // Get version ID for the current PHP version + try + { + $sql = 'SELECT version_id FROM versions WHERE version_name = ?'; + $stmt = $mysqlconn->prepare($sql); + $stmt->execute(array($phpver)); + $version_id = $stmt->fetchColumn(); } - else + catch(PDOException $e) { - // If build fails only update the last attempted build date for the version - $sql = 'UPDATE versions SET version_last_attempted_build_date = ? WHERE version_id = ?'; - $stmt_arr = array($build_datetime, $version_id); + // if error occurs this might be good to log + $version_id = 0; } - $stmt = $mysqlconn->prepare($sql); - $stmt->execute($stmt_arr); - // Update the existing version information - echo 'Build Time: '.$build_time."\n"; - echo 'Code Coverage: '.$codecoverage_percent.'%'."\n"; + if($version_id > 0) + { + // Add new build to the build tables + $build_date = date('Y-m-d'); + $build_datetime = date('Y-m-d H-i-s'); + $stmt = null; -} -else -{ - // we may not want to log this as the PHP version may have been made up -} + $sql = 'INSERT INTO builds (version_id, build_date, build_datetime, build_numerrors, build_numwarnings, build_numfailures, build_numleaks, build_os_info, build_compiler_info, build_linker_info) '. +'VALUES (:version_id, :build_date, :build_datetime, :build_numerrors, :build_numwarnings, :build_numfailures, :build_numleaks, :build_os_info, :build_compiler_info, :build_linker_info) '; + $stmt = $mysqlconn->prepare($sql); -file_put_contents($outdir.DIRECTORY_SEPARATOR.'last_make_status.inc', $makestatus); -#todo: if write fails we need to do something about it + $stmt->bindParam(':version_id', $version_id); + $stmt->bindParam(':build_date', $build_date); + $stmt->bindParam(':build_datetime', $build_datetime); + $stmt->bindParam(':build_numerrors', $totalnumerrors); + $stmt->bindParam(':build_numwarnings', $totalnumwarnings); + $stmt->bindParam(':build_numfailures', $totalnumfailures); + $stmt->bindParam(':build_numleaks', $totalnumleaks); + $stmt->bindParam(':build_os_info', $osinfo); + $stmt->bindParam(':build_compiler_info', $compilerinfo); + $stmt->bindParam(':build_linker_info', $linkerinfo); + $stmt->execute(); + $stmt = null; -// todo: start of XML output + if($makestatus == 'pass') + { + + // todo:for weekly, if a Sunday, call graphs otherwise skip + if(date('D') == 'Sun') + { + require $workdir.'/graph.php'; + } -//$xml_array = array('php_build.log','php_test.log'); + // Do SQL updates for the specific PHP version -// start test log -$contents = file_get_contents($tmpdir.'/php_test.log'); - -$search_for = array($phpdir, $tmpdir, 'quadra23'); -$replace_with = array('/'.$phpver,'/'.$phpver, 'user'); - -$contents = str_replace($search_for, $replace_with, $contents); -file_put_contents($outdir.'/php_test.log.txt', $contents); -// end test log - -$xml_out = '<?xml version="1.0" encoding="UTF-8"?>'."\n" - .'<build>'."\n" - .'<buildinfo>'."\n" - .'<username>johndoe'.'</username>'."\n" - .'<version>'.$phpver.'</version>'."\n" - .'<buildstatus>'.$makestatus.'</buildstatus>'."\n" - .'<buildtime>'.$build_time.'</buildtime>'."\n" - .'<codecoverage>'.$codecoverage_percent.'</codecoverage>'."\n" - .'<compiler>'.$compilerinfo.'</compiler>'."\n" - .'<linker>'.$linkerinfo.'</linker>'."\n" - .'<os>'.$osinfo.'</os>'."\n" - .'</buildinfo>'."\n" - .'<builddata>'."\n"; + $sql = 'UPDATE versions SET version_last_build_time = ?, version_last_attempted_build_date = ?, version_last_successful_build_date = ? WHERE version_id = ?'; + $stmt_arr = array($build_time, $build_datetime, $build_datetime, $version_id); + } + else + { + // If build fails only update the last attempted build date for the version + $sql = 'UPDATE versions SET version_last_attempted_build_date = ? WHERE version_id = ?'; + $stmt_arr = array($build_datetime, $version_id); + } -$xml_search_for = array($phpdir); -$xml_replace_with = array(''); + $stmt = $mysqlconn->prepare($sql); + $stmt->execute($stmt_arr); -if(isset($xmlarray['compile_results'])) + // Update the existing version information + echo 'Build Time: '.$build_time."\n"; + echo 'Code Coverage: '.$codecoverage_percent.'%'."\n"; + + file_put_contents($outdir.DIRECTORY_SEPARATOR.'last_make_status.inc', $makestatus); + #todo: if write fails we need to do something about it + + } // End check for version > 0 + + if(file_put_contents($tmpdir.'/build.xml', $xml_out)) + { + echo 'XML file written'."\n"; + } + +} // End Master Only Section +else { - $xml_out .= '<compile_results>'."\n"; + // Start Slave Only Section // - foreach($xmlarray['compile_results'] as $res) - { - $xml_out .= '<message file="'.$res['file'].'" ' - .'function="'.$res['function'].'" ' - .'line="'.$res['line'].'" ' - .'type="'.$res['type'].'">' - .$res['msg'].'</message>'."\n"; - } + // todo: recode XML creation so its easier to maintain + + // load in the test log + $contents = file_get_contents($tmpdir.'/php_test.log'); + + $search_for = array($phpdir, $tmpdir); + $replace_with = array('/'.$phpver,'/'.$phpver); + + $contents = str_replace($search_for, $replace_with, $contents); + file_put_contents($outdir.'/php_test.log.txt', $contents); + // end test log + + $xml_out = '<?xml version="1.0" encoding="UTF-8"?>'; - $xml_out .= '</compile_results>'."\n"; -} // End check for compile results + $xml_out .= <<< XML +<build> +<buildinfo> +<username>johndoe</username> +<version>$phpver</version> +<buildstatus>$makestatus</buildstatus> +<buildtime>$build_time</buildtime> +<codecoverage>$codecoverage_percent</codecoverage> +<compiler>$compilerinfo</compiler> +<linker>$linkerinfo</linker> +<os>$osinfo</os> +</buildinfo> +<builddata> +XML; -if(isset($xmlarray['tests'])) -{ - $xml_out .= '<tests>'."\n"; + $xml_search_for = array($phpdir); + $xml_replace_with = array(''); - foreach($xmlarray['tests'] as $test) + // Ensure the section actually exists before appending to the XML + if(isset($xmlarray['compile_results'])) { - $xml_out .= '<test status="'.$test['status'].'" ' - .'file="'.$test['file'].'">'; + $xml_out .= <<< XML +<compile_results> +XML; - // Since more info is available for failed tests - if(strtolower($test['status']) == 'fail') + foreach($xmlarray['compile_results'] as $res) { - $xml_out .= "\n" - .'<expected>' - .'<![CDATA[' - .$test['expected'] - .']]>' - .'</expected>'."\n" - .'<output>' - .'<![CDATA[' - .$test['output'] - .']]>' - .'</output>'."\n" - .'<difference>'."\n" - .'<![CDATA[' - .$test['difference'] - .']]>' - .'</difference>'; + $xml_out .= <<< XML + +<message file="$res[file]" function="$res[function]" line="$res[line]" type="$res[type]">$res[msg]</message> +XML; } + + $xml_out .= <<< XML +</compile_results> +XML; + } // End check for compile results definition - $xml_out .= '</test>'."\n"; - } + // todo: output failure and pass type (i.e. native or unicode) + if(isset($xmlarray['tests'])) + { + $xml_out .= <<< XML +<tests> +XML; - $xml_out .= '</tests>'."\n"; + foreach($xmlarray['tests'] as $test) + { + $xml_out .= <<< XML +<test status="$test[status]" file="$test[file]" type="$test[testtype]"> +XML; + + // Since more info is available for failed tests + if(strtolower($test['status']) == 'fail') + { + $diff = base64_encode($test['difference']); + $exp = base64_encode($test['expected']); + $out = base64_encode($test['output']); + + $xml_out .= <<< XML +<difference>$diff</difference> +<expected>$exp</expected> +<output>$out</output> +XML; + + } + + $xml_out .= <<< XML +</test> +XML; + } -} // End check for tests + $xml_out .= <<< XML +</tests> +XML; -if(isset($xmlarray['valgrind'])) -{ - $xml_out .= '<valgrind>'."\n"; + } // End check for tests definition - foreach($xmlarray['valgrind'] as $valgrind) + // todo: output leak type (i.e. native or unicode) + if(isset($xmlarray['valgrind'])) { - $xml_out .= '<leak file="' - .$valgrind['file'].'">'."\n" - .'<script>' - .'<![CDATA[' + $xml_out .= <<< XML +<valgrind> +XML; + + foreach($xmlarray['valgrind'] as $valgrind) + { + + $xml_out .= <<< XML +<leak file="$valgrind[file]" type="$valgrind[testtype]"> +XML; + +/* + $xml_out .= <<< XML +<leak file="$valgrind[file]" type="$valgrind[testtype]"> +<script><![CDATA[' . $valgrind[script] . ']]></script> +<report><![CDATA[' . $valgrind[report] . ']]></report> + +XML; +*/ + + $xml_out .= + '<script>' + .'<![CDATA[' .$valgrind['script'] - .']]>' - .'</script>'."\n" - .'<report>' - .'<![CDATA[' + .']]>' + .'</script>'."\n" + .'<report>' + .'<![CDATA[' .$valgrind['report'] - .']]>' - .'</report>'."\n" - .'</leak>'."\n"; - } + .']]>' + .'</report>'."\n"; - $xml_out .= '</valgrind>'."\n"; -} + $xml_out .= <<< XML +</leak> +XML; + } -$xml_out .= '</builddata>'."\n" - .'</build>'."\n"; + $xml_out .= <<< XML +</valgrind> +XML; + } // End check for valgrind definition + + // End XML + $xml_out .= <<< XML +</builddata> +</build> +XML; -if(file_put_contents($tmpdir.'/build.xml', $xml_out)) -{ - echo 'XML file written'."\n"; -} + if(file_put_contents($tmpdir.'/build.xml', $xml_out)) + { + echo 'XML file written'."\n"; + } + // todo: this file would be gzipped and then sent to server + file_put_contents($outdir.'/build.xml', $xml_out); -// todo: this file would be gzipped and then sent to server -file_put_contents($outdir.'/build.xml', $xml_out); + // Get the array for output (testing only) + ob_start(); + print_r($xmlarray); -// Get the array for output (testing only) -ob_start(); + $contents = ob_get_clean(); -print_r($xmlarray); + file_put_contents($outdir.'/build.txt', $contents); -$contents = ob_get_clean(); + // Setup for data post to remote server + $contents = bzcompress($xml_out); + $contents = base64_encode($contents); -file_put_contents($outdir.'/build.txt', $contents); + // todo: only for testing the size of file, actual decompression needs to be into a string -// Setup for data post to remote server -$contents = bzcompress($xml_out); -$contents = base64_encode($contents); + file_put_contents($tmpdir.'/build.bz2', $contents); -$postdata = array('username' => 'johndoe', - 'password' => 'abcd', - 'contents' => $contents + // Set up the post data + $postdata = array('username' => $server_submit_user, + 'password' => $server_submit_pass, + 'contents' => $contents ); -$uri = 'http://gcov.aristotle.dlitz.net/post.php'; -$result = file_get_contents($uri, false, + $result = file_get_contents($server_submit_url, false, stream_context_create( array('http' => array( @@ -285,11 +350,11 @@ ) ); -if($result === false) - echo 'not posted'; -else - echo 'posted'; -echo "\n"; + if($result === false) + echo 'not posted'; + else + echo 'posted'; + echo "\n"; +} -//require $workdir.'/make-index.php'; // make the index file ?> http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/mailer.php?r1=1.1.2.2&r2=1.1.2.3&diff_format=u Index: php-gcov-web/cron/mailer.php diff -u php-gcov-web/cron/mailer.php:1.1.2.2 php-gcov-web/cron/mailer.php:1.1.2.3 --- php-gcov-web/cron/mailer.php:1.1.2.2 Fri Aug 11 23:59:36 2006 +++ php-gcov-web/cron/mailer.php Sun Aug 13 22:49:35 2006 @@ -7,10 +7,7 @@ var $CharSet = 'iso-8859-1'; var $ContentType = 'text/html'; -/* - var $From = 'someaddress@example.com'; - var $FromName = 'Some Address'; -*/ + var $From = 'some.address@example.com'; var $FromName = 'Some Address'; @@ -24,18 +21,4 @@ var $WordWrap = 75; - function MyMailer() - { - // Handles SMTPAuth (if enabled) - if($SMTPAuth == true) - { - $Username = 'username'; - $Password = 'password'; - } - - $From = 'pronych@php.net'; - $FromName = 'Daniel Pronych'; - - } - } http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/template.php?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-gcov-web/cron/template.php diff -u php-gcov-web/cron/template.php:1.1.2.1 php-gcov-web/cron/template.php:1.1.2.2 --- php-gcov-web/cron/template.php:1.1.2.1 Sat Jul 8 19:25:37 2006 +++ php-gcov-web/cron/template.php Sun Aug 13 22:49:35 2006 @@ -1,48 +1,57 @@ -<?php - -function html_header($title = '') { - - $h1 = $title ? $title : 'PHP Q&A Server'; - return <<< HTML - -<html> -<head> -<title> :: PHP Q&A server :: $title</title> -</head> -<body> -<h1 align="center">$h1</h1> - -HTML; -} - - -function html_footer() { - - date_default_timezone_set('UTC'); - $timestamp = time(); - $date = date('r', $timestamp); - - return <<< HTML -<?php -function time_diff() { - date_default_timezone_set('UTC'); - \$diff = time() - $timestamp; - - if (\$diff < 60) { - echo "\$diff seconds"; - } elseif(\$diff < 3600) { - echo intval(\$diff/60) ." minutes"; - } else { - echo intval(\$diff/3600) ." hours"; - } -} -?> - -<p> </p> -<p align="center"><small>Generated at $date (<?php time_diff() ?> ago)</small></p> -</body> -</html> - -HTML; -} -?> \ No newline at end of file +<?php + +function html_header($title = '') { + + $h1 = $title ? $title : 'PHP Q&A Server'; + return <<< HTML + +<html> +<head> +<title> :: PHP Q&A server :: $title</title> +</head> +<body> +<h1 align="center">$h1</h1> + +HTML; +} + + +function html_footer($closehtml=true) +{ + date_default_timezone_set('UTC'); + $timestamp = time(); + $date = date('r', $timestamp); + + return <<< HTML +<?php + function time_diff() + { + date_default_timezone_set('UTC'); + \$diff = time() - $timestamp; + + if (\$diff < 60) + { + echo "\$diff seconds"; + } + elseif(\$diff < 3600) + { + echo intval(\$diff/60) ." minutes"; + } else + { + echo intval(\$diff/3600) ." hours"; + } + } +?> + +<p> </p> +<p align="center"><small>Generated at $date (<?php time_diff(); ?> ago)</small></p> + +<?php if(\$closehtml) +{ + echo '</body>'."\n".'</html>'."\n"; +} +?> + +HTML; +} +?> http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/tests.php?r1=1.1.2.3&r2=1.1.2.4&diff_format=u Index: php-gcov-web/cron/tests.php diff -u php-gcov-web/cron/tests.php:1.1.2.3 php-gcov-web/cron/tests.php:1.1.2.4 --- php-gcov-web/cron/tests.php:1.1.2.3 Fri Aug 11 23:59:36 2006 +++ php-gcov-web/cron/tests.php Sun Aug 13 22:49:35 2006 @@ -1,5 +1,9 @@ <?php + +// data: contains the contents of $tmpdir/php_test.log +// unicode: true if unicode is included + if(!defined('CRON_PHP')) { echo basename($_SERVER['PHP_SELF']).': Sorry this file must be called by a cron script.'."\n"; @@ -9,43 +13,63 @@ // Ensure the write variable is empty before inserting content $write = ''; -$data = file_get_contents("$tmpdir/php_test.log"); -//$write = html_header('Test Failures'); +// Regular expression used to find a single failure +$fail_re = '/FAIL(:(?P<testtype>[a-z|A-Z]))?/'; -// Grab the results according to failure or pass -preg_match_all('/(?P<status>FAIL|PASS) (?P<title>.+) \[(?P<file>[^\]]+)\]/', $data, $tests, PREG_SET_ORDER); +// Regular expression to find all tests with a pass or failure +$tests_re = '/(?P<status>FAIL|PASS)(:(?P<testtype>[a-z|A-Z]))? (?P<title>.+) \[(?P<file>[^\]]+)\]/'; -// todo: do a count instead of a bloated get all failures -preg_match_all('/FAIL (?P<title>.+) \[(?P<file>[^\]]+)\]/', $data, $failed, PREG_SET_ORDER); +// Grab all tests that match the tests regular expression +preg_match_all($tests_re, $data, $tests, PREG_SET_ORDER); $old_dir = ''; -if (count($failed) < 1) { + +// A single failure is enough to verify that a failure occurred +if (preg_match($fail_re, $data) < 1) +{ $write .= "<p>Congratulations! Currently there are no test failures!</p>\n"; } else { - $totalnumfailures = count($failed); - $write .= <<< HTML <table border="1"> <tr> <td>File</td> + <td>Test Type</td> <td>Name</td> </tr> HTML; } +foreach ($tests as $test) +{ -foreach ($tests as $test) { - + $dir = dirname($test['file']); $file = basename($test['file']); - $status = $test['status']; + $status = $test['status']; // FAIL or PASS $title = $test['title']; - $dir = dirname($test['file']); - $hash = md5($test['file']); + // Note: that the following period is preserved $base = "$phpdir/".substr($test['file'],0,-4); $t = array(); + $t['script'] = file_get_contents($base.'php') + or $t['script'] = 'Script contents not available.'; + + if((isset($test['testtype'])) + && (strtolower($test['testtype']) == 'u')) + { + $t['testtype'] = 'Unicode'; + $base .= 'u.'; + } + else + { + $t['testtype'] = 'Native'; + } + + // Note: the hash reflects the exact filename for native + // i.e. unicode would be file.u.phpt and native file.phpt + $hash = md5($base.'phpt'); + if(strtolower($status) == 'fail') { $t['status'] = 'fail'; @@ -72,31 +96,36 @@ if ($old_dir != $dir) { $old_dir = $dir; - $write .= "<tr><td colspan='2' align='center'><b>$dir</b></td></tr>\n"; + $write .= "<tr><td colspan='3' align='center'><b>$dir</b></td></tr>\n"; } - $write .= "<tr><td><a href='viewer.php?version=$version&func=tests&file=$hash'>$file</a></td><td>$title</td></tr>\n"; + $write .= "<tr><td><a href='viewer.php?version=$version&func=tests&file=$hash'>$file</a></td><td>{$t['testtype']}</td><td>$title</td></tr>\n"; - $additional = - "<h2>Script</h2><pre>\n" . highlight_file($base.'php', true). - "\n</pre><h2>Expected</h2><pre>\n" . htmlspecialchars(file_get_contents($base.'exp')). - "\n</pre><h2>Output</h2><pre>\n" .htmlspecialchars(str_replace($phpdir,'',file_get_contents($base.'out'))). - "\n</pre><h2>Diff</h2><pre>\n".htmlspecialchars(str_replace($phpdir,'',file_get_contents($base.'diff')))."\n</pre>"; - - // now create the test's page - file_put_contents("$outdir/$hash.inc", - //html_header("Test Failure: $file"). - '<?php $filename="'.htmlspecialchars(basename($file)).'"; ?>'. + $additional = + "<h2>Script</h2><pre>\n" + .highlight_string($t['script'], true) + ."\n</pre><h2>Expected</h2><pre>\n" + .htmlspecialchars($t['expected']) + ."\n</pre><h2>Output</h2><pre>\n" + .htmlspecialchars(str_replace($phpdir,'',$t['output'])) + ."\n</pre><h2>Diff</h2><pre>\n" + .htmlspecialchars(str_replace($phpdir,'',$t['difference']))."\n</pre>"; + + // now create the Page for the test + file_put_contents("$outdir/$hash.inc", + '<?php $filename="'.htmlspecialchars(basename($file)).'"; ?>'. $additional. html_footer() ); + + $totalnumfailures += 1; } } -if (count($failed)) +if ($totalnumfailures > 0) $write .= "</table>\n"; -$write .= html_footer(); +$write .= html_footer(false); file_put_contents("$outdir/tests.inc", $write); ?> http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/valgrind.php?r1=1.1.2.4&r2=1.1.2.5&diff_format=u Index: php-gcov-web/cron/valgrind.php diff -u php-gcov-web/cron/valgrind.php:1.1.2.4 php-gcov-web/cron/valgrind.php:1.1.2.5 --- php-gcov-web/cron/valgrind.php:1.1.2.4 Fri Aug 11 23:59:36 2006 +++ php-gcov-web/cron/valgrind.php Sun Aug 13 22:49:35 2006 @@ -6,29 +6,17 @@ exit; } -$unicode = false; // assume unicode is disabled +// data: contains the contents of $tmpdir/php_test.log +// unicode: true if unicode is included in the log files $write = ''; require_once $workdir.'/template.php'; -// ----------------- -// fix filename after the others are fixed -$data = file_get_contents("$tmpdir/php_test.log"); - -// Check if unicode testing is enabled (is this sufficient for PHP > 6?) -if(preg_match('/UNICODE[ ]*:[ ]*ON[ ]?/', $data)) -{ - // Easy way to track that unicode is enabled - $unicode = true; -} - -///LEAK(:(?P<testtype>[a-z|A-Z]))? (?P<title>.+) \[(?P<file>[^\]]+)\]/ - $leak_re = '/LEAK(:(?P<testtype>[a-z|A-Z]))? (?P<title>.+) \[(?P<file>[^\]]+)\]/'; -// Check for Leaks +// Find memory leaks in the data preg_match_all($leak_re, $data, $leaks, PREG_SET_ORDER); $old_dir = ''; @@ -58,18 +46,19 @@ // If test mode is not unicode it is native if((isset($test['testtype'])) && (strtolower($test['testtype']) == 'u')) { - $testtype = 'Unicode'; + $t['testtype'] = 'Unicode'; $report_file = $base.'u.mem'; } else { - $testtype = 'Native'; + $t['testtype'] = 'Native'; $report_file = $base.'mem'; } $title = $test['title']; $dir = dirname($test['file']); - $hash = 'v' . md5($test['file']); + + $hash = 'v' . md5($report_file); if ($old_dir != $dir) { @@ -82,12 +71,10 @@ } // todo: urlencode - $write .= "<tr><td><a href='viewer.php?version=$phpver&func=valgrind&file=$hash'>$file</a></td><td>$testtype</td><td>$title</td></tr>\n"; + $write .= "<tr><td><a href='viewer.php?version=$phpver&func=valgrind&file=$hash'>$file</a></td><td>{$t['testtype']}</td><td>$title</td></tr>\n"; // todo: added str_replace to individual report output - $base = "$phpdir/".substr($test['file'],0,-4); - $script_php = highlight_file($base.'php', true); $script_text = '';