From 6f0834853dfc95812fc530b787f656cf3e2e80e0 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Thu, 2 Sep 2021 22:00:23 +0100 Subject: [PATCH 1/3] CLEAN can be borked too --- run-tests.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/run-tests.php b/run-tests.php index e7df5d694624e..fba17a92eb441 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2502,7 +2502,21 @@ function run_test(string $php, $file, array $env): string if (!$no_clean) { $extra = !IS_WINDOWS ? "unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;" : ""; - system_with_timeout("$extra $php $pass_options $extra_options -q $orig_ini_settings $no_file_cache \"$test_clean\"", $env); + $output = system_with_timeout("$extra $php $pass_options $extra_options -q $orig_ini_settings $no_file_cache \"$test_clean\"", $env); + + if ($output) { + show_result("BORK", $output, $tested_file, 'reason: invalid output from CLEAN', $temp_filenames); + $PHP_FAILED_TESTS['BORKED'][] = [ + 'name' => $file, + 'test_name' => '', + 'output' => '', + 'diff' => '', + 'info' => "$output [$file]", + ]; + + $junit->markTestAs('BORK', $shortname, $tested, null, $output); + return 'BORKED'; + } } if (!$cfg['keep']['clean']) { From f50783dc117b051c7a6df36afccf6f5096837197 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 3 Sep 2021 12:53:52 +0200 Subject: [PATCH 2/3] Only report CLEAN output as BORKED if test passed --- run-tests.php | 90 ++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 52 deletions(-) diff --git a/run-tests.php b/run-tests.php index fba17a92eb441..1c7a1980030f9 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2495,6 +2495,8 @@ function run_test(string $php, $file, array $env): string ]; } + // Remember CLEAN output to report borked test if it otherwise passes. + $clean_output = null; if ($test->sectionNotEmpty('CLEAN') && (!$no_clean || $cfg['keep']['clean'])) { show_file_block('clean', $test->getSection('CLEAN')); save_text($test_clean, trim($test->getSection('CLEAN')), $temp_clean); @@ -2502,21 +2504,7 @@ function run_test(string $php, $file, array $env): string if (!$no_clean) { $extra = !IS_WINDOWS ? "unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;" : ""; - $output = system_with_timeout("$extra $php $pass_options $extra_options -q $orig_ini_settings $no_file_cache \"$test_clean\"", $env); - - if ($output) { - show_result("BORK", $output, $tested_file, 'reason: invalid output from CLEAN', $temp_filenames); - $PHP_FAILED_TESTS['BORKED'][] = [ - 'name' => $file, - 'test_name' => '', - 'output' => '', - 'diff' => '', - 'info' => "$output [$file]", - ]; - - $junit->markTestAs('BORK', $shortname, $tested, null, $output); - return 'BORKED'; - } + $clean_output = system_with_timeout("$extra $php $pass_options $extra_options -q $orig_ini_settings $no_file_cache \"$test_clean\"", $env); } if (!$cfg['keep']['clean']) { @@ -2668,25 +2656,6 @@ function run_test(string $php, $file, array $env): string if (preg_match("/^$wanted_re\$/s", $output)) { $passed = true; - if (!$cfg['keep']['php'] && !$leaked) { - @unlink($test_file); - @unlink($preload_filename); - } - @unlink($tmp_post); - - if (!$leaked && !$failed_headers) { - if ($test->hasSection('XFAIL')) { - $warn = true; - $info = " (warn: XFAIL section but test passes)"; - } elseif ($test->hasSection('XLEAK')) { - $warn = true; - $info = " (warn: XLEAK section but test passes)"; - } else { - show_result("PASS", $tested, $tested_file, '', $temp_filenames); - $junit->markTestAs('PASS', $shortname, $tested); - return 'PASSED'; - } - } } } else { $wanted = trim($test->getSection('EXPECT')); @@ -2696,29 +2665,46 @@ function run_test(string $php, $file, array $env): string // compare and leave on success if (!strcmp($output, $wanted)) { $passed = true; + } + + $wanted_re = null; + } + + if ($passed) { + if (!$cfg['keep']['php'] && !$leaked) { + @unlink($test_file); + @unlink($preload_filename); + } + @unlink($tmp_post); - if (!$cfg['keep']['php'] && !$leaked) { - @unlink($test_file); - @unlink($preload_filename); + if (!$leaked && !$failed_headers) { + // If the test passed and CLEAN produced output, report test as borked. + if ($clean_output) { + show_result("BORK", $output, $tested_file, 'reason: invalid output from CLEAN', $temp_filenames); + $PHP_FAILED_TESTS['BORKED'][] = [ + 'name' => $file, + 'test_name' => '', + 'output' => '', + 'diff' => '', + 'info' => "$clean_output [$file]", + ]; + + $junit->markTestAs('BORK', $shortname, $tested, null, $clean_output); + return 'BORKED'; } - @unlink($tmp_post); - if (!$leaked && !$failed_headers) { - if ($test->hasSection('XFAIL')) { - $warn = true; - $info = " (warn: XFAIL section but test passes)"; - } elseif ($test->hasSection('XLEAK')) { - $warn = true; - $info = " (warn: XLEAK section but test passes)"; - } else { - show_result("PASS", $tested, $tested_file, '', $temp_filenames); - $junit->markTestAs('PASS', $shortname, $tested); - return 'PASSED'; - } + if ($test->hasSection('XFAIL')) { + $warn = true; + $info = " (warn: XFAIL section but test passes)"; + } elseif ($test->hasSection('XLEAK')) { + $warn = true; + $info = " (warn: XLEAK section but test passes)"; + } else { + show_result("PASS", $tested, $tested_file, '', $temp_filenames); + $junit->markTestAs('PASS', $shortname, $tested); + return 'PASSED'; } } - - $wanted_re = null; } // Test failed so we need to report details. From 8fb6e2b13d16a6a68a8e6d36d26441ce08f92fdf Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 6 Sep 2021 14:37:03 +0200 Subject: [PATCH 3/3] Use $orig_php for CLEAN Don't try to run CLEAN under phpdbg/cgi or similar. --- run-tests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-tests.php b/run-tests.php index 1c7a1980030f9..200ba5cd26cfb 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2504,7 +2504,7 @@ function run_test(string $php, $file, array $env): string if (!$no_clean) { $extra = !IS_WINDOWS ? "unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;" : ""; - $clean_output = system_with_timeout("$extra $php $pass_options $extra_options -q $orig_ini_settings $no_file_cache \"$test_clean\"", $env); + $clean_output = system_with_timeout("$extra $orig_php $pass_options -q $orig_ini_settings $no_file_cache \"$test_clean\"", $env); } if (!$cfg['keep']['clean']) {