fs: add test for copyfile() respecting permissions
Add test to test-fs-copyfile.c to check that uv_fs_copyfile() respects destination file permissions. Previously, in macOS, it did not. PR-URL: https://github.com/libuv/libuv/pull/2233 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
parent
5bc4d7738a
commit
c7b87b0d51
@ -185,6 +185,17 @@ TEST_IMPL(fs_copyfile) {
|
||||
if (r == 0)
|
||||
handle_result(&req);
|
||||
|
||||
#ifndef _WIN32
|
||||
/* Copying respects permissions/mode. */
|
||||
unlink(dst);
|
||||
touch_file(dst, 0);
|
||||
chmod(dst, S_IRUSR|S_IRGRP|S_IROTH); /* Sets file mode to 444 (read-only). */
|
||||
r = uv_fs_copyfile(NULL, &req, fixture, dst, 0, NULL);
|
||||
ASSERT(req.result == UV_EACCES);
|
||||
ASSERT(r == UV_EACCES);
|
||||
uv_fs_req_cleanup(&req);
|
||||
#endif
|
||||
|
||||
unlink(dst); /* Cleanup */
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user