cvs: php-gcov-web(SOC06) /cron CLIENT_README MASTER_README build_time.php compile_results.php config.php cron.php database.php graph.php readtags.php
system.php tags.inc template.php tests.php valgrind.php /cron/sql recommended.sql sample.sql tables.sql

From: Date: Mon, 21 Aug 2006 04:02:24 +0000
Subject: cvs: php-gcov-web(SOC06) /cron CLIENT_README MASTER_README build_time.php compile_results.php config.php cron.php database.php graph.php readtags.php
system.php tags.inc template.php tests.php valgrind.php /cron/sql recommended.sql sample.sql tables.sql
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-32205@lists.php.net to get a copy of this message
pronych Mon Aug 21 04:02:24 2006 UTC Added files: (Branch: SOC06) /php-gcov-web/cron CLIENT_README MASTER_README database.php /php-gcov-web/cron/sql recommended.sql sample.sql tables.sql Removed files: /php-gcov-web/cron readtags.php Modified files: /php-gcov-web/cron build_time.php compile_results.php config.php cron.php graph.php system.php tags.inc template.php tests.php valgrind.php Log: Cron scripts updated to support client or master instances by a single configuration change

http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/build_time.php?r1=1.1.2.3&r2=1.1.2.4&diff_format=u Index: php-gcov-web/cron/build_time.php diff -u php-gcov-web/cron/build_time.php:1.1.2.3 php-gcov-web/cron/build_time.php:1.1.2.4 --- php-gcov-web/cron/build_time.php:1.1.2.3 Fri Aug 11 23:59:36 2006 +++ php-gcov-web/cron/build_time.php Mon Aug 21 04:02:24 2006 @@ -7,26 +7,26 @@ // Grab the build time preg_match('/Time taken[ ]*:[ ]* ([0-9]+) seconds/', $content, $matches); -if(is_array($matches)) +if((is_array($matches)) && (is_numeric($matches[1]))) { //echo $matches[1]."\n"; $build_time = $matches[1]; } else { - // This setting will apply when the build time could not be calculated - // -1 may be a good choice since it could indicate an error in calc + // This setting will apply when the build time could not be located $build_time = -1; } // Grab the code coverage rate preg_match('/Overall coverage rate: .+ \((.+)%\)/', $content, $matches); -if(is_array($matches)) +if((is_array($matches)) && (is_numeric($matches[1]))) { $codecoverage_percent = $matches[1]; } else { // an error occurred in reading coverage rate + $codecoverage_percent = -1; } http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/compile_results.php?r1=1.1.2.3&r2=1.1.2.4&diff_format=u Index: php-gcov-web/cron/compile_results.php diff -u php-gcov-web/cron/compile_results.php:1.1.2.3 php-gcov-web/cron/compile_results.php:1.1.2.4 --- php-gcov-web/cron/compile_results.php:1.1.2.3 Fri Aug 11 23:59:36 2006 +++ php-gcov-web/cron/compile_results.php Mon Aug 21 04:02:24 2006 @@ -1,16 +1,6 @@ <?php -// todo: make alphabetical sorting on compile_errors.php - -// todo: START adding for specific compile_errors.php generation only -//$phpdir="/home/quadra23/temp/PHP_5_2"; -//$tmpdir="/home/quadra23/temp/tmp"; -////$outdir="/var/www/PHP_5_2err"; -//$outdir="/var/www/gcov/PHP_5_2/"; -//VALGRIND=valgrind -// todo: END adding for specific compile_errors.php generation only - -//$phpsrc .= '/'; +// Compile Results generation script if(!defined('CRON_PHP')) { @@ -25,127 +15,165 @@ $data = file_get_contents("$tmpdir/php_build.log"); - -// REGEX to fetch the gcc errors/warnings. tuned for gcc 3.4.x and 4.0.x -/* -$gcc_regex = '/^(.+): In function [`\'](\w+)\':\s+'. - '\1:(\d+):\s+(.+)'. - str_repeat('(?:\s+\1:(\d+):\s+(.+))?', 99). // nick hack to capture up to 100 errors in the same function - '/m'; -*/ - -$gcc_regex = '/^(.+): In function [`\'](\w+)\':\s+'. +// Check if build file was readable, and if not, notify the user +if($data === false) +{ + echo basename($_SERVER['PHP_SELF']).": it appears the build process has succeeded but the PHP build log file at $tmpdir/php_build.log could not be opened for processing. If the problem persists, you may want to check the permissions for the cron scripts in the temporary directory to ensure that the user that runs the cron scripts has at least read and write access for the directory $tmpdir and all files contained within this directory.\n"; +} +else +{ + // Regular expression to select the error and warning information + $gcc_regex = '/^(.+): In function [`\'](\w+)\':\s+'. '\1:(\d+): (error|warning):\s+(.+)'. str_repeat('(?:\s+\1:(\d+): (error|warning):\s+(.+))?', 99). '/m'; -preg_match_all($gcc_regex, $data, $data, PREG_SET_ORDER); + preg_match_all($gcc_regex, $data, $data, PREG_SET_ORDER); -$stats = array(); + $stats = array(); -foreach ($data as $error) -{ - - $file = $error[1]; + $index_write = ''; - // Remove the phpdir portion from the file path if it occurs - if(substr($file, 0, strlen($phpdir)) == $phpdir) - { - $filepath = substr($file, strlen($phpdir)); - } - else // todo; fix the need for the additional / in front + foreach ($data as $error) { - //$filepath = '/'.$file; - $file = '/'.$file; - } - - // If stats are not previously set for this file, initialize it to the default values - if(!isset($stats[$file])) - { - @$stats[$file][0] = 0; // number of file errros - @$stats[$file][1] = 0; // number of file warnings - @$stats[$file][2] = ''; // data to write - } - - - - $function = $error[2]; - $write = ''; + $file = $error[1]; - // increment +3 because of the addition of type - for ($i = 3; isset($error[$i]); $i += 3) { - $line = $error[$i]; - $type = $error[$i+1]; // added - $msg = $error[$i+2]; - - $write .= <<< HTML - <tr> - <td>$function</td> - <td><a href="http://lxr.php.net/source/php-src{$filepath}#{$line}">$line</a></td> - <td>$type: $msg</td> - </tr> -HTML; - if($type == 'error') + // Remove the phpdir portion from the file path if it occurs + if(substr($file, 0, strlen($phpdir)) == $phpdir) { - @$stats[$file][0] += 1; // number of file errros - $totalnumerrors++; - } - elseif($type == 'warning') - { - @$stats[$file][1] += 1; // number of file warnings - $totalnumwarnings++; + $filepath = substr($file, strlen($phpdir)); } else { + $file = '/'.$file; + } // End check for phpdir in file path + + // If stats are not previously set for this file, initialize it to the default values + if(!isset($stats[$file])) + { + @$stats[$file][0] = 0; // number of file errros + @$stats[$file][1] = 0; // number of file warnings + @$stats[$file][2] = ''; // data to write } + + $function = $error[2]; - $t = array(); - $t['file'] = $filepath; - $t['function'] = $function; - $t['line'] = $line; - $t['type'] = $type; - $t['msg'] = $msg; + $write = ''; - $xmlarray['compile_results'][] = $t; - } + // Start at 4th element + for ($i = 3; isset($error[$i]); $i += 3) + { + $line = $error[$i]; + $type = $error[$i+1]; // whether the type was an error or a warning + $msg = $error[$i+2]; + + $lxrpath = ''; + + // This section only applies to the master server + if($is_master) + { + if(substr($filepath, 0, 6) == '/Zend/') + { + $lxrpath = str_replace('/Zend/','/ZendEngine2/', $filepath); + $lxrpath = "http://lxr.php.net/source{$lxrpath}#{$line}"; + } + else + { + $lxrpath = "http://lxr.php.net/source/php-src{$filepath}#{$line}"; + } - @$stats[$file][2] .= $write; // data to write + $write .= <<< HTML + <tr> + <td>$function</td> + <td><a href="$lxrpath">$line</a></td> + <td>$type: $msg</td> + </tr> +HTML; + if($type == 'error') + { + @$stats[$file][0] += 1; // number of file errros + $totalnumerrors++; + } + elseif($type == 'warning') + { + @$stats[$file][1] += 1; // number of file warnings + $totalnumwarnings++; + } + else + { + } // End check for type + + } // End check if master server + else + { + $compile_result = array(); + $compile_result['file'] = $filepath; + $compile_result['function'] = $function; + $compile_result['line'] = $line; + $compile_result['type'] = $type; + $compile_result['msg'] = $msg; + + $xmlarray['compile_results'][] = $compile_result; + } // End check for client machine -} + } // End loop through the number of elements in a single result file -// now write the stuff -$fp = fopen("$outdir/compile_results.inc", 'w'); -//fwrite($fp, html_header('Compile errors/warnings')); + @$stats[$file][2] .= $write; // data to write -fwrite($fp, "<p>Number of Errors: {$totalnumerrors}<br />Number of Warnings: {$totalnumwarnings}<br />Total: ".($totalnumerrors+$totalnumwarnings)."</p>"); + } // End loop through the compile results -fwrite($fp, '<table border="1"><tr><td>File</td><td>Number of errors</td><td>Number of warnings</td></tr>'); + // Continue check for master server + if($is_master) + { + $total = $totalnumerrors+$totalnumwarnings; + $index_write .= <<< HTML -$phpdir_len = strlen($phpdir)+1; -$total = 0; +<p>Number of Errors: {$totalnumerrors}<br /> +Number of Warnings: {$totalnumwarnings}<br /> +Total: {$total}</p> -foreach ($stats as $file => $data) -{ +<table border="1"> +<tr> +<td>File</td> +<td>Number of errors</td> +<td>Number of warnings</td> +</tr> +HTML; - $hash = md5($file); // files have consistent start character - - //$short_file = substr($file, $phpdir_len); + $phpdir_len = strlen($phpdir)+1; + $total = 0; + } // End check for master server - // Compare first portion of file name to phpsrc - if(substr($file, 0, strlen($phpdir)) == $phpdir) + foreach ($stats as $file => $data) { - $short_file = substr($file, strlen($phpdir)); - } - else // If phpsrc does not occur, display full file name (todo: verify) - { - $short_file = $file; - } + $hash = md5($file); // files have consistent start character + + // Compare first portion of file name to phpsrc + if(substr($file, 0, strlen($phpdir)) == $phpdir) + { + $short_file = substr($file, strlen($phpdir)); + } + else // If phpsrc does not occur, display full file name (todo: verify) + { + $short_file = $file; + } - $total += $data[0]; - fwrite($fp, "<tr><td><a href='viewer.php?version=$version&func=compile_results&file=$hash'>$short_file</a></td><td>$data[0]</td><td>$data[1]</td></tr>\n"); + $total += $data[0]; + + if($is_master) + { + // Add content to the core compile results file + $index_write .= <<< HTML +<tr> +<td><a href="viewer.php?version=$version&func=compile_results&file=$hash">$short_file</a></td> +<td>$data[0]</td> +<td>$data[1]</td> +</tr> +HTML; - $write = <<< HTML + // Add content to the individual compile results file + $write = <<< HTML <table border="1"> <tr> <td>Function</td> @@ -154,16 +182,20 @@ </tr> HTML; - file_put_contents("$outdir/$hash.inc", - //html_header('Messages specific to "'. basename($file) . '"'). - //' $filename="'.$basename($file).'"; '. - '<?php $filename="'.basename($file).'"; ?>'. - $write. - $data[2]. - '</table>'. - html_footer()); -} + file_put_contents("$outdir/$hash.inc", + '<?php $filename="'.basename($file).'"; ?>'. + $write.$data[2].'</table>'.html_footer(false)); + } // End check for master server + + } // End loop through errors and warnings + + if($is_master) + { + file_put_contents("$outdir/compile_results.inc", + $index_write.'</table>'.html_footer(false)); + + } // End final check for master server + +} // End check if data could be read -fwrite($fp, '</table>'.html_footer()); -fclose($fp); ?> http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/config.php?r1=1.1.2.3&r2=1.1.2.4&diff_format=u Index: php-gcov-web/cron/config.php diff -u php-gcov-web/cron/config.php:1.1.2.3 php-gcov-web/cron/config.php:1.1.2.4 --- php-gcov-web/cron/config.php:1.1.2.3 Mon Aug 14 22:38:08 2006 +++ php-gcov-web/cron/config.php Mon Aug 21 04:02:24 2006 @@ -2,11 +2,11 @@ // Cron configuration file for the PHP scripts -// Todo: if possible integrate the website config to use this config for db // 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 +// Note: if is_master = false; a valid username and password is required +// to post the data to the central server $is_master = false; // Note: these options are specific to is_master = false @@ -26,29 +26,12 @@ $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( - PDO::ATTR_PERSISTENT => true - ); - - // 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; - } + // Include the required database connections + require_once 'database.php'; + } // End check if server is a master else { + // Any client configuration would be made here -} +} // End check if client instance http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/cron.php?r1=1.1.2.5&r2=1.1.2.6&diff_format=u Index: php-gcov-web/cron/cron.php diff -u php-gcov-web/cron/cron.php:1.1.2.5 php-gcov-web/cron/cron.php:1.1.2.6 --- php-gcov-web/cron/cron.php:1.1.2.5 Mon Aug 14 22:38:08 2006 +++ php-gcov-web/cron/cron.php Mon Aug 21 04:02:24 2006 @@ -44,26 +44,25 @@ // Load main configuration including database connection require $workdir.'/config.php'; -// Load templates +// Load templates used by the various components of the cron scripts require $workdir.'/template.php'; -//process stuff -require $workdir.'/compile_results.php'; // make compile errors/warnings file - +// Gathers the key system information require $workdir.'/system.php'; +// Processes the log file to find compile related errors and warnings +require $workdir.'/compile_results.php'; + // This section is required for either system configuration if($makestatus == 'pass') { - // todo: summarize what variables each page modifies - $data = file_get_contents("$tmpdir/php_test.log"); // If file could not be opened we should track the error if($data === false) { - echo "unable to open log"."\n"; + echo basename($_SERVER['PHP_SELF']).": it appears the build process has succeeded but the PHP test log file at $tmpdir/php_test.log could not be opened for processing. If the problem persists, you may want to check the permissions for the cron scripts in the temporary directory to ensure that the user that runs the cron scripts has at least read and write access for the directory $tmpdir and all files contained within this directory.\n"; } else { @@ -81,7 +80,10 @@ // Get the time it took to create the build require $workdir.'/build_time.php'; } -} +} // End check for pass make status for both client and server + +// This file can be used as a reference in the future for the build status +file_put_contents($tmpdir.DIRECTORY_SEPARATOR.'last_make_status.inc', $makestatus); // Start Master Only Section // if($is_master) @@ -100,15 +102,17 @@ $version_id = 0; } + // If version > 0 then we have a valid PHP version 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'); + + // This data is used mainly for the graph generation $stmt = null; - - $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) '; + $sql = 'INSERT INTO local_builds (build_id, version_id, build_date, build_datetime, build_numerrors, build_numwarnings, build_numfailures, build_numleaks, build_percent_code_coverage, build_os_info, build_compiler_info) '. + 'VALUES (NULL, :version_id, :build_date, :build_datetime, :build_numerrors, :build_numwarnings, :build_numfailures, :build_numleaks, :build_percent_code_coverage, :build_os_info, :build_compiler_info) '; $stmt = $mysqlconn->prepare($sql); $stmt->bindParam(':version_id', $version_id); @@ -118,67 +122,60 @@ $stmt->bindParam(':build_numwarnings', $totalnumwarnings); $stmt->bindParam(':build_numfailures', $totalnumfailures); $stmt->bindParam(':build_numleaks', $totalnumleaks); + $stmt->bindParam(':build_percent_code_coverage', $codecoverage_percent); $stmt->bindParam(':build_os_info', $osinfo); $stmt->bindParam(':build_compiler_info', $compilerinfo); - $stmt->bindParam(':build_linker_info', $linkerinfo); $stmt->execute(); + $stmt = null; + // Graphs will be generated and the database updated with the latest build information if($makestatus == 'pass') - { - - // todo:for weekly, if a Sunday, call graphs otherwise skip - if(date('D') == 'Sun') - { + { + //if(date('D') == 'Sun') + //{ + $graph_mode = 'weekly'; + require $workdir.'/graph.php'; + //} + + //if(date('d') == 1) + //{ + $graph_mode = 'monthly'; require $workdir.'/graph.php'; - } + //} // Do SQL updates for the specific PHP version + $sql = 'UPDATE versions SET version_last_build_time=?, version_last_attempted_build_date=?, version_last_successful_build_date=? WHERE version_id=?'; - $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); - } + } // End check makestatus was a pass 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); - } + + } // End check makestatus failed $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"; - + echo 'Version Build Time: '.$build_time."\n"; + echo 'Version Code Coverage: '.$codecoverage_percent.'%'."\n"; + + // Only the master server should have the last make status outputted to the outdir 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 { - // Start Slave Only Section // - - // 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 + // Start Client Only Section // + // At this point the client system would start generating the XML for transmission $xml_out = '<?xml version="1.0" encoding="UTF-8"?>'; $xml_out .= <<< XML @@ -198,10 +195,7 @@ <builddata> XML; - $xml_search_for = array($phpdir); - $xml_replace_with = array(''); - - // Ensure the section actually exists before appending to the XML + // Ensure compile results have been added to the array before adding to the XML file if(isset($xmlarray['compile_results'])) { $xml_out .= <<< XML @@ -214,14 +208,15 @@ <message file="$res[file]" function="$res[function]" line="$res[line]" type="$res[type]">$res[msg]</message> XML; - } + } // End loop for the compile results array - $xml_out .= <<< XML + $xml_out .= <<< XML </compile_results> XML; + } // End check for compile results definition - // todo: output failure and pass type (i.e. native or unicode) + // Ensure tests have been added to the array before adding to the XML file if(isset($xmlarray['tests'])) { $xml_out .= <<< XML @@ -230,6 +225,7 @@ foreach($xmlarray['tests'] as $test) { + // todo: should title be included for passed tests? $xml_out .= <<< XML <test status="$test[status]" file="$test[file]" type="$test[testtype]"> XML; @@ -237,22 +233,27 @@ // Since more info is available for failed tests if(strtolower($test['status']) == 'fail') { + $title = htmlspecialchars($test['title']); + $script = htmlspecialchars($test['script']); $diff = base64_encode($test['difference']); $exp = base64_encode($test['expected']); $out = base64_encode($test['output']); + // Include the content specific to a test failure to the XML section $xml_out .= <<< XML +<title>$title</title> +<script><![CDATA[$script]]></script> <difference>$diff</difference> <expected>$exp</expected> <output>$out</output> XML; - } + } // End additional output for failed tests $xml_out .= <<< XML </test> XML; - } + } // End loop for the tests array $xml_out .= <<< XML </tests> @@ -260,50 +261,31 @@ } // End check for tests definition - // todo: output leak type (i.e. native or unicode) + // Ensure memory leaks have been added to the array before adding to the XML file if(isset($xmlarray['valgrind'])) { $xml_out .= <<< XML <valgrind> XML; - foreach($xmlarray['valgrind'] as $valgrind) + foreach($xmlarray['valgrind'] as $valgrind) { + $title = htmlspecialchars($valgrind['title']); + // Add leak information to the XML file $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[' - .$valgrind['report'] - .']]>' - .'</report>'."\n"; - - $xml_out .= <<< XML +<title>$title</title> +<script><![CDATA[{$valgrind[script]}]]></script> +<report><![CDATA[{$valgrind[report]}]]></report> </leak> XML; - } + } // End loop through each valgrind memory leak $xml_out .= <<< XML </valgrind> XML; - } // End check for valgrind definition + } // End check for valgrind leaks definition // End XML $xml_out .= <<< XML @@ -316,29 +298,13 @@ echo 'XML file written'."\n"; } - // 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); - - $contents = ob_get_clean(); - - file_put_contents($outdir.'/build.txt', $contents); - // Setup for data post to remote server $contents = bzcompress($xml_out); $contents = base64_encode($contents); - // todo: only for testing the size of file, actual decompression needs to be into a string - - file_put_contents($tmpdir.'/build.bz2', $contents); - // Set up the post data $postdata = array('username' => $server_submit_user, - 'password' => $server_submit_pass, + 'password' => md5($server_submit_pass), 'contents' => $contents ); @@ -356,10 +322,10 @@ ); if($result === false) - echo 'not posted'; + echo 'Not posted. Please try again in a few minutes, or check to verify the server address is correct.'; else - echo 'posted'; + echo "Results posted to server, the following is the server response.\n".$result; echo "\n"; -} +} // End of check for client instance ?> http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/graph.php?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-gcov-web/cron/graph.php diff -u php-gcov-web/cron/graph.php:1.1.2.1 php-gcov-web/cron/graph.php:1.1.2.2 --- php-gcov-web/cron/graph.php:1.1.2.1 Tue Aug 8 18:03:03 2006 +++ php-gcov-web/cron/graph.php Mon Aug 21 04:02:24 2006 @@ -1,136 +1,166 @@ <?php -include_once 'config.php'; +// File to generate graphs for a weekly or monthly basis -include_once 'lib/jpgraph/jpgraph.php'; +/* +Inportant Notes: -include_once 'lib/jpgraph/jpgraph_line.php'; +* For the sake of simplicity, the SQL selects the highest number of each of the four criteria with the limitation of one data point allowed per day. This also keeps the graph from becoming too messy with too many data points. -// todo: graph is only created if build occurs during multiple week days +* Graphs can only be generated for the period of time if at least more than one data point exist during that time frame. Otherwise an error would occur when starting the graph creation process. -// todo: a new week is determined if the current day of the week is Sunday +*/ -try -{ - $sql = 'SELECT build_date, max( build_numerrors ) , max( build_numwarnings ) , max( build_numfailures ) , max( build_numleaks ) FROM builds WHERE DATE_SUB( CURDATE( ) , INTERVAL 7 DAY ) <= build_date AND version_id=? GROUP BY build_date'; - $stmt = $mysqlconn->prepare($sql); - $stmt->execute(array($version_id)); -} -catch(PDOException $e) +if(!defined('CRON_PHP')) { - // if error occurs log, outptu and ensure the version_id is not legimate - //$version_id = 0; + echo basename($_SERVER['PHP_SELF']).': Sorry this file must be called by a cron script.'."\n"; + exit; } -// todo: - -$data_numrows = 0; - -$data_x = array(); - -//$data_y = array(); +include_once 'config.php'; -$data_y = array(); -$data_y['warnings'] = array(); // stores number of warnings -$data_y['errors'] = array(); // stores number of errors -$data_y['failures'] = array(); // stores number of test failures -$data_y['memleaks'] = array(); // stores nunber if memory leaks +include_once 'lib/jpgraph/jpgraph.php'; -//$data_x[] = '2006-07-26'; -//$data_y[] = 10; +include_once 'lib/jpgraph/jpgraph_line.php'; -$current_date = date('Y_m_d'); +/* +support for: +weekly ( 7 days ) +monthly ( 30 days ) +*/ -//$graph_array = array('errors','failures','memleaks','warnings'); +$days = 0; -$graph_array = array( - array('name' => 'errors', - 'title' => 'Compile Errors'), - array('name' => 'failures', - 'title' => 'Test Failures'), - array('name' => 'memleaks', - 'title' => 'Memory Leaks'), - array('name' => 'warnings', - 'title' => 'Compile Warnings') -); - -while($row = $stmt->fetch()) +if($graph_mode == 'monthly') { - list($build_date, $build_numerrors, $build_numwarnings, $build_numfailures, $build_numleaks) = $row; - - $data_x[] = substr($build_date,0,10); - //$data_x[] = '2006-07-27'; - $data_y['errors'][] = $build_numerrors; - $data_y['failures'][] = $build_numfailures; - $data_y['memleaks'][] = $build_numleaks; - $data_y['warnings'][] = $build_numwarnings; - - $data_numrows++; + $graph_mode_text = 'Month'; + $graph_days = 30; +} +else if($graph_mode == 'weekly') +{ + $graph_mode_text = 'Week'; + $graph_days = 7; } -if($data_numrows > 1) +// Make sure an acceptable graph mode is selected before continuing +if($graph_days > 0) { -// Create the graphs - foreach($graph_array as $curgraph) + + try + { + $sql = 'SELECT build_date, max( build_percent_code_coverage ) , max( build_numwarnings ) , max( build_numfailures ) , max( build_numleaks ) FROM local_builds WHERE DATE_SUB( CURDATE( ) , INTERVAL ? DAY ) <= build_date AND version_id=? GROUP BY build_date'; + $stmt = $mysqlconn->prepare($sql); + $stmt->execute(array($graph_days, $version_id)); + } + catch(PDOException $e) { - //echo $graph_single."\n"; + // if error occurs log, outptu and ensure the version_id is not legimate + //$version_id = 0; + } - $graph_filename = $outdir.DIRECTORY_SEPARATOR.'graphs'.DIRECTORY_SEPARATOR.$curgraph['name'].'_'.$current_date.'.png'; + $data_numrows = 0; - // Create the graph. These two calls are always required - $graph = new Graph(400,300,"auto"); + $data_x = array(); - $graph->img->SetMargin(40,40,40,40); - - $graph->SetScale("textlin"); - $graph->title->Set($curgraph['title'].' for Week Ending '.$current_date); + $data_y = array(); + $data_y['warnings'] = array(); // stores number of warnings + $data_y['codecoverage'] = array(); // stores number of errors + $data_y['failures'] = array(); // stores number of test failures + $data_y['memleaks'] = array(); // stores nunber if memory leaks + + $current_date = date('M d'); + + $graph_array = array( + array('name' => 'codecoverage', + 'title' => 'Code Coverage', + 'yformat' => 'percent'), + array('name' => 'failures', + 'title' => 'Test Failures', + 'yformat' => 'integer'), + array('name' => 'memleaks', + 'title' => 'Memory Leaks', + 'yformat' => 'integer'), + array('name' => 'warnings', + 'title' => 'Compile Warnings', + 'yformat' => 'integer') + ); - $graph->SetShadow(); + while($row = $stmt->fetch()) + { + list($build_date, $build_codecoverage, $build_numwarnings, $build_numfailures, $build_numleaks) = $row; - //$graph->yscale->SetGrace(10,10); + list($year, $month, $day) = explode('-', $build_date); - // Create the linear plot - $lineplot=new LinePlot($data_y[$curgraph['name']]); // resolves to the y data for the current element - $lineplot->SetColor('blue'); + $data_x[] = $day; - // Add the plot to the graph - $graph->Add($lineplot); - $graph->xaxis->SetTitle('Date'); - $graph->xaxis->SetTickLabels($data_x); - $graph->xaxis->SetTextTickInterval(1); + // Code Coverage less then 0 means could not be located + if($build_codecoverage >= 0) + $data_y['codecoverage'][] = $build_codecoverage; - $graph->yaxis->SetTitle('Number of '.$curgraph['title']); - //$graph->yaxis->SetTextTickInterval(10); + $data_y['failures'][] = $build_numfailures; + $data_y['memleaks'][] = $build_numleaks; + $data_y['warnings'][] = $build_numwarnings; + $data_numrows++; - //$graph->SetLegends($xdata); + } // Cycle through the results - // Output the graph to a file location - $graph->Stroke($graph_filename); + // Ensure more than one data row exist for the period of time + if($data_numrows > 1) + { + // Create the graphs + foreach($graph_array as $curgraph) + { + // Ensure individual graph has enough data to be drawn + if(count($data_y[$curgraph['name']]) > 1) + { + $graph_filename = $outdir.DIRECTORY_SEPARATOR.'graphs'.DIRECTORY_SEPARATOR.$curgraph['name'].'_'.$graph_mode.'.png'; - } -/* - $outfilename = $outdir.DIRECTORY_SEPARATOR.'graph.inc'; + // Create the graph. These two calls are always required + $graph = new Graph(400, 300, 'auto'); - // todo: possibly check that all 4 graphs were actually created - if(file_exists($outfilename)) - { - $contents = file_get_contents($outfilename); - } + $graph->img->SetMargin(40 ,40 ,40, 40); + + $graph->SetScale('textlin'); + $graph->title->Set($curgraph['title'].' for the ' + .$graph_mode_text. ' Ending '.$current_date); + + $graph->SetShadow(); + //$graph->yscale->SetGrace(10,10); + + // Create the linear plot on the Y axis + $lineplot= new LinePlot($data_y[$curgraph['name']]); + + $lineplot->SetColor('blue'); + + // Add the plot to the graph + $graph->Add($lineplot); + $graph->xaxis->SetTitle('Day'); + $graph->xaxis->SetTickLabels($data_x); + $graph->xaxis->SetTextTickInterval(1); + + if($curgraph['yformat'] == 'percent') + $graph->yaxis->SetTitle('Percentage of '.$curgraph['title']); + else // For now else assume integer + $graph->yaxis->SetTitle('Number of '.$curgraph['title']); + + // Output the graph to a file location + $graph->Stroke($graph_filename); + + } // End check for number of data points on the graph + else + echo "graph.php: graph of mode $curgraph[name] had an insufficient number of valid data points.\n"; + } // End looping each graph type + + echo "graph.php: completed this graph mode\n"; + } // End check that number of rows > 1 else { - $contents = ''; + //echo 'insufficient number of data rows'."\n"; + echo "graph.php: has insufficent data rows to make these graphs for $version_id \n"; } - - // Output the new contents at the top and add a new line - $contents = $current_date."\n".$contents; - file_put_contents($outfilename, $contents); - echo 'out file: '.$outfilename."\n"; -*/ - -} // End check that number of rows > 1 -/* +} else { - echo 'insufficient number of data rows'."\n"; -}*/ + echo "graph.php was not called with an acceptable mode\n"; +} http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/system.php?r1=1.1.2.3&r2=1.1.2.4&diff_format=u Index: php-gcov-web/cron/system.php diff -u php-gcov-web/cron/system.php:1.1.2.3 php-gcov-web/cron/system.php:1.1.2.4 --- php-gcov-web/cron/system.php:1.1.2.3 Mon Aug 14 22:38:08 2006 +++ php-gcov-web/cron/system.php Mon Aug 21 04:02:24 2006 @@ -1,32 +1,45 @@ <?php -$write = html_header('System Info'); +// File that generates the system.inc file +// This file gathers the essential information regarding the configuration for the build -// configure (linker?) -$write .= "<h2>Configure Used:</h2>\n"; +// For client the information is gathered here for use in the XML generation +// for server the information is gathered here and output to the system.inc file + +// Configure Section $config = file("$phpdir/config.nice"); $config = array_slice($config, 4); //remove inital comments $configureinfo = implode('', $config); -$write .= "<pre>".$configureinfo."</pre>\n"; -// Compiler -$write .= "<h2>Compiler Used:</h2>\n"; +// Compiler Section $compiler = explode("\n", `cc --version`); $compilerinfo = $compiler[0]; -$write .= '<p>'.$compilerinfo. "</p>\n"; -// OS -// todo:os info should work for Windows and other systems without uname -$write .= "<h2>Operating System:</h2>\n"; +// Operating System Section +// Todo: this section need to be revised for systems without the uname command $osinfo = `uname -srmi`; -$write .= '<p>'.$osinfo."</p>\n"; // Valgrind (calculated but not displayed) -$valgrind = explode("\n", `valgrind --version`); -$valgrindinfo = $valgrind[0]; - - -$write .= html_footer(); - -file_put_contents("$outdir/system.inc", $write); +// Todo: This section is diabled since it needs tweaking for Windows installations +//$valgrind = @explode("\n", `valgrind --version`); +//$valgrindinfo = $valgrind[0]; + +// If master server, updated system.inc in addition to gathering the information +if($is_master) +{ + $write = ''; + + $write .= "<h2>Configure Used:</h2>\n"; + $write .= "<pre>".$configureinfo."</pre>\n"; + + $write .= "<h2>Compiler Used:</h2>\n"; + $write .= '<p>'.$compilerinfo. "</p>\n"; + + $write .= "<h2>Operating System:</h2>\n"; + $write .= '<p>'.$osinfo."</p>\n"; + + file_put_contents("$outdir/system.inc", + $write + .html_footer(false)); +} ?> http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/tags.inc?r1=1.1.2.3&r2=1.1.2.4&diff_format=u Index: php-gcov-web/cron/tags.inc diff -u php-gcov-web/cron/tags.inc:1.1.2.3 php-gcov-web/cron/tags.inc:1.1.2.4 --- php-gcov-web/cron/tags.inc:1.1.2.3 Mon Aug 14 22:38:08 2006 +++ php-gcov-web/cron/tags.inc Mon Aug 21 04:02:24 2006 @@ -1,6 +1,6 @@ /home/quadra23/temp /var/local/gcov/www -PHP_4_4 -PHP_5_1 -PHP_5_2 -PHP_HEAD +PHP_4_4 +PHP_5_1 +PHP_5_2 +PHP_HEAD http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/template.php?r1=1.1.2.2&r2=1.1.2.3&diff_format=u Index: php-gcov-web/cron/template.php diff -u php-gcov-web/cron/template.php:1.1.2.2 php-gcov-web/cron/template.php:1.1.2.3 --- php-gcov-web/cron/template.php:1.1.2.2 Sun Aug 13 22:49:35 2006 +++ php-gcov-web/cron/template.php Mon Aug 21 04:02:24 2006 @@ -21,6 +21,7 @@ date_default_timezone_set('UTC'); $timestamp = time(); $date = date('r', $timestamp); + $current_time_zone = date_default_timezone_get(); return <<< HTML <?php @@ -44,7 +45,7 @@ ?> <p>&nbsp;</p> -<p align="center"><small>Generated at $date (<?php time_diff(); ?> ago)</small></p> +<p align="center"><small>Generated at $date $current_time_zone (<?php time_diff(); ?> ago)</small></p> <?php if(\$closehtml) { http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/tests.php?r1=1.1.2.5&r2=1.1.2.6&diff_format=u Index: php-gcov-web/cron/tests.php diff -u php-gcov-web/cron/tests.php:1.1.2.5 php-gcov-web/cron/tests.php:1.1.2.6 --- php-gcov-web/cron/tests.php:1.1.2.5 Mon Aug 14 22:38:08 2006 +++ php-gcov-web/cron/tests.php Mon Aug 21 04:02:24 2006 @@ -1,16 +1,22 @@ <?php - -// data: contains the contents of $tmpdir/php_test.log -// unicode: true if unicode is included +// Tests generation file if(!defined('CRON_PHP')) { - echo basename($_SERVER['PHP_SELF']).': Sorry this file must be called by a cron script.'."\n"; - exit; + echo basename($_SERVER['PHP_SELF']).': Sorry this file must be called by a cron script.'."\n"; + exit; } -// Ensure the write variable is empty before inserting content +require_once $workdir.'/template.php'; + +// data: contains the contents of $tmpdir/php_test.log +// unicode: true if unicode is included + +// Clear the variable that stores the output file for the core file +$index_write = ''; + +// Clear the variable that stores the output content for the individual files $write = ''; // Regular expression used to find a single failure @@ -22,109 +28,178 @@ // Grab all tests that match the tests regular expression preg_match_all($tests_re, $data, $tests, PREG_SET_ORDER); +// Clear old directory variable $old_dir = ''; // 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 { - $write .= <<< HTML + $index_write .= "<p>Congratulations! Currently there are no test failures!</p>\n"; +} +else +{ + // If there are leaks start the table + + $index_write .= <<< HTML <table border="1"> - <tr> - <td>File</td> - <td>Test Type</td> - <td>Name</td> - </tr> HTML; -} +} + +// Loop through each result foreach ($tests as $test) { $dir = dirname($test['file']); $file = basename($test['file']); - $status = $test['status']; // FAIL or PASS + + $status = strtolower($test['status']); // fail or pass + + $testtype = ''; // test type will be determined later + $title = $test['title']; - // Note: that the following period is preserved + // Note: that the following period is maintained $base = "$phpdir/".substr($test['file'],0,-4); - $newtest = array(); - $newtest['script'] = file_get_contents($base.'php') - or $newtest['script'] = 'Script contents not available.'; + $report_file = $base; - if((isset($test['testtype'])) - && (strtolower($test['testtype']) == 'u')) + if((isset($test['testtype'])) && (strtolower($test['testtype']) == 'u')) { - $newtest['testtype'] = 'Unicode'; - $base .= 'u.'; + $testtype = 'Unicode'; + $report_file .= 'u.'; } else { - $newtest['testtype'] = 'Native'; + $testtype = 'Native'; } + $report_file .= 'phpt'; + // 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'); + $hash = md5($report_file); - if(strtolower($status) == 'fail') + // Failed tests provide more content then passed tests + if($status == 'fail') { - $newtest['status'] = 'fail'; - $newtest['file'] = $test['file']; - $newtest['expected'] = file_get_contents($base.'exp') - or $newtest['expected'] = 'N\A'; - $newtest['output'] = file_get_contents($base.'out') - or $newtest['output'] = 'N\A'; - $newtest['difference'] = file_get_contents($base.'diff') - or $newtest['difference'] = 'N\A'; - } - else // status == 'PASS' - { - $newtest['status'] = 'pass'; - $newtest['file'] = $test['file']; - } + // These variables are only used for failed tests + $difference = file_get_contents($base.'diff') + or $difference = 'N\A'; + $expected = file_get_contents($base.'exp') + or $expected = 'N\A'; + $output = file_get_contents($base.'out') + or $output = 'N\A'; + $script = file_get_contents($base.'php') + or $script = 'Script contents not available.'; + + // Currently only used by master server but may also be useful here + $totalnumfailures += 1; - $xmlarray['tests'][] = $newtest; + // Ensure content is running on a master server before writing up with the output files + if($is_master) + { + if ($old_dir != $dir) + { + $old_dir = $dir; + + $index_write .= <<< HTML + <tr> +<td colspan="3" align="center"><b>$dir</b></td> +</tr> +<tr> +<td width="190">File</td> +<td width="80">Test Type</td> +<td width="*">Name</td> +</tr> +HTML; - // This loop writes the content for a failed test - if(strtolower($status) == 'fail') + } // End check for change of directory location + + $title_html = htmlspecialchars($title); + + $index_write .= <<< HTML +<tr> +<td> +<a href="viewer.php?version=$version&func=tests&file=$hash">$file</a></td> +<td>{$testtype}</td> +<td>{$title_html}</td> +</tr> +HTML; + + // Manipulate the data to work with HTML formatting + $script_html = highlight_string($script, true); + $expected_html = htmlspecialchars($expected); + $difference_html = htmlspecialchars(str_replace($phpdir,'',$difference)); + $output_html = htmlspecialchars(str_replace($phpdir,'',$output)); + + $write = <<< HTML + +<h2>Script</h2> +<pre>$script_html</pre> +<h2>Expected</h2> +<pre>$expected_html</pre> +<h2>Output</h2> +<pre>$output_html</pre> +<h2>Diff</h2> +<pre>$difference_html</pre> +HTML; + + // output the content for the individual test failure + file_put_contents("$outdir/$hash.inc", + '<?php $filename="'.htmlspecialchars(basename($file)).'"; ?>'."\n" + .$write. + html_footer(false) + ); + + } + else + { + // If not master server, add to output array + + $newtest = array(); + $newtest['difference'] = $difference; + $newtest['expected'] = $expected; + $newtest['file'] = $test['file']; + $newtest['output'] = $output; + $newtest['script'] = $script; + $newtest['status'] = $status; + $newtest['testtype'] = $testtype; + $newtest['title'] = $title; + + $xmlarray['tests'][] = $newtest; + } // End check for master server + + } // End check for loop through failed tests + else { + // So far passed tests are not used locally but are used for output - if ($old_dir != $dir) + if(!$is_master) { - $old_dir = $dir; - $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>{$newtest['testtype']}</td><td>$title</td></tr>\n"; - - $additional = - "<h2>Script</h2><pre>\n" - .highlight_string($newtest['script'], true) - ."\n</pre><h2>Expected</h2><pre>\n" - .htmlspecialchars($newtest['expected']) - ."\n</pre><h2>Output</h2><pre>\n" - .htmlspecialchars(str_replace($phpdir,'',$newtest['output'])) - ."\n</pre><h2>Diff</h2><pre>\n" - .htmlspecialchars(str_replace($phpdir,'',$newtest['difference']))."\n</pre>"; - - // now create the Page for the test - file_put_contents("$outdir/$hash.inc", - '<?php $filename="'.htmlspecialchars(basename($file)).'"; ?>'. - $additional. - html_footer() - ); + // test title might be useful for passed tests - $totalnumfailures += 1; - } -} + $newtest = array(); + $newtest['file'] = $test['file']; + $newtest['status'] = $status; + $newtest['testtype'] = $testtype; + + $xmlarray['tests'][] = $newtest; + + } // End check for not master server + + } // End loop through pass tests + +} // End loop through tests + +// Continue master server check for output of the core tests file +if($is_master) +{ + if ($totalnumfailures > 0) + $index_write .= "</table>\n"; -if ($totalnumfailures > 0) - $write .= "</table>\n"; + file_put_contents("$outdir/tests.inc", $index_write.html_footer(false)); -$write .= html_footer(false); +} // End check for master server for core tests file output -file_put_contents("$outdir/tests.inc", $write); ?> http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/valgrind.php?r1=1.1.2.5&r2=1.1.2.6&diff_format=u Index: php-gcov-web/cron/valgrind.php diff -u php-gcov-web/cron/valgrind.php:1.1.2.5 php-gcov-web/cron/valgrind.php:1.1.2.6 --- php-gcov-web/cron/valgrind.php:1.1.2.5 Sun Aug 13 22:49:35 2006 +++ php-gcov-web/cron/valgrind.php Mon Aug 21 04:02:24 2006 @@ -1,129 +1,175 @@ <?php +// File to process memory leaks detected by valgrind + if(!defined('CRON_PHP')) { echo basename($_SERVER['PHP_SELF']).': Sorry this file must be called by a cron script.'."\n"; exit; } +require_once $workdir.'/template.php'; + // 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'; +// Output for core file +$index_write = ''; +// Output for individual files +$write = ''; +// Regular expression to select leaks for both unicode and not $leak_re = '/LEAK(:(?P<testtype>[a-z|A-Z]))? (?P<title>.+) \[(?P<file>[^\]]+)\]/'; // Find memory leaks in the data preg_match_all($leak_re, $data, $leaks, PREG_SET_ORDER); +// Clear the old directory variable $old_dir = ''; // If there are no leaks just notify that no leaks occurred if (count($leaks) < 1) { - $write .= "<p>Congratulations! Currently no memory leaks were found!</p>\n"; + $index_write .= "<p>Congratulations! Currently no memory leaks were found!</p>\n"; } else { $totalnumleaks = count($leaks); - $write .= '<table border="1">'."\n"; -} + $index_write .= '<table border="1">'."\n"; +} // End check for number of leaks +// Loop through each result foreach ($leaks as $test) { $base = "$phpdir/".substr($test['file'],0,-4); - $file = basename($test['file']); + $dir = dirname($test['file']); + + $file = basename($test['file']); + + $hash = 'v' . md5($report_file); $report_file = ''; // Used internally to determine unicode or native filename - $t = array(); + $testtype = ''; + + $title = $test['title']; // If test mode is not unicode it is native if((isset($test['testtype'])) && (strtolower($test['testtype']) == 'u')) { - $t['testtype'] = 'Unicode'; + $testtype = 'Unicode'; + + // This ensure the hash for unicode differs from the native leak $report_file = $base.'u.mem'; } else { - $t['testtype'] = 'Native'; - $report_file = $base.'mem'; - } - - $title = $test['title']; - $dir = dirname($test['file']); + $testtype = 'Native'; - $hash = 'v' . md5($report_file); + $report_file = $base.'mem'; + } // End check for test type - if ($old_dir != $dir) + // Check if master server + if($is_master) { - $old_dir = $dir; - // todo: track if there are 2 or 3 columns - $write .= '<tr>'."\n".'<td colspan="3" align="center">' - ."<b>$dir</b></td>\n</tr>\n"; + if ($old_dir != $dir) + { + $old_dir = $dir; + + $index_write .= <<< HTML +<tr> +<td colspan="3" align="center"><b>$dir</b></td> +</tr> +<tr> +<td width="190">File</td> +<td width="100">Test Type</td> +<td width="*">Name</td> +</tr> +HTML; + + } // End check for directory change + + // Add the test to valgrind main page output + $index_write .= <<< HTML +<tr> +<td><a href="viewer.php?version=$phpver&func=valgrind&file=$hash">$file</a></td> +<td>$testtype</td> +<td>$title</td> +</tr> +HTML; - $write .= "<tr>\n<td>File</td>\n<td>Test Type</td>\n<td>Name</td>\n</tr>\n"; - } - - // todo: urlencode - $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"; + } // End check for master server - // todo: added str_replace to individual report output - - $script_php = highlight_file($base.'php', true); - $script_text = ''; + $script_text = file_get_contents($base.'php'); - if($script_php === false) + if($script_text === false) { - $script_php = 'Script contents were not available.'; $script_text = 'Script contents were not available.'; + $script_php = $script_text; } else { - $script_text = file_get_contents($base.'php') - or $script_text = 'Script contents were not available.'; - } + $script_php = highlight_string($script_text, true); + } // End check for ability to obtain the script file contents $report = file_get_contents($report_file); if($report === false) + { $report = 'Memory leak file contents were not available.'; + } else + { $report = str_replace($phpdir,'',$report); + } // End check for ability to obtain the contents of the mem file - $additional = - "<h2>Script</h2><pre>\n" .$script_php. - "\n</pre><h2>Report</h2><pre>\n".$report."\n</pre>"; - // .out replaced by .mem - // now create the test's page - file_put_contents("$outdir/$hash.inc", - //html_header("Valgrind Report: $file"). - '<?php $filename="'.basename($file).'"; ?>' - .$additional. - html_footer() - ); + if($is_master) + { + $write = <<< HTML +<h2>Script</h2> +<pre>$script_php</pre> +<h2>Report</h2> +<pre>$report</pre> +HTML; + + // Output content for the individual test page + file_put_contents("$outdir/$hash.inc", + '<?php $filename="'.basename($file).'"; ?>'."\n" + .$write. + html_footer(false) + ); - $t['file'] = $test['file']; - - $t['script'] = $script_text; - - $t['report'] = $report; - - $xmlarray['valgrind'][] = $t; -} + } + else + { + // If not master server, add the leak to the output array + + $newleak = array(); + $newleak['testtype'] = $testtype; + $newleak['title'] = $test['title']; + $newleak['file'] = $test['file']; + $newleak['script'] = $script_text; + $newleak['report'] = $report; + $xmlarray['valgrind'][] = $newleak; -if (count($leaks) > 0) + } // End check for master server + +} // End loop through each leak + +// End check for master server +if($is_master) { - $write .= "</table>\n"; -} + if (count($leaks) > 0) + { + $index_write .= "</table>\n"; + } -$write .= html_footer(); + file_put_contents("$outdir/valgrind.inc", + $index_write.html_footer(false)); -file_put_contents("$outdir/valgrind.inc", $write); +} // End check for master server ?> http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/database.php?view=markup&rev=1.1 Index: php-gcov-web/cron/database.php +++ php-gcov-web/cron/database.php http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/sql/recommended.sql?view=markup&rev=1.1 Index: php-gcov-web/cron/sql/recommended.sql +++ php-gcov-web/cron/sql/recommended.sql http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/sql/sample.sql?view=markup&rev=1.1 Index: php-gcov-web/cron/sql/sample.sql +++ php-gcov-web/cron/sql/sample.sql http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/sql/tables.sql?view=markup&rev=1.1 Index: php-gcov-web/cron/sql/tables.sql +++ php-gcov-web/cron/sql/tables.sql
« previous php.mirrors (#32205) next »