]> granicus.if.org Git - php/commitdiff
add support for Valgrind 3.3.0 (which doesn't have --log-file-exactly option)
authorAntony Dovgal <tony2001@php.net>
Wed, 12 Dec 2007 09:20:41 +0000 (09:20 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 12 Dec 2007 09:20:41 +0000 (09:20 +0000)
run-tests.php

index dcd7f3f99291afe7dfecbba1df4effff24772590..fc48fa0309d44ada132dc1c2b8de0481a45bd9f9 100755 (executable)
@@ -76,6 +76,8 @@ putenv('SSH_CONNECTION=deleted');
 $cwd = getcwd();
 set_time_limit(0);
 
+$valgrind_version = 0;
+
 // delete as much output buffers as possible
 while(@ob_end_clean());
 if (ob_get_level()) echo "Not all buffers were deleted.\n";
@@ -972,6 +974,7 @@ function run_test($php, $file, $env, $unicode_semantics)
        global $leak_check, $temp_source, $temp_target, $cfg, $environment;
        global $no_clean;
        global $unicode_and_native;
+       global $valgrind_version;
 
        $temp_filenames = null;
        $org_file = $file;
@@ -1441,7 +1444,26 @@ TEST $file
 
        if ($leak_check) {
                $env['USE_ZEND_ALLOC'] = '0';
-               $cmd = "valgrind -q --tool=memcheck --trace-children=yes --log-file-exactly=$memcheck_filename $cmd";
+               if (!$valgrind_version) {
+                       $valgrind_cmd = "valgrind --version";
+                       $out = system_with_timeout($valgrind_cmd);
+                       $replace_count = 0;
+
+                       if (!$out) {
+                               error("Valgrind returned no version info, cannot proceed.\nPlease check if Valgrind is installed.");
+                       } else {
+                               $valgrind_version = preg_replace("/valgrind-([0-9])\.([0-9])\.([0-9]+)(\s+)/", '$1$2$3', $out, 1, $replace_count);
+                               if ($replace_count != 1 || !is_numeric($valgrind_version)) {
+                                       error("Valgrind returned invalid version info (\"$out\"), cannot proceed.");
+                               }
+                       }
+               }
+               if ($valgrind_version >= 330) {
+                       /* valgrind 3.3.0+ doesn't have --log-file-exactly option */
+                       $cmd = "valgrind -q --tool=memcheck --trace-children=yes --log-file=$memcheck_filename $cmd";
+               } else {
+                       $cmd = "valgrind -q --tool=memcheck --trace-children=yes --log-file-exactly=$memcheck_filename $cmd";
+               }
        } else {
                $env['USE_ZEND_ALLOC'] = '1';
        }