diff options
author | Bert Belder <bertbelder@gmail.com> | 2012-08-20 18:41:07 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2012-08-20 18:41:31 +0200 |
commit | 6bec5440ebced1bc2b91c1c9f3fbc7a361995331 (patch) | |
tree | c30db69d8ffd4d5dcd2469052308c7003220b2c6 /deps/uv/test | |
parent | 772b3bf4c806f881528718d1e0240392d0228c19 (diff) | |
download | android-node-v8-6bec5440ebced1bc2b91c1c9f3fbc7a361995331.tar.gz android-node-v8-6bec5440ebced1bc2b91c1c9f3fbc7a361995331.tar.bz2 android-node-v8-6bec5440ebced1bc2b91c1c9f3fbc7a361995331.zip |
uv: upgrade to 8073a26
Diffstat (limited to 'deps/uv/test')
-rw-r--r-- | deps/uv/test/benchmark-fs-stat.c | 2 | ||||
-rw-r--r-- | deps/uv/test/benchmark-sizes.c | 1 | ||||
-rw-r--r-- | deps/uv/test/runner-win.c | 8 | ||||
-rw-r--r-- | deps/uv/test/runner.c | 2 | ||||
-rw-r--r-- | deps/uv/test/test-counters-init.c | 215 | ||||
-rw-r--r-- | deps/uv/test/test-delayed-accept.c | 9 | ||||
-rw-r--r-- | deps/uv/test/test-list.h | 10 | ||||
-rw-r--r-- | deps/uv/test/test-signal.c | 162 | ||||
-rw-r--r-- | deps/uv/test/test-spawn.c | 56 | ||||
-rw-r--r-- | deps/uv/test/test-tcp-unexpected-read.c | 2 |
10 files changed, 213 insertions, 254 deletions
diff --git a/deps/uv/test/benchmark-fs-stat.c b/deps/uv/test/benchmark-fs-stat.c index e6b8a637b1..ea5b597536 100644 --- a/deps/uv/test/benchmark-fs-stat.c +++ b/deps/uv/test/benchmark-fs-stat.c @@ -26,7 +26,7 @@ #include <stdlib.h> #define NUM_SYNC_REQS (10 * 1e5) -#define NUM_ASYNC_REQS (1 * 1e5) +#define NUM_ASYNC_REQS (1 * (int) 1e5) #define MAX_CONCURRENT_REQS 32 #define sync_stat(req, path) \ diff --git a/deps/uv/test/benchmark-sizes.c b/deps/uv/test/benchmark-sizes.c index b9cf74f2fb..8ccf10ee47 100644 --- a/deps/uv/test/benchmark-sizes.c +++ b/deps/uv/test/benchmark-sizes.c @@ -36,6 +36,7 @@ BENCHMARK_IMPL(sizes) { LOGF("uv_idle_t: %u bytes\n", (unsigned int) sizeof(uv_idle_t)); LOGF("uv_async_t: %u bytes\n", (unsigned int) sizeof(uv_async_t)); LOGF("uv_timer_t: %u bytes\n", (unsigned int) sizeof(uv_timer_t)); + LOGF("uv_fs_poll_t: %u bytes\n", (unsigned int) sizeof(uv_fs_poll_t)); LOGF("uv_fs_event_t: %u bytes\n", (unsigned int) sizeof(uv_fs_event_t)); LOGF("uv_process_t: %u bytes\n", (unsigned int) sizeof(uv_process_t)); LOGF("uv_poll_t: %u bytes\n", (unsigned int) sizeof(uv_poll_t)); diff --git a/deps/uv/test/runner-win.c b/deps/uv/test/runner-win.c index ad36719c8f..2f44ff33a9 100644 --- a/deps/uv/test/runner-win.c +++ b/deps/uv/test/runner-win.c @@ -103,8 +103,8 @@ int process_start(char *name, char *part, process_info_t *p) { goto error; if (part) { - if (_snwprintf((wchar_t*)args, - sizeof(args) / sizeof(wchar_t), + if (_snwprintf((WCHAR*)args, + sizeof(args) / sizeof(WCHAR), L"\"%s\" %S %S", image, name, @@ -112,8 +112,8 @@ int process_start(char *name, char *part, process_info_t *p) { goto error; } } else { - if (_snwprintf((wchar_t*)args, - sizeof(args) / sizeof(wchar_t), + if (_snwprintf((WCHAR*)args, + sizeof(args) / sizeof(WCHAR), L"\"%s\" %S", image, name) < 0) { diff --git a/deps/uv/test/runner.c b/deps/uv/test/runner.c index 5f878a4936..b34acc8430 100644 --- a/deps/uv/test/runner.c +++ b/deps/uv/test/runner.c @@ -42,7 +42,7 @@ const char* fmt(double d) { char* p; p = (char *) calloc(1, 32) + 31; /* leaks memory */ - v = d; + v = (uint64_t) d; #if 0 /* works but we don't care about fractional precision */ if (d - v >= 0.01) { diff --git a/deps/uv/test/test-counters-init.c b/deps/uv/test/test-counters-init.c deleted file mode 100644 index 6318684246..0000000000 --- a/deps/uv/test/test-counters-init.c +++ /dev/null @@ -1,215 +0,0 @@ -/* 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. - */ -#define UNIX (defined(__unix__) || defined(__POSIX__) || defined(__APPLE__)) -#include "task.h" -#include "uv.h" -#include <fcntl.h> - -#if UNIX -#include <unistd.h> /* unlink, rmdir, etc. */ -#else -# include <direct.h> -# include <io.h> -# define unlink _unlink -# define rmdir _rmdir -# define stat _stati64 -# define open _open -# define write _write -# define lseek _lseek -# define close _close -#endif - -static char exepath[1024]; -static size_t exepath_size = 1024; -static char* args[3]; -static uv_fs_t open_req; -static uv_tcp_t tcp; -static uv_udp_t udp; -static uv_pipe_t uvpipe; -static uv_tty_t tty; -static uv_prepare_t prepare; -static uv_check_t check; -static uv_idle_t idle; -static uv_async_t async; -static uv_timer_t timer; -static uv_fs_event_t fs_event; -static uv_process_t process; -static uv_process_options_t options; -static uv_fs_t fs_req; - -static void exit_cb(uv_process_t* process, int exit_status, int term_signal) { - ASSERT(exit_status == 1); - ASSERT(term_signal == 0); - uv_close((uv_handle_t*)process, NULL); -} - -static void init_process_options(char* test, uv_exit_cb exit_cb) { - int r = uv_exepath(exepath, &exepath_size); - ASSERT(r == 0); - exepath[exepath_size] = '\0'; - args[0] = exepath; - args[1] = test; - args[2] = NULL; - options.file = exepath; - options.args = args; - options.exit_cb = exit_cb; -} - -static void create_dir(uv_loop_t* loop, const char* name) { - int r; - uv_fs_t req; - r = uv_fs_rmdir(loop, &req, name, NULL); - r = uv_fs_mkdir(loop, &req, name, 0755, NULL); - ASSERT(r == 0 || uv_last_error(loop).code == UV_EEXIST); - uv_fs_req_cleanup(&req); -} - -static void create_cb(uv_fs_t* req) { - ASSERT(req == &open_req); - ASSERT(req->fs_type == UV_FS_OPEN); - ASSERT(req->result != -1); - uv_fs_req_cleanup(req); - unlink("test_file"); -} - -TEST_IMPL(counters_init) { - int r; - uint64_t eio_init_prev; - uint64_t req_init_prev; - uint64_t handle_init_prev; - uint64_t stream_init_prev; - uint64_t tcp_init_prev; - uint64_t udp_init_prev; - uint64_t pipe_init_prev; - uint64_t tty_init_prev; - uint64_t prepare_init_prev; - uint64_t check_init_prev; - uint64_t idle_init_prev; - uint64_t async_init_prev; - uint64_t timer_init_prev; - uint64_t process_init_prev; - uint64_t fs_event_init_prev; - - /* req_init and eio_init test by uv_fs_open() */ - unlink("test_file"); - req_init_prev = uv_default_loop()->counters.req_init; - eio_init_prev = uv_default_loop()->counters.eio_init; - r = uv_fs_open(uv_default_loop(), &open_req, "test_file", O_WRONLY | O_CREAT, - S_IREAD | S_IWRITE, create_cb); - ASSERT(r == 0); - ASSERT(open_req.result == 0); - ASSERT(uv_default_loop()->counters.req_init == ++req_init_prev); -#ifndef _WIN32 - ASSERT(uv_default_loop()->counters.eio_init == ++eio_init_prev); -#endif - - /* tcp_init, stream_init and handle_init test by uv_tcp_init() */ - tcp_init_prev = uv_default_loop()->counters.tcp_init; - stream_init_prev = uv_default_loop()->counters.stream_init; - handle_init_prev = uv_default_loop()->counters.handle_init; - r = uv_tcp_init(uv_default_loop(), &tcp); - ASSERT(r == 0); - ASSERT(uv_default_loop()->counters.tcp_init == ++tcp_init_prev); - ASSERT(uv_default_loop()->counters.stream_init == ++stream_init_prev); - ASSERT(uv_default_loop()->counters.handle_init == ++handle_init_prev); - uv_close((uv_handle_t*)&tcp, NULL); - - /* udp_init test by uv_udp_init() */ - udp_init_prev = uv_default_loop()->counters.udp_init; - r = uv_udp_init(uv_default_loop(), &udp); - ASSERT(r == 0); - ASSERT(uv_default_loop()->counters.udp_init == ++udp_init_prev); - uv_close((uv_handle_t*)&udp, NULL); - - /* pipe_init uv_pipe_init() */ - pipe_init_prev = uv_default_loop()->counters.pipe_init; - uv_pipe_init(uv_default_loop(), &uvpipe, 0); - ASSERT(r == 0); - ASSERT(uv_default_loop()->counters.pipe_init == ++pipe_init_prev); - uv_close((uv_handle_t*)&uvpipe, NULL); - - /* tty_init test by uv_tty_init()*/ - tty_init_prev = uv_default_loop()->counters.tty_init; - r = uv_tty_init(uv_default_loop(), &tty, 1, 0); - /* uv_tty_init() always returns -1 in run_test in Windows - so that we avoid to check return value. - */ -#ifndef _WIN32 - ASSERT(r == 0); - uv_close((uv_handle_t*)&tty, NULL); -#endif - ASSERT(uv_default_loop()->counters.tty_init == ++tty_init_prev); - - /* prepare_init test by uv_prepare_init() */ - prepare_init_prev = uv_default_loop()->counters.prepare_init; - r = uv_prepare_init(uv_default_loop(), &prepare); - ASSERT(r == 0); - ASSERT(uv_default_loop()->counters.prepare_init == ++prepare_init_prev); - uv_close((uv_handle_t*)&prepare, NULL); - - /* check_init test by uv_check_init() */ - check_init_prev = uv_default_loop()->counters.check_init; - r = uv_check_init(uv_default_loop(), &check); - ASSERT(r == 0); - ASSERT(uv_default_loop()->counters.check_init == ++check_init_prev); - uv_close((uv_handle_t*)&check, NULL); - - /* idle_init test by uv_idle_init() */ - idle_init_prev = uv_default_loop()->counters.idle_init; - r = uv_idle_init(uv_default_loop(), &idle); - ASSERT(r == 0); - ASSERT(uv_default_loop()->counters.idle_init == ++idle_init_prev); - uv_close((uv_handle_t*)&idle, NULL); - - /* async_init test by uv_async_init() */ - async_init_prev = uv_default_loop()->counters.async_init; - r = uv_async_init(uv_default_loop(), &async, NULL); - ASSERT(r == 0); - ASSERT(uv_default_loop()->counters.async_init == ++async_init_prev); - uv_close((uv_handle_t*)&async, NULL); - - /* timer_init test by uv_timer_init() */ - timer_init_prev = uv_default_loop()->counters.timer_init; - r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); - ASSERT(uv_default_loop()->counters.timer_init == ++timer_init_prev); - uv_close((uv_handle_t*)&timer, NULL); - - /* process_init test by uv_spawn() */ - process_init_prev = uv_default_loop()->counters.process_init; - init_process_options("spawn_helper1", exit_cb); - r = uv_spawn(uv_default_loop(), &process, options); - ASSERT(r == 0); - ASSERT(uv_default_loop()->counters.process_init == ++process_init_prev); - r = uv_run(uv_default_loop()); - ASSERT(r == 0); - - /* fs_event_init test by uv_fs_event_init() */ - create_dir(uv_default_loop(), "watch_dir"); - fs_event_init_prev = uv_default_loop()->counters.fs_event_init; - r = uv_fs_event_init(uv_default_loop(), &fs_event, "watch_dir", NULL, 0); - ASSERT(r == 0); - ASSERT(uv_default_loop()->counters.fs_event_init == ++fs_event_init_prev); - uv_fs_rmdir(uv_default_loop(), &fs_req, "watch_dir", NULL); - uv_fs_req_cleanup(&fs_req); - - return 0; -} diff --git a/deps/uv/test/test-delayed-accept.c b/deps/uv/test/test-delayed-accept.c index 990444ef37..672672a900 100644 --- a/deps/uv/test/test-delayed-accept.c +++ b/deps/uv/test/test-delayed-accept.c @@ -50,7 +50,6 @@ static void close_cb(uv_handle_t* handle) { static void do_accept(uv_timer_t* timer_handle, int status) { uv_tcp_t* server; uv_tcp_t* accepted_handle = (uv_tcp_t*)malloc(sizeof *accepted_handle); - uint64_t tcpcnt; int r; ASSERT(timer_handle != NULL); @@ -60,15 +59,10 @@ static void do_accept(uv_timer_t* timer_handle, int status) { r = uv_tcp_init(uv_default_loop(), accepted_handle); ASSERT(r == 0); - /* Test to that uv_default_loop()->counters.tcp_init does not increase across the uv_accept. */ - tcpcnt = uv_default_loop()->counters.tcp_init; - server = (uv_tcp_t*)timer_handle->data; r = uv_accept((uv_stream_t*)server, (uv_stream_t*)accepted_handle); ASSERT(r == 0); - ASSERT(uv_default_loop()->counters.tcp_init == tcpcnt); - do_accept_called++; /* Immediately close the accepted handle. */ @@ -115,9 +109,6 @@ static void start_server() { r = uv_tcp_init(uv_default_loop(), server); ASSERT(r == 0); - ASSERT(uv_default_loop()->counters.tcp_init == 1); - ASSERT(uv_default_loop()->counters.handle_init == 1); - r = uv_tcp_bind(server, addr); ASSERT(r == 0); diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 8d201c9223..47e47eedd5 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -123,6 +123,7 @@ TEST_DECLARE (getsockname_tcp) TEST_DECLARE (getsockname_udp) TEST_DECLARE (fail_always) TEST_DECLARE (pass_always) +TEST_DECLARE (spawn_fails) TEST_DECLARE (spawn_exit_code) TEST_DECLARE (spawn_stdout) TEST_DECLARE (spawn_stdin) @@ -174,11 +175,12 @@ TEST_DECLARE (thread_rwlock) TEST_DECLARE (thread_create) TEST_DECLARE (strlcpy) TEST_DECLARE (strlcat) -TEST_DECLARE (counters_init) TEST_DECLARE (dlerror) TEST_DECLARE (poll_duplex) TEST_DECLARE (poll_unidirectional) TEST_DECLARE (poll_close) +TEST_DECLARE (we_get_signal) +TEST_DECLARE (we_get_signals) #ifdef _WIN32 TEST_DECLARE (spawn_detect_pipe_name_collisions_on_windows) TEST_DECLARE (argument_escaping) @@ -350,6 +352,7 @@ TASK_LIST_START TEST_ENTRY (poll_unidirectional) TEST_ENTRY (poll_close) + TEST_ENTRY (spawn_fails) TEST_ENTRY (spawn_exit_code) TEST_ENTRY (spawn_stdout) TEST_ENTRY (spawn_stdin) @@ -364,6 +367,10 @@ TASK_LIST_START TEST_ENTRY (spawn_stdout_to_file) TEST_ENTRY (fs_poll) TEST_ENTRY (kill) + + TEST_ENTRY (we_get_signal) + TEST_ENTRY (we_get_signals) + #ifdef _WIN32 TEST_ENTRY (spawn_detect_pipe_name_collisions_on_windows) TEST_ENTRY (argument_escaping) @@ -411,7 +418,6 @@ TASK_LIST_START TEST_ENTRY (thread_create) TEST_ENTRY (strlcpy) TEST_ENTRY (strlcat) - TEST_ENTRY (counters_init) TEST_ENTRY (dlerror) #if 0 /* These are for testing the test runner. */ diff --git a/deps/uv/test/test-signal.c b/deps/uv/test/test-signal.c new file mode 100644 index 0000000000..b39bc24460 --- /dev/null +++ b/deps/uv/test/test-signal.c @@ -0,0 +1,162 @@ +/* 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" + +#ifdef _WIN32 + +TEST_IMPL(we_get_signal) { + return 0; +} + + +TEST_IMPL(we_get_signals) { + return 0; +} + +#else /* !_WIN32 */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <errno.h> + +/* This test does not pretend to be cross-platform. */ +#include <pthread.h> +#include <signal.h> +#include <unistd.h> + +#define NSIGNALS 10 + +struct timer_ctx { + unsigned int ncalls; + uv_timer_t handle; + int signum; +}; + +struct signal_ctx { + enum { CLOSE, STOP } stop_or_close; + unsigned int ncalls; + uv_signal_t handle; + int signum; +}; + + +static void signal_cb(uv_signal_t* handle, int signum) { + struct signal_ctx* ctx = container_of(handle, struct signal_ctx, handle); + ASSERT(signum == ctx->signum); + + if (++ctx->ncalls == NSIGNALS) { + if (ctx->stop_or_close == STOP) + uv_signal_stop(handle); + else if (ctx->stop_or_close == CLOSE) + uv_close((uv_handle_t*)handle, NULL); + else + ASSERT(0); + } +} + + +static void timer_cb(uv_timer_t* handle, int status) { + struct timer_ctx* ctx = container_of(handle, struct timer_ctx, handle); + + raise(ctx->signum); + + if (++ctx->ncalls == NSIGNALS) + uv_close((uv_handle_t*)handle, NULL); +} + + +static void start_watcher(uv_loop_t* loop, int signum, struct signal_ctx* ctx) { + ctx->ncalls = 0; + ctx->signum = signum; + ctx->stop_or_close = CLOSE; + ASSERT(0 == uv_signal_init(loop, &ctx->handle)); + ASSERT(0 == uv_signal_start(&ctx->handle, signal_cb, signum)); +} + + +static void start_timer(uv_loop_t* loop, int signum, struct timer_ctx* ctx) { + ctx->ncalls = 0; + ctx->signum = signum; + ASSERT(0 == uv_timer_init(loop, &ctx->handle)); + ASSERT(0 == uv_timer_start(&ctx->handle, timer_cb, 5, 5)); +} + + +TEST_IMPL(we_get_signal) { + struct signal_ctx sc; + struct timer_ctx tc; + uv_loop_t* loop; + + loop = uv_default_loop(); + start_timer(loop, SIGCHLD, &tc); + start_watcher(loop, SIGCHLD, &sc); + sc.stop_or_close = STOP; /* stop, don't close the signal handle */ + ASSERT(0 == uv_run(loop)); + ASSERT(tc.ncalls == NSIGNALS); + ASSERT(sc.ncalls == NSIGNALS); + + start_timer(loop, SIGCHLD, &tc); + ASSERT(0 == uv_run(loop)); + ASSERT(tc.ncalls == NSIGNALS); + ASSERT(sc.ncalls == NSIGNALS); + + sc.ncalls = 0; + sc.stop_or_close = CLOSE; /* now close it when it's done */ + uv_signal_start(&sc.handle, signal_cb, SIGCHLD); + + start_timer(loop, SIGCHLD, &tc); + ASSERT(0 == uv_run(loop)); + ASSERT(tc.ncalls == NSIGNALS); + ASSERT(sc.ncalls == NSIGNALS); + + return 0; +} + + +TEST_IMPL(we_get_signals) { + struct signal_ctx sc[4]; + struct timer_ctx tc[2]; + uv_loop_t* loop; + unsigned int i; + + loop = uv_default_loop(); + start_watcher(loop, SIGUSR1, sc + 0); + start_watcher(loop, SIGUSR1, sc + 1); + start_watcher(loop, SIGUSR2, sc + 2); + start_watcher(loop, SIGUSR2, sc + 3); + start_timer(loop, SIGUSR1, tc + 0); + start_timer(loop, SIGUSR2, tc + 1); + ASSERT(0 == uv_run(loop)); + + for (i = 0; i < ARRAY_SIZE(sc); i++) + ASSERT(sc[i].ncalls == NSIGNALS); + + for (i = 0; i < ARRAY_SIZE(tc); i++) + ASSERT(tc[i].ncalls == NSIGNALS); + + return 0; +} + +#endif /* _WIN32 */ diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c index 06b211bcd8..8cbb01c3ef 100644 --- a/deps/uv/test/test-spawn.c +++ b/deps/uv/test/test-spawn.c @@ -65,7 +65,7 @@ static void exit_cb_failure_expected(uv_process_t* process, int exit_status, int term_signal) { printf("exit_cb\n"); exit_cb_called++; - ASSERT(exit_status == 127); + ASSERT(exit_status == -1); ASSERT(term_signal == 0); uv_close((uv_handle_t*)process, close_cb); } @@ -145,6 +145,17 @@ static void timer_cb(uv_timer_t* handle, int status) { } +TEST_IMPL(spawn_fails) { + init_process_options("", exit_cb_failure_expected); + options.file = options.args[0] = "program-that-had-better-not-exist"; + ASSERT(0 == uv_spawn(uv_default_loop(), &process, options)); + ASSERT(0 != uv_is_active((uv_handle_t*)&process)); + ASSERT(0 == uv_run(uv_default_loop())); + ASSERT(uv_last_error(uv_default_loop()).code == UV_ENOENT); + return 0; +} + + TEST_IMPL(spawn_exit_code) { int r; @@ -578,11 +589,11 @@ TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) { } -wchar_t* make_program_args(char** args, int verbatim_arguments); -wchar_t* quote_cmd_arg(const wchar_t *source, wchar_t *target); +uv_err_t make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr); +WCHAR* quote_cmd_arg(const WCHAR *source, WCHAR *target); TEST_IMPL(argument_escaping) { - const wchar_t* test_str[] = { + const WCHAR* test_str[] = { L"HelloWorld", L"Hello World", L"Hello\"World", @@ -594,12 +605,13 @@ TEST_IMPL(argument_escaping) { L"c:\\path\\to\\node.exe --eval \"require('c:\\\\path\\\\to\\\\test.js')\"" }; const int count = sizeof(test_str) / sizeof(*test_str); - wchar_t** test_output; - wchar_t* command_line; - wchar_t** cracked; + WCHAR** test_output; + WCHAR* command_line; + WCHAR** cracked; size_t total_size = 0; int i; int num_args; + uv_err_t result; char* verbatim[] = { "cmd.exe", @@ -607,18 +619,18 @@ TEST_IMPL(argument_escaping) { "c:\\path\\to\\node.exe --eval \"require('c:\\\\path\\\\to\\\\test.js')\"", NULL }; - wchar_t* verbatim_output; - wchar_t* non_verbatim_output; + WCHAR* verbatim_output; + WCHAR* non_verbatim_output; - test_output = calloc(count, sizeof(wchar_t*)); + test_output = calloc(count, sizeof(WCHAR*)); for (i = 0; i < count; ++i) { - test_output[i] = calloc(2 * (wcslen(test_str[i]) + 2), sizeof(wchar_t)); + test_output[i] = calloc(2 * (wcslen(test_str[i]) + 2), sizeof(WCHAR)); quote_cmd_arg(test_str[i], test_output[i]); wprintf(L"input : %s\n", test_str[i]); wprintf(L"output: %s\n", test_output[i]); total_size += wcslen(test_output[i]) + 1; } - command_line = calloc(total_size + 1, sizeof(wchar_t)); + command_line = calloc(total_size + 1, sizeof(WCHAR)); for (i = 0; i < count; ++i) { wcscat(command_line, test_output[i]); wcscat(command_line, L" "); @@ -638,8 +650,10 @@ TEST_IMPL(argument_escaping) { free(test_output[i]); } - verbatim_output = make_program_args(verbatim, 1); - non_verbatim_output = make_program_args(verbatim, 0); + result = make_program_args(verbatim, 1, &verbatim_output); + ASSERT(result.code == UV_OK); + result = make_program_args(verbatim, 0, &non_verbatim_output); + ASSERT(result.code == UV_OK); wprintf(L" verbatim_output: %s\n", verbatim_output); wprintf(L"non_verbatim_output: %s\n", non_verbatim_output); @@ -653,7 +667,7 @@ TEST_IMPL(argument_escaping) { return 0; } -wchar_t* make_program_env(char** env_block); +WCHAR* make_program_env(char** env_block); TEST_IMPL(environment_creation) { int i; @@ -666,22 +680,22 @@ TEST_IMPL(environment_creation) { NULL }; - wchar_t expected[512]; - wchar_t* ptr = expected; - wchar_t* result; - wchar_t* str; + WCHAR expected[512]; + WCHAR* ptr = expected; + WCHAR* result; + WCHAR* str; for (i = 0; i < sizeof(environment) / sizeof(environment[0]) - 1; i++) { ptr += uv_utf8_to_utf16(environment[i], ptr, expected + sizeof(expected) - ptr); } memcpy(ptr, L"SYSTEMROOT=", sizeof(L"SYSTEMROOT=")); - ptr += sizeof(L"SYSTEMROOT=")/sizeof(wchar_t) - 1; + ptr += sizeof(L"SYSTEMROOT=")/sizeof(WCHAR) - 1; ptr += GetEnvironmentVariableW(L"SYSTEMROOT", ptr, expected + sizeof(expected) - ptr); ++ptr; memcpy(ptr, L"SYSTEMDRIVE=", sizeof(L"SYSTEMDRIVE=")); - ptr += sizeof(L"SYSTEMDRIVE=")/sizeof(wchar_t) - 1; + ptr += sizeof(L"SYSTEMDRIVE=")/sizeof(WCHAR) - 1; ptr += GetEnvironmentVariableW(L"SYSTEMDRIVE", ptr, expected + sizeof(expected) - ptr); ++ptr; *ptr = '\0'; diff --git a/deps/uv/test/test-tcp-unexpected-read.c b/deps/uv/test/test-tcp-unexpected-read.c index 45559c0133..709d7dd50e 100644 --- a/deps/uv/test/test-tcp-unexpected-read.c +++ b/deps/uv/test/test-tcp-unexpected-read.c @@ -107,7 +107,7 @@ TEST_IMPL(tcp_unexpected_read) { * start busy looping when the server sends a message and the client isn't * reading. */ - ASSERT(ticks <= 10); + ASSERT(ticks <= 20); return 0; } |