]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: test-fs-posix - Use the new test-dir API
authorStephan Bosch <stephan.bosch@open-xchange.com>
Mon, 27 Oct 2025 20:58:18 +0000 (21:58 +0100)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 5 Nov 2025 10:17:48 +0000 (10:17 +0000)
src/lib-fs/test-fs-posix.c

index 48a9757be9835801893c519854b27fe1dbd11da1..b4263f3084e05014f4584cb2f1f425270af8befe 100644 (file)
@@ -7,6 +7,7 @@
 #include "safe-mkdir.h"
 #include "safe-mkstemp.h"
 #include "test-common.h"
+#include "test-dir.h"
 #include "unlink-directory.h"
 #include "settings.h"
 #include <sys/stat.h>
 
 static void test_fs_posix(void)
 {
-       const char testdir[] = ".test-fs-posix";
-       const char *unlink_err;
-
-       if (unlink_directory(testdir, UNLINK_DIRECTORY_FLAG_RMDIR, &unlink_err) < 0) {
-               i_error("Couldn't prepare test directory (%s): %s", testdir, unlink_err);
-               goto error_no_testdir;
-       }
-       if (safe_mkdir(testdir, 0700, (uid_t)-1, (gid_t)-1) != 1) {
-               /* Something just raced us to create this directory, bail. */
-               goto error_no_testdir;
-       }
-
        int ret;
        const char *error;
        struct fs *fs;
@@ -37,7 +26,7 @@ static void test_fs_posix(void)
        const char *const settings[] = {
                "fs", "posix",
                "fs/posix/fs_driver", "posix",
-               "fs_posix_prefix", t_strconcat(testdir, "/", NULL),
+               "fs_posix_prefix", t_strconcat(test_dir_get(), "/", NULL),
                NULL
        };
        struct settings_simple test_set;
@@ -140,9 +129,6 @@ static void test_fs_posix(void)
        settings_simple_deinit(&test_set);
 
 error_no_fs:
-       if (unlink_directory(testdir, UNLINK_DIRECTORY_FLAG_RMDIR, &unlink_err) < 0)
-               i_error("Couldn't clean up test directory (%s): %s", testdir, unlink_err);
-error_no_testdir:
        return;
 }
 
@@ -152,5 +138,8 @@ int main(void)
                test_fs_posix,
                NULL
        };
+
+       test_dir_init("fs-posix");
+
        return test_run(test_functions);
 }