aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-11-24 19:52:59 -0500
committerDavid Robillard <d@drobilla.net>2022-11-25 07:05:57 -0500
commit22a5b76450320b8b3dff785d84ea50b1095f7e5e (patch)
treeadfc933be88b6cc36cccf6b657941a92b49103c9
parent245c6157a7d236527a4b91beb612426aeab4215a (diff)
downloadserd-22a5b76450320b8b3dff785d84ea50b1095f7e5e.tar.gz
serd-22a5b76450320b8b3dff785d84ea50b1095f7e5e.tar.bz2
serd-22a5b76450320b8b3dff785d84ea50b1095f7e5e.zip
Avoid creating test files in the current directory
-rw-r--r--test/.clang-tidy1
-rw-r--r--test/test_reader_writer.c22
2 files changed, 22 insertions, 1 deletions
diff --git a/test/.clang-tidy b/test/.clang-tidy
index 2e3f5b1d..4450bf3b 100644
--- a/test/.clang-tidy
+++ b/test/.clang-tidy
@@ -9,6 +9,7 @@ Checks: >
-clang-analyzer-nullability.NullabilityBase,
-clang-analyzer-nullability.NullableDereferenced,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
+ -concurrency-mt-unsafe,
-cppcoreguidelines-avoid-non-const-global-variables,
-hicpp-signed-bitwise,
-readability-function-cognitive-complexity,
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index e93a7942..0da63f85 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -443,13 +443,33 @@ test_reader(const char* path)
int
main(void)
{
+#ifdef _WIN32
+ char tmp[MAX_PATH] = {0};
+ const size_t tmp_len = (size_t)GetTempPath(sizeof(tmp), tmp);
+#else
+ const char* const env_tmp = getenv("TMPDIR");
+ const char* const tmp = env_tmp ? env_tmp : "/tmp";
+ const size_t tmp_len = strlen(tmp);
+#endif
+
+ const char* const name = "serd_test_reader_writer.ttl";
+ const size_t name_len = strlen(name);
+ const size_t path_len = tmp_len + 1 + name_len;
+ char* const path = (char*)calloc(path_len + 1, 1);
+
+ memcpy(path, tmp, tmp_len + 1);
+ path[tmp_len] = '/';
+ memcpy(path + tmp_len + 1, name, name_len + 1);
+
test_read_chunks();
test_read_string();
- const char* const path = "serd_test.ttl";
test_writer(path);
test_reader(path);
+ assert(!remove(path));
+ free(path);
+
printf("Success\n");
return 0;
}