diff --git a/test/test-fs.c b/test/test-fs.c index 76ced14a..1c2dd509 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -53,6 +53,7 @@ typedef struct { } utime_check_t; +static int dummy_cb_count; static int close_cb_count; static int create_cb_count; static int open_cb_count; @@ -127,6 +128,12 @@ void check_permission(const char* filename, int mode) { } +static void dummy_cb(uv_fs_t* req) { + (void) req; + dummy_cb_count++; +} + + static void link_cb(uv_fs_t* req) { ASSERT(req->fs_type == UV_FS_LINK); ASSERT(req->result == 0); @@ -1183,6 +1190,28 @@ TEST_IMPL(fs_link) { } +TEST_IMPL(fs_readlink) { + uv_fs_t req; + + loop = uv_default_loop(); + ASSERT(0 == uv_fs_readlink(loop, &req, "no_such_file", dummy_cb)); + ASSERT(0 == uv_run(loop)); + ASSERT(dummy_cb_count == 1); + ASSERT(req.ptr == NULL); + ASSERT(req.result == -1); + ASSERT(req.errorno == UV_ENOENT); + uv_fs_req_cleanup(&req); + + ASSERT(-1 == uv_fs_readlink(loop, &req, "no_such_file", NULL)); + ASSERT(req.ptr == NULL); + ASSERT(req.result == -1); + ASSERT(req.errorno == UV_ENOENT); + uv_fs_req_cleanup(&req); + + return 0; +} + + TEST_IMPL(fs_symlink) { int r; uv_fs_t req; diff --git a/test/test-list.h b/test/test-list.h index ce70c1f9..53e11550 100644 --- a/test/test-list.h +++ b/test/test-list.h @@ -152,6 +152,7 @@ TEST_DECLARE (fs_fstat) TEST_DECLARE (fs_chmod) TEST_DECLARE (fs_chown) TEST_DECLARE (fs_link) +TEST_DECLARE (fs_readlink) TEST_DECLARE (fs_symlink) TEST_DECLARE (fs_symlink_dir) TEST_DECLARE (fs_utime) @@ -405,6 +406,7 @@ TASK_LIST_START TEST_ENTRY (fs_chown) TEST_ENTRY (fs_utime) TEST_ENTRY (fs_futime) + TEST_ENTRY (fs_readlink) TEST_ENTRY (fs_symlink) TEST_ENTRY (fs_symlink_dir) TEST_ENTRY (fs_stat_missing_path)