summaryrefslogtreecommitdiff
path: root/deps/uv/test/test-fs-copyfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'deps/uv/test/test-fs-copyfile.c')
-rw-r--r--deps/uv/test/test-fs-copyfile.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/deps/uv/test/test-fs-copyfile.c b/deps/uv/test/test-fs-copyfile.c
index 2d1f9079a5..460c1dc6ae 100644
--- a/deps/uv/test/test-fs-copyfile.c
+++ b/deps/uv/test/test-fs-copyfile.c
@@ -68,7 +68,8 @@ static void touch_file(const char* name, unsigned int size) {
int r;
unsigned int i;
- r = uv_fs_open(NULL, &req, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL);
+ r = uv_fs_open(NULL, &req, name, O_WRONLY | O_CREAT | O_TRUNC,
+ S_IWUSR | S_IRUSR, NULL);
uv_fs_req_cleanup(&req);
ASSERT(r >= 0);
file = r;
@@ -119,6 +120,13 @@ TEST_IMPL(fs_copyfile) {
ASSERT(r == 0);
handle_result(&req);
+ /* Copies a file of size zero. */
+ unlink(dst);
+ touch_file(src, 0);
+ r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL);
+ ASSERT(r == 0);
+ handle_result(&req);
+
/* Copies file synchronously. Overwrites existing file. */
r = uv_fs_copyfile(NULL, &req, fixture, dst, 0, NULL);
ASSERT(r == 0);
@@ -129,6 +137,12 @@ TEST_IMPL(fs_copyfile) {
ASSERT(r == UV_EEXIST);
uv_fs_req_cleanup(&req);
+ /* Truncates when an existing destination is larger than the source file. */
+ touch_file(src, 1);
+ r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL);
+ ASSERT(r == 0);
+ handle_result(&req);
+
/* Copies a larger file. */
unlink(dst);
touch_file(src, 4096 * 2);
@@ -141,9 +155,9 @@ TEST_IMPL(fs_copyfile) {
unlink(dst);
r = uv_fs_copyfile(loop, &req, fixture, dst, 0, handle_result);
ASSERT(r == 0);
- ASSERT(result_check_count == 3);
+ ASSERT(result_check_count == 5);
uv_run(loop, UV_RUN_DEFAULT);
- ASSERT(result_check_count == 4);
+ ASSERT(result_check_count == 6);
unlink(dst); /* Cleanup */
return 0;