diff options
author | cjihrig <cjihrig@gmail.com> | 2017-11-30 21:41:16 -0500 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2017-12-01 09:01:04 -0500 |
commit | 5ebfaa88917ebcef1dd69e31e40014ce237c60e2 (patch) | |
tree | c3b3e08a1b9a461252992e29f70cbabc26bbd4b3 /deps/uv/test | |
parent | 3327ce0dd2f1d7d6255deb13314fdd7e7a2fb8aa (diff) | |
download | android-node-v8-5ebfaa88917ebcef1dd69e31e40014ce237c60e2.tar.gz android-node-v8-5ebfaa88917ebcef1dd69e31e40014ce237c60e2.tar.bz2 android-node-v8-5ebfaa88917ebcef1dd69e31e40014ce237c60e2.zip |
deps: upgrade libuv to 1.18.0
PR-URL: https://github.com/nodejs/node/pull/17282
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/uv/test')
-rw-r--r-- | deps/uv/test/run-tests.c | 5 | ||||
-rw-r--r-- | deps/uv/test/test-fs.c | 62 | ||||
-rw-r--r-- | deps/uv/test/test-list.h | 8 | ||||
-rw-r--r-- | deps/uv/test/test-platform-output.c | 4 | ||||
-rw-r--r-- | deps/uv/test/test-spawn.c | 79 | ||||
-rw-r--r-- | deps/uv/test/test-thread.c | 32 |
6 files changed, 170 insertions, 20 deletions
diff --git a/deps/uv/test/run-tests.c b/deps/uv/test/run-tests.c index 4e10b68f3b..da4ac82e43 100644 --- a/deps/uv/test/run-tests.c +++ b/deps/uv/test/run-tests.c @@ -43,6 +43,7 @@ int ipc_send_recv_helper(void); int ipc_helper_bind_twice(void); int stdio_over_pipes_helper(void); int spawn_stdin_stdout(void); +int spawn_tcp_server_helper(void); static int maybe_run_test(int argc, char **argv); @@ -111,6 +112,10 @@ static int maybe_run_test(int argc, char **argv) { return 1; } + if (strcmp(argv[1], "spawn_tcp_server_helper") == 0) { + return spawn_tcp_server_helper(); + } + if (strcmp(argv[1], "spawn_helper3") == 0) { char buffer[256]; ASSERT(buffer == fgets(buffer, sizeof(buffer) - 1, stdin)); diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c index 6afa650793..cae02dd1fd 100644 --- a/deps/uv/test/test-fs.c +++ b/deps/uv/test/test-fs.c @@ -32,8 +32,12 @@ defined(__APPLE__) || defined(_AIX) || defined(__MVS__) #include <unistd.h> /* unlink, rmdir, etc. */ #else +# include <winioctl.h> # include <direct.h> # include <io.h> +# ifndef ERROR_SYMLINK_NOT_SUPPORTED +# define ERROR_SYMLINK_NOT_SUPPORTED 1464 +# endif # define unlink _unlink # define rmdir _rmdir # define open _open @@ -2167,7 +2171,6 @@ TEST_IMPL(fs_utime) { #ifdef _WIN32 TEST_IMPL(fs_stat_root) { int r; - uv_loop_t* loop = uv_default_loop(); r = uv_fs_stat(NULL, &stat_req, "\\", NULL); ASSERT(r == 0); @@ -3061,3 +3064,60 @@ TEST_IMPL(fs_null_req) { return 0; } + +#ifdef _WIN32 +TEST_IMPL(fs_exclusive_sharing_mode) { + int r; + + /* Setup. */ + unlink("test_file"); + + ASSERT(UV_FS_O_EXLOCK > 0); + + r = uv_fs_open(NULL, + &open_req1, + "test_file", + O_RDWR | O_CREAT | UV_FS_O_EXLOCK, + S_IWUSR | S_IRUSR, + NULL); + ASSERT(r >= 0); + ASSERT(open_req1.result >= 0); + uv_fs_req_cleanup(&open_req1); + + r = uv_fs_open(NULL, + &open_req2, + "test_file", + O_RDONLY | UV_FS_O_EXLOCK, + S_IWUSR | S_IRUSR, + NULL); + ASSERT(r < 0); + ASSERT(open_req2.result < 0); + uv_fs_req_cleanup(&open_req2); + + r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); + ASSERT(r == 0); + ASSERT(close_req.result == 0); + uv_fs_req_cleanup(&close_req); + + r = uv_fs_open(NULL, + &open_req2, + "test_file", + O_RDONLY | UV_FS_O_EXLOCK, + S_IWUSR | S_IRUSR, + NULL); + ASSERT(r >= 0); + ASSERT(open_req2.result >= 0); + uv_fs_req_cleanup(&open_req2); + + r = uv_fs_close(NULL, &close_req, open_req2.result, NULL); + ASSERT(r == 0); + ASSERT(close_req.result == 0); + uv_fs_req_cleanup(&close_req); + + /* Cleanup */ + unlink("test_file"); + + MAKE_VALGRIND_HAPPY(); + return 0; +} +#endif diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 3e88e6c928..2adbe6a017 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -260,6 +260,7 @@ TEST_DECLARE (spawn_closed_process_io) TEST_DECLARE (spawn_reads_child_path) TEST_DECLARE (spawn_inherit_streams) TEST_DECLARE (spawn_quoted_path) +TEST_DECLARE (spawn_tcp_server) TEST_DECLARE (fs_poll) TEST_DECLARE (fs_poll_getpath) TEST_DECLARE (kill) @@ -321,6 +322,9 @@ TEST_DECLARE (fs_write_alotof_bufs) TEST_DECLARE (fs_write_alotof_bufs_with_offset) TEST_DECLARE (fs_file_pos_after_op_with_offset) TEST_DECLARE (fs_null_req) +#ifdef _WIN32 +TEST_DECLARE (fs_exclusive_sharing_mode) +#endif TEST_DECLARE (threadpool_queue_work_simple) TEST_DECLARE (threadpool_queue_work_einval) TEST_DECLARE (threadpool_multiple_event_loops) @@ -740,6 +744,7 @@ TASK_LIST_START TEST_ENTRY (spawn_reads_child_path) TEST_ENTRY (spawn_inherit_streams) TEST_ENTRY (spawn_quoted_path) + TEST_ENTRY (spawn_tcp_server) TEST_ENTRY (fs_poll) TEST_ENTRY (fs_poll_getpath) TEST_ENTRY (kill) @@ -832,6 +837,9 @@ TASK_LIST_START TEST_ENTRY (fs_read_write_null_arguments) TEST_ENTRY (fs_file_pos_after_op_with_offset) TEST_ENTRY (fs_null_req) +#ifdef _WIN32 + TEST_ENTRY (fs_exclusive_sharing_mode) +#endif TEST_ENTRY (get_osfhandle_valid_handle) TEST_ENTRY (threadpool_queue_work_simple) TEST_ENTRY (threadpool_queue_work_einval) diff --git a/deps/uv/test/test-platform-output.c b/deps/uv/test/test-platform-output.c index 50ed59a6d2..4025fba540 100644 --- a/deps/uv/test/test-platform-output.c +++ b/deps/uv/test/test-platform-output.c @@ -29,6 +29,7 @@ TEST_IMPL(platform_output) { size_t rss; size_t size; double uptime; + uv_pid_t pid; uv_pid_t ppid; uv_rusage_t rusage; uv_cpu_info_t* cpus; @@ -145,6 +146,9 @@ TEST_IMPL(platform_output) { printf(" shell: %s\n", pwd.shell); printf(" home directory: %s\n", pwd.homedir); + pid = uv_os_getpid(); + ASSERT(pid > 0); + printf("uv_os_getpid: %d\n", (int) pid); ppid = uv_os_getppid(); ASSERT(ppid > 0); printf("uv_os_getppid: %d\n", (int) ppid); diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c index d3958fe216..4b138265a5 100644 --- a/deps/uv/test/test-spawn.c +++ b/deps/uv/test/test-spawn.c @@ -50,6 +50,7 @@ static size_t exepath_size = 1024; static char* args[5]; static int no_term_signal; static int timer_counter; +static uv_tcp_t tcp_server; #define OUTPUT_SIZE 1024 static char output[OUTPUT_SIZE]; @@ -622,6 +623,84 @@ TEST_IMPL(spawn_stdio_greater_than_3) { } +int spawn_tcp_server_helper(void) { + uv_tcp_t tcp; + uv_os_sock_t handle; + int r; + + r = uv_tcp_init(uv_default_loop(), &tcp); + ASSERT(r == 0); + +#ifdef _WIN32 + handle = _get_osfhandle(3); +#else + handle = 3; +#endif + r = uv_tcp_open(&tcp, handle); + ASSERT(r == 0); + + /* Make sure that we can listen on a socket that was + * passed down from the parent process + */ + r = uv_listen((uv_stream_t*)&tcp, SOMAXCONN, NULL); + ASSERT(r == 0); + + return 1; +} + + +TEST_IMPL(spawn_tcp_server) { + uv_stdio_container_t stdio[4]; + struct sockaddr_in addr; + int fd; + int r; +#ifdef _WIN32 + uv_os_fd_t handle; +#endif + + init_process_options("spawn_tcp_server_helper", exit_cb); + + ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + + fd = -1; + r = uv_tcp_init_ex(uv_default_loop(), &tcp_server, AF_INET); + ASSERT(r == 0); + r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); + ASSERT(r == 0); +#ifdef _WIN32 + r = uv_fileno((uv_handle_t*)&tcp_server, &handle); + fd = _open_osfhandle((intptr_t) handle, 0); +#else + r = uv_fileno((uv_handle_t*)&tcp_server, &fd); + #endif + ASSERT(r == 0); + ASSERT(fd > 0); + + options.stdio = stdio; + options.stdio[0].flags = UV_INHERIT_FD; + options.stdio[0].data.fd = 0; + options.stdio[1].flags = UV_INHERIT_FD; + options.stdio[1].data.fd = 1; + options.stdio[2].flags = UV_INHERIT_FD; + options.stdio[2].data.fd = 2; + options.stdio[3].flags = UV_INHERIT_FD; + options.stdio[3].data.fd = fd; + options.stdio_count = 4; + + r = uv_spawn(uv_default_loop(), &process, &options); + ASSERT(r == 0); + + r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); + ASSERT(r == 0); + + ASSERT(exit_cb_called == 1); + ASSERT(close_cb_called == 1); + + MAKE_VALGRIND_HAPPY(); + return 0; +} + + TEST_IMPL(spawn_ignored_stdio) { int r; diff --git a/deps/uv/test/test-thread.c b/deps/uv/test/test-thread.c index b0e87e2081..955c9f2f1b 100644 --- a/deps/uv/test/test-thread.c +++ b/deps/uv/test/test-thread.c @@ -44,7 +44,7 @@ struct fs_req { struct test_thread { uv_thread_t thread_id; - volatile int thread_called; + int thread_called; }; static void getaddrinfo_do(struct getaddrinfo_req* req); @@ -54,7 +54,7 @@ static void getaddrinfo_cb(uv_getaddrinfo_t* handle, static void fs_do(struct fs_req* req); static void fs_cb(uv_fs_t* handle); -static volatile int thread_called; +static int thread_called; static uv_key_t tls_key; @@ -105,36 +105,30 @@ static void fs_cb(uv_fs_t* handle) { static void do_work(void* arg) { - struct getaddrinfo_req getaddrinfo_reqs[16]; - struct fs_req fs_reqs[16]; - uv_loop_t* loop; + struct getaddrinfo_req getaddrinfo_reqs[4]; + struct fs_req fs_reqs[4]; + uv_loop_t loop; size_t i; - int r; struct test_thread* thread = arg; - loop = malloc(sizeof *loop); - ASSERT(loop != NULL); - ASSERT(0 == uv_loop_init(loop)); + ASSERT(0 == uv_loop_init(&loop)); for (i = 0; i < ARRAY_SIZE(getaddrinfo_reqs); i++) { struct getaddrinfo_req* req = getaddrinfo_reqs + i; - req->counter = 16; - req->loop = loop; + req->counter = 4; + req->loop = &loop; getaddrinfo_do(req); } for (i = 0; i < ARRAY_SIZE(fs_reqs); i++) { struct fs_req* req = fs_reqs + i; - req->counter = 16; - req->loop = loop; + req->counter = 4; + req->loop = &loop; fs_do(req); } - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(0 == uv_loop_close(loop)); - free(loop); + ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); + ASSERT(0 == uv_loop_close(&loop)); thread->thread_called = 1; } @@ -179,7 +173,7 @@ TEST_IMPL(threadpool_multiple_event_loops) { for (i = 0; i < ARRAY_SIZE(threads); i++) { r = uv_thread_join(&threads[i].thread_id); ASSERT(r == 0); - ASSERT(threads[i].thread_called); + ASSERT(threads[i].thread_called == 1); } return 0; |