From: Michael Tremer Date: Thu, 11 Aug 2022 16:47:03 +0000 (+0000) Subject: tests: Check if Pakfire was initialized correctly X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=84e596799f36d519fc48270d74d738cdfb4d3f8e;p=people%2Fstevee%2Fpakfire.git tests: Check if Pakfire was initialized correctly Signed-off-by: Michael Tremer --- diff --git a/tests/testsuite.c b/tests/testsuite.c index 65fca38c..417a60b9 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -55,6 +55,12 @@ static int test_run(int i, struct test* t) { goto ERROR; } + // Check if the instance was created properly + if (r == 0 && !t->pakfire) { + LOG("ERROR: Pakfire was not initialized, but no error was raised: %m\n"); + goto ERROR; + } + // Copy command into environment r = pakfire_copy_in(t->pakfire, TEST_STUB_COMMAND, "/command"); if (r) { @@ -69,16 +75,18 @@ static int test_run(int i, struct test* t) { ERROR: // Release pakfire - p = pakfire_unref(t->pakfire); + if (t->pakfire) { + p = pakfire_unref(t->pakfire); - // Check if Pakfire was actually released - if (p) { - LOG("Error: Pakfire instance was not released in test %d\n", i); - return 1; - } + // Check if Pakfire was actually released + if (p) { + LOG("Error: Pakfire instance was not released in test %d\n", i); + return 1; + } - // Reset pointer (just in case) - t->pakfire = NULL; + // Reset pointer (just in case) + t->pakfire = NULL; + } // Cleanup root pakfire_rmtree(root, 0);