summaryrefslogtreecommitdiff
path: root/deps/uv/test
diff options
context:
space:
mode:
Diffstat (limited to 'deps/uv/test')
-rw-r--r--deps/uv/test/test-connect-unspecified.c14
-rw-r--r--deps/uv/test/test-fs-copyfile.c16
-rw-r--r--deps/uv/test/test-fs-event.c38
-rw-r--r--deps/uv/test/test-fs.c80
-rw-r--r--deps/uv/test/test-list.h14
-rw-r--r--deps/uv/test/test-poll.c5
-rw-r--r--deps/uv/test/test-tcp-bind-error.c42
-rw-r--r--deps/uv/test/test-tcp-oob.c2
-rw-r--r--deps/uv/test/test-tcp-write-queue-order.c2
9 files changed, 203 insertions, 10 deletions
diff --git a/deps/uv/test/test-connect-unspecified.c b/deps/uv/test/test-connect-unspecified.c
index 04e1c8a5f7..5f32b67a6a 100644
--- a/deps/uv/test/test-connect-unspecified.c
+++ b/deps/uv/test/test-connect-unspecified.c
@@ -48,12 +48,14 @@ TEST_IMPL(connect_unspecified) {
(const struct sockaddr*) &addr4,
connect_4) == 0);
- ASSERT(uv_tcp_init(loop, &socket6) == 0);
- ASSERT(uv_ip6_addr("::", TEST_PORT, &addr6) == 0);
- ASSERT(uv_tcp_connect(&connect6,
- &socket6,
- (const struct sockaddr*) &addr6,
- connect_6) == 0);
+ if (can_ipv6()) {
+ ASSERT(uv_tcp_init(loop, &socket6) == 0);
+ ASSERT(uv_ip6_addr("::", TEST_PORT, &addr6) == 0);
+ ASSERT(uv_tcp_connect(&connect6,
+ &socket6,
+ (const struct sockaddr*) &addr6,
+ connect_6) == 0);
+ }
ASSERT(uv_run(loop, UV_RUN_DEFAULT) == 0);
diff --git a/deps/uv/test/test-fs-copyfile.c b/deps/uv/test/test-fs-copyfile.c
index 4b1fdc5e79..6cd43b4502 100644
--- a/deps/uv/test/test-fs-copyfile.c
+++ b/deps/uv/test/test-fs-copyfile.c
@@ -168,6 +168,22 @@ TEST_IMPL(fs_copyfile) {
r = uv_fs_copyfile(loop, &req, fixture, dst, -1, fail_cb);
ASSERT(r == UV_EINVAL);
uv_run(loop, UV_RUN_DEFAULT);
+
+ /* Copies file using UV_FS_COPYFILE_FICLONE. */
+ unlink(dst);
+ r = uv_fs_copyfile(NULL, &req, fixture, dst, UV_FS_COPYFILE_FICLONE, NULL);
+ ASSERT(r == 0);
+ handle_result(&req);
+
+ /* Copies file using UV_FS_COPYFILE_FICLONE_FORCE. */
+ unlink(dst);
+ r = uv_fs_copyfile(NULL, &req, fixture, dst, UV_FS_COPYFILE_FICLONE_FORCE,
+ NULL);
+ ASSERT(r == 0 || r == UV_ENOSYS || r == UV_ENOTSUP || r == UV_ENOTTY);
+
+ if (r == 0)
+ handle_result(&req);
+
unlink(dst); /* Cleanup */
return 0;
}
diff --git a/deps/uv/test/test-fs-event.c b/deps/uv/test/test-fs-event.c
index 39d73300dc..5ddccffd0a 100644
--- a/deps/uv/test/test-fs-event.c
+++ b/deps/uv/test/test-fs-event.c
@@ -129,7 +129,7 @@ static void fs_event_cb_dir(uv_fs_event_t* handle, const char* filename,
++fs_event_cb_called;
ASSERT(handle == &fs_event);
ASSERT(status == 0);
- ASSERT(events == UV_RENAME);
+ ASSERT(events == UV_CHANGE);
#if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
ASSERT(strcmp(filename, "file1") == 0);
#else
@@ -477,6 +477,42 @@ TEST_IMPL(fs_event_watch_dir_recursive) {
#endif
}
+#ifdef _WIN32
+TEST_IMPL(fs_event_watch_dir_short_path) {
+ uv_loop_t* loop;
+ int r;
+
+ /* Setup */
+ loop = uv_default_loop();
+ remove("watch_dir/file1");
+ remove("watch_dir/");
+ create_dir("watch_dir");
+ create_file("watch_dir/file1");
+
+ r = uv_fs_event_init(loop, &fs_event);
+ ASSERT(r == 0);
+ r = uv_fs_event_start(&fs_event, fs_event_cb_dir, "watch_~1", 0);
+ ASSERT(r == 0);
+ r = uv_timer_init(loop, &timer);
+ ASSERT(r == 0);
+ r = uv_timer_start(&timer, timer_cb_file, 100, 0);
+ ASSERT(r == 0);
+
+ uv_run(loop, UV_RUN_DEFAULT);
+
+ ASSERT(fs_event_cb_called == 1);
+ ASSERT(timer_cb_called == 1);
+ ASSERT(close_cb_called == 1);
+
+ /* Cleanup */
+ remove("watch_dir/file1");
+ remove("watch_dir/");
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
+#endif
+
TEST_IMPL(fs_event_watch_file) {
#if defined(NO_FS_EVENTS)
diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c
index 3318b86649..0075a02be6 100644
--- a/deps/uv/test/test-fs.c
+++ b/deps/uv/test/test-fs.c
@@ -1367,6 +1367,28 @@ TEST_IMPL(fs_chmod) {
check_permission("test_file", 0600);
+#ifdef _WIN32
+ /* Test clearing read-only flag from files with Archive flag cleared */
+ /* Make the file read-only and clear archive flag */
+ r = SetFileAttributes("test_file", FILE_ATTRIBUTE_READONLY);
+ ASSERT(r != 0);
+ check_permission("test_file", 0400);
+
+ r = uv_fs_open(NULL, &req, "test_file", 0, 0, NULL);
+ ASSERT(r >= 0);
+ ASSERT(req.result >= 0);
+ uv_fs_req_cleanup(&req);
+
+ r = uv_fs_fchmod(NULL, &req, file, 0600, NULL);
+ ASSERT(r == 0);
+ ASSERT(req.result == 0);
+ uv_fs_req_cleanup(&req);
+
+ check_permission("test_file", 0600);
+ /* Restore Archive flag for rest of the tests */
+ r = SetFileAttributes("test_file", FILE_ATTRIBUTE_ARCHIVE);
+ ASSERT(r != 0);
+#endif
#ifndef _WIN32
/* async chmod */
{
@@ -1474,6 +1496,64 @@ TEST_IMPL(fs_unlink_readonly) {
return 0;
}
+#ifdef _WIN32
+TEST_IMPL(fs_unlink_archive_readonly) {
+ int r;
+ uv_fs_t req;
+ uv_file file;
+
+ /* Setup. */
+ unlink("test_file");
+
+ loop = uv_default_loop();
+
+ r = uv_fs_open(NULL,
+ &req,
+ "test_file",
+ O_RDWR | O_CREAT,
+ S_IWUSR | S_IRUSR,
+ NULL);
+ ASSERT(r >= 0);
+ ASSERT(req.result >= 0);
+ file = req.result;
+ uv_fs_req_cleanup(&req);
+
+ iov = uv_buf_init(test_buf, sizeof(test_buf));
+ r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL);
+ ASSERT(r == sizeof(test_buf));
+ ASSERT(req.result == sizeof(test_buf));
+ uv_fs_req_cleanup(&req);
+
+ close(file);
+
+ /* Make the file read-only and clear archive flag */
+ r = SetFileAttributes("test_file", FILE_ATTRIBUTE_READONLY);
+ ASSERT(r != 0);
+ uv_fs_req_cleanup(&req);
+
+ check_permission("test_file", 0400);
+
+ /* Try to unlink the file */
+ r = uv_fs_unlink(NULL, &req, "test_file", NULL);
+ ASSERT(r == 0);
+ ASSERT(req.result == 0);
+ uv_fs_req_cleanup(&req);
+
+ /*
+ * Run the loop just to check we don't have make any extraneous uv_ref()
+ * calls. This should drop out immediately.
+ */
+ uv_run(loop, UV_RUN_DEFAULT);
+
+ /* Cleanup. */
+ uv_fs_chmod(NULL, &req, "test_file", 0600, NULL);
+ uv_fs_req_cleanup(&req);
+ unlink("test_file");
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
+#endif
TEST_IMPL(fs_chown) {
int r;
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index ff0a31d16b..b89930d709 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -95,6 +95,7 @@ TEST_DECLARE (tcp_bind_error_fault)
TEST_DECLARE (tcp_bind_error_inval)
TEST_DECLARE (tcp_bind_localhost_ok)
TEST_DECLARE (tcp_bind_invalid_flags)
+TEST_DECLARE (tcp_bind_writable_flags)
TEST_DECLARE (tcp_listen_without_bind)
TEST_DECLARE (tcp_connect_error_fault)
TEST_DECLARE (tcp_connect_timeout)
@@ -283,6 +284,9 @@ TEST_DECLARE (fs_access)
TEST_DECLARE (fs_chmod)
TEST_DECLARE (fs_copyfile)
TEST_DECLARE (fs_unlink_readonly)
+#ifdef _WIN32
+TEST_DECLARE (fs_unlink_archive_readonly)
+#endif
TEST_DECLARE (fs_chown)
TEST_DECLARE (fs_link)
TEST_DECLARE (fs_readlink)
@@ -300,6 +304,9 @@ TEST_DECLARE (fs_stat_missing_path)
TEST_DECLARE (fs_read_file_eof)
TEST_DECLARE (fs_event_watch_dir)
TEST_DECLARE (fs_event_watch_dir_recursive)
+#ifdef _WIN32
+TEST_DECLARE (fs_event_watch_dir_short_path)
+#endif
TEST_DECLARE (fs_event_watch_file)
TEST_DECLARE (fs_event_watch_file_exact_path)
TEST_DECLARE (fs_event_watch_file_twice)
@@ -535,6 +542,7 @@ TASK_LIST_START
TEST_ENTRY (tcp_bind_error_inval)
TEST_ENTRY (tcp_bind_localhost_ok)
TEST_ENTRY (tcp_bind_invalid_flags)
+ TEST_ENTRY (tcp_bind_writable_flags)
TEST_ENTRY (tcp_listen_without_bind)
TEST_ENTRY (tcp_connect_error_fault)
TEST_ENTRY (tcp_connect_timeout)
@@ -810,6 +818,9 @@ TASK_LIST_START
TEST_ENTRY (fs_chmod)
TEST_ENTRY (fs_copyfile)
TEST_ENTRY (fs_unlink_readonly)
+#ifdef _WIN32
+ TEST_ENTRY (fs_unlink_archive_readonly)
+#endif
TEST_ENTRY (fs_chown)
TEST_ENTRY (fs_utime)
TEST_ENTRY (fs_futime)
@@ -826,6 +837,9 @@ TASK_LIST_START
TEST_ENTRY (fs_file_open_append)
TEST_ENTRY (fs_event_watch_dir)
TEST_ENTRY (fs_event_watch_dir_recursive)
+#ifdef _WIN32
+ TEST_ENTRY (fs_event_watch_dir_short_path)
+#endif
TEST_ENTRY (fs_event_watch_file)
TEST_ENTRY (fs_event_watch_file_exact_path)
TEST_ENTRY (fs_event_watch_file_twice)
diff --git a/deps/uv/test/test-poll.c b/deps/uv/test/test-poll.c
index e828addbb4..0d1b1d7ec9 100644
--- a/deps/uv/test/test-poll.c
+++ b/deps/uv/test/test-poll.c
@@ -134,7 +134,10 @@ static void close_socket(uv_os_sock_t sock) {
#else
r = close(sock);
#endif
- ASSERT(r == 0);
+ /* On FreeBSD close() can fail with ECONNRESET if the socket was shutdown by
+ * the peer before all pending data was delivered.
+ */
+ ASSERT(r == 0 || errno == ECONNRESET);
}
diff --git a/deps/uv/test/test-tcp-bind-error.c b/deps/uv/test/test-tcp-bind-error.c
index 10ed68e10e..1456d081ae 100644
--- a/deps/uv/test/test-tcp-bind-error.c
+++ b/deps/uv/test/test-tcp-bind-error.c
@@ -214,3 +214,45 @@ TEST_IMPL(tcp_listen_without_bind) {
MAKE_VALGRIND_HAPPY();
return 0;
}
+
+
+TEST_IMPL(tcp_bind_writable_flags) {
+ struct sockaddr_in addr;
+ uv_tcp_t server;
+ uv_buf_t buf;
+ uv_write_t write_req;
+ uv_shutdown_t shutdown_req;
+ int r;
+
+ ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr));
+ r = uv_tcp_init(uv_default_loop(), &server);
+ ASSERT(r == 0);
+ r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0);
+ ASSERT(r == 0);
+ r = uv_listen((uv_stream_t*)&server, 128, NULL);
+ ASSERT(r == 0);
+
+ ASSERT(0 == uv_is_writable((uv_stream_t*) &server));
+ ASSERT(0 == uv_is_readable((uv_stream_t*) &server));
+
+ buf = uv_buf_init("PING", 4);
+ r = uv_write(&write_req, (uv_stream_t*) &server, &buf, 1, NULL);
+ ASSERT(r == UV_EPIPE);
+ r = uv_shutdown(&shutdown_req, (uv_stream_t*) &server, NULL);
+#ifdef _WIN32
+ ASSERT(r == UV_EPIPE);
+#else
+ ASSERT(r == UV_ENOTCONN);
+#endif
+ r = uv_read_start((uv_stream_t*) &server, NULL, NULL);
+ ASSERT(r == UV_ENOTCONN);
+
+ uv_close((uv_handle_t*)&server, close_cb);
+
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
+
+ ASSERT(close_cb_called == 1);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
diff --git a/deps/uv/test/test-tcp-oob.c b/deps/uv/test/test-tcp-oob.c
index 4f1397a82f..ca2361f9bb 100644
--- a/deps/uv/test/test-tcp-oob.c
+++ b/deps/uv/test/test-tcp-oob.c
@@ -61,7 +61,7 @@ static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
#endif
uv_os_fd_t fd;
- ASSERT(nread > 0);
+ ASSERT(nread >= 0);
ASSERT(0 == uv_fileno((uv_handle_t*)handle, &fd));
ASSERT(0 == uv_idle_start(&idle, idle_cb));
diff --git a/deps/uv/test/test-tcp-write-queue-order.c b/deps/uv/test/test-tcp-write-queue-order.c
index 5119be6d33..1ff9c517ce 100644
--- a/deps/uv/test/test-tcp-write-queue-order.c
+++ b/deps/uv/test/test-tcp-write-queue-order.c
@@ -90,7 +90,7 @@ static void connection_cb(uv_stream_t* tcp, int status) {
ASSERT(0 == uv_accept(tcp, (uv_stream_t*) &incoming));
ASSERT(0 == uv_timer_init(uv_default_loop(), &timer));
- ASSERT(0 == uv_timer_start(&timer, timer_cb, 1, 0));
+ ASSERT(0 == uv_timer_start(&timer, timer_cb, 1000, 0));
connection_cb_called++;
}