5 if ($x !== $y) { echo "Failed: $y\n"; echo "Got: $x\n";
6 var_dump(debug_backtrace()); }
8 function VERIFY($x) { VS($x != false, true); }
10 //////////////////////////////////////////////////////////////////////
12 $output = shell_exec("echo hello");
13 VS($output, "hello\n");
16 VS(shell_exec("/bin/pwd"), "/tmp\n");
18 pcntl_signal_dispatch();
20 $last_line = exec("echo hello; echo world;", $output, $ret);
21 VS($output, array("hello", "world"));
22 VS($last_line, "world");
26 VS(exec("/bin/pwd"), "/tmp");
30 passthru("echo hello; echo world;", $ret);
36 $last_line = system("echo hello; echo world;", $ret);
37 VS($last_line, "world");
41 VS(system("/bin/pwd"), "/tmp");
43 $errout = tempnam('/tmp', 'vmtesterrout');
47 array(array("pipe", "r"),
49 array("file", $errout, "a"));
51 putenv("inherit_me=please");
52 $process = proc_open('echo $inherit_me', $descriptorspec, $pipes);
53 VERIFY($process != false);
57 VS(proc_close($process), 0);
59 // Ensure that PATH makes it through too
60 $process = proc_open('echo $PATH', $descriptorspec, $pipes);
61 VERIFY($process != false);
63 VERIFY(strlen(fgets($pipes[1])) > 2);
65 VS(proc_close($process), 0);
68 array(array("pipe", "r"),
70 array("file", $errout, "a"));
73 $process = proc_open("sh", $descriptorspec, $pipes, $cwd);
74 VERIFY($process != false);
76 fprintf($pipes[0], "echo Sup");
79 VS(proc_close($process), 0);
82 array(array("pipe", "r"),
84 array("file", $errout, "a"));
85 $process = proc_open('cat', $descriptorspec, $pipes);
86 VERIFY($process != false);
87 VERIFY(proc_terminate($process));
88 // still need to close it, not to leave a zombie behind
91 $process = proc_open('cat', $descriptorspec, $pipes);
92 VERIFY($process != false);
93 $ret = proc_get_status($process);
94 VS($ret['command'], 'cat');
95 VERIFY($ret['pid'] > 0);
96 VERIFY($ret['running']);
97 VERIFY(!$ret['signaled']);
98 VS($ret['exitcode'], -1);
99 VS($ret['termsig'], 0);
100 VS($ret['stopsig'], 0);
101 proc_close($process);
103 VERIFY(proc_nice(0));
105 VS(escapeshellarg("\""), "'\"'");
107 VS(escapeshellcmd("perl \""), "perl \\\"");