diff options
author | David Robillard <d@drobilla.net> | 2024-12-10 15:46:55 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-12-11 00:19:44 -0500 |
commit | 23cdd12bf40c8128b1c8df9127e5110af89ff460 (patch) | |
tree | 27114d05c8a76e93772b7eab2304477b045b7fe2 /test/test_filesystem.c | |
parent | 317e6d70d3b2d2eb16b6f9b656183c49b24b4f07 (diff) | |
download | zix-23cdd12bf40c8128b1c8df9127e5110af89ff460.tar.gz zix-23cdd12bf40c8128b1c8df9127e5110af89ff460.tar.bz2 zix-23cdd12bf40c8128b1c8df9127e5110af89ff460.zip |
Keep test paths within created temporary directory
Creates a subdirectory for testing ".." to stay within the created test
directory for compatibility with sandboxing.
Diffstat (limited to 'test/test_filesystem.c')
-rw-r--r-- | test/test_filesystem.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/test/test_filesystem.c b/test/test_filesystem.c index d57dc3f..40fc9a2 100644 --- a/test/test_filesystem.c +++ b/test/test_filesystem.c @@ -1,4 +1,4 @@ -// Copyright 2020-2023 David Robillard <d@drobilla.net> +// Copyright 2020-2024 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC #undef NDEBUG @@ -64,6 +64,10 @@ test_canonical_path(void) char* const temp_dir = create_temp_dir("zixXXXXXX"); assert(temp_dir); + char* const sub_dir = zix_path_join(NULL, temp_dir, "sub"); + assert(!zix_create_directory(sub_dir)); + assert(zix_file_type(temp_dir) == ZIX_FILE_TYPE_DIRECTORY); + char* const file_path = zix_path_join(NULL, temp_dir, "zix_test_file"); assert(file_path); @@ -96,10 +100,10 @@ test_canonical_path(void) // Test dot segment resolution - char* const parent_dir_1 = zix_path_join(NULL, temp_dir, ".."); + char* const parent_dir_1 = zix_path_join(NULL, sub_dir, ".."); assert(parent_dir_1); - const ZixStringView parent_view = zix_path_parent_path(temp_dir); + const ZixStringView parent_view = zix_path_parent_path(sub_dir); char* const parent_dir_2 = zix_string_view_copy(NULL, parent_view); assert(parent_dir_2); assert(parent_dir_2[0]); @@ -120,6 +124,7 @@ test_canonical_path(void) // Clean everything up assert(!zix_remove(file_path)); + assert(!zix_remove(sub_dir)); assert(!zix_remove(temp_dir)); free(real_parent_dir_2); @@ -127,6 +132,7 @@ test_canonical_path(void) free(parent_dir_2); free(parent_dir_1); free(file_path); + free(sub_dir); free(temp_dir); } |