From: Michael Tremer Date: Sun, 5 Jan 2025 16:31:21 +0000 (+0000) Subject: tests: Always globally load the test configuration file X-Git-Tag: 0.9.30~523 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bb5779f5f783e4b8f3a9dadd79e1076fec13a6e;p=pakfire.git tests: Always globally load the test configuration file Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index d027a020e..a8dc9caf7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1164,7 +1164,7 @@ TESTSUITE_CPPFLAGS = \ $(AM_CPPFLAGS) \ -I$(top_srcdir)/src \ -DABS_TOP_SRCDIR=\"$(abs_top_srcdir)\" \ - -DTEST_CONFIG_FILE=\"$(abs_top_srcdir)/contrib/config/pakfire.conf\" \ + -DTEST_CONFIG_FILE=\"$(abs_top_srcdir)/tests/pakfire.conf\" \ -DTEST_DATA_DIR=\"$(abs_top_srcdir)/tests/data\" \ -DTEST_ROOTFS=\"$(TEST_ROOTFS)\" \ -DTEST_STUB_ROOT=\"$(TEST_STUB_ROOT)\" diff --git a/tests/testsuite.c b/tests/testsuite.c index 1c8cd1af4..fbba9f12a 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -35,7 +35,6 @@ struct testsuite ts; static int test_run(int i, struct test* t) { - struct pakfire_config* config = NULL; struct pakfire_ctx* ctx = NULL; struct pakfire* p = NULL; int r; @@ -55,23 +54,23 @@ static int test_run(int i, struct test* t) { // Log everything to the console pakfire_ctx_set_log_callback(t->ctx, pakfire_log_stderr, NULL); - // Create a pakfire instance (if requested) - if (t->flags & TEST_WANTS_PAKFIRE) { - // Create a configuration object - r = pakfire_config_create(&config); - if (r < 0) { - LOG("Could not create configuration object: %s\n", strerror(-r)); - goto ERROR; - } + // Create a configuration object + r = pakfire_config_create(&t->config); + if (r < 0) { + LOG("Could not create configuration object: %s\n", strerror(-r)); + goto ERROR; + } - // Read the configuration file - r = pakfire_config_read_path(config, TEST_SRC_PATH "/pakfire.conf"); - if (r < 0) { - LOG("Could not read the configuration: %s\n", strerror(-r)); - goto ERROR; - } + // Read the configuration file + r = pakfire_config_read_path(t->config, TEST_CONFIG_FILE); + if (r < 0) { + LOG("Could not read the configuration: %s\n", strerror(-r)); + goto ERROR; + } - r = pakfire_create(&t->pakfire, t->ctx, config, TEST_STUB_ROOT, NULL, 0); + // Create a pakfire instance (if requested) + if (t->flags & TEST_WANTS_PAKFIRE) { + r = pakfire_create(&t->pakfire, t->ctx, t->config, TEST_STUB_ROOT, NULL, 0); if (r < 0) { LOG("ERROR: Could not initialize pakfire: %s\n", strerror(-r)); goto ERROR; @@ -131,8 +130,8 @@ ERROR: t->ctx = NULL; } - if (config) - pakfire_config_unref(config); + if (t->config) + pakfire_config_unref(t->config); return r; } diff --git a/tests/testsuite.h b/tests/testsuite.h index db69f769d..c6bbe71e4 100644 --- a/tests/testsuite.h +++ b/tests/testsuite.h @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -44,6 +45,9 @@ struct test { int (*func)(const struct test* t); int flags; + // Config + struct pakfire_config* config; + // Pakfire Context struct pakfire_ctx* ctx;