summaryrefslogtreecommitdiff
path: root/deps/uv/test/test-fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'deps/uv/test/test-fs.c')
-rw-r--r--deps/uv/test/test-fs.c69
1 files changed, 67 insertions, 2 deletions
diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c
index 030245eadc..c482ab5c71 100644
--- a/deps/uv/test/test-fs.c
+++ b/deps/uv/test/test-fs.c
@@ -125,7 +125,7 @@ static void check_permission(const char* filename, unsigned int mode) {
ASSERT(req.result == 0);
s = &req.statbuf;
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MSYS__)
/*
* On Windows, chmod can only modify S_IWUSR (_S_IWRITE) bit,
* so only testing for the specified flags.
@@ -240,7 +240,7 @@ static void chown_cb(uv_fs_t* req) {
static void chown_root_cb(uv_fs_t* req) {
ASSERT(req->fs_type == UV_FS_CHOWN);
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__MSYS__)
/* On windows, chown is a no-op and always succeeds. */
ASSERT(req->result == 0);
#else
@@ -250,7 +250,12 @@ static void chown_root_cb(uv_fs_t* req) {
if (geteuid() == 0)
ASSERT(req->result == 0);
else
+# if defined(__CYGWIN__)
+ /* On Cygwin, uid 0 is invalid (no root). */
+ ASSERT(req->result == UV_EINVAL);
+# else
ASSERT(req->result == UV_EPERM);
+# endif
#endif
chown_cb_count++;
uv_fs_req_cleanup(req);
@@ -641,6 +646,11 @@ TEST_IMPL(fs_file_loop) {
*/
if (r == UV_ENOTSUP || r == UV_EPERM)
return 0;
+#elif defined(__MSYS__)
+ /* MSYS2's approximation of symlinks with copies does not work for broken
+ links. */
+ if (r == UV_ENOENT)
+ return 0;
#endif
ASSERT(r == 0);
uv_fs_req_cleanup(&req);
@@ -1485,6 +1495,7 @@ TEST_IMPL(fs_chown) {
/* chown to root (fail) */
chown_cb_count = 0;
r = uv_fs_chown(loop, &req, "test_file", 0, 0, chown_root_cb);
+ ASSERT(r == 0);
uv_run(loop, UV_RUN_DEFAULT);
ASSERT(chown_cb_count == 1);
@@ -1734,6 +1745,10 @@ TEST_IMPL(fs_symlink) {
ASSERT(r == 0);
uv_fs_req_cleanup(&req);
+#if defined(__MSYS__)
+ RETURN_SKIP("symlink reading is not supported on MSYS2");
+#endif
+
r = uv_fs_readlink(NULL, &req, "test_file_symlink_symlink", NULL);
ASSERT(r == 0);
ASSERT(strcmp(req.ptr, "test_file_symlink") == 0);
@@ -1877,6 +1892,9 @@ TEST_IMPL(fs_symlink_dir) {
r = uv_fs_lstat(NULL, &req, "test_dir_symlink", NULL);
ASSERT(r == 0);
+#if defined(__MSYS__)
+ RETURN_SKIP("symlink reading is not supported on MSYS2");
+#endif
ASSERT(((uv_stat_t*)req.ptr)->st_mode & S_IFLNK);
#ifdef _WIN32
ASSERT(((uv_stat_t*)req.ptr)->st_size == strlen(test_dir + 4));
@@ -2102,8 +2120,13 @@ TEST_IMPL(fs_futime) {
uv_fs_req_cleanup(&req);
r = uv_fs_futime(NULL, &req, file, atime, mtime, NULL);
+#if defined(__CYGWIN__) || defined(__MSYS__)
+ ASSERT(r == UV_ENOSYS);
+ RETURN_SKIP("futime not supported on Cygwin");
+#else
ASSERT(r == 0);
ASSERT(req.result == 0);
+#endif
uv_fs_req_cleanup(&req);
r = uv_fs_stat(NULL, &req, path, NULL);
@@ -2412,6 +2435,9 @@ TEST_IMPL(fs_rename_to_existing_file) {
TEST_IMPL(fs_read_file_eof) {
+#if defined(__CYGWIN__) || defined(__MSYS__)
+ RETURN_SKIP("Cygwin pread at EOF may (incorrectly) return data!");
+#endif
int r;
/* Setup. */
@@ -2739,3 +2765,42 @@ TEST_IMPL(fs_read_write_null_arguments) {
return 0;
}
+
+
+TEST_IMPL(get_osfhandle_valid_handle) {
+ int r;
+ uv_os_fd_t fd;
+
+ /* Setup. */
+ unlink("test_file");
+
+ loop = uv_default_loop();
+
+ r = uv_fs_open(NULL,
+ &open_req1,
+ "test_file",
+ O_RDWR | O_CREAT,
+ S_IWUSR | S_IRUSR,
+ NULL);
+ ASSERT(r >= 0);
+ ASSERT(open_req1.result >= 0);
+ uv_fs_req_cleanup(&open_req1);
+
+ fd = uv_get_osfhandle(open_req1.result);
+#ifdef _WIN32
+ ASSERT(fd != INVALID_HANDLE_VALUE);
+#else
+ ASSERT(fd >= 0);
+#endif
+
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
+ ASSERT(r == 0);
+ ASSERT(close_req.result == 0);
+ uv_fs_req_cleanup(&close_req);
+
+ /* Cleanup. */
+ unlink("test_file");
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}