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:
Rich Trott 2019-03-27 08:36:25 -07:00 committed by cjihrig
parent 5bc4d7738a
commit c7b87b0d51
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5

View File

@ -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;
}