summaryrefslogtreecommitdiff
path: root/run-tests.php
diff options
context:
space:
mode:
Diffstat (limited to 'run-tests.php')
-rwxr-xr-xrun-tests.php218
1 files changed, 156 insertions, 62 deletions
diff --git a/run-tests.php b/run-tests.php
index 5df1c5f42b..96733e58a9 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -2,7 +2,7 @@
<?php
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2016 The PHP Group |
+----------------------------------------------------------------------+
@@ -114,7 +114,6 @@ if (ob_get_level()) echo "Not all buffers were deleted.\n";
error_reporting(E_ALL);
if (PHP_MAJOR_VERSION < 6) {
- ini_set('magic_quotes_runtime',0); // this would break tests by modifying EXPECT sections
if (ini_get('safe_mode')) {
echo <<< SAFE_MODE_WARNING
@@ -142,6 +141,7 @@ if ((substr(PHP_OS, 0, 3) == "WIN") && empty($environment["SystemRoot"])) {
$php = null;
$php_cgi = null;
+$phpdbg = null;
if (getenv('TEST_PHP_EXECUTABLE')) {
$php = getenv('TEST_PHP_EXECUTABLE');
@@ -159,6 +159,16 @@ if (getenv('TEST_PHP_EXECUTABLE')) {
$php_cgi = null;
}
}
+
+ if (!getenv('TEST_PHPDBG_EXECUTABLE')) {
+ $phpdbg = $cwd . '/sapi/phpdbg/phpdbg';
+
+ if (file_exists($phpdbg)) {
+ putenv("TEST_PHP_CGI_EXECUTABLE=$phpdbg");
+ } else {
+ $phpdbg = null;
+ }
+ }
}
$environment['TEST_PHP_EXECUTABLE'] = $php;
}
@@ -174,6 +184,17 @@ if (getenv('TEST_PHP_CGI_EXECUTABLE')) {
$environment['TEST_PHP_CGI_EXECUTABLE'] = $php_cgi;
}
+if (getenv('TEST_PHPDBG_EXECUTABLE')) {
+ $phpdbg = getenv('TEST_PHPDBG_EXECUTABLE');
+
+ if ($phpdbg=='auto') {
+ $phpdbg = $cwd . '/sapi/phpdbg/phpdbg';
+ putenv("TEST_PHPDBG_EXECUTABLE=$phpdbg");
+ }
+
+ $environment['TEST_PHPDBG_EXECUTABLE'] = $phpdbg;
+}
+
function verify_config()
{
global $php;
@@ -236,7 +257,6 @@ $ini_overwrites = array(
'error_append_string=',
'auto_prepend_file=',
'auto_append_file=',
- 'magic_quotes_runtime=0',
'ignore_repeated_errors=0',
'precision=14',
'memory_limit=128M',
@@ -245,9 +265,11 @@ $ini_overwrites = array(
'opcache.file_update_protection=0',
);
+$no_file_cache = '-d opcache.file_cache= -d opcache.file_cache_only=0';
+
function write_information($show_html)
{
- global $cwd, $php, $php_cgi, $php_info, $user_tests, $ini_overwrites, $pass_options, $exts_to_test, $leak_check, $valgrind_header;
+ global $cwd, $php, $php_cgi, $phpdbg, $php_info, $user_tests, $ini_overwrites, $pass_options, $exts_to_test, $leak_check, $valgrind_header, $no_file_cache;
// Get info from php
$info_file = __DIR__ . '/run-test-info.php';
@@ -263,22 +285,30 @@ More .INIs : " , (function_exists(\'php_ini_scanned_files\') ? str_replace("\n"
$info_params = array();
settings2array($ini_overwrites, $info_params);
settings2params($info_params);
- $php_info = `$php $pass_options $info_params "$info_file"`;
+ $php_info = `$php $pass_options $info_params $no_file_cache "$info_file"`;
define('TESTED_PHP_VERSION', `$php -n -r "echo PHP_VERSION;"`);
if ($php_cgi && $php != $php_cgi) {
- $php_info_cgi = `$php_cgi $pass_options $info_params -q "$info_file"`;
+ $php_info_cgi = `$php_cgi $pass_options $info_params $no_file_cache -q "$info_file"`;
$php_info_sep = "\n---------------------------------------------------------------------";
$php_cgi_info = "$php_info_sep\nPHP : $php_cgi $php_info_cgi$php_info_sep";
} else {
$php_cgi_info = '';
}
+ if ($phpdbg) {
+ $phpdbg_info = `$phpdbg $pass_options $info_params $no_file_cache -qrr "$info_file"`;
+ $php_info_sep = "\n---------------------------------------------------------------------";
+ $phpdbg_info = "$php_info_sep\nPHP : $phpdbg $phpdbg_info$php_info_sep";
+ } else {
+ $phpdbg_info = '';
+ }
+
@unlink($info_file);
// load list of enabled extensions
save_text($info_file, '<?php echo join(",", get_loaded_extensions()); ?>');
- $exts_to_test = explode(',',`$php $pass_options $info_params "$info_file"`);
+ $exts_to_test = explode(',',`$php $pass_options $info_params $no_file_cache "$info_file"`);
// check for extensions that need special handling and regenerate
$info_params_ex = array(
'session' => array('session.auto_start=0'),
@@ -299,7 +329,7 @@ More .INIs : " , (function_exists(\'php_ini_scanned_files\') ? str_replace("\n"
// Write test context information.
echo "
=====================================================================
-PHP : $php $php_info $php_cgi_info
+PHP : $php $php_info $php_cgi_info $phpdbg_info
CWD : $cwd
Extra dirs : ";
foreach ($user_tests as $test_dir) {
@@ -324,7 +354,7 @@ function save_or_mail_results()
/* We got failed Tests, offer the user to send an e-mail to QA team, unless NO_INTERACTION is set */
if (!getenv('NO_INTERACTION') && !TRAVIS_CI) {
$fp = fopen("php://stdin", "r+");
- if ($sum_results['FAILED'] || $sum_results['BORKED'] || $sum_results['WARNED'] || $sum_results['LEAKED'] || $sum_results['XFAILED']) {
+ if ($sum_results['FAILED'] || $sum_results['BORKED'] || $sum_results['WARNED'] || $sum_results['LEAKED']) {
echo "\nYou may have found a problem in PHP.";
}
echo "\nThis report can be automatically sent to the PHP QA team at\n";
@@ -343,7 +373,7 @@ function save_or_mail_results()
if ($just_save_results || TRAVIS_CI || strlen(trim($user_input)) == 0 || strtolower($user_input[0]) == 'y') {
/*
* Collect information about the host system for our report
- * Fetch phpinfo() output so that we can see the PHP enviroment
+ * Fetch phpinfo() output so that we can see the PHP environment
* Make an archive of all the failed tests
* Send an email
*/
@@ -595,6 +625,9 @@ if (isset($argc) && $argc > 1) {
}
$pass_option_n = true;
break;
+ case 'e':
+ $pass_options .= ' -e';
+ break;
case '--no-clean':
$no_clean = true;
break;
@@ -851,7 +884,7 @@ $exts_skipped = 0;
$ignored_by_ext = 0;
sort($exts_to_test);
$test_dirs = array();
-$optionals = array('tests', 'ext', 'Zend', 'ZendEngine2', 'sapi/cli', 'sapi/cgi', 'sapi/fpm');
+$optionals = array('tests', 'ext', 'Zend', 'sapi');
foreach($optionals as $dir) {
if (@filetype($dir) == 'dir') {
@@ -1124,7 +1157,10 @@ function system_with_timeout($commandline, $env = null, $stdin = null)
$stat = proc_get_status($proc);
if ($stat['signaled']) {
- $data .= "\nTermsig=" . $stat['stopsig'];
+ $data .= "\nTermsig=" . $stat['stopsig'] . "\n";
+ }
+ if ($stat["exitcode"] > 128 && $stat["exitcode"] < 160) {
+ $data .= "\nTermsig=" . ($stat["exitcode"] - 128) . "\n";
}
$code = proc_close($proc);
@@ -1190,6 +1226,8 @@ function run_test($php, $file, $env)
global $no_clean;
global $valgrind_version;
global $JUNIT;
+ global $SHOW_ONLY_GROUPS;
+ global $no_file_cache;
$temp_filenames = null;
$org_file = $file;
@@ -1197,6 +1235,10 @@ function run_test($php, $file, $env)
$php_cgi = $env['TEST_PHP_CGI_EXECUTABLE'];
}
+ if (isset($env['TEST_PHPDBG_EXECUTABLE'])) {
+ $phpdbg = $env['TEST_PHPDBG_EXECUTABLE'];
+ }
+
if (is_array($file)) {
$file = $file[0];
}
@@ -1282,7 +1324,7 @@ TEST $file
} else {
- if (@count($section_text['FILE']) + @count($section_text['FILEEOF']) + @count($section_text['FILE_EXTERNAL']) != 1) {
+ if (!isset($section_text['PHPDBG']) && @count($section_text['FILE']) + @count($section_text['FILEEOF']) + @count($section_text['FILE_EXTERNAL']) != 1) {
$bork_info = "missing section --FILE--";
$borked = true;
}
@@ -1364,7 +1406,41 @@ TEST $file
}
}
- show_test($test_idx, $shortname);
+ /* For phpdbg tests, check if phpdbg sapi is available and if it is, use it. */
+ if (array_key_exists('PHPDBG', $section_text)) {
+ if (!isset($section_text['STDIN'])) {
+ $section_text['STDIN'] = $section_text['PHPDBG']."\n";
+ }
+
+ if (isset($phpdbg)) {
+ $old_php = $php;
+ $php = $phpdbg . ' -qIb';
+ } else if (!strncasecmp(PHP_OS, "win", 3) && file_exists(dirname($php) . "/phpdbg.exe")) {
+ $old_php = $php;
+ $php = realpath(dirname($php) . "/phpdbg.exe") . ' -qIb ';
+ } else {
+ if (file_exists(dirname($php) . "/../../sapi/phpdbg/phpdbg")) {
+ $old_php = $php;
+ $php = realpath(dirname($php) . "/../../sapi/phpdbg/phpdbg") . ' -qIb ';
+ } else if (file_exists("./sapi/phpdbg/phpdbg")) {
+ $old_php = $php;
+ $php = realpath("./sapi/phpdbg/phpdbg") . ' -qIb ';
+ } else if (file_exists(dirname($php) . "/phpdbg")) {
+ $old_php = $php;
+ $php = realpath(dirname($php) . "/phpdbg") . ' -qIb ';
+ } else {
+ show_result('SKIP', $tested, $tested_file, "reason: phpdbg not available");
+
+ junit_init_suite(junit_get_suitename_for($shortname));
+ junit_mark_test_as('SKIP', $shortname, $tested, 0, 'phpdbg not available');
+ return 'SKIPPED';
+ }
+ }
+ }
+
+ if (!$SHOW_ONLY_GROUPS) {
+ show_test($test_idx, $shortname);
+ }
if (is_array($IN_REDIRECT)) {
$temp_dir = $test_dir = $IN_REDIRECT['dir'];
@@ -1463,18 +1539,6 @@ TEST $file
// Default ini settings
$ini_settings = array();
- // additional ini overwrites
- //$ini_overwrites[] = 'setting=value';
- settings2array($ini_overwrites, $ini_settings);
-
- // Any special ini settings
- // these may overwrite the test defaults...
- if (array_key_exists('INI', $section_text)) {
- if (strpos($section_text['INI'], '{PWD}') !== false) {
- $section_text['INI'] = str_replace('{PWD}', dirname($file), $section_text['INI']);
- }
- settings2array(preg_split( "/[\n\r]+/", $section_text['INI']), $ini_settings);
- }
// Additional required extensions
if (array_key_exists('EXTENSIONS', $section_text)) {
@@ -1488,6 +1552,19 @@ TEST $file
}
}
+ // additional ini overwrites
+ //$ini_overwrites[] = 'setting=value';
+ settings2array($ini_overwrites, $ini_settings);
+
+ // Any special ini settings
+ // these may overwrite the test defaults...
+ if (array_key_exists('INI', $section_text)) {
+ if (strpos($section_text['INI'], '{PWD}') !== false) {
+ $section_text['INI'] = str_replace('{PWD}', dirname($file), $section_text['INI']);
+ }
+ settings2array(preg_split( "/[\n\r]+/", $section_text['INI']), $ini_settings);
+ }
+
settings2params($ini_settings);
// Check if test should be skipped.
@@ -1512,7 +1589,7 @@ TEST $file
junit_start_timer($shortname);
- $output = system_with_timeout("$extra $php $pass_options -q $ini_settings -d display_errors=0 \"$test_skipif\"", $env);
+ $output = system_with_timeout("$extra $php $pass_options -q $ini_settings $no_file_cache -d display_errors=0 \"$test_skipif\"", $env);
junit_finish_timer($shortname);
@@ -1642,8 +1719,12 @@ TEST $file
}
// We've satisfied the preconditions - run the test!
- show_file_block('php', $section_text['FILE'], 'TEST');
- save_text($test_file, $section_text['FILE'], $temp_file);
+ if (isset($section_text['FILE'])) {
+ show_file_block('php', $section_text['FILE'], 'TEST');
+ save_text($test_file, $section_text['FILE'], $temp_file);
+ } else {
+ $test_file = $temp_file = "";
+ }
if (array_key_exists('GET', $section_text)) {
$query_string = trim($section_text['GET']);
@@ -1652,9 +1733,15 @@ TEST $file
}
$env['REDIRECT_STATUS'] = '1';
- $env['QUERY_STRING'] = $query_string;
- $env['PATH_TRANSLATED'] = $test_file;
- $env['SCRIPT_FILENAME'] = $test_file;
+ if (empty($env['QUERY_STRING'])) {
+ $env['QUERY_STRING'] = $query_string;
+ }
+ if (empty($env['PATH_TRANSLATED'])) {
+ $env['PATH_TRANSLATED'] = $test_file;
+ }
+ if (empty($env['SCRIPT_FILENAME'])) {
+ $env['SCRIPT_FILENAME'] = $test_file;
+ }
if (array_key_exists('COOKIE', $section_text)) {
$env['HTTP_COOKIE'] = trim($section_text['COOKIE']);
@@ -1725,7 +1812,7 @@ TEST $file
$env['REQUEST_METHOD'] = 'PUT';
if (empty($request)) {
- junit_mark_test_as('BORK', $shortname, $tested, null, 'empty $request');
+ junit_mark_test_as('BORK', $shortname, $tested, null, 'empty $request');
return 'BORKED';
}
@@ -1735,43 +1822,47 @@ TEST $file
} else if (array_key_exists('POST', $section_text) && !empty($section_text['POST'])) {
$post = trim($section_text['POST']);
- save_text($tmp_post, $post);
$content_length = strlen($post);
+ save_text($tmp_post, $post);
$env['REQUEST_METHOD'] = 'POST';
- $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
- $env['CONTENT_LENGTH'] = $content_length;
+ if (empty($env['CONTENT_TYPE'])) {
+ $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
+ }
- $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
+ if (empty($env['CONTENT_LENGTH'])) {
+ $env['CONTENT_LENGTH'] = $content_length;
+ }
- } else if (array_key_exists('GZIP_POST', $section_text) && !empty($section_text['GZIP_POST'])) {
+ $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
- $post = trim($section_text['GZIP_POST']);
- $post = gzencode($post, 9, FORCE_GZIP);
- $env['HTTP_CONTENT_ENCODING'] = 'gzip';
+ } else if (array_key_exists('GZIP_POST', $section_text) && !empty($section_text['GZIP_POST'])) {
- save_text($tmp_post, $post);
- $content_length = strlen($post);
+ $post = trim($section_text['GZIP_POST']);
+ $post = gzencode($post, 9, FORCE_GZIP);
+ $env['HTTP_CONTENT_ENCODING'] = 'gzip';
- $env['REQUEST_METHOD'] = 'POST';
- $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
- $env['CONTENT_LENGTH'] = $content_length;
+ save_text($tmp_post, $post);
+ $content_length = strlen($post);
- $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
+ $env['REQUEST_METHOD'] = 'POST';
+ $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
+ $env['CONTENT_LENGTH'] = $content_length;
- } else if (array_key_exists('DEFLATE_POST', $section_text) && !empty($section_text['DEFLATE_POST'])) {
- $post = trim($section_text['DEFLATE_POST']);
- $post = gzcompress($post, 9);
- $env['HTTP_CONTENT_ENCODING'] = 'deflate';
- save_text($tmp_post, $post);
- $content_length = strlen($post);
+ $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
- $env['REQUEST_METHOD'] = 'POST';
- $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
- $env['CONTENT_LENGTH'] = $content_length;
+ } else if (array_key_exists('DEFLATE_POST', $section_text) && !empty($section_text['DEFLATE_POST'])) {
+ $post = trim($section_text['DEFLATE_POST']);
+ $post = gzcompress($post, 9);
+ $env['HTTP_CONTENT_ENCODING'] = 'deflate';
+ save_text($tmp_post, $post);
+ $content_length = strlen($post);
- $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
+ $env['REQUEST_METHOD'] = 'POST';
+ $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
+ $env['CONTENT_LENGTH'] = $content_length;
+ $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
} else {
@@ -1786,11 +1877,14 @@ TEST $file
$env['USE_ZEND_ALLOC'] = '0';
$env['ZEND_DONT_UNLOAD_MODULES'] = 1;
- if (version_compare($valgrind_version, '3.3.0', '>=')) {
+ /* --vex-iropt-register-updates=allregs-at-mem-access is necessary for phpdbg watchpoint tests */
+ if (version_compare($valgrind_version, '3.8.0', '>=')) {
/* valgrind 3.3.0+ doesn't have --log-file-exactly option */
- $cmd = "valgrind -q --tool=memcheck --trace-children=yes --log-file=$memcheck_filename $cmd";
+ $cmd = "valgrind -q --tool=memcheck --trace-children=yes --vex-iropt-register-updates=allregs-at-mem-access --log-file=$memcheck_filename $cmd";
+ } elseif (version_compare($valgrind_version, '3.3.0', '>=')) {
+ $cmd = "valgrind -q --tool=memcheck --trace-children=yes --vex-iropt-precise-memory-exns=yes --log-file=$memcheck_filename $cmd";
} else {
- $cmd = "valgrind -q --tool=memcheck --trace-children=yes --log-file-exactly=$memcheck_filename $cmd";
+ $cmd = "valgrind -q --tool=memcheck --trace-children=yes --vex-iropt-precise-memory-exns=yes --log-file-exactly=$memcheck_filename $cmd";
}
} else {
@@ -1828,7 +1922,7 @@ COMMAND $cmd
settings2params($clean_params);
$extra = substr(PHP_OS, 0, 3) !== "WIN" ?
"unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;": "";
- system_with_timeout("$extra $php $pass_options -q $clean_params \"$test_clean\"", $env);
+ system_with_timeout("$extra $php $pass_options -q $clean_params $no_file_cache \"$test_clean\"", $env);
}
if (!$cfg['keep']['clean']) {
@@ -2570,7 +2664,7 @@ function show_result($result, $tested, $tested_file, $extra = '', $temp_filename
if (!$SHOW_ONLY_GROUPS || in_array($result, $SHOW_ONLY_GROUPS)) {
echo "$result $tested [$tested_file] $extra\n";
- } else {
+ } else if (!$SHOW_ONLY_GROUPS) {
// Write over the last line to avoid random trailing chars on next echo
echo str_repeat(" ", $line_length), "\r";
}