diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-02-26 20:30:12 +0100 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-02-26 20:30:12 +0100 |
commit | 7bc449c06329716770d4bbf59b252c66ba17a9d1 (patch) | |
tree | f5c1b5d2f6ce734d3377c99c094aebe422ac765a /deps/uv/test | |
parent | e505f91266c80d9846dd4cf2967e6f063772f24f (diff) | |
download | node-new-7bc449c06329716770d4bbf59b252c66ba17a9d1.tar.gz |
deps: upgrade libuv to a0c1d84
Diffstat (limited to 'deps/uv/test')
-rw-r--r-- | deps/uv/test/runner.c | 7 | ||||
-rw-r--r-- | deps/uv/test/test-list.h | 2 | ||||
-rw-r--r-- | deps/uv/test/test-loop-stop.c | 73 |
3 files changed, 80 insertions, 2 deletions
diff --git a/deps/uv/test/runner.c b/deps/uv/test/runner.c index 1b9a980926..6e4b4f6736 100644 --- a/deps/uv/test/runner.c +++ b/deps/uv/test/runner.c @@ -102,7 +102,9 @@ int run_tests(int timeout, int benchmark_output) { continue; } - rewind_cursor(); + if (!tap_output) + rewind_cursor(); + if (!benchmark_output && !tap_output) { log_progress(total, passed, failed, task->task_name); } @@ -115,7 +117,8 @@ int run_tests(int timeout, int benchmark_output) { current++; } - rewind_cursor(); + if (!tap_output) + rewind_cursor(); if (!benchmark_output && !tap_output) { log_progress(total, passed, failed, "Done.\n"); diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 6c7da04ce0..2341463a19 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -23,6 +23,7 @@ TEST_DECLARE (platform_output) TEST_DECLARE (callback_order) TEST_DECLARE (run_once) TEST_DECLARE (run_nowait) +TEST_DECLARE (loop_stop) TEST_DECLARE (barrier_1) TEST_DECLARE (barrier_2) TEST_DECLARE (barrier_3) @@ -230,6 +231,7 @@ TASK_LIST_START #endif TEST_ENTRY (run_once) TEST_ENTRY (run_nowait) + TEST_ENTRY (loop_stop) TEST_ENTRY (barrier_1) TEST_ENTRY (barrier_2) TEST_ENTRY (barrier_3) diff --git a/deps/uv/test/test-loop-stop.c b/deps/uv/test/test-loop-stop.c new file mode 100644 index 0000000000..db52a094e7 --- /dev/null +++ b/deps/uv/test/test-loop-stop.c @@ -0,0 +1,73 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "uv.h" +#include "task.h" + +static uv_prepare_t prepare_handle; +static uv_timer_t timer_handle; +static int prepare_called = 0; +static int timer_called = 0; +static int num_ticks = 10; + + +static void prepare_cb(uv_prepare_t* handle, int status) { + ASSERT(handle == &prepare_handle); + ASSERT(status == 0); + prepare_called++; + if (prepare_called == num_ticks) + uv_prepare_stop(handle); +} + + +static void timer_cb(uv_timer_t* handle, int status) { + ASSERT(handle == &timer_handle); + ASSERT(status == 0); + timer_called++; + if (timer_called == 1) + uv_stop(uv_default_loop()); + else if (timer_called == num_ticks) + uv_timer_stop(handle); +} + + +TEST_IMPL(loop_stop) { + int r; + uv_prepare_init(uv_default_loop(), &prepare_handle); + uv_prepare_start(&prepare_handle, prepare_cb); + uv_timer_init(uv_default_loop(), &timer_handle); + uv_timer_start(&timer_handle, timer_cb, 100, 100); + + r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); + ASSERT(r != 0); + ASSERT(timer_called == 1); + + r = uv_run(uv_default_loop(), UV_RUN_NOWAIT); + ASSERT(r != 0); + ASSERT(prepare_called == 3); + + r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); + ASSERT(r == 0); + ASSERT(timer_called == 10); + ASSERT(prepare_called == 10); + + return 0; +} |