aboutsummaryrefslogtreecommitdiff
path: root/tests/test_utils.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2025-02-04 10:58:04 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2025-02-04 10:58:04 -0500
commitdd4b634ac4a6c1dbfbe3e103019b48430fb5682e (patch)
tree59050082958356ed85d44f32f288bfb82dc051a7 /tests/test_utils.c
parentb67ad320163238989047779a37ba973d8fd46ed5 (diff)
downloadstasis-dd4b634ac4a6c1dbfbe3e103019b48430fb5682e.tar.gz
tests: free allocated resources
Diffstat (limited to 'tests/test_utils.c')
-rw-r--r--tests/test_utils.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/test_utils.c b/tests/test_utils.c
index 9090b05..8f0a667 100644
--- a/tests/test_utils.c
+++ b/tests/test_utils.c
@@ -46,6 +46,7 @@ void test_redact_sensitive() {
char output[100] = {0};
redact_sensitive(to_redact, sizeof(to_redact) / sizeof(*to_redact), input, output, sizeof(output) - 1);
STASIS_ASSERT(strcmp(output, expected[i]) == 0, "incorrect redaction");
+ guard_free(input);
}
}
@@ -118,6 +119,7 @@ void test_path_store() {
STASIS_ASSERT(dest != NULL, "dest should not be NULL");
STASIS_ASSERT(dest && (access(dest, F_OK) == 0), "destination path was not created");
rmtree(dest);
+ guard_free(dest);
}
void test_isempty_dir() {
@@ -226,6 +228,7 @@ void test_git_clone_and_describe() {
char *taginfo_bad = git_describe("abc1234_not_here_or_there");
STASIS_ASSERT(taginfo_bad == NULL, "a repository that shouldn't exist... exists and has a tag.");
chdir(cwd);
+ guard_free(cwd);
}
void test_touch() {
@@ -414,9 +417,11 @@ void test_pushd_popd() {
// we should be inside the test directory, not the starting directory
STASIS_ASSERT(strcmp(cwd_workspace, cwd) != 0, "");
STASIS_ASSERT(popd() == 0, "return from directory failed");
+ guard_free(cwd);
char *cwd_after_popd = getcwd(NULL, PATH_MAX);
STASIS_ASSERT(strcmp(cwd_workspace, cwd_after_popd) == 0, "should be the path where we started");
+ guard_free(cwd_after_popd);
}
void test_pushd_popd_suggested_workflow() {
@@ -436,6 +441,7 @@ void test_pushd_popd_suggested_workflow() {
// cwd should be our starting directory
char *cwd = getcwd(NULL, PATH_MAX);
STASIS_ASSERT(strcmp(cwd_workspace, cwd) == 0, NULL);
+ guard_free(cwd);
} else {
STASIS_ASSERT(false, "mkdir function failed");
}