Navigation Menu

Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
test: test if UV_ELOOP mapping works
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalecki authored and bnoordhuis committed Feb 3, 2012
1 parent 3ff3626 commit 0596c59
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/test-fs.c
Expand Up @@ -432,6 +432,14 @@ static void open_nametoolong_cb(uv_fs_t* req) {
uv_fs_req_cleanup(req);
}

static void open_loop_cb(uv_fs_t* req) {
ASSERT(req->fs_type == UV_FS_OPEN);
ASSERT(req->errorno == UV_ELOOP);
ASSERT(req->result == -1);
open_cb_count++;
uv_fs_req_cleanup(req);
}


TEST_IMPL(fs_file_noent) {
uv_fs_t req;
Expand Down Expand Up @@ -483,6 +491,33 @@ TEST_IMPL(fs_file_nametoolong) {
return 0;
}

TEST_IMPL(fs_file_loop) {
uv_fs_t req;
int r;

loop = uv_default_loop();

unlink("test_symlink");
symlink("test_symlink", "test_symlink");

r = uv_fs_open(loop, &req, "test_symlink", O_RDONLY, 0, NULL);
ASSERT(r == -1);
ASSERT(req.result == -1);
ASSERT(uv_last_error(loop).code == UV_ELOOP);
uv_fs_req_cleanup(&req);

r = uv_fs_open(loop, &req, "test_symlink", O_RDONLY, 0, open_loop_cb);
ASSERT(r == 0);

ASSERT(open_cb_count == 0);
uv_run(loop);
ASSERT(open_cb_count == 1);

unlink("test_symlink");

return 0;
}

static void check_utime(const char* path, double atime, double mtime) {
struct stat* s;
uv_fs_t req;
Expand Down
2 changes: 2 additions & 0 deletions test/test-list.h
Expand Up @@ -105,6 +105,7 @@ TEST_DECLARE (spawn_and_ping)
TEST_DECLARE (kill)
TEST_DECLARE (fs_file_noent)
TEST_DECLARE (fs_file_nametoolong)
TEST_DECLARE (fs_file_loop)
TEST_DECLARE (fs_file_async)
TEST_DECLARE (fs_file_sync)
TEST_DECLARE (fs_async_dir)
Expand Down Expand Up @@ -275,6 +276,7 @@ TASK_LIST_START

TEST_ENTRY (fs_file_noent)
TEST_ENTRY (fs_file_nametoolong)
TEST_ENTRY (fs_file_loop)
TEST_ENTRY (fs_file_async)
TEST_ENTRY (fs_file_sync)
TEST_ENTRY (fs_async_dir)
Expand Down

0 comments on commit 0596c59

Please sign in to comment.