aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_conda.c6
-rw-r--r--tests/test_junitxml.c9
-rw-r--r--tests/test_str.c8
3 files changed, 15 insertions, 8 deletions
diff --git a/tests/test_conda.c b/tests/test_conda.c
index 84f98bc..63a2781 100644
--- a/tests/test_conda.c
+++ b/tests/test_conda.c
@@ -202,7 +202,11 @@ int main(int argc, char *argv[]) {
test_delivery_gather_tool_versions,
};
- const char *ws = "workspace";
+ char ws[] = "workspace_XXXXXX";
+ if (!mkdtemp(ws)) {
+ perror("mkdtemp");
+ exit(1);
+ }
getcwd(cwd_start, sizeof(cwd_start) - 1);
mkdir(ws, 0755);
chdir(ws);
diff --git a/tests/test_junitxml.c b/tests/test_junitxml.c
index e222b56..362cb32 100644
--- a/tests/test_junitxml.c
+++ b/tests/test_junitxml.c
@@ -3,7 +3,10 @@
void test_junitxml_testsuite_read() {
struct JUNIT_Testsuite *testsuite;
- STASIS_ASSERT_FATAL((testsuite = junitxml_testsuite_read("data/result.xml")) != NULL, "failed to load testsuite data");
+ char datafile[PATH_MAX] = {0};
+ snprintf(datafile, sizeof(datafile) - 1, "%s/result.xml", TEST_DATA_DIR);
+
+ STASIS_ASSERT_FATAL((testsuite = junitxml_testsuite_read(datafile)) != NULL, "failed to load testsuite data");
STASIS_ASSERT(testsuite->name != NULL, "Test suite must be named");
STASIS_ASSERT(testsuite->skipped > 0, "missed skipped tests");
STASIS_ASSERT(testsuite->failures > 0, "missed failed tests");
@@ -44,7 +47,9 @@ void test_junitxml_testsuite_read() {
void test_junitxml_testsuite_read_error() {
struct JUNIT_Testsuite *testsuite;
- STASIS_ASSERT_FATAL((testsuite = junitxml_testsuite_read("data/result_error.xml")) != NULL, "failed to load testsuite data");
+ char datafile[PATH_MAX] = {0};
+ snprintf(datafile, sizeof(datafile) - 1, "%s/result_error.xml", TEST_DATA_DIR);
+ STASIS_ASSERT_FATAL((testsuite = junitxml_testsuite_read(datafile)) != NULL, "failed to load testsuite data");
STASIS_ASSERT(testsuite->name != NULL, "test suite must be named");
STASIS_ASSERT(testsuite->skipped == 0, "should not have any skipped tests");
diff --git a/tests/test_str.c b/tests/test_str.c
index 4991c1c..3aea50b 100644
--- a/tests/test_str.c
+++ b/tests/test_str.c
@@ -204,8 +204,7 @@ void test_split() {
{.data = NULL, .delim = NULL, NULL},
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
- char **result;
- result = split(tc[i].data, tc[i].delim, tc[i].max_split);
+ char **result = split((char *) tc[i].data, tc[i].delim, tc[i].max_split);
STASIS_ASSERT(strcmp_array((const char **) result, tc[i].expected) == 0, "Split failed");
GENERIC_ARRAY_FREE(result);
}
@@ -243,8 +242,7 @@ void test_join_ex() {
{.delim = "\n\n", .expected = "a\n\nb\n\nc\n\nd\n\ne"},
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
- char *result;
- result = join_ex((char *) tc[i].delim, "a", "b", "c", "d", "e", NULL);
+ char *result = join_ex((char *) tc[i].delim, "a", "b", "c", "d", "e", NULL);
STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "failed to join array");
guard_free(result);
}
@@ -270,7 +268,7 @@ void test_substring_between() {
{.data = "nothing () here", .delim = "()", .expected = ""}, // nothing exists between delimiters
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
- char *result = substring_between(tc[i].data, tc[i].delim);
+ char *result = substring_between((char *) tc[i].data, tc[i].delim);
STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "unable to extract substring");
guard_free(result);
}