summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-11-12 17:54:11 -0500
committerDavid Robillard <d@drobilla.net>2022-11-16 10:22:55 -0500
commit67a33e70aa2b3f2f78742e773bac5ccb7be95c20 (patch)
treea00d94889233cfccaf01592906121b74db0b39bb /test
parentd7fce849783d54c15658431552e1bd2eeec54378 (diff)
downloadlilv-67a33e70aa2b3f2f78742e773bac5ccb7be95c20.tar.gz
lilv-67a33e70aa2b3f2f78742e773bac5ccb7be95c20.tar.bz2
lilv-67a33e70aa2b3f2f78742e773bac5ccb7be95c20.zip
Use zix_file_type() and zix_symlink_type()
Diffstat (limited to 'test')
-rw-r--r--test/test_filesystem.c26
-rw-r--r--test/test_state.c29
2 files changed, 21 insertions, 34 deletions
diff --git a/test/test_filesystem.c b/test/test_filesystem.c
index 610021d..a0e3bc8 100644
--- a/test/test_filesystem.c
+++ b/test/test_filesystem.c
@@ -7,6 +7,8 @@
#include "../src/filesystem.h"
+#include "zix/filesystem.h"
+
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
@@ -281,27 +283,6 @@ test_path_canonical(void)
}
static void
-test_path_exists(void)
-{
- char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
- char* const file_path = lilv_path_join(temp_dir, "lilv_test_file");
-
- assert(!lilv_path_exists(file_path));
-
- FILE* f = fopen(file_path, "w");
- fprintf(f, "test\n");
- fclose(f);
-
- assert(lilv_path_exists(file_path));
-
- assert(!lilv_remove(file_path));
- assert(!lilv_remove(temp_dir));
-
- free(file_path);
- free(temp_dir);
-}
-
-static void
test_is_directory(void)
{
char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
@@ -337,7 +318,7 @@ 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")) {
+ if (zix_file_type("/dev/full") != ZIX_FILE_TYPE_NONE) {
// Copy short file (error after flushing)
assert(lilv_copy_file(file_path, "/dev/full") == ENOSPC);
@@ -527,7 +508,6 @@ main(void)
test_path_filename();
test_path_join();
test_path_canonical();
- test_path_exists();
test_is_directory();
test_copy_file();
test_flock();
diff --git a/test/test_state.c b/test/test_state.c
index d0ccdfe..524a495 100644
--- a/test/test_state.c
+++ b/test/test_state.c
@@ -13,6 +13,7 @@
#include "lv2/state/state.h"
#include "lv2/urid/urid.h"
#include "serd/serd.h"
+#include "zix/filesystem.h"
#ifdef _WIN32
# include <direct.h>
@@ -585,7 +586,7 @@ test_to_files(void)
// Check that the test plugin has made its recording scratch file
char* const recfile_path = lilv_path_join(dirs.scratch, "recfile");
- assert(lilv_path_exists(recfile_path));
+ assert(zix_file_type(recfile_path) == ZIX_FILE_TYPE_REGULAR);
// Get state
char* const bundle_1_path = lilv_path_join(dirs.top, "state1.lv2");
@@ -597,7 +598,7 @@ test_to_files(void)
// Check that a snapshop of the recfile was created
char* const recfile_copy_1 = lilv_path_join(dirs.copy, "recfile");
- assert(lilv_path_exists(recfile_copy_1));
+ assert(zix_file_type(recfile_copy_1) == ZIX_FILE_TYPE_REGULAR);
// Save state to a bundle
assert(!lilv_state_save(ctx->env->world,
@@ -610,14 +611,17 @@ test_to_files(void)
// Check that a manifest exists
char* const manifest_path = lilv_path_join(bundle_1_path, "manifest.ttl");
- assert(lilv_path_exists(manifest_path));
+ assert(zix_file_type(manifest_path) == ZIX_FILE_TYPE_REGULAR);
// Check that the expected statements are in the manifest file
assert(count_statements(manifest_path) == 3);
// Check that a link to the recfile exists in the saved bundle
char* const recfile_link_1 = lilv_path_join(bundle_1_path, "recfile");
- assert(lilv_path_exists(recfile_link_1));
+ assert(zix_file_type(recfile_link_1) == ZIX_FILE_TYPE_REGULAR);
+#ifndef _WIN32
+ assert(zix_symlink_type(recfile_link_1) == ZIX_FILE_TYPE_SYMLINK);
+#endif
// Check that link points to the corresponding copy
assert(lilv_file_equals(recfile_link_1, recfile_copy_1));
@@ -641,11 +645,14 @@ test_to_files(void)
// Check that a new snapshop of the recfile was created
char* const recfile_copy_2 = lilv_path_join(dirs.copy, "recfile.2");
- assert(lilv_path_exists(recfile_copy_2));
+ assert(zix_file_type(recfile_copy_2) == ZIX_FILE_TYPE_REGULAR);
// Check that a link to the recfile exists in the updated bundle
char* const recfile_link_2 = lilv_path_join(bundle_2_path, "recfile");
- assert(lilv_path_exists(recfile_link_2));
+ assert(zix_file_type(recfile_link_2) == ZIX_FILE_TYPE_REGULAR);
+#ifndef _WIN32
+ assert(zix_symlink_type(recfile_link_2) == ZIX_FILE_TYPE_SYMLINK);
+#endif
// Check that link points to the corresponding copy
assert(lilv_file_equals(recfile_link_2, recfile_copy_2));
@@ -704,11 +711,11 @@ test_multi_save(void)
// Check that a manifest exists
char* const manifest_path = lilv_path_join(bundle_1_path, "manifest.ttl");
- assert(lilv_path_exists(manifest_path));
+ assert(zix_file_type(manifest_path) == ZIX_FILE_TYPE_REGULAR);
// Check that the state file exists
char* const state_path = lilv_path_join(bundle_1_path, "state.ttl");
- assert(lilv_path_exists(state_path));
+ assert(zix_file_type(state_path) == ZIX_FILE_TYPE_REGULAR);
// Check that the expected statements are in the files
assert(count_statements(manifest_path) == 3);
@@ -724,8 +731,8 @@ test_multi_save(void)
"state.ttl"));
// Check that everything is the same
- assert(lilv_path_exists(manifest_path));
- assert(lilv_path_exists(state_path));
+ assert(zix_file_type(manifest_path) == ZIX_FILE_TYPE_REGULAR);
+ assert(zix_file_type(state_path) == ZIX_FILE_TYPE_REGULAR);
assert(count_statements(manifest_path) == 3);
assert(count_statements(state_path) == 21);
@@ -1066,7 +1073,7 @@ test_delete(void)
assert(n_shared_files_before == n_shared_files_after);
// Ensure the state directory has been deleted
- assert(!lilv_path_exists(bundle_path));
+ assert(zix_file_type(bundle_path) == ZIX_FILE_TYPE_NONE);
cleanup_test_directories(dirs);