diff --git a/CMakeLists.txt b/CMakeLists.txt index d2629ea6aeb..69750d401db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,156 @@ set(uv_sources src/uv-data-getter-setters.c src/version.c) +set(uv_test_sources + test/blackhole-server.c + test/echo-server.c + test/run-tests.c + test/runner.c + test/test-active.c + test/test-async-null-cb.c + test/test-async.c + test/test-barrier.c + test/test-callback-order.c + test/test-callback-stack.c + test/test-close-fd.c + test/test-close-order.c + test/test-condvar.c + test/test-connect-unspecified.c + test/test-connection-fail.c + test/test-cwd-and-chdir.c + test/test-default-loop-close.c + test/test-delayed-accept.c + test/test-dlerror.c + test/test-eintr-handling.c + test/test-embed.c + test/test-emfile.c + test/test-env-vars.c + test/test-error.c + test/test-fail-always.c + test/test-fork.c + test/test-fs-copyfile.c + test/test-fs-event.c + test/test-fs-poll.c + test/test-fs.c + test/test-get-currentexe.c + test/test-get-loadavg.c + test/test-get-memory.c + test/test-get-passwd.c + test/test-getaddrinfo.c + test/test-gethostname.c + test/test-getnameinfo.c + test/test-getsockname.c + test/test-getters-setters.c + test/test-handle-fileno.c + test/test-homedir.c + test/test-hrtime.c + test/test-idle.c + test/test-idna.c + test/test-ip4-addr.c + test/test-ip6-addr.c + test/test-ip6-addr.c + test/test-ipc-heavy-traffic-deadlock-bug.c + test/test-ipc-send-recv.c + test/test-ipc.c + test/test-loop-alive.c + test/test-loop-close.c + test/test-loop-configure.c + test/test-loop-handles.c + test/test-loop-stop.c + test/test-loop-time.c + test/test-multiple-listen.c + test/test-mutexes.c + test/test-osx-select.c + test/test-pass-always.c + test/test-ping-pong.c + test/test-pipe-bind-error.c + test/test-pipe-close-stdout-read-stdin.c + test/test-pipe-connect-error.c + test/test-pipe-connect-multiple.c + test/test-pipe-connect-prepare.c + test/test-pipe-getsockname.c + test/test-pipe-pending-instances.c + test/test-pipe-sendmsg.c + test/test-pipe-server-close.c + test/test-pipe-set-fchmod.c + test/test-pipe-set-non-blocking.c + test/test-platform-output.c + test/test-poll-close-doesnt-corrupt-stack.c + test/test-poll-close.c + test/test-poll-closesocket.c + test/test-poll-oob.c + test/test-poll.c + test/test-process-priority.c + test/test-process-title-threadsafe.c + test/test-process-title.c + test/test-queue-foreach-delete.c + test/test-ref.c + test/test-run-nowait.c + test/test-run-once.c + test/test-semaphore.c + test/test-shutdown-close.c + test/test-shutdown-eof.c + test/test-shutdown-twice.c + test/test-signal-multiple-loops.c + test/test-signal.c + test/test-socket-buffer-size.c + test/test-spawn.c + test/test-stdio-over-pipes.c + test/test-strscpy.c + test/test-tcp-alloc-cb-fail.c + test/test-tcp-bind-error.c + test/test-tcp-bind6-error.c + test/test-tcp-close-accept.c + test/test-tcp-close-while-connecting.c + test/test-tcp-close.c + test/test-tcp-connect-error-after-write.c + test/test-tcp-connect-error.c + test/test-tcp-connect-timeout.c + test/test-tcp-connect6-error.c + test/test-tcp-create-socket-early.c + test/test-tcp-flags.c + test/test-tcp-oob.c + test/test-tcp-open.c + test/test-tcp-read-stop.c + test/test-tcp-shutdown-after-write.c + test/test-tcp-try-write.c + test/test-tcp-unexpected-read.c + test/test-tcp-write-after-connect.c + test/test-tcp-write-fail.c + test/test-tcp-write-queue-order.c + test/test-tcp-write-to-half-open-connection.c + test/test-tcp-writealot.c + test/test-thread-equal.c + test/test-thread.c + test/test-threadpool-cancel.c + test/test-threadpool.c + test/test-timer-again.c + test/test-timer-from-check.c + test/test-timer.c + test/test-tmpdir.c + test/test-tty-duplicate-key.c + test/test-tty.c + test/test-udp-alloc-cb-fail.c + test/test-udp-bind.c + test/test-udp-create-socket-early.c + test/test-udp-dgram-too-big.c + test/test-udp-ipv6.c + test/test-udp-multicast-interface.c + test/test-udp-multicast-interface6.c + test/test-udp-multicast-join.c + test/test-udp-multicast-join6.c + test/test-udp-multicast-ttl.c + test/test-udp-open.c + test/test-udp-options.c + test/test-udp-send-and-recv.c + test/test-udp-send-hang-loop.c + test/test-udp-send-immediate.c + test/test-udp-send-unreachable.c + test/test-udp-try-send.c + test/test-uname.c + test/test-walk-handles.c + test/test-watcher-cross-stop.c) + if(WIN32) list(APPEND uv_defines WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0600) list(APPEND uv_libraries diff --git a/Makefile.am b/Makefile.am index 7a0947faacc..9907a932a7e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -281,7 +281,6 @@ test_run_tests_SOURCES = test/blackhole-server.c \ test/test-timer.c \ test/test-tmpdir.c \ test/test-tty-duplicate-key.c \ - test/test-tty-escape-sequence-processing.c \ test/test-tty.c \ test/test-udp-alloc-cb-fail.c \ test/test-udp-bind.c \ diff --git a/test/test-list.h b/test/test-list.h index 7f1cbd96737..bd13db66a37 100644 --- a/test/test-list.h +++ b/test/test-list.h @@ -57,22 +57,6 @@ TEST_DECLARE (tty_raw_cancel) TEST_DECLARE (tty_duplicate_vt100_fn_key) TEST_DECLARE (tty_duplicate_alt_modifier_key) TEST_DECLARE (tty_composing_character) -TEST_DECLARE (tty_cursor_up) -TEST_DECLARE (tty_cursor_down) -TEST_DECLARE (tty_cursor_forward) -TEST_DECLARE (tty_cursor_back) -TEST_DECLARE (tty_cursor_next_line) -TEST_DECLARE (tty_cursor_previous_line) -TEST_DECLARE (tty_cursor_horizontal_move_absolute) -TEST_DECLARE (tty_cursor_move_absolute) -TEST_DECLARE (tty_hide_show_cursor) -TEST_DECLARE (tty_set_cursor_shape) -TEST_DECLARE (tty_erase) -TEST_DECLARE (tty_erase_line) -TEST_DECLARE (tty_set_style) -TEST_DECLARE (tty_save_restore_cursor_position) -TEST_DECLARE (tty_full_reset) -TEST_DECLARE (tty_escape_sequence_processing) #endif TEST_DECLARE (tty_file) TEST_DECLARE (tty_pty) @@ -541,22 +525,6 @@ TASK_LIST_START TEST_ENTRY (tty_duplicate_vt100_fn_key) TEST_ENTRY (tty_duplicate_alt_modifier_key) TEST_ENTRY (tty_composing_character) - TEST_ENTRY (tty_cursor_up) - TEST_ENTRY (tty_cursor_down) - TEST_ENTRY (tty_cursor_forward) - TEST_ENTRY (tty_cursor_back) - TEST_ENTRY (tty_cursor_next_line) - TEST_ENTRY (tty_cursor_previous_line) - TEST_ENTRY (tty_cursor_horizontal_move_absolute) - TEST_ENTRY (tty_cursor_move_absolute) - TEST_ENTRY (tty_hide_show_cursor) - TEST_ENTRY (tty_set_cursor_shape) - TEST_ENTRY (tty_erase) - TEST_ENTRY (tty_erase_line) - TEST_ENTRY (tty_set_style) - TEST_ENTRY (tty_save_restore_cursor_position) - TEST_ENTRY (tty_full_reset) - TEST_ENTRY (tty_escape_sequence_processing) #endif TEST_ENTRY (tty_file) TEST_ENTRY (tty_pty) diff --git a/test/test-tty-duplicate-key.c b/test/test-tty-duplicate-key.c index 8ec9ec3fdde..1ec2f3695d9 100644 --- a/test/test-tty-duplicate-key.c +++ b/test/test-tty-duplicate-key.c @@ -53,7 +53,7 @@ static void print_err_msg(const char* expect, ssize_t expect_len, fprintf(stderr, "\n"); } -static void tty_alloc(uv_handle_t* ttyin_fd, size_t size, uv_buf_t* buf) { +static void tty_alloc(uv_handle_t* handle, size_t size, uv_buf_t* buf) { buf->base = malloc(size); ASSERT(buf->base != NULL); buf->len = size; @@ -133,23 +133,26 @@ static void make_key_event_records(WORD virt_key, DWORD ctr_key_state, TEST_IMPL(tty_duplicate_vt100_fn_key) { int r; - uv_os_fd_t ttyin_fd; + int ttyin_fd; uv_tty_t tty_in; uv_loop_t* loop; + HANDLE handle; INPUT_RECORD records[2]; DWORD written; loop = uv_default_loop(); /* Make sure we have an FD that refers to a tty */ - ttyin_fd = CreateFileA("conin$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - ASSERT(ttyin_fd != INVALID_HANDLE_VALUE); + handle = CreateFileA("conin$", + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + ASSERT(handle != INVALID_HANDLE_VALUE); + ttyin_fd = _open_osfhandle((intptr_t) handle, 0); + ASSERT(ttyin_fd >= 0); ASSERT(UV_TTY == uv_guess_handle(ttyin_fd)); r = uv_tty_init(uv_default_loop(), &tty_in, ttyin_fd, 1); /* Readable. */ @@ -172,7 +175,7 @@ TEST_IMPL(tty_duplicate_vt100_fn_key) { * duplicate. */ make_key_event_records(VK_F1, 0, TRUE, records); - WriteConsoleInputW(ttyin_fd, records, ARRAY_SIZE(records), &written); + WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); ASSERT(written == ARRAY_SIZE(records)); uv_run(loop, UV_RUN_DEFAULT); @@ -183,9 +186,10 @@ TEST_IMPL(tty_duplicate_vt100_fn_key) { TEST_IMPL(tty_duplicate_alt_modifier_key) { int r; - uv_os_fd_t ttyin_fd; + int ttyin_fd; uv_tty_t tty_in; uv_loop_t* loop; + HANDLE handle; INPUT_RECORD records[2]; INPUT_RECORD alt_records[2]; DWORD written; @@ -193,14 +197,16 @@ TEST_IMPL(tty_duplicate_alt_modifier_key) { loop = uv_default_loop(); /* Make sure we have an FD that refers to a tty */ - ttyin_fd = CreateFileA("conin$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - ASSERT(ttyin_fd != INVALID_HANDLE_VALUE); + handle = CreateFileA("conin$", + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + ASSERT(handle != INVALID_HANDLE_VALUE); + ttyin_fd = _open_osfhandle((intptr_t) handle, 0); + ASSERT(ttyin_fd >= 0); ASSERT(UV_TTY == uv_guess_handle(ttyin_fd)); r = uv_tty_init(uv_default_loop(), &tty_in, ttyin_fd, 1); /* Readable. */ @@ -220,22 +226,22 @@ TEST_IMPL(tty_duplicate_alt_modifier_key) { /* Emulate transmission of M-a at normal console */ make_key_event_records(VK_MENU, 0, TRUE, alt_records); - WriteConsoleInputW(ttyin_fd, &alt_records[0], 1, &written); + WriteConsoleInputW(handle, &alt_records[0], 1, &written); ASSERT(written == 1); make_key_event_records(L'A', LEFT_ALT_PRESSED, FALSE, records); - WriteConsoleInputW(ttyin_fd, records, ARRAY_SIZE(records), &written); + WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); ASSERT(written == 2); - WriteConsoleInputW(ttyin_fd, &alt_records[1], 1, &written); + WriteConsoleInputW(handle, &alt_records[1], 1, &written); ASSERT(written == 1); /* Emulate transmission of M-a at WSL(#2111) */ make_key_event_records(VK_MENU, 0, TRUE, alt_records); - WriteConsoleInputW(ttyin_fd, &alt_records[0], 1, &written); + WriteConsoleInputW(handle, &alt_records[0], 1, &written); ASSERT(written == 1); make_key_event_records(L'A', LEFT_ALT_PRESSED, TRUE, records); - WriteConsoleInputW(ttyin_fd, records, ARRAY_SIZE(records), &written); + WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); ASSERT(written == 2); - WriteConsoleInputW(ttyin_fd, &alt_records[1], 1, &written); + WriteConsoleInputW(handle, &alt_records[1], 1, &written); ASSERT(written == 1); uv_run(loop, UV_RUN_DEFAULT); @@ -246,9 +252,10 @@ TEST_IMPL(tty_duplicate_alt_modifier_key) { TEST_IMPL(tty_composing_character) { int r; - uv_os_fd_t ttyin_fd; + int ttyin_fd; uv_tty_t tty_in; uv_loop_t* loop; + HANDLE handle; INPUT_RECORD records[2]; INPUT_RECORD alt_records[2]; DWORD written; @@ -256,14 +263,16 @@ TEST_IMPL(tty_composing_character) { loop = uv_default_loop(); /* Make sure we have an FD that refers to a tty */ - ttyin_fd = CreateFileA("conin$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - ASSERT(ttyin_fd != INVALID_HANDLE_VALUE); + handle = CreateFileA("conin$", + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + ASSERT(handle != INVALID_HANDLE_VALUE); + ttyin_fd = _open_osfhandle((intptr_t) handle, 0); + ASSERT(ttyin_fd >= 0); ASSERT(UV_TTY == uv_guess_handle(ttyin_fd)); r = uv_tty_init(uv_default_loop(), &tty_in, ttyin_fd, 1); /* Readable. */ @@ -284,20 +293,20 @@ TEST_IMPL(tty_composing_character) { /* Emulate EUR inputs by LEFT ALT+NUMPAD ASCII KeyComos */ make_key_event_records(VK_MENU, 0, FALSE, alt_records); alt_records[1].Event.KeyEvent.uChar.UnicodeChar = EUR_UNICODE; - WriteConsoleInputW(ttyin_fd, &alt_records[0], 1, &written); + WriteConsoleInputW(handle, &alt_records[0], 1, &written); make_key_event_records(VK_NUMPAD0, LEFT_ALT_PRESSED, FALSE, records); - WriteConsoleInputW(ttyin_fd, records, ARRAY_SIZE(records), &written); + WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); ASSERT(written == ARRAY_SIZE(records)); make_key_event_records(VK_NUMPAD1, LEFT_ALT_PRESSED, FALSE, records); - WriteConsoleInputW(ttyin_fd, records, ARRAY_SIZE(records), &written); + WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); ASSERT(written == ARRAY_SIZE(records)); make_key_event_records(VK_NUMPAD2, LEFT_ALT_PRESSED, FALSE, records); - WriteConsoleInputW(ttyin_fd, records, ARRAY_SIZE(records), &written); + WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); ASSERT(written == ARRAY_SIZE(records)); make_key_event_records(VK_NUMPAD8, LEFT_ALT_PRESSED, FALSE, records); - WriteConsoleInputW(ttyin_fd, records, ARRAY_SIZE(records), &written); + WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); ASSERT(written == ARRAY_SIZE(records)); - WriteConsoleInputW(ttyin_fd, &alt_records[1], 1, &written); + WriteConsoleInputW(handle, &alt_records[1], 1, &written); uv_run(loop, UV_RUN_DEFAULT); diff --git a/test/test.gyp b/test/test.gyp index e396c4b1f9e..e59a45f5209 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -137,7 +137,6 @@ 'test-timer-from-check.c', 'test-timer.c', 'test-tty-duplicate-key.c', - 'test-tty-escape-sequence-processing.c', 'test-tty.c', 'test-udp-alloc-cb-fail.c', 'test-udp-bind.c',