From 42f8a3ad0941661cebb6dbb9edbad7d4f7252421 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 6 Aug 2020 22:00:21 +0200 Subject: Fix error handling when copying files --- test/test_filesystem.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/test_filesystem.c') diff --git a/test/test_filesystem.c b/test/test_filesystem.c index 20faa2a..8c7b1ba 100644 --- a/test/test_filesystem.c +++ b/test/test_filesystem.c @@ -21,6 +21,7 @@ #include "../src/filesystem.h" #include +#include #include #include #include @@ -272,6 +273,19 @@ test_copy_file(void) assert(!lilv_copy_file(file_path, copy_path)); assert(lilv_file_equals(file_path, copy_path)); + if (lilv_path_exists("/dev/full")) { + // Copy short file (error after flushing) + assert(lilv_copy_file(file_path, "/dev/full") == ENOSPC); + + // Copy long file (error during writing) + f = fopen(file_path, "w"); + for (size_t i = 0; i < 4096; ++i) { + fprintf(f, "test\n"); + } + fclose(f); + assert(lilv_copy_file(file_path, "/dev/full") == ENOSPC); + } + assert(!lilv_remove(copy_path)); assert(!lilv_remove(file_path)); assert(!lilv_remove(temp_dir)); -- cgit v1.2.1