diff options
Diffstat (limited to 'deps/uv/test/test-fs.c')
-rw-r--r-- | deps/uv/test/test-fs.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c index 7c481f0711..3318b86649 100644 --- a/deps/uv/test/test-fs.c +++ b/deps/uv/test/test-fs.c @@ -319,6 +319,9 @@ static void ftruncate_cb(uv_fs_t* req) { ASSERT(r == 0); } +static void fail_cb(uv_fs_t* req) { + FATAL("fail_cb should not have been called"); +} static void read_cb(uv_fs_t* req) { int r; @@ -2884,7 +2887,19 @@ TEST_IMPL(fs_read_write_null_arguments) { uv_fs_req_cleanup(&read_req); r = uv_fs_write(NULL, &write_req, 0, NULL, 0, -1, NULL); + /* Validate some memory management on failed input validation before sending + fs work to the thread pool. */ ASSERT(r == UV_EINVAL); + ASSERT(write_req.path == NULL); + ASSERT(write_req.ptr == NULL); +#ifdef _WIN32 + ASSERT(write_req.file.pathw == NULL); + ASSERT(write_req.fs.info.new_pathw == NULL); + ASSERT(write_req.fs.info.bufs == NULL); +#else + ASSERT(write_req.new_path == NULL); + ASSERT(write_req.bufs == NULL); +#endif uv_fs_req_cleanup(&write_req); iov = uv_buf_init(NULL, 0); @@ -2897,6 +2912,31 @@ TEST_IMPL(fs_read_write_null_arguments) { ASSERT(r == UV_EINVAL); uv_fs_req_cleanup(&write_req); + /* If the arguments are invalid, the loop should not be kept open */ + loop = uv_default_loop(); + + r = uv_fs_read(loop, &read_req, 0, NULL, 0, -1, fail_cb); + ASSERT(r == UV_EINVAL); + uv_run(loop, UV_RUN_DEFAULT); + uv_fs_req_cleanup(&read_req); + + r = uv_fs_write(loop, &write_req, 0, NULL, 0, -1, fail_cb); + ASSERT(r == UV_EINVAL); + uv_run(loop, UV_RUN_DEFAULT); + uv_fs_req_cleanup(&write_req); + + iov = uv_buf_init(NULL, 0); + r = uv_fs_read(loop, &read_req, 0, &iov, 0, -1, fail_cb); + ASSERT(r == UV_EINVAL); + uv_run(loop, UV_RUN_DEFAULT); + uv_fs_req_cleanup(&read_req); + + iov = uv_buf_init(NULL, 0); + r = uv_fs_write(loop, &write_req, 0, &iov, 0, -1, fail_cb); + ASSERT(r == UV_EINVAL); + uv_run(loop, UV_RUN_DEFAULT); + uv_fs_req_cleanup(&write_req); + return 0; } @@ -3084,7 +3124,7 @@ TEST_IMPL(fs_exclusive_sharing_mode) { unlink("test_file"); ASSERT(UV_FS_O_EXLOCK > 0); - + r = uv_fs_open(NULL, &open_req1, "test_file", |