]> granicus.if.org Git - php/commitdiff
Create .php and .sh on valgrind failure
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 1 Feb 2021 09:10:09 +0000 (10:10 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 1 Feb 2021 09:10:09 +0000 (10:10 +0100)
run-tests.php

index a9f56f9484aefb3068d18f4ba8aaf3bd5913dbe3..613b1391e1e1553274ee0d1c6f3e63870499a69b 100755 (executable)
@@ -2503,6 +2503,7 @@ TEST $file
         $cmd = "$php $pass_options $repeat_option $ini_settings -f \"$test_file\" $args$cmdRedirect";
     }
 
+    $orig_cmd = $cmd;
     if ($valgrind) {
         $env['USE_ZEND_ALLOC'] = '0';
         $env['ZEND_DONT_UNLOAD_MODULES'] = 1;
@@ -2705,7 +2706,7 @@ COMMAND $cmd
 
         if (preg_match("/^$wanted_re\$/s", $output)) {
             $passed = true;
-            if (!$cfg['keep']['php']) {
+            if (!$cfg['keep']['php'] && !$leaked) {
                 @unlink($test_file);
             }
             @unlink($tmp_post);
@@ -2810,6 +2811,20 @@ COMMAND $cmd
             error("Cannot create test diff - $diff_filename");
         }
 
+        // write .log
+        if (strpos($log_format, 'L') !== false && file_put_contents($log_filename, "
+---- EXPECTED OUTPUT
+$wanted
+---- ACTUAL OUTPUT
+$output
+---- FAILED
+") === false) {
+            error("Cannot create test log - $log_filename");
+            error_report($file, $log_filename, $tested);
+        }
+    }
+
+    if (!$passed || $leaked) {
         // write .sh
         if (strpos($log_format, 'S') !== false) {
             $sh_script = <<<SH
@@ -2817,16 +2832,16 @@ COMMAND $cmd
 
 case "$1" in
 "gdb")
-    gdb --args {$cmd}
+    gdb --args {$orig_cmd}
     ;;
 "valgrind")
-    USE_ZEND_ALLOC=0 valgrind $2 ${cmd}
+    USE_ZEND_ALLOC=0 valgrind $2 ${orig_cmd}
     ;;
 "rr")
-    rr record $2 ${cmd}
+    rr record $2 ${orig_cmd}
     ;;
 *)
-    {$cmd}
+    {$orig_cmd}
     ;;
 esac
 SH;
@@ -2835,18 +2850,6 @@ SH;
             }
             chmod($sh_filename, 0755);
         }
-
-        // write .log
-        if (strpos($log_format, 'L') !== false && file_put_contents($log_filename, "
----- EXPECTED OUTPUT
-$wanted
----- ACTUAL OUTPUT
-$output
----- FAILED
-") === false) {
-            error("Cannot create test log - $log_filename");
-            error_report($file, $log_filename, $tested);
-        }
     }
 
     if ($valgrind && $leaked && $cfg["show"]["mem"]) {