summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-11-17 14:35:02 -0500
committerDavid Robillard <d@drobilla.net>2023-11-17 14:44:36 -0500
commite90109eac8151498fa3b4650abc8f74a8a453c8d (patch)
tree4aae70cd9f53cf7d7587484a4ca6bb28f9be16e6
parenta6f804073de1f1e626464a9dd0a169fd3f69fdff (diff)
downloadzix-e90109eac8151498fa3b4650abc8f74a8a453c8d.tar.gz
zix-e90109eac8151498fa3b4650abc8f74a8a453c8d.tar.bz2
zix-e90109eac8151498fa3b4650abc8f74a8a453c8d.zip
Test zix_copy_file() in Wasm
-rw-r--r--test/test_filesystem.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/test/test_filesystem.c b/test/test_filesystem.c
index cc68249..4a1ad4f 100644
--- a/test/test_filesystem.c
+++ b/test/test_filesystem.c
@@ -248,7 +248,7 @@ write_to_path(const char* const path, const char* const contents)
}
static void
-test_copy_file(const char* const data_file_path)
+test_copy_file(const char* data_file_path)
{
char* const temp_dir = create_temp_dir("zixXXXXXX");
char* const tmp_file_path = zix_path_join(NULL, temp_dir, "zix_test_file");
@@ -257,6 +257,10 @@ test_copy_file(const char* const data_file_path)
assert(tmp_file_path);
assert(copy_path);
+ if (!data_file_path) {
+ data_file_path = tmp_file_path;
+ }
+
assert(!write_to_path(tmp_file_path, "test\n"));
assert(zix_copy_file(NULL, tmp_file_path, "/does/not/exist", 0U));
@@ -686,14 +690,11 @@ test_create_hard_link(void)
int
main(const int argc, char** const argv)
{
-#ifdef __EMSCRIPTEN__
- (void)argc;
- (void)argv;
-
- const char* const data_file_path = NULL;
-#else
- const char* const data_file_path = argc > 1 ? argv[1] : "build.ninja";
-#endif
+ // Try to find some existing data file that's ideally not on a tmpfs
+ const char* data_file_path = (argc > 1) ? argv[1] : "build.ninja";
+ if (zix_file_type(data_file_path) != ZIX_FILE_TYPE_REGULAR) {
+ data_file_path = NULL;
+ }
test_temp_directory_path();
test_current_path();