022.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. STDIN/OUT/ERR stream type
  3. --SKIPIF--
  4. <?php
  5. if (!getenv("TEST_PHP_EXECUTABLE")) die("skip TEST_PHP_EXECUTABLE not set");
  6. if (substr(PHP_OS, 0, 3) == "WIN") die("skip non windows test");
  7. ?>
  8. --FILE--
  9. <?php
  10. $php = getenv("TEST_PHP_EXECUTABLE");
  11. $socket_file = tempnam(sys_get_temp_dir(), pathinfo(__FILE__, PATHINFO_FILENAME) . '.sock');
  12. $test_file = __DIR__ . '/' . pathinfo(__FILE__, PATHINFO_FILENAME) . '.inc';
  13. if (file_exists($socket_file)) {
  14. unlink($socket_file);
  15. }
  16. $socket = stream_socket_server('unix://' . $socket_file);
  17. var_dump($socket);
  18. if (!$socket) {
  19. exit(1);
  20. }
  21. $desc = array(
  22. 0 => $socket,
  23. 1 => STDOUT,
  24. 2 => STDERR,
  25. );
  26. $pipes = array();
  27. $proc = proc_open("$php -n " . escapeshellarg($test_file), $desc, $pipes);
  28. var_dump($proc);
  29. if (!$proc) {
  30. exit(1);
  31. }
  32. $client_socket = stream_socket_client('unix://' . $socket_file);
  33. var_dump($client_socket);
  34. echo stream_get_contents($client_socket);
  35. fclose($client_socket);
  36. proc_terminate($proc);
  37. proc_close($proc);
  38. unlink($socket_file);
  39. ?>
  40. --EXPECTF--
  41. resource(%d) of type (stream)
  42. resource(%d) of type (process)
  43. resource(%d) of type (stream)
  44. resource(%d) of type (stream)
  45. resource(%d) of type (stream)