test: add platform-specific checks for kill-after-spawn test

This commit is contained in:
Ben Noordhuis 2011-08-02 00:45:16 +02:00
parent 5a15717144
commit aa37c698ee

View File

@ -53,6 +53,20 @@ static void exit_cb(uv_process_t* process, int exit_status, int term_signal) {
}
static void kill_cb(uv_process_t* process, int exit_status, int term_signal) {
printf("exit_cb\n");
exit_cb_called++;
#ifdef _WIN32
ASSERT(exit_status == 1);
ASSERT(term_signal == 0);
#else
ASSERT(exit_status == 0);
ASSERT(term_signal == 15);
#endif
uv_close((uv_handle_t*)process, close_cb);
}
uv_buf_t on_alloc(uv_stream_t* tcp, size_t suggested_size) {
uv_buf_t buf;
buf.base = output + output_used;
@ -80,7 +94,7 @@ void write_cb(uv_write_t* req, int status) {
}
static void init_process_options(char* test) {
static void init_process_options(char* test, uv_exit_cb exit_cb) {
/* Note spawn_helper1 defined in test/run-tests.c */
int r = uv_exepath(exepath, &exepath_size);
ASSERT(r == 0);
@ -95,7 +109,7 @@ static void init_process_options(char* test) {
static void timer_cb(uv_timer_t* handle, int status) {
uv_process_kill(&process, 0);
uv_process_kill(&process, /* SIGTERM */ 15);
uv_close((uv_handle_t*)handle, close_cb);
}
@ -105,7 +119,7 @@ TEST_IMPL(spawn_exit_code) {
uv_init();
init_process_options("spawn_helper1");
init_process_options("spawn_helper1", exit_cb);
r = uv_spawn(&process, options);
ASSERT(r == 0);
@ -126,7 +140,7 @@ TEST_IMPL(spawn_stdout) {
uv_init();
init_process_options("spawn_helper2");
init_process_options("spawn_helper2", exit_cb);
uv_pipe_init(&out);
options.stdout_stream = &out;
@ -159,7 +173,7 @@ int r;
uv_init();
init_process_options("spawn_helper3");
init_process_options("spawn_helper3", exit_cb);
uv_pipe_init(&out);
uv_pipe_init(&in);
@ -193,7 +207,7 @@ TEST_IMPL(spawn_and_kill) {
uv_init();
init_process_options("spawn_helper4");
init_process_options("spawn_helper4", kill_cb);
r = uv_spawn(&process, options);
ASSERT(r == 0);
@ -201,7 +215,7 @@ TEST_IMPL(spawn_and_kill) {
r = uv_timer_init(&timer);
ASSERT(r == 0);
r = uv_timer_start(&timer, timer_cb, 1000, 0);
r = uv_timer_start(&timer, timer_cb, 500, 0);
ASSERT(r == 0);
r = uv_run();