mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
1 parent
c82828ec27
commit
bc96302fae
17 files changed
+256
-53
No files matched your search
Vendored
+22
@@ -76,12 +76,14 @@ typedef enum {
|
||||
UV_ENFILE,
|
||||
UV_ENOBUFS,
|
||||
UV_ENOMEM,
|
||||
UV_ENOTDIR,
|
||||
UV_ENONET,
|
||||
UV_ENOPROTOOPT,
|
||||
UV_ENOTCONN,
|
||||
UV_ENOTSOCK,
|
||||
UV_ENOTSUP,
|
||||
UV_ENOENT,
|
||||
UV_ENOSYS,
|
||||
UV_EPIPE,
|
||||
UV_EPROTO,
|
||||
UV_EPROTONOSUPPORT,
|
||||
@@ -239,6 +241,11 @@ typedef void (*uv_after_work_cb)(uv_work_t* req);
|
||||
typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, const char* filename,
|
||||
int events, int status);
|
||||
|
||||
typedef enum {
|
||||
UV_LEAVE_GROUP = 0,
|
||||
UV_JOIN_GROUP
|
||||
} uv_membership;
|
||||
|
||||
|
||||
struct uv_err_s {
|
||||
/* read-only */
|
||||
@@ -550,6 +557,21 @@ int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr, unsigned flags);
|
||||
int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr, unsigned flags);
|
||||
int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name, int* namelen);
|
||||
|
||||
/*
|
||||
* Set membership for a multicast address
|
||||
*
|
||||
* Arguments:
|
||||
* handle UDP handle. Should have been initialized with `uv_udp_init`.
|
||||
* multicast_addr multicast address to set membership for
|
||||
* interface_addr interface address
|
||||
* membership Should be UV_JOIN_GROUP or UV_LEAVE_GROUP
|
||||
*
|
||||
* Returns:
|
||||
* 0 on success, -1 on error.
|
||||
*/
|
||||
int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr,
|
||||
const char* interface_addr, uv_membership membership);
|
||||
|
||||
/*
|
||||
* Send data. If the socket has not previously been bound with `uv_udp_bind`
|
||||
* or `uv_udp_bind6`, it is bound to 0.0.0.0 (the "all interfaces" address)
|
||||
|
||||
Vendored
+1
-1
@@ -11,7 +11,7 @@
|
||||
#define HAVE_UTIMES 1
|
||||
|
||||
/* futimes(2) is available */
|
||||
/* #undef HAVE_FUTIMES */
|
||||
#define HAVE_FUTIMES 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
Vendored
+4
@@ -108,6 +108,10 @@ static void eio_destroy (eio_req *req);
|
||||
|
||||
#define EIO_ENOSYS() EIO_ERRNO (ENOSYS, -1)
|
||||
|
||||
#ifdef __sun
|
||||
# define futimes(fd, times) futimesat (fd, NULL, times)
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <direct.h>
|
||||
|
||||
Vendored
+4
@@ -58,6 +58,7 @@ void uv_fatal_error(const int errorno, const char* syscall) {
|
||||
|
||||
static int uv__translate_lib_error(int code) {
|
||||
switch (code) {
|
||||
case UV_ENOSYS: return ENOSYS;
|
||||
case UV_ENOENT: return ENOENT;
|
||||
case UV_EACCESS: return EACCES;
|
||||
case UV_EBADF: return EBADF;
|
||||
@@ -71,6 +72,7 @@ static int uv__translate_lib_error(int code) {
|
||||
case UV_ECONNREFUSED: return ECONNREFUSED;
|
||||
case UV_EADDRINUSE: return EADDRINUSE;
|
||||
case UV_EADDRNOTAVAIL: return EADDRNOTAVAIL;
|
||||
case UV_ENOTDIR: return ENOTDIR;
|
||||
case UV_ENOTCONN: return ENOTCONN;
|
||||
case UV_EEXIST: return EEXIST;
|
||||
default: return -1;
|
||||
@@ -84,6 +86,7 @@ static int uv__translate_lib_error(int code) {
|
||||
uv_err_code uv_translate_sys_error(int sys_errno) {
|
||||
switch (sys_errno) {
|
||||
case 0: return UV_OK;
|
||||
case ENOSYS: return UV_ENOSYS;
|
||||
case ENOENT: return UV_ENOENT;
|
||||
case EACCES: return UV_EACCESS;
|
||||
case EBADF: return UV_EBADF;
|
||||
@@ -97,6 +100,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
|
||||
case ECONNREFUSED: return UV_ECONNREFUSED;
|
||||
case EADDRINUSE: return UV_EADDRINUSE;
|
||||
case EADDRNOTAVAIL: return UV_EADDRNOTAVAIL;
|
||||
case ENOTDIR: return UV_ENOTDIR;
|
||||
case ENOTCONN: return UV_ENOTCONN;
|
||||
case EEXIST: return UV_EEXIST;
|
||||
default: return UV_UNKNOWN;
|
||||
|
||||
Vendored
+6
-2
@@ -496,7 +496,7 @@ int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime,
|
||||
}
|
||||
|
||||
|
||||
#if defined(HAVE_FUTIMES)
|
||||
#if HAVE_FUTIMES
|
||||
static int _futime(const uv_file file, double atime, double mtime) {
|
||||
struct timeval tv[2];
|
||||
|
||||
@@ -507,14 +507,18 @@ static int _futime(const uv_file file, double atime, double mtime) {
|
||||
tv[1].tv_sec = mtime;
|
||||
tv[1].tv_usec = (unsigned long)(mtime * 1000000) % 1000000;
|
||||
|
||||
#ifdef __sun
|
||||
return futimesat(file, NULL, tv);
|
||||
#else
|
||||
return futimes(file, tv);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime,
|
||||
double mtime, uv_fs_cb cb) {
|
||||
#if defined(HAVE_FUTIMES)
|
||||
#if HAVE_FUTIMES
|
||||
const char* path = NULL;
|
||||
|
||||
uv_fs_req_init(loop, req, UV_FS_FUTIME, path, cb);
|
||||
|
||||
Vendored
+1
-5
@@ -49,11 +49,7 @@
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
#ifdef __APPLE__
|
||||
# define HAVE_FUTIMES 1
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun)
|
||||
# define HAVE_FUTIMES 1
|
||||
#endif
|
||||
|
||||
|
||||
Vendored
+3
-21
@@ -65,28 +65,9 @@ int uv_exepath(char* buffer, size_t* size) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
double uv_get_free_memory(void) {
|
||||
kstat_ctl_t *kc;
|
||||
kstat_t *ksp;
|
||||
kstat_named_t *knp;
|
||||
|
||||
ulong_t freemem;
|
||||
|
||||
if ((kc = kstat_open()) == NULL) return -1;
|
||||
|
||||
ksp = kstat_lookup(kc, (char *)"unix", 0, (char *)"system_pages");
|
||||
|
||||
if(kstat_read(kc, ksp, NULL) == -1){
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
knp = (kstat_named_t *) kstat_data_lookup(ksp, (char *)"freemem");
|
||||
freemem = knp->value.ul;
|
||||
}
|
||||
|
||||
kstat_close(kc);
|
||||
|
||||
return (double) freemem * sysconf(_SC_PAGESIZE);
|
||||
return (double) sysconf(_SC_PAGESIZE) * sysconf(_SC_AVPHYS_PAGES);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +75,7 @@ double uv_get_total_memory(void) {
|
||||
return (double) sysconf(_SC_PAGESIZE) * sysconf(_SC_PHYS_PAGES);
|
||||
}
|
||||
|
||||
|
||||
void uv_loadavg(double avg[3]) {
|
||||
(void) getloadavg(avg, 3);
|
||||
}
|
||||
|
||||
Vendored
+36
@@ -459,6 +459,42 @@ int uv__udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr, unsigned flags) {
|
||||
}
|
||||
|
||||
|
||||
int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr,
|
||||
const char* interface_addr, uv_membership membership) {
|
||||
|
||||
int optname;
|
||||
struct ip_mreq mreq;
|
||||
memset(&mreq, 0, sizeof mreq);
|
||||
|
||||
if (interface_addr) {
|
||||
mreq.imr_interface.s_addr = inet_addr(interface_addr);
|
||||
} else {
|
||||
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
||||
}
|
||||
|
||||
mreq.imr_multiaddr.s_addr = inet_addr(multicast_addr);
|
||||
|
||||
switch (membership) {
|
||||
case UV_JOIN_GROUP:
|
||||
optname = IP_ADD_MEMBERSHIP;
|
||||
break;
|
||||
case UV_LEAVE_GROUP:
|
||||
optname = IP_DROP_MEMBERSHIP;
|
||||
break;
|
||||
default:
|
||||
uv__set_sys_error(handle->loop, EFAULT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (setsockopt(handle->fd, IPPROTO_IP, optname, (void*) &mreq, sizeof mreq) == -1) {
|
||||
uv__set_sys_error(handle->loop, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name,
|
||||
int* namelen) {
|
||||
socklen_t socklen;
|
||||
|
||||
Vendored
+2
@@ -76,12 +76,14 @@ const char* uv_err_name(uv_err_t err) {
|
||||
case UV_ENFILE: return "ENFILE";
|
||||
case UV_ENOBUFS: return "ENOBUFS";
|
||||
case UV_ENOMEM: return "ENOMEM";
|
||||
case UV_ENOTDIR: return "ENOTDIR";
|
||||
case UV_ENONET: return "ENONET";
|
||||
case UV_ENOPROTOOPT: return "ENOPROTOOPT";
|
||||
case UV_ENOTCONN: return "ENOTCONN";
|
||||
case UV_ENOTSOCK: return "ENOTSOCK";
|
||||
case UV_ENOTSUP: return "ENOTSUP";
|
||||
case UV_ENOENT: return "ENOENT";
|
||||
case UV_ENOSYS: return "ENOSYS";
|
||||
case UV_EPIPE: return "EPIPE";
|
||||
case UV_EPROTO: return "EPROTO";
|
||||
case UV_EPROTONOSUPPORT: return "EPROTONOSUPPORT";
|
||||
|
||||
Vendored
+44
-11
@@ -72,7 +72,6 @@
|
||||
req->flags |= UV_FS_ASYNC_QUEUED; \
|
||||
uv_ref((loop));
|
||||
|
||||
|
||||
#define SET_UV_LAST_ERROR_FROM_REQ(req) \
|
||||
if (req->flags & UV_FS_LAST_ERROR_SET) { \
|
||||
uv__set_sys_error(req->loop, req->last_error); \
|
||||
@@ -96,6 +95,14 @@
|
||||
req->errorno = uv_translate_sys_error(sys_errno); \
|
||||
SET_REQ_LAST_ERROR(req, sys_errno);
|
||||
|
||||
#define VERIFY_UV_FILE(file, req) \
|
||||
if (file == -1) { \
|
||||
req->result = -1; \
|
||||
req->errorno = UV_EBADF; \
|
||||
req->last_error = ERROR_SUCCESS; \
|
||||
return; \
|
||||
}
|
||||
|
||||
|
||||
void uv_fs_init() {
|
||||
_fmode = _O_BINARY;
|
||||
@@ -241,7 +248,11 @@ end:
|
||||
}
|
||||
|
||||
void fs__close(uv_fs_t* req, uv_file file) {
|
||||
int result = _close(file);
|
||||
int result;
|
||||
|
||||
VERIFY_UV_FILE(file, req);
|
||||
|
||||
result = _close(file);
|
||||
SET_REQ_RESULT(req, result);
|
||||
}
|
||||
|
||||
@@ -253,6 +264,8 @@ void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,
|
||||
LARGE_INTEGER offset_;
|
||||
DWORD bytes;
|
||||
|
||||
VERIFY_UV_FILE(file, req);
|
||||
|
||||
handle = (HANDLE) _get_osfhandle(file);
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
SET_REQ_RESULT(req, -1);
|
||||
@@ -291,6 +304,8 @@ void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length,
|
||||
LARGE_INTEGER offset_;
|
||||
DWORD bytes;
|
||||
|
||||
VERIFY_UV_FILE(file, req);
|
||||
|
||||
handle = (HANDLE) _get_osfhandle(file);
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
SET_REQ_RESULT(req, -1);
|
||||
@@ -342,7 +357,7 @@ void fs__rmdir(uv_fs_t* req, const char* path) {
|
||||
|
||||
void fs__readdir(uv_fs_t* req, const char* path, int flags) {
|
||||
int result;
|
||||
char* buf, *ptr, *name;
|
||||
char* buf = NULL, *ptr, *name;
|
||||
HANDLE dir;
|
||||
WIN32_FIND_DATAA ent = {0};
|
||||
size_t len = strlen(path);
|
||||
@@ -365,12 +380,6 @@ void fs__readdir(uv_fs_t* req, const char* path, int flags) {
|
||||
return;
|
||||
}
|
||||
|
||||
buf = (char*)malloc(buf_size);
|
||||
if (!buf) {
|
||||
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
||||
}
|
||||
|
||||
ptr = buf;
|
||||
result = 0;
|
||||
|
||||
do {
|
||||
@@ -379,6 +388,15 @@ void fs__readdir(uv_fs_t* req, const char* path, int flags) {
|
||||
if (name[0] != '.' || (name[1] && (name[1] != '.' || name[2]))) {
|
||||
len = strlen(name);
|
||||
|
||||
if (!buf) {
|
||||
buf = (char*)malloc(buf_size);
|
||||
if (!buf) {
|
||||
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
||||
}
|
||||
|
||||
ptr = buf;
|
||||
}
|
||||
|
||||
while ((ptr - buf) + len + 1 > buf_size) {
|
||||
buf_size *= 2;
|
||||
path2 = buf;
|
||||
@@ -422,6 +440,8 @@ void fs__stat(uv_fs_t* req, const char* path) {
|
||||
void fs__fstat(uv_fs_t* req, uv_file file) {
|
||||
int result;
|
||||
|
||||
VERIFY_UV_FILE(file, req);
|
||||
|
||||
result = _fstati64(file, &req->stat);
|
||||
if (result == -1) {
|
||||
req->ptr = NULL;
|
||||
@@ -440,7 +460,11 @@ void fs__rename(uv_fs_t* req, const char* path, const char* new_path) {
|
||||
|
||||
|
||||
void fs__fsync(uv_fs_t* req, uv_file file) {
|
||||
int result = FlushFileBuffers((HANDLE)_get_osfhandle(file)) ? 0 : -1;
|
||||
int result;
|
||||
|
||||
VERIFY_UV_FILE(file, req);
|
||||
|
||||
result = FlushFileBuffers((HANDLE)_get_osfhandle(file)) ? 0 : -1;
|
||||
if (result == -1) {
|
||||
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
|
||||
} else {
|
||||
@@ -450,7 +474,11 @@ void fs__fsync(uv_fs_t* req, uv_file file) {
|
||||
|
||||
|
||||
void fs__ftruncate(uv_fs_t* req, uv_file file, off_t offset) {
|
||||
int result = _chsize(file, offset);
|
||||
int result;
|
||||
|
||||
VERIFY_UV_FILE(file, req);
|
||||
|
||||
result = _chsize(file, offset);
|
||||
SET_REQ_RESULT(req, result);
|
||||
}
|
||||
|
||||
@@ -508,6 +536,8 @@ void fs__fchmod(uv_fs_t* req, uv_file file, int mode) {
|
||||
IO_STATUS_BLOCK io_status;
|
||||
FILE_BASIC_INFORMATION file_info;
|
||||
|
||||
VERIFY_UV_FILE(file, req);
|
||||
|
||||
handle = (HANDLE)_get_osfhandle(file);
|
||||
|
||||
nt_status = pNtQueryInformationFile(handle,
|
||||
@@ -556,6 +586,9 @@ void fs__utime(uv_fs_t* req, const char* path, double atime, double mtime) {
|
||||
void fs__futime(uv_fs_t* req, uv_file file, double atime, double mtime) {
|
||||
int result;
|
||||
struct _utimbuf b = {(time_t)atime, (time_t)mtime};
|
||||
|
||||
VERIFY_UV_FILE(file, req);
|
||||
|
||||
result = _futime(file, &b);
|
||||
SET_REQ_RESULT(req, result);
|
||||
}
|
||||
|
||||
Vendored
+27
-6
@@ -1053,13 +1053,34 @@ done:
|
||||
|
||||
|
||||
int uv_process_kill(uv_process_t* process, int signum) {
|
||||
process->exit_signal = signum;
|
||||
DWORD status;
|
||||
|
||||
/* On windows killed processes normally return 1 */
|
||||
if (process->process_handle != INVALID_HANDLE_VALUE &&
|
||||
TerminateProcess(process->process_handle, 1)) {
|
||||
return 0;
|
||||
if (process->process_handle == INVALID_HANDLE_VALUE) {
|
||||
uv__set_artificial_error(process->loop, UV_EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
if (signum) {
|
||||
/* Kill the process. On Windows, killed processes normally return 1. */
|
||||
if (TerminateProcess(process->process_handle, 1)) {
|
||||
process->exit_signal = signum;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
uv__set_sys_error(process->loop, GetLastError());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Health check: is the process still alive? */
|
||||
if (GetExitCodeProcess(process->process_handle, &status) && status == STILL_ACTIVE) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
uv__set_artificial_error(process->loop, UV_EINVAL);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
assert(0 && "unreachable");
|
||||
}
|
||||
Vendored
+9
@@ -223,6 +223,15 @@ int uv__udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr,
|
||||
}
|
||||
|
||||
|
||||
int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr,
|
||||
const char* interface_addr, uv_membership membership) {
|
||||
|
||||
/* not implemented yet */
|
||||
uv__set_artificial_error(handle->loop, UV_ENOSYS);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static void uv_udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) {
|
||||
uv_req_t* req;
|
||||
uv_buf_t buf;
|
||||
|
||||
Vendored
+33
@@ -364,6 +364,17 @@ static void empty_readdir_cb(uv_fs_t* req) {
|
||||
}
|
||||
|
||||
|
||||
static void file_readdir_cb(uv_fs_t* req) {
|
||||
ASSERT(req == &readdir_req);
|
||||
ASSERT(req->fs_type == UV_FS_READDIR);
|
||||
ASSERT(req->result == -1);
|
||||
ASSERT(req->ptr == NULL);
|
||||
ASSERT(uv_last_error(req->loop).code == UV_ENOTDIR);
|
||||
uv_fs_req_cleanup(req);
|
||||
readdir_cb_count++;
|
||||
}
|
||||
|
||||
|
||||
static void stat_cb(uv_fs_t* req) {
|
||||
ASSERT(req == &stat_req);
|
||||
ASSERT(req->fs_type == UV_FS_STAT || req->fs_type == UV_FS_LSTAT);
|
||||
@@ -1333,3 +1344,25 @@ TEST_IMPL(fs_readdir_empty_dir) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(fs_readdir_file) {
|
||||
const char* path;
|
||||
int r;
|
||||
|
||||
path = "test/fixtures/empty_file";
|
||||
loop = uv_default_loop();
|
||||
|
||||
r = uv_fs_readdir(loop, &readdir_req, path, 0, NULL);
|
||||
ASSERT(r == -1);
|
||||
ASSERT(uv_last_error(loop).code == UV_ENOTDIR);
|
||||
|
||||
r = uv_fs_readdir(loop, &readdir_req, path, 0, file_readdir_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
ASSERT(readdir_cb_count == 0);
|
||||
uv_run(loop);
|
||||
ASSERT(readdir_cb_count == 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Vendored
+2
@@ -26,6 +26,8 @@ TEST_IMPL(get_memory) {
|
||||
double free_mem = uv_get_free_memory();
|
||||
double total_mem = uv_get_total_memory();
|
||||
|
||||
printf("free_mem=%.0f, total_mem=%.0f\n", free_mem, total_mem);
|
||||
|
||||
ASSERT(free_mem > 0);
|
||||
ASSERT(total_mem > 0);
|
||||
ASSERT(total_mem > free_mem);
|
||||
|
||||
Vendored
+6
@@ -43,6 +43,7 @@ TEST_DECLARE (tcp_bind6_error_fault)
|
||||
TEST_DECLARE (tcp_bind6_error_inval)
|
||||
TEST_DECLARE (tcp_bind6_localhost_ok)
|
||||
TEST_DECLARE (udp_send_and_recv)
|
||||
TEST_DECLARE (udp_multicast_join)
|
||||
TEST_DECLARE (udp_dgram_too_big)
|
||||
TEST_DECLARE (udp_dual_stack)
|
||||
TEST_DECLARE (udp_ipv6_only)
|
||||
@@ -83,6 +84,7 @@ TEST_DECLARE (spawn_exit_code)
|
||||
TEST_DECLARE (spawn_stdout)
|
||||
TEST_DECLARE (spawn_stdin)
|
||||
TEST_DECLARE (spawn_and_kill)
|
||||
TEST_DECLARE (spawn_and_ping)
|
||||
TEST_DECLARE (fs_file_noent)
|
||||
TEST_DECLARE (fs_file_async)
|
||||
TEST_DECLARE (fs_file_sync)
|
||||
@@ -100,6 +102,7 @@ TEST_DECLARE (fs_event_watch_dir)
|
||||
TEST_DECLARE (fs_event_watch_file)
|
||||
TEST_DECLARE (fs_event_watch_file_current_dir)
|
||||
TEST_DECLARE (fs_readdir_empty_dir)
|
||||
TEST_DECLARE (fs_readdir_file)
|
||||
TEST_DECLARE (threadpool_queue_work_simple)
|
||||
#ifdef _WIN32
|
||||
TEST_DECLARE (spawn_detect_pipe_name_collisions_on_windows)
|
||||
@@ -155,6 +158,7 @@ TASK_LIST_START
|
||||
TEST_ENTRY (udp_dgram_too_big)
|
||||
TEST_ENTRY (udp_dual_stack)
|
||||
TEST_ENTRY (udp_ipv6_only)
|
||||
TEST_ENTRY (udp_multicast_join)
|
||||
|
||||
TEST_ENTRY (pipe_bind_error_addrinuse)
|
||||
TEST_ENTRY (pipe_bind_error_addrnotavail)
|
||||
@@ -212,6 +216,7 @@ TASK_LIST_START
|
||||
TEST_ENTRY (spawn_stdout)
|
||||
TEST_ENTRY (spawn_stdin)
|
||||
TEST_ENTRY (spawn_and_kill)
|
||||
TEST_ENTRY (spawn_and_ping)
|
||||
#ifdef _WIN32
|
||||
TEST_ENTRY (spawn_detect_pipe_name_collisions_on_windows)
|
||||
TEST_ENTRY (argument_escaping)
|
||||
@@ -234,6 +239,7 @@ TASK_LIST_START
|
||||
TEST_ENTRY (fs_event_watch_file)
|
||||
TEST_ENTRY (fs_event_watch_file_current_dir)
|
||||
TEST_ENTRY (fs_readdir_empty_dir)
|
||||
TEST_ENTRY (fs_readdir_file)
|
||||
|
||||
TEST_ENTRY (threadpool_queue_work_simple)
|
||||
|
||||
|
||||
Vendored
+42
-1
@@ -160,7 +160,7 @@ TEST_IMPL(spawn_stdout) {
|
||||
|
||||
|
||||
TEST_IMPL(spawn_stdin) {
|
||||
int r;
|
||||
int r;
|
||||
uv_pipe_t out;
|
||||
uv_pipe_t in;
|
||||
uv_write_t write_req;
|
||||
@@ -220,6 +220,47 @@ TEST_IMPL(spawn_and_kill) {
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(spawn_and_ping) {
|
||||
uv_write_t write_req;
|
||||
uv_pipe_t in, out;
|
||||
uv_buf_t buf;
|
||||
int r;
|
||||
|
||||
init_process_options("spawn_helper3", exit_cb);
|
||||
buf = uv_buf_init("TEST", 4);
|
||||
|
||||
uv_pipe_init(uv_default_loop(), &out, 0);
|
||||
uv_pipe_init(uv_default_loop(), &in, 0);
|
||||
options.stdout_stream = &out;
|
||||
options.stdin_stream = ∈
|
||||
|
||||
r = uv_spawn(uv_default_loop(), &process, options);
|
||||
ASSERT(r == 0);
|
||||
|
||||
/* Sending signum == 0 should check if the
|
||||
* child process is still alive, not kill it.
|
||||
*/
|
||||
r = uv_process_kill(&process, 0);
|
||||
ASSERT(r == 0);
|
||||
|
||||
r = uv_write(&write_req, (uv_stream_t*)&in, &buf, 1, write_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
r = uv_read_start((uv_stream_t*)&out, on_alloc, on_read);
|
||||
ASSERT(r == 0);
|
||||
|
||||
ASSERT(exit_cb_called == 0);
|
||||
|
||||
r = uv_run(uv_default_loop());
|
||||
ASSERT(r == 0);
|
||||
|
||||
ASSERT(exit_cb_called == 1);
|
||||
ASSERT(strcmp(output, "TEST") == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) {
|
||||
int r;
|
||||
|
||||
Vendored
+14
-6
@@ -1,4 +1,17 @@
|
||||
{
|
||||
'target_defaults': {
|
||||
'conditions': [
|
||||
['OS != "win"', {
|
||||
'defines': [
|
||||
'_LARGEFILE_SOURCE',
|
||||
'_FILE_OFFSET_BITS=64',
|
||||
'_GNU_SOURCE',
|
||||
'EIO_STACKSIZE=262144'
|
||||
],
|
||||
}],
|
||||
],
|
||||
},
|
||||
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'uv',
|
||||
@@ -171,12 +184,6 @@
|
||||
'src/unix/ev/event.h',
|
||||
],
|
||||
'include_dirs': [ 'src/unix/ev', ],
|
||||
'defines': [
|
||||
'_LARGEFILE_SOURCE',
|
||||
'_FILE_OFFSET_BITS=64',
|
||||
'_GNU_SOURCE',
|
||||
'EIO_STACKSIZE=262144'
|
||||
],
|
||||
'libraries': [ '-lm' ]
|
||||
}],
|
||||
[ 'OS=="mac"', {
|
||||
@@ -285,6 +292,7 @@
|
||||
'test/test-udp-dgram-too-big.c',
|
||||
'test/test-udp-ipv6.c',
|
||||
'test/test-udp-send-and-recv.c',
|
||||
'test/test-udp-multicast-join.c',
|
||||
],
|
||||
'conditions': [
|
||||
[ 'OS=="win"', {
|
||||
|
||||
Reference in new issue
Block a user