xref: /PHP-5.3/ext/standard/tests/file/bug22414.phpt (revision f1ebec34)
1--TEST--
2Bug #22414 (passthru() does not read data correctly)
3--INI--
4safe_mode=
5output_handler=
6--FILE--
7<?php
8
9	$php = getenv('TEST_PHP_EXECUTABLE');
10	$tmpfile = tempnam(__DIR__, 'phpt');
11	$args = ' -n -dsafe_mode=off ';
12
13	/* Regular Data Test */
14	passthru($php . $args . ' -r " echo \"HELLO\"; "');
15
16	echo "\n";
17
18	/* Binary Data Test */
19
20	if (substr(PHP_OS, 0, 3) != 'WIN') {
21		$cmd = $php . $args . ' -r \"readfile(@getenv(\'TEST_PHP_EXECUTABLE\')); \"';
22		$cmd = $php . $args . ' -r \' passthru("'.$cmd.'"); \' > '.$tmpfile ;
23	} else {
24		$cmd = $php . $args . ' -r \"readfile(@getenv(\\\\\\"TEST_PHP_EXECUTABLE\\\\\\")); \"';
25		$cmd = $php . $args . ' -r " passthru(\''.$cmd.'\');" > '.$tmpfile ;
26	}
27	exec($cmd);
28
29	if (md5_file($php) == md5_file($tmpfile)) {
30		echo "Works\n";
31	} else {
32		echo "Does not work\n";
33	}
34
35	@unlink($tmpfile);
36?>
37--EXPECT--
38HELLO
39Works
40