test: uv_process_kill(proc, 0) should not kill the process

This commit is contained in:
Ben Noordhuis 2011-10-11 21:00:56 +02:00
parent a3d1f6fd6f
commit acc98ca922
2 changed files with 44 additions and 1 deletions

View File

@ -84,6 +84,7 @@ TEST_DECLARE (spawn_exit_code)
TEST_DECLARE (spawn_stdout)
TEST_DECLARE (spawn_stdin)
TEST_DECLARE (spawn_and_kill)
TEST_DECLARE (spawn_and_ping)
TEST_DECLARE (fs_file_noent)
TEST_DECLARE (fs_file_async)
TEST_DECLARE (fs_file_sync)
@ -214,6 +215,7 @@ TASK_LIST_START
TEST_ENTRY (spawn_stdout)
TEST_ENTRY (spawn_stdin)
TEST_ENTRY (spawn_and_kill)
TEST_ENTRY (spawn_and_ping)
#ifdef _WIN32
TEST_ENTRY (spawn_detect_pipe_name_collisions_on_windows)
TEST_ENTRY (argument_escaping)

View File

@ -160,7 +160,7 @@ TEST_IMPL(spawn_stdout) {
TEST_IMPL(spawn_stdin) {
int r;
int r;
uv_pipe_t out;
uv_pipe_t in;
uv_write_t write_req;
@ -220,6 +220,47 @@ TEST_IMPL(spawn_and_kill) {
}
TEST_IMPL(spawn_and_ping) {
uv_write_t write_req;
uv_pipe_t in, out;
uv_buf_t buf;
int r;
init_process_options("spawn_helper3", exit_cb);
buf = uv_buf_init("TEST", 4);
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);
/* Sending signum == 0 should check if the
* child process is still alive, not kill it.
*/
r = uv_process_kill(&process, 0);
ASSERT(r == 0);
r = uv_write(&write_req, (uv_stream_t*)&in, &buf, 1, write_cb);
ASSERT(r == 0);
r = uv_read_start((uv_stream_t*)&out, on_alloc, on_read);
ASSERT(r == 0);
ASSERT(exit_cb_called == 0);
r = uv_run(uv_default_loop());
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
ASSERT(strcmp(output, "TEST") == 0);
return 0;
}
#ifdef _WIN32
TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) {
int r;