diff options
author | Pierre Joye <pajoye@php.net> | 2006-05-03 21:33:44 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2006-05-03 21:33:44 +0000 |
commit | 9e4283227d3a5bce8d28a7075f6e5c3373bb22b6 (patch) | |
tree | 84b1a1719efdae8059c7b7caecfc8b1bd064c0c3 /run-tests.php | |
parent | 24f070186760b462d84e53759f447c82beebba7e (diff) | |
download | php-git-9e4283227d3a5bce8d28a7075f6e5c3373bb22b6.tar.gz |
- add support for POST_RAW, allow to pass raw POST data
- add support for TEST_PHP_CGI_EXECUTABLE env variable, it is now possible
to set both TEST_PHP_EXECUTABLE and CGI
Diffstat (limited to 'run-tests.php')
-rwxr-xr-x | run-tests.php | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/run-tests.php b/run-tests.php index f9ffbb5a01..ad72c02052 100755 --- a/run-tests.php +++ b/run-tests.php @@ -112,6 +112,15 @@ if (getenv('TEST_PHP_EXECUTABLE')) { $environment['TEST_PHP_EXECUTABLE'] = $php; } +if (getenv('TEST_PHP_CGI_EXECUTABLE')) { + $php_cgi = getenv('TEST_PHP_CGI_EXECUTABLE'); + if ($php_cgi=='auto') { + $php_cgi = $cwd.'/sapi/cgi/php'; + putenv("TEST_PHP_CGI_EXECUTABLE=$php_cgi"); + } + $environment['TEST_PHP_CGI_EXECUTABLE'] = $php_cgi; +} + if ($argc !=2 || ($argv[1] != '-h' && $argv[1] != '-help' && $argv != '--help')) { if (empty($php) || !file_exists($php)) { @@ -919,7 +928,11 @@ function run_test($php, $file, $env) $temp_filenames = null; $org_file = $file; - + + if (isset($env['TEST_PHP_CGI_EXECUTABLE'])) { + $php_cgi = $env['TEST_PHP_CGI_EXECUTABLE']; + } + if (is_array($file)) $file = $file[0]; if ($DETAILED) echo " @@ -932,7 +945,9 @@ TEST $file 'TEST' => '', 'SKIPIF' => '', 'GET' => '', + 'POST_RAW' => '', 'POST' => '', + 'UPLOAD' => '', 'ARGS' => '', ); @@ -957,7 +972,7 @@ TEST $file $line = fgets($fp); // Match the beginning of a section. - if (preg_match('/^--([A-Z]+)--/', $line, $r)) { + if (preg_match('/^--([A-Z_]+)--/', $line, $r)) { $section = $r[1]; $section_text[$section] = ''; $secfile = $section == 'FILE' || $section == 'FILEEOF'; @@ -1019,8 +1034,11 @@ TEST $file $tested = trim($section_text['TEST']); /* For GET/POST tests, check if cgi sapi is available and if it is, use it. */ - if ((!empty($section_text['GET']) || !empty($section_text['POST']))) { - if (!strncasecmp(PHP_OS, "win", 3) && file_exists(dirname($php) ."/php-cgi.exe")) { + if (!empty($section_text['GET']) || !empty($section_text['POST']) || !empty($section_text['POST_RAW'])) { + if (isset($php_cgi)) { + $old_php = $php; + $php = $php_cgi .' -C '; + } elseif (!strncasecmp(PHP_OS, "win", 3) && file_exists(dirname($php) ."/php-cgi.exe")) { $old_php = $php; $php = realpath(dirname($php) ."/php-cgi.exe") .' -C '; } elseif (file_exists("./sapi/cgi/php")) { @@ -1256,18 +1274,39 @@ TEST $file $args = $section_text['ARGS'] ? ' -- '.$section_text['ARGS'] : ''; - if (array_key_exists('POST', $section_text) && !empty($section_text['POST'])) { + if (array_key_exists('POST_RAW', $section_text) && !empty($section_text['POST_RAW'])) { + $post = trim($section_text['POST_RAW']); + $raw_lines = explode("\n", $post); + + $request = ''; + foreach ($raw_lines as $line) { + if (empty($env['CONTENT_TYPE']) && eregi('^(Content-Type:)(.*)', $line, $res)) { + $env['CONTENT_TYPE'] = trim(str_replace("\r", '', $res[2])); + continue; + } + $request .= $line . "\n"; + } + + $env['CONTENT_LENGTH'] = strlen($request); + $env['REQUEST_METHOD'] = 'POST'; + + if (empty($request)) { + return 'BORKED'; + } + save_text($tmp_post, $request); + $cmd = "$php$pass_options$ini_settings -f \"$test_file\" 2>&1 < $tmp_post"; + } elseif (array_key_exists('POST', $section_text) && !empty($section_text['POST'])) { $post = trim($section_text['POST']); save_text($tmp_post, $post); - $content_length = strlen($post); + $content_length = strlen($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"; - + save_text('/home/pierre/cmd.txt', $cmd); } else { $env['REQUEST_METHOD'] = 'GET'; |