]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
tests: Check if context was propertly released
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2023 14:13:41 +0000 (14:13 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2023 14:13:41 +0000 (14:13 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/testsuite.c

index e711ecfa8b85f09c7ec7d8147f149e458afae23e..a5a2605c29f3ac1416c204a40f3002d7ab57c9c1 100644 (file)
@@ -34,6 +34,7 @@
 struct testsuite ts;
 
 static int test_run(int i, struct test* t) {
+       struct pakfire_ctx* ctx = NULL;
        struct pakfire* p = NULL;
        FILE* c = NULL;
 
@@ -110,8 +111,19 @@ ERROR:
                t->pakfire = NULL;
        }
 
-       if (t->ctx)
-               pakfire_ctx_unref(t->ctx);
+       // Release context
+       if (t->ctx) {
+               ctx = pakfire_ctx_unref(t->ctx);
+
+               // Check if the context was actually released
+               if (ctx) {
+                       LOG("Error: Context was not released in test %s\n", t->name);
+                       r = 1;
+               }
+
+               // Reset pointer (just in case)
+               t->ctx = NULL;
+       }
 
        // Close the configuration file
        if (c)