test: fs: add tests for read EOF
This fix was merged without tests:
https://github.com/philips/libuv/tree/fix-read-on-windows-to-handle-eof
So take tests from igorzi:
46024bf33d
This commit is contained in:
parent
4f1782a54b
commit
d07f2466d0
@ -1667,3 +1667,59 @@ TEST_IMPL(fs_rename_to_existing_file) {
|
|||||||
|
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@ -124,6 +124,7 @@ TEST_DECLARE (fs_utime)
|
|||||||
TEST_DECLARE (fs_futime)
|
TEST_DECLARE (fs_futime)
|
||||||
TEST_DECLARE (fs_file_open_append)
|
TEST_DECLARE (fs_file_open_append)
|
||||||
TEST_DECLARE (fs_stat_missing_path)
|
TEST_DECLARE (fs_stat_missing_path)
|
||||||
|
TEST_DECLARE (fs_read_file_eof)
|
||||||
TEST_DECLARE (fs_event_watch_dir)
|
TEST_DECLARE (fs_event_watch_dir)
|
||||||
TEST_DECLARE (fs_event_watch_file)
|
TEST_DECLARE (fs_event_watch_file)
|
||||||
TEST_DECLARE (fs_event_watch_file_current_dir)
|
TEST_DECLARE (fs_event_watch_file_current_dir)
|
||||||
@ -308,6 +309,7 @@ TASK_LIST_START
|
|||||||
TEST_ENTRY (fs_futime)
|
TEST_ENTRY (fs_futime)
|
||||||
TEST_ENTRY (fs_symlink)
|
TEST_ENTRY (fs_symlink)
|
||||||
TEST_ENTRY (fs_stat_missing_path)
|
TEST_ENTRY (fs_stat_missing_path)
|
||||||
|
TEST_ENTRY (fs_read_file_eof)
|
||||||
TEST_ENTRY (fs_file_open_append)
|
TEST_ENTRY (fs_file_open_append)
|
||||||
TEST_ENTRY (fs_event_watch_dir)
|
TEST_ENTRY (fs_event_watch_dir)
|
||||||
TEST_ENTRY (fs_event_watch_file)
|
TEST_ENTRY (fs_event_watch_file)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user