From: Michael Tremer Date: Tue, 17 Oct 2023 08:47:17 +0000 (+0000) Subject: tests: Make the context accessible X-Git-Tag: 0.9.30~1478 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab11cb4c7e322850e6dbc78afd00c8a813519884;p=pakfire.git tests: Make the context accessible Signed-off-by: Michael Tremer --- diff --git a/tests/testsuite.c b/tests/testsuite.c index 209693831..52c419ede 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -34,7 +34,6 @@ struct testsuite ts; static int test_run(int i, struct test* t) { - struct pakfire_ctx* ctx = NULL; struct pakfire* p = NULL; FILE* c = NULL; @@ -51,17 +50,17 @@ static int test_run(int i, struct test* t) { LOG("running %s (%s)\n", t->name, root); // Create a new context - r = pakfire_ctx_create(&ctx, NULL); + r = pakfire_ctx_create(&t->ctx, NULL); if (r) { LOG("Could not create context: %m\n"); goto ERROR; } // Set the log level to DEBUG - pakfire_ctx_set_log_level(ctx, LOG_DEBUG); + pakfire_ctx_set_log_level(t->ctx, LOG_DEBUG); // Log everything to the console - pakfire_ctx_set_log_callback(ctx, pakfire_log_stderr, NULL); + pakfire_ctx_set_log_callback(t->ctx, pakfire_log_stderr, NULL); // Open the configuration file c = fopen(TEST_SRC_PATH "/pakfire.conf", "r"); @@ -72,7 +71,7 @@ static int test_run(int i, struct test* t) { } // Create a pakfire instance - r = pakfire_create(&t->pakfire, ctx, root, NULL, c, 0); + r = pakfire_create(&t->pakfire, t->ctx, root, NULL, c, 0); if (r) { LOG("ERROR: Could not initialize pakfire: %m\n"); goto ERROR; @@ -111,8 +110,8 @@ ERROR: t->pakfire = NULL; } - if (ctx) - pakfire_ctx_unref(ctx); + if (t->ctx) + pakfire_ctx_unref(t->ctx); // Close the configuration file if (c) diff --git a/tests/testsuite.h b/tests/testsuite.h index 4661ea168..7581bd0cc 100644 --- a/tests/testsuite.h +++ b/tests/testsuite.h @@ -26,6 +26,7 @@ #include #include +#include #include #define MAX_TESTS 128 @@ -35,6 +36,11 @@ struct test { const char* name; int (*func)(const struct test* t); + + // Pakfire Context + struct pakfire_ctx* ctx; + + // Pakfire struct pakfire* pakfire; };