Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
test: process should not wait for stdio before terminating
Browse files Browse the repository at this point in the history
  • Loading branch information
seebees authored and bnoordhuis committed Nov 23, 2011
1 parent b52b8c7 commit 59f9a73
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/test-list.h
Expand Up @@ -90,6 +90,7 @@ TEST_DECLARE (spawn_exit_code)
TEST_DECLARE (spawn_stdout)
TEST_DECLARE (spawn_stdin)
TEST_DECLARE (spawn_and_kill)
TEST_DECLARE (spawn_and_kill_with_std)
TEST_DECLARE (spawn_and_ping)
TEST_DECLARE (kill)
TEST_DECLARE (fs_file_noent)
Expand Down Expand Up @@ -241,6 +242,7 @@ TASK_LIST_START
TEST_ENTRY (spawn_stdout)
TEST_ENTRY (spawn_stdin)
TEST_ENTRY (spawn_and_kill)
TEST_ENTRY (spawn_and_kill_with_std)
TEST_ENTRY (spawn_and_ping)
TEST_ENTRY (kill)
#ifdef _WIN32
Expand Down
31 changes: 31 additions & 0 deletions test/test-spawn.c
Expand Up @@ -231,6 +231,37 @@ TEST_IMPL(spawn_and_kill) {
}


TEST_IMPL(spawn_and_kill_with_std) {
int r;
uv_pipe_t out;
uv_pipe_t in;

init_process_options("spawn_helper4", kill_cb);

uv_pipe_init(uv_default_loop(), &out, 0);
uv_pipe_init(uv_default_loop(), &in, 0);
options.stdout_stream = &out;
options.stdin_stream = ∈

r = uv_spawn(uv_default_loop(), &process, options);
ASSERT(r == 0);

r = uv_timer_init(uv_default_loop(), &timer);
ASSERT(r == 0);

r = uv_timer_start(&timer, timer_cb, 500, 0);
ASSERT(r == 0);

r = uv_run(uv_default_loop());
ASSERT(r == 0);

ASSERT(exit_cb_called == 1);
ASSERT(close_cb_called == 2); /* Once for process and once for timer. */

return 0;
}


TEST_IMPL(spawn_and_ping) {
uv_write_t write_req;
uv_pipe_t in, out;
Expand Down

0 comments on commit 59f9a73

Please sign in to comment.