diff options
Diffstat (limited to 'deps/uv/test/test-fs.c')
-rw-r--r-- | deps/uv/test/test-fs.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c index 8dc7147310..a8fe0abb97 100644 --- a/deps/uv/test/test-fs.c +++ b/deps/uv/test/test-fs.c @@ -225,6 +225,7 @@ static void close_cb(uv_fs_t* req) { uv_fs_req_cleanup(req); if (close_cb_count == 3) { r = uv_fs_unlink(loop, &unlink_req, "test_file2", unlink_cb); + ASSERT(r == 0); } } @@ -237,6 +238,7 @@ static void ftruncate_cb(uv_fs_t* req) { ftruncate_cb_count++; uv_fs_req_cleanup(req); r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); + ASSERT(r == 0); } @@ -255,6 +257,7 @@ static void read_cb(uv_fs_t* req) { ASSERT(strcmp(buf, "test-bu") == 0); r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); } + ASSERT(r == 0); } @@ -274,6 +277,7 @@ static void open_cb(uv_fs_t* req) { memset(buf, 0, sizeof(buf)); r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, read_cb); + ASSERT(r == 0); } @@ -298,6 +302,7 @@ static void fsync_cb(uv_fs_t* req) { fsync_cb_count++; uv_fs_req_cleanup(req); r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); + ASSERT(r == 0); } @@ -309,6 +314,7 @@ static void fdatasync_cb(uv_fs_t* req) { fdatasync_cb_count++; uv_fs_req_cleanup(req); r = uv_fs_fsync(loop, &fsync_req, open_req1.result, fsync_cb); + ASSERT(r == 0); } @@ -320,6 +326,7 @@ static void write_cb(uv_fs_t* req) { write_cb_count++; uv_fs_req_cleanup(req); r = uv_fs_fdatasync(loop, &fdatasync_req, open_req1.result, fdatasync_cb); + ASSERT(r == 0); } @@ -332,6 +339,7 @@ static void create_cb(uv_fs_t* req) { uv_fs_req_cleanup(req); r = uv_fs_write(loop, &write_req, req->result, test_buf, sizeof(test_buf), -1, write_cb); + ASSERT(r == 0); } @@ -1665,3 +1673,59 @@ TEST_IMPL(fs_rename_to_existing_file) { return 0; } + + +TEST_IMPL(fs_read_file_eof) { + int r; + + /* Setup. */ + unlink("test_file"); + + loop = uv_default_loop(); + + r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, + S_IWRITE | S_IREAD, NULL); + ASSERT(r != -1); + ASSERT(open_req1.result != -1); + uv_fs_req_cleanup(&open_req1); + + r = uv_fs_write(loop, &write_req, open_req1.result, test_buf, + sizeof(test_buf), -1, NULL); + ASSERT(r != -1); + ASSERT(write_req.result != -1); + uv_fs_req_cleanup(&write_req); + + r = uv_fs_close(loop, &close_req, open_req1.result, NULL); + ASSERT(r != -1); + ASSERT(close_req.result != -1); + uv_fs_req_cleanup(&close_req); + + r = uv_fs_open(loop, &open_req1, "test_file", O_RDONLY, 0, NULL); + ASSERT(r != -1); + ASSERT(open_req1.result != -1); + uv_fs_req_cleanup(&open_req1); + + memset(buf, 0, sizeof(buf)); + r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, + NULL); + ASSERT(r != -1); + ASSERT(read_req.result != -1); + ASSERT(strcmp(buf, test_buf) == 0); + uv_fs_req_cleanup(&read_req); + + r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), + read_req.result, NULL); + ASSERT(r == 0); + ASSERT(read_req.result == 0); + uv_fs_req_cleanup(&read_req); + + r = uv_fs_close(loop, &close_req, open_req1.result, NULL); + ASSERT(r != -1); + ASSERT(close_req.result != -1); + uv_fs_req_cleanup(&close_req); + + /* Cleanup */ + unlink("test_file"); + + return 0; +} |