summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-06 22:00:21 +0200
committerDavid Robillard <d@drobilla.net>2020-08-07 01:30:23 +0200
commit42f8a3ad0941661cebb6dbb9edbad7d4f7252421 (patch)
treefab515b59918ae4beade6192d6d7984dbc83dbeb /test
parent18eba7b656ab19e27c2351e63a9990b570417b8f (diff)
downloadlilv-42f8a3ad0941661cebb6dbb9edbad7d4f7252421.tar.gz
lilv-42f8a3ad0941661cebb6dbb9edbad7d4f7252421.tar.bz2
lilv-42f8a3ad0941661cebb6dbb9edbad7d4f7252421.zip
Fix error handling when copying files
Diffstat (limited to 'test')
-rw-r--r--test/test_filesystem.c14
1 files changed, 14 insertions, 0 deletions
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 <assert.h>
+#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -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));