cvs: php-gcov-web(SOC06) /cron build_time.php compile_results.php config.php cron.php mailer.php post.php tests.php valgrind.php

From: Date: Fri, 11 Aug 2006 23:59:36 +0000
Subject: cvs: php-gcov-web(SOC06) /cron build_time.php compile_results.php config.php cron.php mailer.php post.php tests.php valgrind.php
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-32147@lists.php.net to get a copy of this message
pronych Fri Aug 11 23:59:36 2006 UTC Added files: (Branch: SOC06) /php-gcov-web/cron config.php post.php Modified files: /php-gcov-web/cron build_time.php compile_results.php cron.php mailer.php tests.php valgrind.php Log: Update including initial supportfor sending posts to GCOV server

http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/build_time.php?r1=1.1.2.2&r2=1.1.2.3&diff_format=u Index: php-gcov-web/cron/build_time.php diff -u php-gcov-web/cron/build_time.php:1.1.2.2 php-gcov-web/cron/build_time.php:1.1.2.3 --- php-gcov-web/cron/build_time.php:1.1.2.2 Tue Aug 8 18:03:03 2006 +++ php-gcov-web/cron/build_time.php Fri Aug 11 23:59:36 2006 @@ -4,17 +4,29 @@ $content = file_get_contents($tmpdir.DIRECTORY_SEPARATOR.'php_test.log'); -//$buildtime = preg_match('/Time taken[ ]? :[ ]?(\d*)[ ]?seconds/', $content); - +// Grab the build time preg_match('/Time taken[ ]*:[ ]* ([0-9]+) seconds/', $content, $matches); -//echo $buildtime.' seconds'."\n"; - -//print_r($matches); -//echo "\n"; - if(is_array($matches)) { //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 + $build_time = -1; +} + +// Grab the code coverage rate +preg_match('/Overall coverage rate: .+ \((.+)%\)/', $content, $matches); + +if(is_array($matches)) +{ + $codecoverage_percent = $matches[1]; +} +else +{ + // an error occurred in reading coverage rate +} http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/compile_results.php?r1=1.1.2.2&r2=1.1.2.3&diff_format=u Index: php-gcov-web/cron/compile_results.php diff -u php-gcov-web/cron/compile_results.php:1.1.2.2 php-gcov-web/cron/compile_results.php:1.1.2.3 --- php-gcov-web/cron/compile_results.php:1.1.2.2 Tue Aug 8 18:03:03 2006 +++ php-gcov-web/cron/compile_results.php Fri Aug 11 23:59:36 2006 @@ -14,7 +14,7 @@ if(!defined('CRON_PHP')) { - echo 'Sorry this file must be called by a cron script'."\n"; + echo basename($_SERVER['PHP_SELF']).': Sorry this file must be called by a cron script.'."\n"; exit; } http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/cron.php?r1=1.1.2.2&r2=1.1.2.3&diff_format=u Index: php-gcov-web/cron/cron.php diff -u php-gcov-web/cron/cron.php:1.1.2.2 php-gcov-web/cron/cron.php:1.1.2.3 --- php-gcov-web/cron/cron.php:1.1.2.2 Tue Aug 8 18:03:03 2006 +++ php-gcov-web/cron/cron.php Fri Aug 11 23:59:36 2006 @@ -1,6 +1,9 @@ <?php -if ($argc != 6) die("cron.php requires 5 arguments: [tmp] [out] [phpsrc] [makestatus] [phpversion]\n\n"); +if ($argc != 6) +{ + die("cron.php requires 5 arguments: [tmp] [out] [phpsrc] [makestatus] [phpversion]\n\n"); +} define('CRON_PHP',true); @@ -24,6 +27,8 @@ $compilerinfo = 'N/A'; // Information regarding compiler (system.php) $osinfo = 'N/A'; // Information regarding operating system (system.php) +$codecoverage_percent = -1; // Information regarding the code coverage + $version_id = 0; $xmlarray = array(); @@ -83,7 +88,14 @@ if($makestatus == 'pass') { + + // Run the PHP tests 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 @@ -108,7 +120,7 @@ // Update the existing version information echo 'Build Time: '.$build_time."\n"; - + echo 'Code Coverage: '.$codecoverage_percent.'%'."\n"; } else @@ -123,22 +135,15 @@ //$xml_array = array('php_build.log','php_test.log'); +// start test log +$contents = file_get_contents($tmpdir.'/php_test.log'); -// Parse valgrind output file -$valgrind_serialized = file_get_contents("$outdir/valgrind.txt") or $valgrind_serialized = null; +$search_for = array($phpdir, $tmpdir, 'quadra23'); +$replace_with = array('/'.$phpver,'/'.$phpver, 'user'); -if(!is_null($valgrind_serialized)) -{ - //$xml_array['valgrind'] = array(); - $xmlarray['valgrind'] = unserialize($valgrind_serialized); - - //$valgrind = unserialize($valgrind_serialized); - -} -else -{ - echo 'no valgrind to read'."\n"; -} +$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" @@ -146,6 +151,8 @@ .'<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" @@ -155,11 +162,9 @@ $xml_search_for = array($phpdir); $xml_replace_with = array(''); - if(isset($xmlarray['compile_results'])) { $xml_out .= '<compile_results>'."\n"; - //$xml_out .= '<files>'."\n"; foreach($xmlarray['compile_results'] as $res) { @@ -183,22 +188,27 @@ $xml_out .= '<test status="'.$test['status'].'" ' .'file="'.$test['file'].'">'; + // Since more info is available for failed tests if(strtolower($test['status']) == 'fail') { $xml_out .= "\n" .'<expected>' - .htmlspecialchars($test['expected']) + .'<![CDATA[' + .$test['expected'] + .']]>' .'</expected>'."\n" .'<output>' - .htmlspecialchars($test['output']) + .'<![CDATA[' + .$test['output'] + .']]>' .'</output>'."\n" .'<difference>'."\n" - .htmlspecialchars($test['difference']) + .'<![CDATA[' + .$test['difference'] + .']]>' .'</difference>'; } - else - { - } + $xml_out .= '</test>'."\n"; } @@ -206,28 +216,80 @@ } // End check for tests +if(isset($xmlarray['valgrind'])) +{ + $xml_out .= '<valgrind>'."\n"; + + foreach($xmlarray['valgrind'] as $valgrind) + { + $xml_out .= '<leak file="' + .$valgrind['file'].'">'."\n" + .'<script>' + .'<![CDATA[' + .$valgrind['script'] + .']]>' + .'</script>'."\n" + .'<report>' + .'<![CDATA[' + .$valgrind['report'] + .']]>' + .'</report>'."\n" + .'</leak>'."\n"; + } + + $xml_out .= '</valgrind>'."\n"; +} $xml_out .= '</builddata>'."\n" .'</build>'."\n"; -if(file_put_contents($tmpdir.'/build.new.xml', $xml_out)) +if(file_put_contents($tmpdir.'/build.xml', $xml_out)) { echo 'XML file written'."\n"; } -file_put_contents($outdir.'/build.new.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); $contents = ob_get_clean(); -file_put_contents($outdir.'/build.new.txt', $contents); +file_put_contents($outdir.'/build.txt', $contents); + +// Setup for data post to remote server +$contents = bzcompress($xml_out); +$contents = base64_encode($contents); + +$postdata = array('username' => 'johndoe', + 'password' => 'abcd', + 'contents' => $contents + ); + +$uri = 'http://gcov.aristotle.dlitz.net/post.php'; + +$result = file_get_contents($uri, false, + stream_context_create( + array('http' => + array( + 'method'=>'POST', + 'headers'=> 'Content-type: application/x-www-form-urlencoded', + 'content' => http_build_query($postdata) + ) + ) + ) + ); +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.1&r2=1.1.2.2&diff_format=u Index: php-gcov-web/cron/mailer.php diff -u php-gcov-web/cron/mailer.php:1.1.2.1 php-gcov-web/cron/mailer.php:1.1.2.2 --- php-gcov-web/cron/mailer.php:1.1.2.1 Tue Aug 8 18:03:03 2006 +++ php-gcov-web/cron/mailer.php Fri Aug 11 23:59:36 2006 @@ -7,9 +7,12 @@ 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'; var $Host = 'localhost'; @@ -21,11 +24,6 @@ var $WordWrap = 75; - function Subject($subject) - { - $this->Subject($subject); - } - function MyMailer() { // Handles SMTPAuth (if enabled) @@ -34,6 +32,10 @@ $Username = 'username'; $Password = 'password'; } + + $From = 'pronych@php.net'; + $FromName = 'Daniel Pronych'; + } } http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/tests.php?r1=1.1.2.2&r2=1.1.2.3&diff_format=u Index: php-gcov-web/cron/tests.php diff -u php-gcov-web/cron/tests.php:1.1.2.2 php-gcov-web/cron/tests.php:1.1.2.3 --- php-gcov-web/cron/tests.php:1.1.2.2 Tue Aug 8 18:03:04 2006 +++ php-gcov-web/cron/tests.php Fri Aug 11 23:59:36 2006 @@ -1,25 +1,20 @@ <?php +if(!defined('CRON_PHP')) +{ + 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 $write = ''; $data = file_get_contents("$tmpdir/php_test.log"); //$write = html_header('Test Failures'); -$test_regex = '/Number of tests :\s*\d+\s+\d+\n'. - 'Tests skipped :\s*\d+\s*\(\s*\d+\.\d+%\) --------\n'. - 'Tests warned :\s*\d+\s*\(\s*\d+\.\d+%\) \(\s*\d+\.\d+%\)\n'. - 'Tests failed :\s*\d+\s*\(\s*\d+\.\d+%\) \(\s*\d+\.\d+%\)\n'. - 'Tests passed :\s*\d+\s*\(\s*\d+\.\d+%\) \(\s*\d+\.\d+%\)/'; - -preg_match($test_regex, $data, $m); -$test_summary = $m[0]; - // Grab the results according to failure or pass preg_match_all('/(?P<status>FAIL|PASS) (?P<title>.+) \[(?P<file>[^\]]+)\]/', $data, $tests, PREG_SET_ORDER); -//print_r($tests); - // todo: do a count instead of a bloated get all failures preg_match_all('/FAIL (?P<title>.+) \[(?P<file>[^\]]+)\]/', $data, $failed, PREG_SET_ORDER); @@ -67,6 +62,7 @@ $t['status'] = 'pass'; $t['file'] = $test['file']; } + $xmlarray['tests'][] = $t; // This loop writes the content for a failed test http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/valgrind.php?r1=1.1.2.3&r2=1.1.2.4&diff_format=u Index: php-gcov-web/cron/valgrind.php diff -u php-gcov-web/cron/valgrind.php:1.1.2.3 php-gcov-web/cron/valgrind.php:1.1.2.4 --- php-gcov-web/cron/valgrind.php:1.1.2.3 Tue Aug 8 19:04:26 2006 +++ php-gcov-web/cron/valgrind.php Fri Aug 11 23:59:36 2006 @@ -1,89 +1,49 @@ <?php -// stolen from cron.php -if ($argc != 4) die("only 3 arguments: [tmp] [out] [phpsrc]\n\n"); - -$tmpdir = $argv[1]; -$outdir = $argv[2]; -$phpdir = $argv[3]; -$workdir = dirname(__FILE__); +if(!defined('CRON_PHP')) +{ + echo basename($_SERVER['PHP_SELF']).': Sorry this file must be called by a cron script.'."\n"; + exit; +} $unicode = false; // assume unicode is disabled $write = ''; -$valgrind = array(); - -require $workdir.'/template.php'; +require_once $workdir.'/template.php'; // ----------------- - // todo: make this dynamic or based on the tags instead -$version = basename($phpdir, __FILE__); // fix filename after the others are fixed $data = file_get_contents("$tmpdir/php_test.log"); -//$write = html_header('Valgrind Reports'); - // Check if unicode testing is enabled (is this sufficient for PHP > 6?) if(preg_match('/UNICODE[ ]*:[ ]*ON[ ]?/', $data)) { - // Regular expression to match leaks if unicode is enabled - $leak_re = '/(?P<teststatus>FAIL|LEAK):(?P<testtype>[a-z|A-Z]) (?P<title>.+) \[(?P<file>[^\]]+)\]/'; + // Easy way to track that unicode is enabled $unicode = true; - echo 'unicode: on'."\n"; -} -else -{ - // /LEAK (?P<title>.+) \[(?P<file>[^\]]+)\]/ - $leak_re = '/(?P<teststatus>FAIL|LEAK) (?P<title>.+) \[(?P<file>[^\]]+)\]/'; - echo 'unicode: off'."\n"; } -$test_regex = '/Number of tests :\s*\d+\s+\d+\n'. - 'Tests skipped :\s*\d+\s*\(\s*\d+\.\d+%\) --------\n'. - 'Tests warned :\s*\d+\s*\(\s*\d+\.\d+%\) \(\s*\d+\.\d+%\)\n'. - 'Tests failed :\s*\d+\s*\(\s*\d+\.\d+%\) \(\s*\d+\.\d+%\)\n'. - 'Tests passed :\s*\d+\s*\(\s*\d+\.\d+%\) \(\s*\d+\.\d+%\)/'; - -preg_match($test_regex, $data, $m); - -file_put_contents("$tmpdir/php_valgrind_summary.txt", $m[0]); - -//file_put_contents("$tmpdir/valgrind_summary.inc", $m[0]); - - -// todo: is this FAIL or LEAK? (was fail previously) -//preg_match_all('/LEAK:(\s) (?P<title>.+) \[(?P<file>[^\]]+)\]/', $data, $failed, PREG_SET_ORDER); +///LEAK(:(?P<testtype>[a-z|A-Z]))? (?P<title>.+) \[(?P<file>[^\]]+)\]/ -// todo: verify PHP 6 is used and that unicode is specified +$leak_re = '/LEAK(:(?P<testtype>[a-z|A-Z]))? (?P<title>.+) \[(?P<file>[^\]]+)\]/'; +// Check for Leaks preg_match_all($leak_re, $data, $leaks, PREG_SET_ORDER); -//print_r($leaks); - $old_dir = ''; -if (count($leaks) == 0) { - $write .= "<p>Congratulations! Currently there are no test failures!</p>\n"; -} else { +// 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"; +} +else +{ $totalnumleaks = count($leaks); - $write .= '<table border="1">'."\n"; -/* - $write .= <<< HTML -<table border="1"> - <tr> - <td>File</td> - <td>Test Type</td> - <td>Name</td> - </tr> -HTML; - -*/ } - foreach ($leaks as $test) { @@ -95,99 +55,88 @@ $t = array(); - // If test is a leak perform all operations - if(strtolower($test['teststatus']) == 'leak') + // If test mode is not unicode it is native + if((isset($test['testtype'])) && (strtolower($test['testtype']) == 'u')) { - // If test mode is not unicode it is native - if((isset($test['testtype'])) && (strtolower($test['testtype']) == 'u')) - { - $testtype = 'Unicode'; - $report_file = $base.'u.mem'; - } - else - { - $testtype = 'Native'; - $report_file = $base.'mem'; - } - - $title = $test['title']; - $dir = dirname($test['file']); - $hash = 'v' . md5($test['file']); - - if ($old_dir != $dir) - { - $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"; - - $write .= "<tr>\n<td>File</td>\n<td>Test Type</td>\n<td>Name</td>\n</tr>\n"; - } - - // todo: if testtype is not set don't output it - $write .= "<tr><td><a href='viewer.php?version=$version&func=valgrind&file=$hash'>$file</a></td><td>$testtype</td><td>$title</td></tr>\n"; - - // todo: added str_replace to individual report output - - $base = "$phpdir/".substr($test['file'],0,-4); - - $script = highlight_file($base.'php', true) - or $script = 'Script contents were not available.'; - - $report = file_get_contents($report_file); - - if($report === false) - $report = 'Memory leak file contents were not available.'; - else - $report = str_replace($phpdir,'',$report); - - $additional = - "<h2>Script</h2><pre>\n" .$script. - "\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() - ); - - $t['file'] = $test['file']; - $t['teststatus'] = $test['teststatus']; - $t['script'] = $script; - $t['report'] = $report; + $testtype = 'Unicode'; + $report_file = $base.'u.mem'; } - else // For valgrind failure we only know file and status + else { - // todo: fix this if more information can be gathered - $t['file'] = $test['file']; - $t['teststatus'] = $test['teststatus']; + $testtype = 'Native'; + $report_file = $base.'mem'; } - $valgrind[] = $t; - -} + $title = $test['title']; + $dir = dirname($test['file']); + $hash = 'v' . md5($test['file']); -if (count($leaks)) - $write .= "</table>\n"; + if ($old_dir != $dir) + { + $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"; -$write .= html_footer(); + $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>$testtype</td><td>$title</td></tr>\n"; -file_put_contents("$outdir/valgrind.inc", $write); + // todo: added str_replace to individual report output + + $base = "$phpdir/".substr($test['file'],0,-4); -// Serialize testing + $script_php = highlight_file($base.'php', true); + $script_text = ''; -// This prevents writing the file if there is no content -if(count($valgrind) > 0) -{ - ob_start(); + if($script_php === false) + { + $script_php = 'Script contents were not available.'; + $script_text = 'Script contents were not available.'; + } + else + { + $script_text = file_get_contents($base.'php') + or $script_text = 'Script contents were not available.'; + } + + $report = file_get_contents($report_file); - echo serialize($valgrind); + if($report === false) + $report = 'Memory leak file contents were not available.'; + else + $report = str_replace($phpdir,'',$report); + + $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() + ); - $contents = ob_get_clean(); + $t['file'] = $test['file']; + + $t['script'] = $script_text; + + $t['report'] = $report; + + $xmlarray['valgrind'][] = $t; +} - file_put_contents("$outdir/valgrind.txt", $contents); +if (count($leaks) > 0) +{ + $write .= "</table>\n"; } +$write .= html_footer(); + +file_put_contents("$outdir/valgrind.inc", $write); + ?> http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/config.php?view=markup&rev=1.1 Index: php-gcov-web/cron/config.php +++ php-gcov-web/cron/config.php http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/post.php?view=markup&rev=1.1 Index: php-gcov-web/cron/post.php +++ php-gcov-web/cron/post.php
« previous php.mirrors (#32147) next »