From dd18517ab5b3738b4dc511e5d690fc24b55265e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Wed, 12 Feb 2025 15:54:06 +0100 Subject: [PATCH] Add test --- test/test-fs.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test-fs.c b/test/test-fs.c index e2c05db3..6641beac 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -1717,6 +1717,18 @@ TEST_IMPL(fs_access) { ASSERT_EQ(1, access_cb_count); access_cb_count = 0; /* reset for the next test */ + /* Make the file read-only */ + r = uv_fs_fchmod(NULL, &req, file, 0400, NULL); + ASSERT_OK(r); + ASSERT_OK(req.result); + uv_fs_req_cleanup(&req); + + /* Check that the file is not writable */ + r = uv_fs_access(NULL, &req, "test_file", W_OK, NULL); + ASSERT_EQ(r, UV_EACCES); + ASSERT_EQ(req.result, UV_EACCES); + uv_fs_req_cleanup(&req); + /* Close file */ r = uv_fs_close(NULL, &req, file, NULL); ASSERT_OK(r); @@ -1740,6 +1752,8 @@ TEST_IMPL(fs_access) { uv_run(loop, UV_RUN_DEFAULT); /* Cleanup. */ + uv_fs_chmod(NULL, &req, "test_file", 0600, NULL); + uv_fs_req_cleanup(&req); unlink("test_file"); rmdir("test_dir");