test: add uv_fs_readlink test

This commit is contained in:
Ben Noordhuis 2012-09-30 03:26:48 +02:00
parent e2cffdcf5f
commit 1923abda94
2 changed files with 31 additions and 0 deletions

View File

@ -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;

View File

@ -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)