mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
deps: upgrade to libuv 1.26.0
Notable changes: - A bug that could result in 100% CPU utilization in Node has been fixed (https://github.com/libuv/libuv/issues/2162) - Node's report module will now include the entire Windows product name (https://github.com/libuv/libuv/pull/2170) PR-URL: https://github.com/nodejs/node/pull/26037 Fixes: https://github.com/nodejs/node/issues/26013 Fixes: https://github.com/nodejs/node/issues/25875 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
3
deps/uv/AUTHORS
vendored
3
deps/uv/AUTHORS
vendored
@@ -366,3 +366,6 @@ ptlomholt <pt@lomholt.com>
|
||||
Victor Costan <pwnall@chromium.org>
|
||||
sid <sidyhe@hotmail.com>
|
||||
Kevin Adler <kadler@us.ibm.com>
|
||||
Stephen Belanger <admin@stephenbelanger.com>
|
||||
yeyuanfeng <yeyuanfeng@bytedance.com>
|
||||
erw7 <erw7.github@gmail.com>
|
||||
|
||||
1
deps/uv/CMakeLists.txt
vendored
1
deps/uv/CMakeLists.txt
vendored
@@ -149,6 +149,7 @@ set(uv_test_sources
|
||||
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
|
||||
|
||||
23
deps/uv/ChangeLog
vendored
23
deps/uv/ChangeLog
vendored
@@ -1,3 +1,26 @@
|
||||
2019.02.11, Version 1.26.0 (Stable), 8669d8d3e93cddb62611b267ef62a3ddb5ba3ca0
|
||||
|
||||
Changes since version 1.25.0:
|
||||
|
||||
* doc: fix uv_get_free_memory doc (Stephen Belanger)
|
||||
|
||||
* unix: fix epoll cpu 100% issue (yeyuanfeng)
|
||||
|
||||
* openbsd,tcp: special handling of EINVAL on connect (ptlomholt)
|
||||
|
||||
* win: simplify registry closing in uv_cpu_info() (cjihrig)
|
||||
|
||||
* src,include: define UV_MAXHOSTNAMESIZE (cjihrig)
|
||||
|
||||
* win: return product name in uv_os_uname() version (cjihrig)
|
||||
|
||||
* thread: allow specifying stack size for new thread (Anna Henningsen)
|
||||
|
||||
* win: fix duplicate tty vt100 fn key (erw7)
|
||||
|
||||
* unix: don't attempt to invalidate invalid fd (Ben Noordhuis)
|
||||
|
||||
|
||||
2019.01.19, Version 1.25.0 (Stable), 4a10a9d425863330af199e4b74bd688e62d945f1
|
||||
|
||||
Changes since version 1.24.1:
|
||||
|
||||
1
deps/uv/Makefile.am
vendored
1
deps/uv/Makefile.am
vendored
@@ -277,6 +277,7 @@ test_run_tests_SOURCES = test/blackhole-server.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 \
|
||||
|
||||
2
deps/uv/configure.ac
vendored
2
deps/uv/configure.ac
vendored
@@ -13,7 +13,7 @@
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
AC_PREREQ(2.57)
|
||||
AC_INIT([libuv], [1.25.0], [https://github.com/libuv/libuv/issues])
|
||||
AC_INIT([libuv], [1.26.0], [https://github.com/libuv/libuv/issues])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
m4_include([m4/libuv-extra-automake-flags.m4])
|
||||
m4_include([m4/as_case.m4])
|
||||
|
||||
9
deps/uv/docs/src/misc.rst
vendored
9
deps/uv/docs/src/misc.rst
vendored
@@ -431,7 +431,10 @@ API
|
||||
|
||||
.. versionadded:: 1.9.0
|
||||
|
||||
.. uint64_t uv_get_free_memory(void)
|
||||
.. c:function:: uint64_t uv_get_free_memory(void)
|
||||
|
||||
Gets memory information (in bytes).
|
||||
|
||||
.. c:function:: uint64_t uv_get_total_memory(void)
|
||||
|
||||
Gets memory information (in bytes).
|
||||
@@ -531,6 +534,10 @@ API
|
||||
|
||||
.. versionadded:: 1.12.0
|
||||
|
||||
.. versionchanged:: 1.26.0 `UV_MAXHOSTNAMESIZE` is available and represents
|
||||
the maximum `buffer` size required to store a
|
||||
hostname and terminating `nul` character.
|
||||
|
||||
.. c:function:: int uv_os_getpriority(uv_pid_t pid, int* priority)
|
||||
|
||||
Retrieves the scheduling priority of the process specified by `pid`. The
|
||||
|
||||
29
deps/uv/docs/src/threading.rst
vendored
29
deps/uv/docs/src/threading.rst
vendored
@@ -55,10 +55,39 @@ API
|
||||
Threads
|
||||
^^^^^^^
|
||||
|
||||
.. c:type:: uv_thread_options_t
|
||||
|
||||
Options for spawning a new thread (passed to :c:func:`uv_thread_create_ex`).
|
||||
|
||||
::
|
||||
|
||||
typedef struct uv_process_options_s {
|
||||
enum {
|
||||
UV_THREAD_NO_FLAGS = 0x00,
|
||||
UV_THREAD_HAS_STACK_SIZE = 0x01
|
||||
} flags;
|
||||
size_t stack_size;
|
||||
} uv_process_options_t;
|
||||
|
||||
More fields may be added to this struct at any time, so its exact
|
||||
layout and size should not be relied upon.
|
||||
|
||||
.. versionadded:: 1.26.0
|
||||
|
||||
.. c:function:: int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg)
|
||||
|
||||
.. versionchanged:: 1.4.1 returns a UV_E* error code on failure
|
||||
|
||||
.. c:function:: int uv_thread_create_ex(uv_thread_t* tid, const uv_thread_options_t* params, uv_thread_cb entry, void* arg)
|
||||
|
||||
Like :c:func:`uv_thread_create`, but additionally specifies options for creating a new thread.
|
||||
|
||||
If `UV_THREAD_HAS_STACK_SIZE` is set, `stack_size` specifies a stack size for the new thread.
|
||||
`0` indicates that the default value should be used, i.e. behaves as if the flag was not set.
|
||||
Other values will be rounded up to the nearest page boundary.
|
||||
|
||||
.. versionadded:: 1.26.0
|
||||
|
||||
.. c:function:: uv_thread_t uv_thread_self(void)
|
||||
.. c:function:: int uv_thread_join(uv_thread_t *tid)
|
||||
.. c:function:: int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2)
|
||||
|
||||
29
deps/uv/include/uv.h
vendored
29
deps/uv/include/uv.h
vendored
@@ -1144,6 +1144,17 @@ UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size);
|
||||
UV_EXTERN int uv_os_setenv(const char* name, const char* value);
|
||||
UV_EXTERN int uv_os_unsetenv(const char* name);
|
||||
|
||||
#ifdef MAXHOSTNAMELEN
|
||||
# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1)
|
||||
#else
|
||||
/*
|
||||
Fallback for the maximum hostname size, including the null terminator. The
|
||||
Windows gethostname() documentation states that 256 bytes will always be
|
||||
large enough to hold the null-terminated hostname.
|
||||
*/
|
||||
# define UV_MAXHOSTNAMESIZE 256
|
||||
#endif
|
||||
|
||||
UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size);
|
||||
|
||||
UV_EXTERN int uv_os_uname(uv_utsname_t* buffer);
|
||||
@@ -1574,6 +1585,24 @@ UV_EXTERN void uv_key_set(uv_key_t* key, void* value);
|
||||
typedef void (*uv_thread_cb)(void* arg);
|
||||
|
||||
UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg);
|
||||
|
||||
typedef enum {
|
||||
UV_THREAD_NO_FLAGS = 0x00,
|
||||
UV_THREAD_HAS_STACK_SIZE = 0x01
|
||||
} uv_thread_create_flags;
|
||||
|
||||
struct uv_thread_options_s {
|
||||
unsigned int flags;
|
||||
size_t stack_size;
|
||||
/* More fields may be added at any time. */
|
||||
};
|
||||
|
||||
typedef struct uv_thread_options_s uv_thread_options_t;
|
||||
|
||||
UV_EXTERN int uv_thread_create_ex(uv_thread_t* tid,
|
||||
const uv_thread_options_t* params,
|
||||
uv_thread_cb entry,
|
||||
void* arg);
|
||||
UV_EXTERN uv_thread_t uv_thread_self(void);
|
||||
UV_EXTERN int uv_thread_join(uv_thread_t *tid);
|
||||
UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2);
|
||||
|
||||
3
deps/uv/include/uv/unix.h
vendored
3
deps/uv/include/uv/unix.h
vendored
@@ -31,13 +31,14 @@
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netdb.h> /* MAXHOSTNAMELEN on Solaris */
|
||||
|
||||
#include <termios.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#if !defined(__MVS__)
|
||||
#include <semaphore.h>
|
||||
#include <sys/param.h> /* MAXHOSTNAMELEN on Linux and the BSDs */
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
|
||||
2
deps/uv/include/uv/version.h
vendored
2
deps/uv/include/uv/version.h
vendored
@@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#define UV_VERSION_MAJOR 1
|
||||
#define UV_VERSION_MINOR 25
|
||||
#define UV_VERSION_MINOR 26
|
||||
#define UV_VERSION_PATCH 0
|
||||
#define UV_VERSION_IS_RELEASE 1
|
||||
#define UV_VERSION_SUFFIX ""
|
||||
|
||||
1
deps/uv/src/unix/aix.c
vendored
1
deps/uv/src/unix/aix.c
vendored
@@ -1041,6 +1041,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
|
||||
struct poll_ctl pc;
|
||||
|
||||
assert(loop->watchers != NULL);
|
||||
assert(fd >= 0);
|
||||
|
||||
events = (struct pollfd*) loop->watchers[loop->nwatchers];
|
||||
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
|
||||
|
||||
15
deps/uv/src/unix/core.c
vendored
15
deps/uv/src/unix/core.c
vendored
@@ -43,7 +43,6 @@
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#ifdef __sun
|
||||
# include <netdb.h> /* MAXHOSTNAMELEN on Solaris */
|
||||
# include <sys/filio.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/wait.h>
|
||||
@@ -88,15 +87,6 @@
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#if !defined(__MVS__)
|
||||
#include <sys/param.h> /* MAXHOSTNAMELEN on Linux and the BSDs */
|
||||
#endif
|
||||
|
||||
/* Fallback for the maximum hostname length */
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
# define MAXHOSTNAMELEN 256
|
||||
#endif
|
||||
|
||||
static int uv__run_pending(uv_loop_t* loop);
|
||||
|
||||
/* Verify that uv_buf_t is ABI-compatible with struct iovec. */
|
||||
@@ -892,7 +882,8 @@ void uv__io_close(uv_loop_t* loop, uv__io_t* w) {
|
||||
QUEUE_REMOVE(&w->pending_queue);
|
||||
|
||||
/* Remove stale events for this file descriptor */
|
||||
uv__platform_invalidate_fd(loop, w->fd);
|
||||
if (w->fd != -1)
|
||||
uv__platform_invalidate_fd(loop, w->fd);
|
||||
}
|
||||
|
||||
|
||||
@@ -1291,7 +1282,7 @@ int uv_os_gethostname(char* buffer, size_t* size) {
|
||||
instead by creating a large enough buffer and comparing the hostname length
|
||||
to the size input.
|
||||
*/
|
||||
char buf[MAXHOSTNAMELEN + 1];
|
||||
char buf[UV_MAXHOSTNAMESIZE];
|
||||
size_t len;
|
||||
|
||||
if (buffer == NULL || size == NULL || *size == 0)
|
||||
|
||||
1
deps/uv/src/unix/kqueue.c
vendored
1
deps/uv/src/unix/kqueue.c
vendored
@@ -387,6 +387,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
|
||||
uintptr_t nfds;
|
||||
|
||||
assert(loop->watchers != NULL);
|
||||
assert(fd >= 0);
|
||||
|
||||
events = (struct kevent*) loop->watchers[loop->nwatchers];
|
||||
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
|
||||
|
||||
1
deps/uv/src/unix/linux-core.c
vendored
1
deps/uv/src/unix/linux-core.c
vendored
@@ -141,6 +141,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
|
||||
uintptr_t nfds;
|
||||
|
||||
assert(loop->watchers != NULL);
|
||||
assert(fd >= 0);
|
||||
|
||||
events = (struct epoll_event*) loop->watchers[loop->nwatchers];
|
||||
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
|
||||
|
||||
1
deps/uv/src/unix/os390.c
vendored
1
deps/uv/src/unix/os390.c
vendored
@@ -657,6 +657,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
|
||||
uintptr_t nfds;
|
||||
|
||||
assert(loop->watchers != NULL);
|
||||
assert(fd >= 0);
|
||||
|
||||
events = (struct epoll_event*) loop->watchers[loop->nwatchers];
|
||||
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
|
||||
|
||||
2
deps/uv/src/unix/pipe.c
vendored
2
deps/uv/src/unix/pipe.c
vendored
@@ -215,7 +215,7 @@ void uv_pipe_connect(uv_connect_t* req,
|
||||
}
|
||||
|
||||
if (err == 0)
|
||||
uv__io_start(handle->loop, &handle->io_watcher, POLLIN | POLLOUT);
|
||||
uv__io_start(handle->loop, &handle->io_watcher, POLLOUT);
|
||||
|
||||
out:
|
||||
handle->delayed_error = err;
|
||||
|
||||
2
deps/uv/src/unix/posix-poll.c
vendored
2
deps/uv/src/unix/posix-poll.c
vendored
@@ -298,6 +298,8 @@ update_timeout:
|
||||
void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
|
||||
size_t i;
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
if (loop->poll_fds_iterating) {
|
||||
/* uv__io_poll is currently iterating. Just invalidate fd. */
|
||||
for (i = 0; i < loop->poll_fds_used; i++)
|
||||
|
||||
1
deps/uv/src/unix/sunos.c
vendored
1
deps/uv/src/unix/sunos.c
vendored
@@ -117,6 +117,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
|
||||
uintptr_t nfds;
|
||||
|
||||
assert(loop->watchers != NULL);
|
||||
assert(fd >= 0);
|
||||
|
||||
events = (struct port_event*) loop->watchers[loop->nwatchers];
|
||||
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
|
||||
|
||||
14
deps/uv/src/unix/tcp.c
vendored
14
deps/uv/src/unix/tcp.c
vendored
@@ -235,12 +235,16 @@ int uv__tcp_connect(uv_connect_t* req,
|
||||
if (r == -1 && errno != 0) {
|
||||
if (errno == EINPROGRESS)
|
||||
; /* not an error */
|
||||
else if (errno == ECONNREFUSED)
|
||||
/* If we get a ECONNREFUSED wait until the next tick to report the
|
||||
* error. Solaris wants to report immediately--other unixes want to
|
||||
* wait.
|
||||
else if (errno == ECONNREFUSED
|
||||
#if defined(__OpenBSD__)
|
||||
|| errno == EINVAL
|
||||
#endif
|
||||
)
|
||||
/* If we get ECONNREFUSED (Solaris) or EINVAL (OpenBSD) wait until the
|
||||
* next tick to report the error. Solaris and OpenBSD wants to report
|
||||
* immediately -- other unixes want to wait.
|
||||
*/
|
||||
handle->delayed_error = UV__ERR(errno);
|
||||
handle->delayed_error = UV__ERR(ECONNREFUSED);
|
||||
else
|
||||
return UV__ERR(errno);
|
||||
}
|
||||
|
||||
25
deps/uv/src/unix/thread.c
vendored
25
deps/uv/src/unix/thread.c
vendored
@@ -194,13 +194,34 @@ static size_t thread_stack_size(void) {
|
||||
|
||||
|
||||
int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) {
|
||||
uv_thread_options_t params;
|
||||
params.flags = UV_THREAD_NO_FLAGS;
|
||||
return uv_thread_create_ex(tid, ¶ms, entry, arg);
|
||||
}
|
||||
|
||||
int uv_thread_create_ex(uv_thread_t* tid,
|
||||
const uv_thread_options_t* params,
|
||||
void (*entry)(void *arg),
|
||||
void *arg) {
|
||||
int err;
|
||||
size_t stack_size;
|
||||
pthread_attr_t* attr;
|
||||
pthread_attr_t attr_storage;
|
||||
size_t pagesize;
|
||||
size_t stack_size;
|
||||
|
||||
stack_size =
|
||||
params->flags & UV_THREAD_HAS_STACK_SIZE ? params->stack_size : 0;
|
||||
|
||||
attr = NULL;
|
||||
stack_size = thread_stack_size();
|
||||
if (stack_size == 0) {
|
||||
stack_size = thread_stack_size();
|
||||
} else {
|
||||
pagesize = (size_t)getpagesize();
|
||||
/* Round up to the nearest page boundary. */
|
||||
stack_size = (stack_size + pagesize - 1) &~ (pagesize - 1);
|
||||
if (stack_size < PTHREAD_STACK_MIN)
|
||||
stack_size = PTHREAD_STACK_MIN;
|
||||
}
|
||||
|
||||
if (stack_size > 0) {
|
||||
attr = &attr_storage;
|
||||
|
||||
27
deps/uv/src/win/thread.c
vendored
27
deps/uv/src/win/thread.c
vendored
@@ -112,9 +112,34 @@ static UINT __stdcall uv__thread_start(void* arg) {
|
||||
|
||||
|
||||
int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) {
|
||||
uv_thread_options_t params;
|
||||
params.flags = UV_THREAD_NO_FLAGS;
|
||||
return uv_thread_create_ex(tid, ¶ms, entry, arg);
|
||||
}
|
||||
|
||||
int uv_thread_create_ex(uv_thread_t* tid,
|
||||
const uv_thread_options_t* params,
|
||||
void (*entry)(void *arg),
|
||||
void *arg) {
|
||||
struct thread_ctx* ctx;
|
||||
int err;
|
||||
HANDLE thread;
|
||||
SYSTEM_INFO sysinfo;
|
||||
size_t stack_size;
|
||||
size_t pagesize;
|
||||
|
||||
stack_size =
|
||||
params->flags & UV_THREAD_HAS_STACK_SIZE ? params->stack_size : 0;
|
||||
|
||||
if (stack_size != 0) {
|
||||
GetNativeSystemInfo(&sysinfo);
|
||||
pagesize = (size_t)sysinfo.dwPageSize;
|
||||
/* Round up to the nearest page boundary. */
|
||||
stack_size = (stack_size + pagesize - 1) &~ (pagesize - 1);
|
||||
|
||||
if ((unsigned)stack_size != stack_size)
|
||||
return UV_EINVAL;
|
||||
}
|
||||
|
||||
ctx = uv__malloc(sizeof(*ctx));
|
||||
if (ctx == NULL)
|
||||
@@ -126,7 +151,7 @@ int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) {
|
||||
/* Create the thread in suspended state so we have a chance to pass
|
||||
* its own creation handle to it */
|
||||
thread = (HANDLE) _beginthreadex(NULL,
|
||||
0,
|
||||
(unsigned)stack_size,
|
||||
uv__thread_start,
|
||||
ctx,
|
||||
CREATE_SUSPENDED,
|
||||
|
||||
4
deps/uv/src/win/tty.c
vendored
4
deps/uv/src/win/tty.c
vendored
@@ -736,8 +736,8 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
|
||||
/* Ignore keyup events, unless the left alt key was held and a valid
|
||||
* unicode character was emitted. */
|
||||
if (!KEV.bKeyDown &&
|
||||
KEV.wVirtualKeyCode != VK_MENU &&
|
||||
KEV.uChar.UnicodeChar != 0) {
|
||||
(KEV.wVirtualKeyCode != VK_MENU ||
|
||||
KEV.uChar.UnicodeChar == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
80
deps/uv/src/win/util.c
vendored
80
deps/uv/src/win/util.c
vendored
@@ -59,13 +59,6 @@
|
||||
# define UNLEN 256
|
||||
#endif
|
||||
|
||||
/*
|
||||
Max hostname length. The Windows gethostname() documentation states that 256
|
||||
bytes will always be large enough to hold the null-terminated hostname.
|
||||
*/
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
# define MAXHOSTNAMELEN 256
|
||||
#endif
|
||||
|
||||
/* Maximum environment variable size, including the terminating null */
|
||||
#define MAX_ENV_VAR_LENGTH 32767
|
||||
@@ -684,12 +677,9 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos_ptr, int* cpu_count_ptr) {
|
||||
NULL,
|
||||
(BYTE*)&cpu_brand,
|
||||
&cpu_brand_size);
|
||||
if (err != ERROR_SUCCESS) {
|
||||
RegCloseKey(processor_key);
|
||||
goto error;
|
||||
}
|
||||
|
||||
RegCloseKey(processor_key);
|
||||
if (err != ERROR_SUCCESS)
|
||||
goto error;
|
||||
|
||||
cpu_info = &cpu_infos[i];
|
||||
cpu_info->speed = cpu_speed;
|
||||
@@ -1510,7 +1500,7 @@ int uv_os_unsetenv(const char* name) {
|
||||
|
||||
|
||||
int uv_os_gethostname(char* buffer, size_t* size) {
|
||||
char buf[MAXHOSTNAMELEN + 1];
|
||||
char buf[UV_MAXHOSTNAMESIZE];
|
||||
size_t len;
|
||||
|
||||
if (buffer == NULL || size == NULL || *size == 0)
|
||||
@@ -1634,6 +1624,10 @@ int uv_os_uname(uv_utsname_t* buffer) {
|
||||
https://github.com/gagern/gnulib/blob/master/lib/uname.c */
|
||||
OSVERSIONINFOW os_info;
|
||||
SYSTEM_INFO system_info;
|
||||
HKEY registry_key;
|
||||
WCHAR product_name_w[256];
|
||||
DWORD product_name_w_size;
|
||||
int version_size;
|
||||
int processor_level;
|
||||
int r;
|
||||
|
||||
@@ -1658,16 +1652,56 @@ int uv_os_uname(uv_utsname_t* buffer) {
|
||||
}
|
||||
|
||||
/* Populate the version field. */
|
||||
if (WideCharToMultiByte(CP_UTF8,
|
||||
0,
|
||||
os_info.szCSDVersion,
|
||||
-1,
|
||||
buffer->version,
|
||||
sizeof(buffer->version),
|
||||
NULL,
|
||||
NULL) == 0) {
|
||||
r = uv_translate_sys_error(GetLastError());
|
||||
goto error;
|
||||
version_size = 0;
|
||||
r = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
|
||||
0,
|
||||
KEY_QUERY_VALUE,
|
||||
®istry_key);
|
||||
|
||||
if (r == ERROR_SUCCESS) {
|
||||
product_name_w_size = sizeof(product_name_w);
|
||||
r = RegGetValueW(registry_key,
|
||||
NULL,
|
||||
L"ProductName",
|
||||
RRF_RT_REG_SZ,
|
||||
NULL,
|
||||
(PVOID) product_name_w,
|
||||
&product_name_w_size);
|
||||
RegCloseKey(registry_key);
|
||||
|
||||
if (r == ERROR_SUCCESS) {
|
||||
version_size = WideCharToMultiByte(CP_UTF8,
|
||||
0,
|
||||
product_name_w,
|
||||
-1,
|
||||
buffer->version,
|
||||
sizeof(buffer->version),
|
||||
NULL,
|
||||
NULL);
|
||||
if (version_size == 0) {
|
||||
r = uv_translate_sys_error(GetLastError());
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Append service pack information to the version if present. */
|
||||
if (os_info.szCSDVersion[0] != L'\0') {
|
||||
if (version_size > 0)
|
||||
buffer->version[version_size - 1] = ' ';
|
||||
|
||||
if (WideCharToMultiByte(CP_UTF8,
|
||||
0,
|
||||
os_info.szCSDVersion,
|
||||
-1,
|
||||
buffer->version + version_size,
|
||||
sizeof(buffer->version) - version_size,
|
||||
NULL,
|
||||
NULL) == 0) {
|
||||
r = uv_translate_sys_error(GetLastError());
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
/* Populate the sysname field. */
|
||||
|
||||
8
deps/uv/test/test-gethostname.c
vendored
8
deps/uv/test/test-gethostname.c
vendored
@@ -23,12 +23,8 @@
|
||||
#include "task.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
# define MAXHOSTNAMELEN 256
|
||||
#endif
|
||||
|
||||
TEST_IMPL(gethostname) {
|
||||
char buf[MAXHOSTNAMELEN + 1];
|
||||
char buf[UV_MAXHOSTNAMESIZE];
|
||||
size_t size;
|
||||
size_t enobufs_size;
|
||||
int r;
|
||||
@@ -52,7 +48,7 @@ TEST_IMPL(gethostname) {
|
||||
ASSERT(enobufs_size > 1);
|
||||
|
||||
/* Successfully get the hostname */
|
||||
size = MAXHOSTNAMELEN + 1;
|
||||
size = UV_MAXHOSTNAMESIZE;
|
||||
r = uv_os_gethostname(buf, &size);
|
||||
ASSERT(r == 0);
|
||||
ASSERT(size > 1 && size == strlen(buf));
|
||||
|
||||
8
deps/uv/test/test-list.h
vendored
8
deps/uv/test/test-list.h
vendored
@@ -53,6 +53,9 @@ TEST_DECLARE (tty_raw)
|
||||
TEST_DECLARE (tty_empty_write)
|
||||
TEST_DECLARE (tty_large_write)
|
||||
TEST_DECLARE (tty_raw_cancel)
|
||||
TEST_DECLARE (tty_duplicate_vt100_fn_key)
|
||||
TEST_DECLARE (tty_duplicate_alt_modifier_key)
|
||||
TEST_DECLARE (tty_composing_character)
|
||||
#endif
|
||||
TEST_DECLARE (tty_file)
|
||||
TEST_DECLARE (tty_pty)
|
||||
@@ -365,6 +368,7 @@ TEST_DECLARE (threadpool_cancel_fs)
|
||||
TEST_DECLARE (threadpool_cancel_single)
|
||||
TEST_DECLARE (thread_local_storage)
|
||||
TEST_DECLARE (thread_stack_size)
|
||||
TEST_DECLARE (thread_stack_size_explicit)
|
||||
TEST_DECLARE (thread_mutex)
|
||||
TEST_DECLARE (thread_mutex_recursive)
|
||||
TEST_DECLARE (thread_rwlock)
|
||||
@@ -500,6 +504,9 @@ TASK_LIST_START
|
||||
TEST_ENTRY (tty_empty_write)
|
||||
TEST_ENTRY (tty_large_write)
|
||||
TEST_ENTRY (tty_raw_cancel)
|
||||
TEST_ENTRY (tty_duplicate_vt100_fn_key)
|
||||
TEST_ENTRY (tty_duplicate_alt_modifier_key)
|
||||
TEST_ENTRY (tty_composing_character)
|
||||
#endif
|
||||
TEST_ENTRY (tty_file)
|
||||
TEST_ENTRY (tty_pty)
|
||||
@@ -930,6 +937,7 @@ TASK_LIST_START
|
||||
TEST_ENTRY (threadpool_cancel_single)
|
||||
TEST_ENTRY (thread_local_storage)
|
||||
TEST_ENTRY (thread_stack_size)
|
||||
TEST_ENTRY (thread_stack_size_explicit)
|
||||
TEST_ENTRY (thread_mutex)
|
||||
TEST_ENTRY (thread_mutex_recursive)
|
||||
TEST_ENTRY (thread_rwlock)
|
||||
|
||||
57
deps/uv/test/test-thread.c
vendored
57
deps/uv/test/test-thread.c
vendored
@@ -26,6 +26,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* memset */
|
||||
|
||||
#ifdef __POSIX__
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
struct getaddrinfo_req {
|
||||
uv_thread_t thread_id;
|
||||
unsigned int counter;
|
||||
@@ -207,10 +211,15 @@ TEST_IMPL(thread_local_storage) {
|
||||
|
||||
static void thread_check_stack(void* arg) {
|
||||
#if defined(__APPLE__)
|
||||
size_t expected;
|
||||
expected = arg == NULL ? 0 : ((uv_thread_options_t*)arg)->stack_size;
|
||||
/* 512 kB is the default stack size of threads other than the main thread
|
||||
* on MacOS. */
|
||||
ASSERT(pthread_get_stacksize_np(pthread_self()) > 512*1024);
|
||||
if (expected == 0)
|
||||
expected = 512 * 1024;
|
||||
ASSERT(pthread_get_stacksize_np(pthread_self()) >= expected);
|
||||
#elif defined(__linux__) && defined(__GLIBC__)
|
||||
size_t expected;
|
||||
struct rlimit lim;
|
||||
size_t stack_size;
|
||||
pthread_attr_t attr;
|
||||
@@ -219,7 +228,10 @@ static void thread_check_stack(void* arg) {
|
||||
lim.rlim_cur = 2 << 20; /* glibc default. */
|
||||
ASSERT(0 == pthread_getattr_np(pthread_self(), &attr));
|
||||
ASSERT(0 == pthread_attr_getstacksize(&attr, &stack_size));
|
||||
ASSERT(stack_size >= lim.rlim_cur);
|
||||
expected = arg == NULL ? 0 : ((uv_thread_options_t*)arg)->stack_size;
|
||||
if (expected == 0)
|
||||
expected = (size_t)lim.rlim_cur;
|
||||
ASSERT(stack_size >= expected);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -230,3 +242,44 @@ TEST_IMPL(thread_stack_size) {
|
||||
ASSERT(0 == uv_thread_join(&thread));
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_IMPL(thread_stack_size_explicit) {
|
||||
uv_thread_t thread;
|
||||
uv_thread_options_t options;
|
||||
|
||||
options.flags = UV_THREAD_HAS_STACK_SIZE;
|
||||
options.stack_size = 1024 * 1024;
|
||||
ASSERT(0 == uv_thread_create_ex(&thread, &options,
|
||||
thread_check_stack, &options));
|
||||
ASSERT(0 == uv_thread_join(&thread));
|
||||
|
||||
options.stack_size = 8 * 1024 * 1024; /* larger than most default os sizes */
|
||||
ASSERT(0 == uv_thread_create_ex(&thread, &options,
|
||||
thread_check_stack, &options));
|
||||
ASSERT(0 == uv_thread_join(&thread));
|
||||
|
||||
options.stack_size = 0;
|
||||
ASSERT(0 == uv_thread_create_ex(&thread, &options,
|
||||
thread_check_stack, &options));
|
||||
ASSERT(0 == uv_thread_join(&thread));
|
||||
|
||||
#ifdef PTHREAD_STACK_MIN
|
||||
options.stack_size = PTHREAD_STACK_MIN - 42; /* unaligned size */
|
||||
ASSERT(0 == uv_thread_create_ex(&thread, &options,
|
||||
thread_check_stack, &options));
|
||||
ASSERT(0 == uv_thread_join(&thread));
|
||||
|
||||
options.stack_size = PTHREAD_STACK_MIN / 2 - 42; /* unaligned size */
|
||||
ASSERT(0 == uv_thread_create_ex(&thread, &options,
|
||||
thread_check_stack, &options));
|
||||
ASSERT(0 == uv_thread_join(&thread));
|
||||
#endif
|
||||
|
||||
/* unaligned size, should be larger than PTHREAD_STACK_MIN */
|
||||
options.stack_size = 1234567;
|
||||
ASSERT(0 == uv_thread_create_ex(&thread, &options,
|
||||
thread_check_stack, &options));
|
||||
ASSERT(0 == uv_thread_join(&thread));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
321
deps/uv/test/test-tty-duplicate-key.c
vendored
Normal file
321
deps/uv/test/test-tty-duplicate-key.c
vendored
Normal file
@@ -0,0 +1,321 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include "uv.h"
|
||||
#include "task.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <io.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
|
||||
#define ESC "\x1b"
|
||||
#define EUR_UTF8 "\xe2\x82\xac"
|
||||
#define EUR_UNICODE 0x20AC
|
||||
|
||||
|
||||
const char* expect_str = NULL;
|
||||
ssize_t expect_nread = 0;
|
||||
|
||||
static void dump_str(const char* str, ssize_t len) {
|
||||
ssize_t i;
|
||||
for (i = 0; i < len; i++) {
|
||||
fprintf(stderr, "%#02x ", *(str + i));
|
||||
}
|
||||
}
|
||||
|
||||
static void print_err_msg(const char* expect, ssize_t expect_len,
|
||||
const char* found, ssize_t found_len) {
|
||||
fprintf(stderr, "expect ");
|
||||
dump_str(expect, expect_len);
|
||||
fprintf(stderr, ", but found ");
|
||||
dump_str(found, found_len);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static void tty_read(uv_stream_t* tty_in, ssize_t nread, const uv_buf_t* buf) {
|
||||
if (nread > 0) {
|
||||
if (nread != expect_nread) {
|
||||
fprintf(stderr, "expected nread %ld, but found %ld\n",
|
||||
(long)expect_nread, (long)nread);
|
||||
print_err_msg(expect_str, expect_nread, buf->base, nread);
|
||||
ASSERT(FALSE);
|
||||
}
|
||||
if (strncmp(buf->base, expect_str, nread) != 0) {
|
||||
print_err_msg(expect_str, expect_nread, buf->base, nread);
|
||||
ASSERT(FALSE);
|
||||
}
|
||||
uv_close((uv_handle_t*) tty_in, NULL);
|
||||
} else {
|
||||
ASSERT(nread == 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void make_key_event_records(WORD virt_key, DWORD ctr_key_state,
|
||||
BOOL is_wsl, INPUT_RECORD* records) {
|
||||
# define KEV(I) records[(I)].Event.KeyEvent
|
||||
BYTE kb_state[256] = {0};
|
||||
WCHAR buf[2];
|
||||
int ret;
|
||||
|
||||
records[0].EventType = records[1].EventType = KEY_EVENT;
|
||||
KEV(0).bKeyDown = TRUE;
|
||||
KEV(1).bKeyDown = FALSE;
|
||||
KEV(0).wVirtualKeyCode = KEV(1).wVirtualKeyCode = virt_key;
|
||||
KEV(0).wRepeatCount = KEV(1).wRepeatCount = 1;
|
||||
KEV(0).wVirtualScanCode = KEV(1).wVirtualScanCode =
|
||||
MapVirtualKeyW(virt_key, MAPVK_VK_TO_VSC);
|
||||
KEV(0).dwControlKeyState = KEV(1).dwControlKeyState = ctr_key_state;
|
||||
if (ctr_key_state & LEFT_ALT_PRESSED) {
|
||||
kb_state[VK_LMENU] = 0x01;
|
||||
}
|
||||
if (ctr_key_state & RIGHT_ALT_PRESSED) {
|
||||
kb_state[VK_RMENU] = 0x01;
|
||||
}
|
||||
if (ctr_key_state & LEFT_CTRL_PRESSED) {
|
||||
kb_state[VK_LCONTROL] = 0x01;
|
||||
}
|
||||
if (ctr_key_state & RIGHT_CTRL_PRESSED) {
|
||||
kb_state[VK_RCONTROL] = 0x01;
|
||||
}
|
||||
if (ctr_key_state & SHIFT_PRESSED) {
|
||||
kb_state[VK_SHIFT] = 0x01;
|
||||
}
|
||||
ret = ToUnicode(virt_key, KEV(0).wVirtualScanCode, kb_state, buf, 2, 0);
|
||||
if (ret == 1) {
|
||||
if(!is_wsl &&
|
||||
((ctr_key_state & LEFT_ALT_PRESSED) ||
|
||||
(ctr_key_state & RIGHT_ALT_PRESSED))) {
|
||||
/*
|
||||
* If ALT key is pressed, the UnicodeChar value of the keyup event is
|
||||
* set to 0 on nomal console. Emulate this behavior.
|
||||
* See https://github.com/Microsoft/console/issues/320
|
||||
*/
|
||||
KEV(0).uChar.UnicodeChar = buf[0];
|
||||
KEV(1).uChar.UnicodeChar = 0;
|
||||
} else{
|
||||
/*
|
||||
* In WSL UnicodeChar is normally set. This behavior cause #2111.
|
||||
*/
|
||||
KEV(0).uChar.UnicodeChar = KEV(1).uChar.UnicodeChar = buf[0];
|
||||
}
|
||||
} else {
|
||||
KEV(0).uChar.UnicodeChar = KEV(1).uChar.UnicodeChar = 0;
|
||||
}
|
||||
# undef KEV
|
||||
}
|
||||
|
||||
TEST_IMPL(tty_duplicate_vt100_fn_key) {
|
||||
int r;
|
||||
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 */
|
||||
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. */
|
||||
ASSERT(r == 0);
|
||||
ASSERT(uv_is_readable((uv_stream_t*) &tty_in));
|
||||
ASSERT(!uv_is_writable((uv_stream_t*) &tty_in));
|
||||
|
||||
r = uv_read_start((uv_stream_t*)&tty_in, tty_alloc, tty_read);
|
||||
ASSERT(r == 0);
|
||||
|
||||
expect_str = ESC"[[A";
|
||||
expect_nread = strlen(expect_str);
|
||||
|
||||
/* Turn on raw mode. */
|
||||
r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_RAW);
|
||||
ASSERT(r == 0);
|
||||
|
||||
/*
|
||||
* Send F1 keystrokes. Test of issue cause by #2114 that vt100 fn key
|
||||
* duplicate.
|
||||
*/
|
||||
make_key_event_records(VK_F1, 0, TRUE, records);
|
||||
WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written);
|
||||
ASSERT(written == ARRAY_SIZE(records));
|
||||
|
||||
uv_run(loop, UV_RUN_DEFAULT);
|
||||
|
||||
MAKE_VALGRIND_HAPPY();
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_IMPL(tty_duplicate_alt_modifier_key) {
|
||||
int r;
|
||||
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;
|
||||
|
||||
loop = uv_default_loop();
|
||||
|
||||
/* Make sure we have an FD that refers to a tty */
|
||||
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. */
|
||||
ASSERT(r == 0);
|
||||
ASSERT(uv_is_readable((uv_stream_t*) &tty_in));
|
||||
ASSERT(!uv_is_writable((uv_stream_t*) &tty_in));
|
||||
|
||||
r = uv_read_start((uv_stream_t*)&tty_in, tty_alloc, tty_read);
|
||||
ASSERT(r == 0);
|
||||
|
||||
expect_str = ESC"a"ESC"a";
|
||||
expect_nread = strlen(expect_str);
|
||||
|
||||
/* Turn on raw mode. */
|
||||
r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_RAW);
|
||||
ASSERT(r == 0);
|
||||
|
||||
/* Emulate transmission of M-a at normal console */
|
||||
make_key_event_records(VK_MENU, 0, TRUE, alt_records);
|
||||
WriteConsoleInputW(handle, &alt_records[0], 1, &written);
|
||||
ASSERT(written == 1);
|
||||
make_key_event_records(L'A', LEFT_ALT_PRESSED, FALSE, records);
|
||||
WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written);
|
||||
ASSERT(written == 2);
|
||||
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(handle, &alt_records[0], 1, &written);
|
||||
ASSERT(written == 1);
|
||||
make_key_event_records(L'A', LEFT_ALT_PRESSED, TRUE, records);
|
||||
WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written);
|
||||
ASSERT(written == 2);
|
||||
WriteConsoleInputW(handle, &alt_records[1], 1, &written);
|
||||
ASSERT(written == 1);
|
||||
|
||||
uv_run(loop, UV_RUN_DEFAULT);
|
||||
|
||||
MAKE_VALGRIND_HAPPY();
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_IMPL(tty_composing_character) {
|
||||
int r;
|
||||
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;
|
||||
|
||||
loop = uv_default_loop();
|
||||
|
||||
/* Make sure we have an FD that refers to a tty */
|
||||
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. */
|
||||
ASSERT(r == 0);
|
||||
ASSERT(uv_is_readable((uv_stream_t*) &tty_in));
|
||||
ASSERT(!uv_is_writable((uv_stream_t*) &tty_in));
|
||||
|
||||
r = uv_read_start((uv_stream_t*)&tty_in, tty_alloc, tty_read);
|
||||
ASSERT(r == 0);
|
||||
|
||||
expect_str = EUR_UTF8;
|
||||
expect_nread = strlen(expect_str);
|
||||
|
||||
/* Turn on raw mode. */
|
||||
r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_RAW);
|
||||
ASSERT(r == 0);
|
||||
|
||||
/* 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(handle, &alt_records[0], 1, &written);
|
||||
make_key_event_records(VK_NUMPAD0, LEFT_ALT_PRESSED, FALSE, records);
|
||||
WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written);
|
||||
ASSERT(written == ARRAY_SIZE(records));
|
||||
make_key_event_records(VK_NUMPAD1, LEFT_ALT_PRESSED, FALSE, records);
|
||||
WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written);
|
||||
ASSERT(written == ARRAY_SIZE(records));
|
||||
make_key_event_records(VK_NUMPAD2, LEFT_ALT_PRESSED, FALSE, records);
|
||||
WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written);
|
||||
ASSERT(written == ARRAY_SIZE(records));
|
||||
make_key_event_records(VK_NUMPAD8, LEFT_ALT_PRESSED, FALSE, records);
|
||||
WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written);
|
||||
ASSERT(written == ARRAY_SIZE(records));
|
||||
WriteConsoleInputW(handle, &alt_records[1], 1, &written);
|
||||
|
||||
uv_run(loop, UV_RUN_DEFAULT);
|
||||
|
||||
MAKE_VALGRIND_HAPPY();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */
|
||||
|
||||
#endif /* ifndef _WIN32 */
|
||||
1
deps/uv/test/test.gyp
vendored
1
deps/uv/test/test.gyp
vendored
@@ -133,6 +133,7 @@
|
||||
'test-timer-again.c',
|
||||
'test-timer-from-check.c',
|
||||
'test-timer.c',
|
||||
'test-tty-duplicate-key.c',
|
||||
'test-tty.c',
|
||||
'test-udp-alloc-cb-fail.c',
|
||||
'test-udp-bind.c',
|
||||
|
||||
Reference in New Issue
Block a user