diff options
Diffstat (limited to 'deps/uv/test')
25 files changed, 188 insertions, 36 deletions
diff --git a/deps/uv/test/run-tests.c b/deps/uv/test/run-tests.c index 42bde0bb96..2a699f46dc 100644 --- a/deps/uv/test/run-tests.c +++ b/deps/uv/test/run-tests.c @@ -142,11 +142,11 @@ static int maybe_run_test(int argc, char **argv) { if (strcmp(argv[1], "spawn_helper5") == 0) { const char out[] = "fourth stdio!\n"; notify_parent_process(); + { #ifdef _WIN32 - DWORD bytes; - WriteFile((HANDLE) _get_osfhandle(3), out, sizeof(out) - 1, &bytes, NULL); + DWORD bytes; + WriteFile((HANDLE) _get_osfhandle(3), out, sizeof(out) - 1, &bytes, NULL); #else - { ssize_t r; do @@ -154,8 +154,8 @@ static int maybe_run_test(int argc, char **argv) { while (r == -1 && errno == EINTR); fsync(3); - } #endif + } return 1; } diff --git a/deps/uv/test/runner-win.c b/deps/uv/test/runner-win.c index e3e91a7b69..f60c23df3e 100644 --- a/deps/uv/test/runner-win.c +++ b/deps/uv/test/runner-win.c @@ -194,7 +194,7 @@ int process_wait(process_info_t *vec, int n, int timeout) { result = WaitForMultipleObjects(n, handles, TRUE, timeout_api); - if (result >= WAIT_OBJECT_0 && result < WAIT_OBJECT_0 + n) { + if (result < WAIT_OBJECT_0 + n) { /* All processes are terminated. */ return 0; } @@ -268,7 +268,8 @@ int process_read_last_line(process_info_t *p, if (!ReadFile(p->stdio_out, buffer, buffer_len - 1, &read, &overlapped)) return -1; - for (start = read - 1; start >= 0; start--) { + start = read; + while (start-- > 0) { if (buffer[start] == '\n' || buffer[start] == '\r') break; } @@ -308,7 +309,7 @@ void process_cleanup(process_info_t *p) { } -static int clear_line() { +static int clear_line(void) { HANDLE handle; CONSOLE_SCREEN_BUFFER_INFO info; COORD coord; diff --git a/deps/uv/test/runner-win.h b/deps/uv/test/runner-win.h index 8cc4c16eb2..975eed7931 100644 --- a/deps/uv/test/runner-win.h +++ b/deps/uv/test/runner-win.h @@ -20,7 +20,9 @@ */ /* Don't complain about write(), fileno() etc. being deprecated. */ +#ifdef _MSC_VER #pragma warning(disable : 4996) +#endif #include <winsock2.h> diff --git a/deps/uv/test/test-close-fd.c b/deps/uv/test/test-close-fd.c index 93a7bd7c02..2ed9a10032 100644 --- a/deps/uv/test/test-close-fd.c +++ b/deps/uv/test/test-close-fd.c @@ -73,4 +73,8 @@ TEST_IMPL(close_fd) { return 0; } -#endif /* !defined(_WIN32) */ +#else + +typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */ + +#endif /* !_WIN32 */ diff --git a/deps/uv/test/test-condvar.c b/deps/uv/test/test-condvar.c index 50f3c047c0..32abccc2e7 100644 --- a/deps/uv/test/test-condvar.c +++ b/deps/uv/test/test-condvar.c @@ -235,7 +235,7 @@ TEST_IMPL(condvar_5) { uint64_t elapsed; uint64_t timeout; - timeout = 100 * 1e6; /* 100 ms in ns */ + timeout = 100 * 1000 * 1000; /* 100 ms in ns */ /* Mostly irrelevant. We need cond and mutex initialized. */ worker_config_init(&wc, 0, NULL, NULL); diff --git a/deps/uv/test/test-emfile.c b/deps/uv/test/test-emfile.c index 8e44ac5c77..bc1fce5f55 100644 --- a/deps/uv/test/test-emfile.c +++ b/deps/uv/test/test-emfile.c @@ -38,6 +38,11 @@ static uv_tcp_t client_handle; TEST_IMPL(emfile) { + struct sockaddr_in addr; + struct rlimit limits; + uv_connect_t connect_req; + uv_loop_t* loop; + int first_fd; #if defined(_AIX) || defined(__MVS__) /* On AIX, if a 'accept' call fails ECONNRESET is set on the socket * which causes uv__emfile_trick to not work as intended and this test @@ -45,11 +50,6 @@ TEST_IMPL(emfile) { */ RETURN_SKIP("uv__emfile_trick does not work on this OS"); #endif - struct sockaddr_in addr; - struct rlimit limits; - uv_connect_t connect_req; - uv_loop_t* loop; - int first_fd; /* Lower the file descriptor limit and use up all fds save one. */ limits.rlim_cur = limits.rlim_max = maxfd + 1; @@ -114,4 +114,8 @@ static void connect_cb(uv_connect_t* req, int status) { uv_close((uv_handle_t*) &client_handle, NULL); } -#endif /* !defined(_WIN32) */ +#else + +typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */ + +#endif /* !_WIN32 */ diff --git a/deps/uv/test/test-fork.c b/deps/uv/test/test-fork.c index f47ae3e656..9e4684f0e1 100644 --- a/deps/uv/test/test-fork.c +++ b/deps/uv/test/test-fork.c @@ -676,5 +676,8 @@ TEST_IMPL(fork_threadpool_queue_work_simple) { } #endif /* !__MVS__ */ +#else + +typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */ #endif /* !_WIN32 */ diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c index 038d2dd615..5eed160de2 100644 --- a/deps/uv/test/test-fs.c +++ b/deps/uv/test/test-fs.c @@ -154,7 +154,7 @@ int uv_test_getiovmax(void) { static unsigned REPARSE_TAG = 0x9913; static GUID REPARSE_GUID = { 0x1bf6205f, 0x46ae, 0x4527, - 0xb1, 0x0c, 0xc5, 0x09, 0xb7, 0x55, 0x22, 0x80 }; + { 0xb1, 0x0c, 0xc5, 0x09, 0xb7, 0x55, 0x22, 0x80 }}; #endif static void check_permission(const char* filename, unsigned int mode) { @@ -2331,9 +2331,6 @@ TEST_IMPL(fs_stat_root) { TEST_IMPL(fs_futime) { -#if defined(_AIX) && !defined(_AIX71) - RETURN_SKIP("futime is not implemented for AIX versions below 7.1"); -#else utime_check_t checkme; const char* path = "test_file"; double atime; @@ -2341,6 +2338,9 @@ TEST_IMPL(fs_futime) { uv_file file; uv_fs_t req; int r; +#if defined(_AIX) && !defined(_AIX71) + RETURN_SKIP("futime is not implemented for AIX versions below 7.1"); +#endif /* Setup. */ loop = uv_default_loop(); @@ -2402,7 +2402,6 @@ TEST_IMPL(fs_futime) { MAKE_VALGRIND_HAPPY(); return 0; -#endif } @@ -3602,6 +3601,53 @@ TEST_IMPL(fs_exclusive_sharing_mode) { #endif #ifdef _WIN32 +TEST_IMPL(fs_file_flag_no_buffering) { + int r; + + /* Setup. */ + unlink("test_file"); + + ASSERT(UV_FS_O_APPEND > 0); + ASSERT(UV_FS_O_CREAT > 0); + ASSERT(UV_FS_O_DIRECT > 0); + ASSERT(UV_FS_O_RDWR > 0); + + /* FILE_APPEND_DATA must be excluded from FILE_GENERIC_WRITE: */ + r = uv_fs_open(NULL, + &open_req1, + "test_file", + UV_FS_O_RDWR | UV_FS_O_CREAT | UV_FS_O_DIRECT, + S_IWUSR | S_IRUSR, + NULL); + ASSERT(r >= 0); + ASSERT(open_req1.result >= 0); + uv_fs_req_cleanup(&open_req1); + + 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); + + /* FILE_APPEND_DATA and FILE_FLAG_NO_BUFFERING are mutually exclusive: */ + r = uv_fs_open(NULL, + &open_req2, + "test_file", + UV_FS_O_APPEND | UV_FS_O_DIRECT, + S_IWUSR | S_IRUSR, + NULL); + ASSERT(r == UV_EINVAL); + ASSERT(open_req2.result == UV_EINVAL); + uv_fs_req_cleanup(&open_req2); + + /* Cleanup */ + unlink("test_file"); + + MAKE_VALGRIND_HAPPY(); + return 0; +} +#endif + +#ifdef _WIN32 int call_icacls(const char* command, ...) { char icacls_command[1024]; va_list args; diff --git a/deps/uv/test/test-ip4-addr.c b/deps/uv/test/test-ip4-addr.c index 3d6e0cf286..c72f36a694 100644 --- a/deps/uv/test/test-ip4-addr.c +++ b/deps/uv/test/test-ip4-addr.c @@ -27,8 +27,13 @@ TEST_IMPL(ip4_addr) { - struct sockaddr_in addr; + char dst[16]; + + ASSERT(0 == uv_inet_ntop(AF_INET, "\xFF\xFF\xFF\xFF", dst, sizeof(dst))); + ASSERT(0 == strcmp(dst, "255.255.255.255")); + ASSERT(UV_ENOSPC == uv_inet_ntop(AF_INET, "\xFF\xFF\xFF\xFF", + dst, sizeof(dst) - 1)); ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); ASSERT(0 == uv_ip4_addr("255.255.255.255", TEST_PORT, &addr)); diff --git a/deps/uv/test/test-ip6-addr.c b/deps/uv/test/test-ip6-addr.c index 25570dcacd..bbf33a4854 100644 --- a/deps/uv/test/test-ip6-addr.c +++ b/deps/uv/test/test-ip6-addr.c @@ -83,7 +83,7 @@ TEST_IMPL(ip6_addr_link_local) { ASSERT(0 == r); #ifdef _WIN32 /* On Windows, the interface identifier is the numeric string of the index. */ - ASSERT(strtol(interface_id, NULL, 10) == iface_index); + ASSERT(strtoul(interface_id, NULL, 10) == iface_index); #else /* On Unix/Linux, the interface identifier is the interface device name. */ ASSERT(0 == strcmp(device_name, interface_id)); diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 46db4b2710..cc37bc039b 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -349,9 +349,11 @@ TEST_DECLARE (fs_null_req) TEST_DECLARE (fs_read_dir) #ifdef _WIN32 TEST_DECLARE (fs_exclusive_sharing_mode) +TEST_DECLARE (fs_file_flag_no_buffering) TEST_DECLARE (fs_open_readonly_acl) TEST_DECLARE (fs_fchmod_archive_readonly) #endif +TEST_DECLARE (strscpy) TEST_DECLARE (threadpool_queue_work_simple) TEST_DECLARE (threadpool_queue_work_einval) TEST_DECLARE (threadpool_multiple_event_loops) @@ -904,11 +906,13 @@ TASK_LIST_START TEST_ENTRY (fs_read_dir) #ifdef _WIN32 TEST_ENTRY (fs_exclusive_sharing_mode) + TEST_ENTRY (fs_file_flag_no_buffering) TEST_ENTRY (fs_open_readonly_acl) TEST_ENTRY (fs_fchmod_archive_readonly) #endif TEST_ENTRY (get_osfhandle_valid_handle) TEST_ENTRY (open_osfhandle_valid_handle) + TEST_ENTRY (strscpy) TEST_ENTRY (threadpool_queue_work_simple) TEST_ENTRY (threadpool_queue_work_einval) TEST_ENTRY (threadpool_multiple_event_loops) diff --git a/deps/uv/test/test-pipe-close-stdout-read-stdin.c b/deps/uv/test/test-pipe-close-stdout-read-stdin.c index c8804b0e18..126be2cc46 100644 --- a/deps/uv/test/test-pipe-close-stdout-read-stdin.c +++ b/deps/uv/test/test-pipe-close-stdout-read-stdin.c @@ -105,4 +105,8 @@ TEST_IMPL(pipe_close_stdout_read_stdin) { return 0; } +#else + +typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */ + #endif /* ifndef _WIN32 */ diff --git a/deps/uv/test/test-platform-output.c b/deps/uv/test/test-platform-output.c index 4025fba540..43ed119deb 100644 --- a/deps/uv/test/test-platform-output.c +++ b/deps/uv/test/test-platform-output.c @@ -49,7 +49,7 @@ TEST_IMPL(platform_output) { printf("uv_cwd: %s\n", buffer); err = uv_resident_set_memory(&rss); -#if defined(__CYGWIN__) || defined(__MSYS__) +#if defined(__MSYS__) ASSERT(err == UV_ENOSYS); #else ASSERT(err == 0); diff --git a/deps/uv/test/test-poll-close-doesnt-corrupt-stack.c b/deps/uv/test/test-poll-close-doesnt-corrupt-stack.c index 1dfc80e352..3393820fc4 100644 --- a/deps/uv/test/test-poll-close-doesnt-corrupt-stack.c +++ b/deps/uv/test/test-poll-close-doesnt-corrupt-stack.c @@ -49,7 +49,7 @@ static void poll_cb(uv_poll_t* h, int status, int events) { } -static void NO_INLINE close_socket_and_verify_stack() { +static void NO_INLINE close_socket_and_verify_stack(void) { const uint32_t MARKER = 0xDEADBEEF; const int VERIFY_AFTER = 10; /* ms */ int r; diff --git a/deps/uv/test/test-poll-oob.c b/deps/uv/test/test-poll-oob.c index 2a6da843c6..77ffe31e96 100644 --- a/deps/uv/test/test-poll-oob.c +++ b/deps/uv/test/test-poll-oob.c @@ -202,4 +202,9 @@ TEST_IMPL(poll_oob) { MAKE_VALGRIND_HAPPY(); return 0; } + +#else + +typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */ + #endif diff --git a/deps/uv/test/test-process-title-threadsafe.c b/deps/uv/test/test-process-title-threadsafe.c index c0dee48a79..19098eda0c 100644 --- a/deps/uv/test/test-process-title-threadsafe.c +++ b/deps/uv/test/test-process-title-threadsafe.c @@ -70,7 +70,7 @@ TEST_IMPL(process_title_threadsafe) { #if defined(__sun) || defined(__CYGWIN__) || defined(__MSYS__) || \ defined(__MVS__) RETURN_SKIP("uv_(get|set)_process_title is not implemented."); -#else +#endif ASSERT(0 == uv_set_process_title(titles[0])); ASSERT(0 == uv_thread_create(&getter_thread, getter_thread_body, NULL)); @@ -82,5 +82,4 @@ TEST_IMPL(process_title_threadsafe) { ASSERT(0 == uv_thread_join(&setter_threads[i])); return 0; -#endif } diff --git a/deps/uv/test/test-process-title.c b/deps/uv/test/test-process-title.c index 886f83a7d3..efd48142b7 100644 --- a/deps/uv/test/test-process-title.c +++ b/deps/uv/test/test-process-title.c @@ -62,7 +62,8 @@ static void uv_get_process_title_edge_cases(void) { TEST_IMPL(process_title) { #if defined(__sun) || defined(__CYGWIN__) || defined(__MSYS__) RETURN_SKIP("uv_(get|set)_process_title is not implemented."); -#else +#endif + /* Check for format string vulnerabilities. */ set_title("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"); set_title("new title"); @@ -71,5 +72,4 @@ TEST_IMPL(process_title) { uv_get_process_title_edge_cases(); return 0; -#endif } diff --git a/deps/uv/test/test-signal-multiple-loops.c b/deps/uv/test/test-signal-multiple-loops.c index 79242fc9fa..4281d23d72 100644 --- a/deps/uv/test/test-signal-multiple-loops.c +++ b/deps/uv/test/test-signal-multiple-loops.c @@ -295,4 +295,8 @@ TEST_IMPL(signal_multiple_loops) { return 0; } -#endif /* !_WIN32 */ +#else + +typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */ + +#endif /* !_WIN32 */ diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c index 594a64c60b..05c76f6145 100644 --- a/deps/uv/test/test-spawn.c +++ b/deps/uv/test/test-spawn.c @@ -49,7 +49,9 @@ static char exepath[1024]; static size_t exepath_size = 1024; static char* args[5]; static int no_term_signal; +#ifndef _WIN32 static int timer_counter; +#endif static uv_tcp_t tcp_server; #define OUTPUT_SIZE 1024 @@ -138,10 +140,12 @@ static void on_read(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { } +#ifndef _WIN32 static void on_read_once(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { uv_read_stop(tcp); on_read(tcp, nread, buf); } +#endif static void write_cb(uv_write_t* req, int status) { @@ -173,9 +177,11 @@ static void timer_cb(uv_timer_t* handle) { } +#ifndef _WIN32 static void timer_counter_cb(uv_timer_t* handle) { ++timer_counter; } +#endif TEST_IMPL(spawn_fails) { @@ -1198,7 +1204,7 @@ TEST_IMPL(argument_escaping) { int make_program_env(char** env_block, WCHAR** dst_ptr); TEST_IMPL(environment_creation) { - int i; + size_t i; char* environment[] = { "FOO=BAR", "SYSTEM=ROOT", /* substring of a supplied var name */ diff --git a/deps/uv/test/test-strscpy.c b/deps/uv/test/test-strscpy.c new file mode 100644 index 0000000000..4e7db6ffec --- /dev/null +++ b/deps/uv/test/test-strscpy.c @@ -0,0 +1,53 @@ +/* Copyright libuv project 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" +#include <string.h> + +#include "../src/strscpy.h" +#include "../src/strscpy.c" + +TEST_IMPL(strscpy) { + char d[4]; + + ASSERT(0 == uv__strscpy(d, "", 0)); + ASSERT(0 == uv__strscpy(d, "x", 0)); + + memset(d, 0, sizeof(d)); + ASSERT(1 == uv__strscpy(d, "x", sizeof(d))); + ASSERT(0 == memcmp(d, "x\0\0", sizeof(d))); + + memset(d, 0, sizeof(d)); + ASSERT(2 == uv__strscpy(d, "xy", sizeof(d))); + ASSERT(0 == memcmp(d, "xy\0", sizeof(d))); + + ASSERT(3 == uv__strscpy(d, "xyz", sizeof(d))); + ASSERT(0 == memcmp(d, "xyz", sizeof(d))); + + ASSERT(UV_E2BIG == uv__strscpy(d, "xyzz", sizeof(d))); + ASSERT(0 == memcmp(d, "xyz", sizeof(d))); + + ASSERT(UV_E2BIG == uv__strscpy(d, "xyzzy", sizeof(d))); + ASSERT(0 == memcmp(d, "xyz", sizeof(d))); + + return 0; +} diff --git a/deps/uv/test/test-tcp-close-accept.c b/deps/uv/test/test-tcp-close-accept.c index e4878398c8..624262bcfe 100644 --- a/deps/uv/test/test-tcp-close-accept.c +++ b/deps/uv/test/test-tcp-close-accept.c @@ -191,4 +191,8 @@ TEST_IMPL(tcp_close_accept) { return 0; } -#endif /* !_WIN32 */ +#else + +typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */ + +#endif /* !_WIN32 */ diff --git a/deps/uv/test/test-tcp-oob.c b/deps/uv/test/test-tcp-oob.c index ca2361f9bb..53f8231e83 100644 --- a/deps/uv/test/test-tcp-oob.c +++ b/deps/uv/test/test-tcp-oob.c @@ -138,4 +138,9 @@ TEST_IMPL(tcp_oob) { MAKE_VALGRIND_HAPPY(); return 0; } -#endif + +#else + +typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */ + +#endif /* !_WIN32 */ diff --git a/deps/uv/test/test-tcp-write-after-connect.c b/deps/uv/test/test-tcp-write-after-connect.c index aa03228f13..8198e7e184 100644 --- a/deps/uv/test/test-tcp-write-after-connect.c +++ b/deps/uv/test/test-tcp-write-after-connect.c @@ -65,4 +65,8 @@ TEST_IMPL(tcp_write_after_connect) { return 0; } -#endif +#else + +typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */ + +#endif /* !_WIN32 */ diff --git a/deps/uv/test/test-tty.c b/deps/uv/test/test-tty.c index 979a6ec38d..688711e508 100644 --- a/deps/uv/test/test-tty.c +++ b/deps/uv/test/test-tty.c @@ -315,10 +315,8 @@ TEST_IMPL(tty_raw_cancel) { int r; int ttyin_fd; uv_tty_t tty_in; - uv_loop_t* loop; HANDLE handle; - loop = uv_default_loop(); /* Make sure we have an FD that refers to a tty */ handle = CreateFileA("conin$", GENERIC_READ | GENERIC_WRITE, diff --git a/deps/uv/test/test.gyp b/deps/uv/test/test.gyp index 098512208c..ae7dc0d628 100644 --- a/deps/uv/test/test.gyp +++ b/deps/uv/test/test.gyp @@ -34,6 +34,7 @@ 'test-fs.c', 'test-fs-copyfile.c', 'test-fs-event.c', + 'test-fs-poll.c', 'test-getters-setters.c', 'test-get-currentexe.c', 'test-get-memory.c', @@ -96,7 +97,7 @@ 'test-signal-multiple-loops.c', 'test-socket-buffer-size.c', 'test-spawn.c', - 'test-fs-poll.c', + 'test-strscpy.c', 'test-stdio-over-pipes.c', 'test-tcp-alloc-cb-fail.c', 'test-tcp-bind-error.c', |