aboutsummaryrefslogtreecommitdiff
path: root/deps/uv/test
diff options
context:
space:
mode:
Diffstat (limited to 'deps/uv/test')
-rw-r--r--deps/uv/test/test-fs-poll.c39
-rw-r--r--deps/uv/test/test-fs.c50
-rw-r--r--deps/uv/test/test-get-memory.c6
-rw-r--r--deps/uv/test/test-list.h6
-rw-r--r--deps/uv/test/test-spawn.c6
5 files changed, 91 insertions, 16 deletions
diff --git a/deps/uv/test/test-fs-poll.c b/deps/uv/test/test-fs-poll.c
index e19a68780f..9dfd5fdd6a 100644
--- a/deps/uv/test/test-fs-poll.c
+++ b/deps/uv/test/test-fs-poll.c
@@ -37,6 +37,10 @@ static void poll_cb_fail(uv_fs_poll_t* handle,
int status,
const uv_stat_t* prev,
const uv_stat_t* curr);
+static void poll_cb_noop(uv_fs_poll_t* handle,
+ int status,
+ const uv_stat_t* prev,
+ const uv_stat_t* curr);
static uv_fs_poll_t poll_handle;
static uv_timer_t timer_handle;
@@ -84,6 +88,12 @@ static void poll_cb_fail(uv_fs_poll_t* handle,
ASSERT(0 && "fail_cb called");
}
+static void poll_cb_noop(uv_fs_poll_t* handle,
+ int status,
+ const uv_stat_t* prev,
+ const uv_stat_t* curr) {
+}
+
static void poll_cb(uv_fs_poll_t* handle,
int status,
@@ -259,3 +269,32 @@ TEST_IMPL(fs_poll_close_request_multi_stop_start) {
MAKE_VALGRIND_HAPPY();
return 0;
}
+
+TEST_IMPL(fs_poll_close_request_stop_when_active) {
+ /* Regression test for https://github.com/libuv/libuv/issues/2287. */
+ uv_loop_t loop;
+ uv_fs_poll_t poll_handle;
+
+ remove(FIXTURE);
+
+ ASSERT(0 == uv_loop_init(&loop));
+
+ /* Set up all handles. */
+ ASSERT(0 == uv_fs_poll_init(&loop, &poll_handle));
+ ASSERT(0 == uv_fs_poll_start(&poll_handle, poll_cb_noop, FIXTURE, 100));
+ uv_run(&loop, UV_RUN_ONCE);
+
+ /* Close the timer handle, and do not crash. */
+ ASSERT(0 == uv_fs_poll_stop(&poll_handle));
+ uv_run(&loop, UV_RUN_ONCE);
+
+ /* Clean up after the test. */
+ uv_close((uv_handle_t*) &poll_handle, close_cb);
+ uv_run(&loop, UV_RUN_ONCE);
+ ASSERT(close_cb_called == 1);
+
+ ASSERT(0 == uv_loop_close(&loop));
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c
index 35f7d0c3f1..c3153c717b 100644
--- a/deps/uv/test/test-fs.c
+++ b/deps/uv/test/test-fs.c
@@ -611,6 +611,15 @@ static void sendfile_cb(uv_fs_t* req) {
}
+static void sendfile_nodata_cb(uv_fs_t* req) {
+ ASSERT(req == &sendfile_req);
+ ASSERT(req->fs_type == UV_FS_SENDFILE);
+ ASSERT(req->result == 0);
+ sendfile_cb_count++;
+ uv_fs_req_cleanup(req);
+}
+
+
static void open_noent_cb(uv_fs_t* req) {
ASSERT(req->fs_type == UV_FS_OPEN);
ASSERT(req->result == UV_ENOENT);
@@ -1049,7 +1058,7 @@ TEST_IMPL(fs_async_dir) {
}
-TEST_IMPL(fs_async_sendfile) {
+static int test_sendfile(void (*setup)(int), uv_fs_cb cb, off_t expected_size) {
int f, r;
struct stat s1, s2;
@@ -1062,14 +1071,8 @@ TEST_IMPL(fs_async_sendfile) {
f = open("test_file", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
ASSERT(f != -1);
- r = write(f, "begin\n", 6);
- ASSERT(r == 6);
-
- r = lseek(f, 65536, SEEK_CUR);
- ASSERT(r == 65542);
-
- r = write(f, "end\n", 4);
- ASSERT(r != -1);
+ if (setup != NULL)
+ setup(f);
r = close(f);
ASSERT(r == 0);
@@ -1087,7 +1090,7 @@ TEST_IMPL(fs_async_sendfile) {
uv_fs_req_cleanup(&open_req2);
r = uv_fs_sendfile(loop, &sendfile_req, open_req2.result, open_req1.result,
- 0, 131072, sendfile_cb);
+ 0, 131072, cb);
ASSERT(r == 0);
uv_run(loop, UV_RUN_DEFAULT);
@@ -1100,9 +1103,10 @@ TEST_IMPL(fs_async_sendfile) {
ASSERT(r == 0);
uv_fs_req_cleanup(&close_req);
- stat("test_file", &s1);
- stat("test_file2", &s2);
- ASSERT(65546 == s2.st_size && s1.st_size == s2.st_size);
+ ASSERT(0 == stat("test_file", &s1));
+ ASSERT(0 == stat("test_file2", &s2));
+ ASSERT(s1.st_size == s2.st_size);
+ ASSERT(s2.st_size == expected_size);
/* Cleanup. */
unlink("test_file");
@@ -1113,6 +1117,23 @@ TEST_IMPL(fs_async_sendfile) {
}
+static void sendfile_setup(int f) {
+ ASSERT(6 == write(f, "begin\n", 6));
+ ASSERT(65542 == lseek(f, 65536, SEEK_CUR));
+ ASSERT(4 == write(f, "end\n", 4));
+}
+
+
+TEST_IMPL(fs_async_sendfile) {
+ return test_sendfile(sendfile_setup, sendfile_cb, 65546);
+}
+
+
+TEST_IMPL(fs_async_sendfile_nodata) {
+ return test_sendfile(NULL, sendfile_nodata_cb, 0);
+}
+
+
TEST_IMPL(fs_mkdtemp) {
int r;
const char* path_template = "test_dir_XXXXXX";
@@ -1171,6 +1192,7 @@ TEST_IMPL(fs_fstat) {
ASSERT(req.result == sizeof(test_buf));
uv_fs_req_cleanup(&req);
+ memset(&req.statbuf, 0xaa, sizeof(req.statbuf));
r = uv_fs_fstat(NULL, &req, file, NULL);
ASSERT(r == 0);
ASSERT(req.result == 0);
@@ -1257,6 +1279,8 @@ TEST_IMPL(fs_fstat) {
s->st_birthtim.tv_sec == t.st_ctim.tv_sec);
ASSERT(s->st_birthtim.tv_nsec == 0 ||
s->st_birthtim.tv_nsec == t.st_ctim.tv_nsec);
+ ASSERT(s->st_flags == 0);
+ ASSERT(s->st_gen == 0);
#endif
uv_fs_req_cleanup(&req);
diff --git a/deps/uv/test/test-get-memory.c b/deps/uv/test/test-get-memory.c
index 2396939bcb..0e0864038b 100644
--- a/deps/uv/test/test-get-memory.c
+++ b/deps/uv/test/test-get-memory.c
@@ -25,10 +25,12 @@
TEST_IMPL(get_memory) {
uint64_t free_mem = uv_get_free_memory();
uint64_t total_mem = uv_get_total_memory();
+ uint64_t constrained_mem = uv_get_constrained_memory();
- printf("free_mem=%llu, total_mem=%llu\n",
+ printf("free_mem=%llu, total_mem=%llu, constrained_mem=%llu\n",
(unsigned long long) free_mem,
- (unsigned long long) total_mem);
+ (unsigned long long) total_mem,
+ (unsigned long long) constrained_mem);
ASSERT(free_mem > 0);
ASSERT(total_mem > 0);
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index ace501c979..8886b07c8a 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -290,6 +290,7 @@ TEST_DECLARE (fs_poll_getpath)
TEST_DECLARE (fs_poll_close_request)
TEST_DECLARE (fs_poll_close_request_multi_start_stop)
TEST_DECLARE (fs_poll_close_request_multi_stop_start)
+TEST_DECLARE (fs_poll_close_request_stop_when_active)
TEST_DECLARE (kill)
TEST_DECLARE (kill_invalid_signum)
TEST_DECLARE (fs_file_noent)
@@ -300,6 +301,7 @@ TEST_DECLARE (fs_file_sync)
TEST_DECLARE (fs_file_write_null_buffer)
TEST_DECLARE (fs_async_dir)
TEST_DECLARE (fs_async_sendfile)
+TEST_DECLARE (fs_async_sendfile_nodata)
TEST_DECLARE (fs_mkdtemp)
TEST_DECLARE (fs_fstat)
TEST_DECLARE (fs_access)
@@ -843,6 +845,7 @@ TASK_LIST_START
TEST_ENTRY (fs_poll_close_request)
TEST_ENTRY (fs_poll_close_request_multi_start_stop)
TEST_ENTRY (fs_poll_close_request_multi_stop_start)
+ TEST_ENTRY (fs_poll_close_request_stop_when_active)
TEST_ENTRY (kill)
TEST_ENTRY (kill_invalid_signum)
@@ -886,6 +889,7 @@ TASK_LIST_START
TEST_ENTRY (fs_file_write_null_buffer)
TEST_ENTRY (fs_async_dir)
TEST_ENTRY (fs_async_sendfile)
+ TEST_ENTRY (fs_async_sendfile_nodata)
TEST_ENTRY (fs_mkdtemp)
TEST_ENTRY (fs_fstat)
TEST_ENTRY (fs_access)
@@ -959,7 +963,7 @@ TASK_LIST_START
TEST_ENTRY (strscpy)
TEST_ENTRY (threadpool_queue_work_simple)
TEST_ENTRY (threadpool_queue_work_einval)
- TEST_ENTRY (threadpool_multiple_event_loops)
+ TEST_ENTRY_CUSTOM (threadpool_multiple_event_loops, 0, 0, 60000)
TEST_ENTRY (threadpool_cancel_getaddrinfo)
TEST_ENTRY (threadpool_cancel_getnameinfo)
TEST_ENTRY (threadpool_cancel_work)
diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c
index e5fc308a0e..fea1165d89 100644
--- a/deps/uv/test/test-spawn.c
+++ b/deps/uv/test/test-spawn.c
@@ -1406,6 +1406,12 @@ TEST_IMPL(spawn_setuid_fails) {
options.flags |= UV_PROCESS_SETUID;
options.uid = 0;
+ /* These flags should be ignored on Unices. */
+ options.flags |= UV_PROCESS_WINDOWS_HIDE;
+ options.flags |= UV_PROCESS_WINDOWS_HIDE_CONSOLE;
+ options.flags |= UV_PROCESS_WINDOWS_HIDE_GUI;
+ options.flags |= UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS;
+
r = uv_spawn(uv_default_loop(), &process, &options);
#if defined(__CYGWIN__)
ASSERT(r == UV_EINVAL);