From 1cd9642cbb2c6d2acac80d686e1471d4daa20048 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sat, 2 Jun 2012 21:34:21 +0200 Subject: [PATCH] test: stdin/out/err should be set to /dev/null when ignored --- test/run-tests.c | 12 ++++++++++++ test/test-list.h | 2 ++ test/test-spawn.c | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/test/run-tests.c b/test/run-tests.c index 37f91da4..76255a62 100644 --- a/test/run-tests.c +++ b/test/run-tests.c @@ -120,5 +120,17 @@ static int maybe_run_test(int argc, char **argv) { return 1; } + if (strcmp(argv[1], "spawn_helper6") == 0) { + int r; + + r = fprintf(stdout, "hello world\n"); + ASSERT(r > 0); + + r = fprintf(stderr, "hello errworld\n"); + ASSERT(r > 0); + + return 1; + } + return run_test(argv[1], TEST_TIMEOUT, 0); } diff --git a/test/test-list.h b/test/test-list.h index 58f13d66..acb15150 100644 --- a/test/test-list.h +++ b/test/test-list.h @@ -120,6 +120,7 @@ TEST_DECLARE (spawn_exit_code) TEST_DECLARE (spawn_stdout) TEST_DECLARE (spawn_stdin) TEST_DECLARE (spawn_stdio_greater_than_3) +TEST_DECLARE (spawn_ignored_stdio) TEST_DECLARE (spawn_and_kill) TEST_DECLARE (spawn_detached) TEST_DECLARE (spawn_and_kill_with_std) @@ -337,6 +338,7 @@ TASK_LIST_START TEST_ENTRY (spawn_stdout) TEST_ENTRY (spawn_stdin) TEST_ENTRY (spawn_stdio_greater_than_3) + TEST_ENTRY (spawn_ignored_stdio) TEST_ENTRY (spawn_and_kill) TEST_ENTRY (spawn_detached) TEST_ENTRY (spawn_and_kill_with_std) diff --git a/test/test-spawn.c b/test/test-spawn.c index 60430438..51ed2e59 100644 --- a/test/test-spawn.c +++ b/test/test-spawn.c @@ -329,6 +329,27 @@ TEST_IMPL(spawn_stdio_greater_than_3) { } +TEST_IMPL(spawn_ignored_stdio) { + int r; + + init_process_options("spawn_helper6", exit_cb); + + options.stdio = NULL; + options.stdio_count = 0; + + r = uv_spawn(uv_default_loop(), &process, options); + ASSERT(r == 0); + + r = uv_run(uv_default_loop()); + ASSERT(r == 0); + + ASSERT(exit_cb_called == 1); + ASSERT(close_cb_called == 1); + + return 0; +} + + TEST_IMPL(spawn_and_kill) { int r;