summaryrefslogtreecommitdiff
path: root/ext/standard/tests/file/bug22414.phpt
blob: 809ce50014d9250d0179aba19f0a377fd62d6249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--TEST--
Bug #22414: passthru() does not read data correctly
--SKIPIF--
<?php
	$cat_path = @shell_exec("which cat");
	if (empty($cat_path)) {
		die('skip cat binary needed for this test is not avaliable');
	}
?>
--POST--
--GET--
--FILE--
<?php
	$php = getenv('TEST_PHP_EXECUTABLE');
	$pwd = realpath(dirname(__FILE__));
	
	/* Regular Data Test */
	passthru($php . ' -r " echo \"HELLO\"; "');

	echo "\n";

	/* Binary Data Test */
	@unlink($pwd . '/passthru_test');
	
	$cmd = $php . ' -r \' passthru("cat ' . $php . '"); \' > ' . $pwd . '/passthru_test';
	exec($cmd);
	
	if (md5_file($php) == md5_file($pwd . '/passthru_test')) {
		echo "Works\n";
	} else {
		echo "Does not work\n";
	}
	
	@unlink($pwd . '/passthru_test');
?>
--EXPECT--
HELLO
Works