Skip to content

CLEAN can be borked too #7456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -2495,14 +2495,16 @@ 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);

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);
$clean_output = system_with_timeout("$extra $orig_php $pass_options -q $orig_ini_settings $no_file_cache \"$test_clean\"", $env);
}

if (!$cfg['keep']['clean']) {
Expand Down Expand Up @@ -2654,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'));
Expand All @@ -2682,29 +2665,46 @@ function run_test(string $php, $file, array $env): string
// compare and leave on success
if (!strcmp($output, $wanted)) {
$passed = true;
}

if (!$cfg['keep']['php'] && !$leaked) {
@unlink($test_file);
@unlink($preload_filename);
$wanted_re = null;
}

if ($passed) {
if (!$cfg['keep']['php'] && !$leaked) {
@unlink($test_file);
@unlink($preload_filename);
}
@unlink($tmp_post);

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.
Expand Down