com phpruntests: More valgrind stuff: src/configuration/rtEnvironmentVariables.php src/configuration/rtExternalTool.php
src/configuration/rtMemoryTool.php src/configuration/rtRuntestsConfiguration.php src/configuration/tools/rtValgrind.php src/rtClassMap.php
src/testcase/rtTestResults.php src/testcase/sections/executablesections/rtFileSection.php
| From: | David Soria Parra | Date: | Sun, 02 Aug 2009 20:33:32 +0000 |
| Subject: | com phpruntests: More valgrind stuff: src/configuration/rtEnvironmentVariables.php src/configuration/rtExternalTool.php src/configuration/rtMemoryTool.php src/configuration/rtRuntestsConfiguration.php src/configuration/tools/rtValgrind.php src/rtClassMap.php src/testcase/rtTestResults.php src/testcase/sections/executablesections/rtFileSection.php |
||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66306@lists.php.net to get a copy of this message | ||
Commit: b188fce78dfb55bbedf2fd4682a011cc27015158
Author: Zoe Slattery <zoe@php.net> Sun, 2 Aug 2009 20:33:32 +0000
Parents: b13441112ddb293a957b9223f3d3b2e00b9c5deb
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=b188fce78dfb55bbedf2fd4682a011cc27015158
Log:
More valgrind stuff
Changed paths:
M src/configuration/rtEnvironmentVariables.php
D src/configuration/rtExternalTool.php
A src/configuration/rtMemoryTool.php
M src/configuration/rtRuntestsConfiguration.php
M src/configuration/tools/rtValgrind.php
M src/rtClassMap.php
M src/testcase/rtTestResults.php
M src/testcase/sections/executablesections/rtFileSection.php
diff --git a/src/configuration/rtEnvironmentVariables.php b/src/configuration/rtEnvironmentVariables.php index d9b03d3..deafa0b 100644 --- a/src/configuration/rtEnvironmentVariables.php +++ b/src/configuration/rtEnvironmentVariables.php @@ -57,6 +57,7 @@ class rtEnvironmentVariables $this->environmentVariables[$variable] = getenv($variable); } } + } public function setVariable($var,$value) diff --git a/src/configuration/rtExternalTool.php b/src/configuration/rtExternalTool.php deleted file mode 100644 index 06019e5..0000000 --- a/src/configuration/rtExternalTool.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/** - * rtExternalTool - * - * Class to handle using an external tool (default is valgrind) - * - * @category Testing - * @package RUNTESTS - * @author Zoe Slattery <zoe@php.net> - * @author Stefan Priebsch <spriebsch@php.net> - * @copyright 2009 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @link http://qa.php.net/ - * - */ - -class rtExternalTool -{ - protected $command; - protected $options; - protected $version; - - public static function getInstance($configuration) - { - if($configuration->hasCommandLineOption('m')) { - return new rtValgrind(); - } else { - $name = 'rt' . $configuration->getCommandLineOption('mtool'); - return new $name(); - } - } - - public function init(rtRuntestsConfiguration $configuration) { - $this->setVersion(); - $this->setCommand($configuration); - $this->setOptions($configuration); - } - - public function getCommand() { - return $this->command; - } - - -} -?> \ No newline at end of file diff --git a/src/configuration/rtMemoryTool.php b/src/configuration/rtMemoryTool.php new file mode 100644 index 0000000..63d75f8 --- /dev/null +++ b/src/configuration/rtMemoryTool.php @@ -0,0 +1,46 @@ +<?php +/** + * rtExternalTool + * + * Class to handle using an external tool (default is valgrind) + * + * @category Testing + * @package RUNTESTS + * @author Zoe Slattery <zoe@php.net> + * @author Stefan Priebsch <spriebsch@php.net> + * @copyright 2009 The PHP Group + * @license http://www.php.net/license/3_01.txt PHP License 3.01 + * @link http://qa.php.net/ + * + */ + +class rtMemoryTool +{ + protected $command; + protected $options; + protected $version; + + public static function getInstance($configuration) + { + if($configuration->hasCommandLineOption('m')) { + return new rtValgrind(); + } else { + $name = 'rt' . $configuration->getCommandLineOption('mtool'); + return new $name(); + } + } + + public function init(rtRuntestsConfiguration $configuration) { + $this->setVersion(); + $this->setCommand($configuration); + $this->setOptions($configuration); + $this->setEnvironment($configuration); + } + + public function getCommand() { + return $this->command; + } + + +} +?> \ No newline at end of file diff --git a/src/configuration/rtRuntestsConfiguration.php b/src/configuration/rtRuntestsConfiguration.php index 8c8f2f5..62b7e9c 100644 --- a/src/configuration/rtRuntestsConfiguration.php +++ b/src/configuration/rtRuntestsConfiguration.php @@ -23,7 +23,7 @@ abstract class rtRuntestsConfiguration private $environmentVariables; private $commandLine; - private $externalTool = null; + private $memoryTool = null; private $settingNames = array ( @@ -70,12 +70,12 @@ abstract class rtRuntestsConfiguration $options = new rtAddToCommandLine(); $options->parseAdditionalOptions($this->commandLine, $this->environmentVariables); - //if there is an external tool - configure it + //if there is an memory tool - configure it if($this->commandLine->hasOption('m') || $this->commandLine->hasOption('mtool')) { - $this->externalTool = rtExternalTool::getInstance($this); - $this->externalTool->checkAvailable($this); - $this->externalTool->init($this); + $this->memoryTool = rtMemoryTool::getInstance($this); + $this->memoryTool->checkAvailable($this); + $this->memoryTool->init($this); } @@ -136,7 +136,7 @@ abstract class rtRuntestsConfiguration } /** - * required for testing? + * required for testing - also used by memory tools * * @param unknown_type $name * @param unknown_type $value @@ -156,15 +156,15 @@ abstract class rtRuntestsConfiguration $this->environmentVariables->getUserSuppliedVariables(); } - public function hasExternalTool() { - if($this->externalTool != null) { + public function hasMemoryTool() { + if($this->memoryTool != null) { return true; } return false; } - public function getExternalToolCommand() { - return $this->externalTool->getCommand(); + public function getMemoryToolCommand() { + return $this->memoryTool->getCommand(); } } diff --git a/src/configuration/tools/rtValgrind.php b/src/configuration/tools/rtValgrind.php index f2c5f40..9122f6f 100644 --- a/src/configuration/tools/rtValgrind.php +++ b/src/configuration/tools/rtValgrind.php @@ -15,7 +15,7 @@ */ -class rtValgrind extends rtExternalTool +class rtValgrind extends rtMemoryTool { public function checkAvailable($configuration) { @@ -48,5 +48,9 @@ class rtValgrind extends rtExternalTool $this->command .= " " . $options . " --log-file-exactly="; } } + + public function setEnvironment($configuration) { + $configuration->setEnvironmentVariable('USE_ZEND_ALLOC', '0'); + } } ?> \ No newline at end of file diff --git a/src/rtClassMap.php b/src/rtClassMap.php index 80674f7..268da45 100644 --- a/src/rtClassMap.php +++ b/src/rtClassMap.php @@ -23,8 +23,8 @@ $rtClassMap = array( 'rtAddToCommandLine' => 'configuration/rtAddToCommandLine.php', 'rtCommandLineOptions' => 'configuration/rtCommandLineOptions.php', 'rtEnvironmentVariables' => 'configuration/rtEnvironmentVariables.php', - 'rtExternalTool' => 'configuration/rtExternalTool.php', 'rtIniAsCommandLineArgs' => 'configuration/rtIniAsCommandLineArgs.php', + 'rtMemoryTool' => 'configuration/rtMemoryTool.php', 'rtPreCondition' => 'configuration/rtPreCondition.php', 'rtPreConditionList' => 'configuration/rtPreConditionList.php', 'rtRuntestsConfiguration' => 'configuration/rtRuntestsConfiguration.php', diff --git a/src/testcase/rtTestResults.php b/src/testcase/rtTestResults.php index 2b1d52e..b058e24 100644 --- a/src/testcase/rtTestResults.php +++ b/src/testcase/rtTestResults.php @@ -54,6 +54,16 @@ class rtTestResults } else { echo "no status? something wrong here\n"; } + + //Deal with mem files generated by memory checking tools. Save or not, irrespective of status + + if(file_exists($this->testName . '.mem')) { + if(filesize($this->testName . '.mem') > 0) { + $this->savedFileNames['mem'] = $this->testName. ".mem"; + } else { + @unlink($this->testName . '.mem'); + } + } } /** @@ -95,6 +105,7 @@ class rtTestResults if ($testCase->hasSection('SKIPIF')) { $testCase->getSection('SKIPIF')->deleteFile(); } + } private function onFail(rtPhpTest $testCase) diff --git a/src/testcase/sections/executablesections/rtFileSection.php b/src/testcase/sections/executablesections/rtFileSection.php index 1fa205b..295f371 100644 --- a/src/testcase/sections/executablesections/rtFileSection.php +++ b/src/testcase/sections/executablesections/rtFileSection.php @@ -29,13 +29,13 @@ class rtFileSection extends rtExecutableSection public function run(rtPhpTest $testCase, rtRuntestsConfiguration $runConfiguration) { - + $testStatus = $testCase->getStatus(); $this->writeExecutableFile(); - + $commandPrefix = ""; - if($runConfiguration->hasExternalTool()) { - $commandPrefix = $runConfiguration->getExternalToolCommand(); + if($runConfiguration->hasMemoryTool()) { + $commandPrefix = $runConfiguration->getMemoryToolCommand(); //This assumes that the external tool write its output to a *.mem file $commandPrefix .= $this->memFileName; } @@ -45,7 +45,7 @@ class rtFileSection extends rtExecutableSection // The CGI excutable is null if it is not available, check and SKIP if necessary if (is_null($phpExecutable)) { $testStatus->setTrue('skip'); - $testStatus->setMessage('skip', 'The CGI executable is unavailable' ); + $testStatus->setMessage('skip', 'The CGI executable is unavailable' ); return $testStatus; } @@ -80,20 +80,24 @@ class rtFileSection extends rtExecutableSection } catch (rtException $e) { $testStatus->setTrue('fail'); - $testStatus->setMessage('fail', $e->getMessage() ); + $testStatus->setMessage('fail', $e->getMessage() ); } - - return $testStatus; -} -/** - * - */ -public function getHeaders() -{ - return $this->headers; -} + return $testStatus; + } + + /** + * + */ + public function getHeaders() + { + return $this->headers; + } + + public function deleteMemFile() { + @unlink($this->memFileName); + } } ?>
diff --git a/src/configuration/rtEnvironmentVariables.php b/src/configuration/rtEnvironmentVariables.php index d9b03d3..deafa0b 100644 --- a/src/configuration/rtEnvironmentVariables.php +++ b/src/configuration/rtEnvironmentVariables.php @@ -57,6 +57,7 @@ class rtEnvironmentVariables $this->environmentVariables[$variable] = getenv($variable); } } + } public function setVariable($var,$value) diff --git a/src/configuration/rtExternalTool.php b/src/configuration/rtExternalTool.php deleted file mode 100644 index 06019e5..0000000 --- a/src/configuration/rtExternalTool.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/** - * rtExternalTool - * - * Class to handle using an external tool (default is valgrind) - * - * @category Testing - * @package RUNTESTS - * @author Zoe Slattery <zoe@php.net> - * @author Stefan Priebsch <spriebsch@php.net> - * @copyright 2009 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @link http://qa.php.net/ - * - */ - -class rtExternalTool -{ - protected $command; - protected $options; - protected $version; - - public static function getInstance($configuration) - { - if($configuration->hasCommandLineOption('m')) { - return new rtValgrind(); - } else { - $name = 'rt' . $configuration->getCommandLineOption('mtool'); - return new $name(); - } - } - - public function init(rtRuntestsConfiguration $configuration) { - $this->setVersion(); - $this->setCommand($configuration); - $this->setOptions($configuration); - } - - public function getCommand() { - return $this->command; - } - - -} -?> \ No newline at end of file diff --git a/src/configuration/rtMemoryTool.php b/src/configuration/rtMemoryTool.php new file mode 100644 index 0000000..63d75f8 --- /dev/null +++ b/src/configuration/rtMemoryTool.php @@ -0,0 +1,46 @@ +<?php +/** + * rtExternalTool + * + * Class to handle using an external tool (default is valgrind) + * + * @category Testing + * @package RUNTESTS + * @author Zoe Slattery <zoe@php.net> + * @author Stefan Priebsch <spriebsch@php.net> + * @copyright 2009 The PHP Group + * @license http://www.php.net/license/3_01.txt PHP License 3.01 + * @link http://qa.php.net/ + * + */ + +class rtMemoryTool +{ + protected $command; + protected $options; + protected $version; + + public static function getInstance($configuration) + { + if($configuration->hasCommandLineOption('m')) { + return new rtValgrind(); + } else { + $name = 'rt' . $configuration->getCommandLineOption('mtool'); + return new $name(); + } + } + + public function init(rtRuntestsConfiguration $configuration) { + $this->setVersion(); + $this->setCommand($configuration); + $this->setOptions($configuration); + $this->setEnvironment($configuration); + } + + public function getCommand() { + return $this->command; + } + + +} +?> \ No newline at end of file diff --git a/src/configuration/rtRuntestsConfiguration.php b/src/configuration/rtRuntestsConfiguration.php index 8c8f2f5..62b7e9c 100644 --- a/src/configuration/rtRuntestsConfiguration.php +++ b/src/configuration/rtRuntestsConfiguration.php @@ -23,7 +23,7 @@ abstract class rtRuntestsConfiguration private $environmentVariables; private $commandLine; - private $externalTool = null; + private $memoryTool = null; private $settingNames = array ( @@ -70,12 +70,12 @@ abstract class rtRuntestsConfiguration $options = new rtAddToCommandLine(); $options->parseAdditionalOptions($this->commandLine, $this->environmentVariables); - //if there is an external tool - configure it + //if there is an memory tool - configure it if($this->commandLine->hasOption('m') || $this->commandLine->hasOption('mtool')) { - $this->externalTool = rtExternalTool::getInstance($this); - $this->externalTool->checkAvailable($this); - $this->externalTool->init($this); + $this->memoryTool = rtMemoryTool::getInstance($this); + $this->memoryTool->checkAvailable($this); + $this->memoryTool->init($this); } @@ -136,7 +136,7 @@ abstract class rtRuntestsConfiguration } /** - * required for testing? + * required for testing - also used by memory tools * * @param unknown_type $name * @param unknown_type $value @@ -156,15 +156,15 @@ abstract class rtRuntestsConfiguration $this->environmentVariables->getUserSuppliedVariables(); } - public function hasExternalTool() { - if($this->externalTool != null) { + public function hasMemoryTool() { + if($this->memoryTool != null) { return true; } return false; } - public function getExternalToolCommand() { - return $this->externalTool->getCommand(); + public function getMemoryToolCommand() { + return $this->memoryTool->getCommand(); } } diff --git a/src/configuration/tools/rtValgrind.php b/src/configuration/tools/rtValgrind.php index f2c5f40..9122f6f 100644 --- a/src/configuration/tools/rtValgrind.php +++ b/src/configuration/tools/rtValgrind.php @@ -15,7 +15,7 @@ */ -class rtValgrind extends rtExternalTool +class rtValgrind extends rtMemoryTool { public function checkAvailable($configuration) { @@ -48,5 +48,9 @@ class rtValgrind extends rtExternalTool $this->command .= " " . $options . " --log-file-exactly="; } } + + public function setEnvironment($configuration) { + $configuration->setEnvironmentVariable('USE_ZEND_ALLOC', '0'); + } } ?> \ No newline at end of file diff --git a/src/rtClassMap.php b/src/rtClassMap.php index 80674f7..268da45 100644 --- a/src/rtClassMap.php +++ b/src/rtClassMap.php @@ -23,8 +23,8 @@ $rtClassMap = array( 'rtAddToCommandLine' => 'configuration/rtAddToCommandLine.php', 'rtCommandLineOptions' => 'configuration/rtCommandLineOptions.php', 'rtEnvironmentVariables' => 'configuration/rtEnvironmentVariables.php', - 'rtExternalTool' => 'configuration/rtExternalTool.php', 'rtIniAsCommandLineArgs' => 'configuration/rtIniAsCommandLineArgs.php', + 'rtMemoryTool' => 'configuration/rtMemoryTool.php', 'rtPreCondition' => 'configuration/rtPreCondition.php', 'rtPreConditionList' => 'configuration/rtPreConditionList.php', 'rtRuntestsConfiguration' => 'configuration/rtRuntestsConfiguration.php', diff --git a/src/testcase/rtTestResults.php b/src/testcase/rtTestResults.php index 2b1d52e..b058e24 100644 --- a/src/testcase/rtTestResults.php +++ b/src/testcase/rtTestResults.php @@ -54,6 +54,16 @@ class rtTestResults } else { echo "no status? something wrong here\n"; } + + //Deal with mem files generated by memory checking tools. Save or not, irrespective of status + + if(file_exists($this->testName . '.mem')) { + if(filesize($this->testName . '.mem') > 0) { + $this->savedFileNames['mem'] = $this->testName. ".mem"; + } else { + @unlink($this->testName . '.mem'); + } + } } /** @@ -95,6 +105,7 @@ class rtTestResults if ($testCase->hasSection('SKIPIF')) { $testCase->getSection('SKIPIF')->deleteFile(); } + } private function onFail(rtPhpTest $testCase) diff --git a/src/testcase/sections/executablesections/rtFileSection.php b/src/testcase/sections/executablesections/rtFileSection.php index 1fa205b..295f371 100644 --- a/src/testcase/sections/executablesections/rtFileSection.php +++ b/src/testcase/sections/executablesections/rtFileSection.php @@ -29,13 +29,13 @@ class rtFileSection extends rtExecutableSection public function run(rtPhpTest $testCase, rtRuntestsConfiguration $runConfiguration) { - + $testStatus = $testCase->getStatus(); $this->writeExecutableFile(); - + $commandPrefix = ""; - if($runConfiguration->hasExternalTool()) { - $commandPrefix = $runConfiguration->getExternalToolCommand(); + if($runConfiguration->hasMemoryTool()) { + $commandPrefix = $runConfiguration->getMemoryToolCommand(); //This assumes that the external tool write its output to a *.mem file $commandPrefix .= $this->memFileName; } @@ -45,7 +45,7 @@ class rtFileSection extends rtExecutableSection // The CGI excutable is null if it is not available, check and SKIP if necessary if (is_null($phpExecutable)) { $testStatus->setTrue('skip'); - $testStatus->setMessage('skip', 'The CGI executable is unavailable' ); + $testStatus->setMessage('skip', 'The CGI executable is unavailable' ); return $testStatus; } @@ -80,20 +80,24 @@ class rtFileSection extends rtExecutableSection } catch (rtException $e) { $testStatus->setTrue('fail'); - $testStatus->setMessage('fail', $e->getMessage() ); + $testStatus->setMessage('fail', $e->getMessage() ); } - - return $testStatus; -} -/** - * - */ -public function getHeaders() -{ - return $this->headers; -} + return $testStatus; + } + + /** + * + */ + public function getHeaders() + { + return $this->headers; + } + + public function deleteMemFile() { + @unlink($this->memFileName); + } } ?>