]> git.ipfire.org Git - pakfire.git/commitdiff
tests: Let Pakfire create its own temporary directories
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 17 Oct 2024 18:26:55 +0000 (18:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 17 Oct 2024 18:26:55 +0000 (18:26 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/testsuite.c

index 4f82c170098ace8caa8c66fd3796b431c7b4d051..b6cb90e7716603ad1b4cb7d8f36250b9d9786036 100644 (file)
@@ -37,18 +37,9 @@ static int test_run(int i, struct test* t) {
        struct pakfire_ctx* ctx = NULL;
        struct pakfire* p = NULL;
        FILE* c = NULL;
-
-       char root[PATH_MAX] = TEST_ROOTFS "/pakfire-test-XXXXXX";
        int r;
 
-       // Create test root directory
-       char* tmp = pakfire_mkdtemp(root);
-       if (!tmp) {
-               LOG("Could not create temporary directory %s: %m\n", root);
-               exit(1);
-       }
-
-       LOG("running %s (%s)\n", t->name, root);
+       LOG("running %s\n", t->name);
 
        // Create a new context
        r = pakfire_ctx_create(&t->ctx, TEST_CONFIG_FILE);
@@ -73,9 +64,9 @@ static int test_run(int i, struct test* t) {
 
        // Create a pakfire instance (if requested)
        if (t->flags & TEST_WANTS_PAKFIRE) {
-               r = pakfire_create(&t->pakfire, t->ctx, root, NULL, c, 0);
-               if (r) {
-                       LOG("ERROR: Could not initialize pakfire: %m\n");
+               r = pakfire_create(&t->pakfire, t->ctx, NULL, NULL, c, 0);
+               if (r < 0) {
+                       LOG("ERROR: Could not initialize pakfire: %s\n", strerror(-r));
                        goto ERROR;
                }
 
@@ -96,7 +87,7 @@ static int test_run(int i, struct test* t) {
        // Create a HTTP client (if requested)
        if (t->flags & TEST_WANTS_HTTPCLIENT) {
                r = pakfire_httpclient_create(&t->httpclient, t->ctx, NULL);
-               if (r) {
+               if (r < 0) {
                        LOG("ERROR: Could not initialize the HTTP client: %s\n", strerror(-r));
                        goto ERROR;
                }
@@ -144,9 +135,6 @@ ERROR:
        if (c)
                fclose(c);
 
-       // Cleanup root
-       pakfire_rmtree(root, 0);
-
        return r;
 }