From: Michael Tremer Date: Sat, 11 Jan 2025 11:47:39 +0000 (+0000) Subject: tests: Fix the parser tester X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ee1d98a0ff3ad98d944143a835af893b5bef8abb;p=people%2Fric9%2Fpakfire.git tests: Fix the parser tester Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 8856020b1..0a4a85bfe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1000,7 +1000,8 @@ dist_tests_parser_test_SOURCES = \ tests_parser_test_CPPFLAGS = \ $(AM_CPPFLAGS) \ - -I$(top_srcdir)/src + -I$(top_srcdir)/src \ + -DTEST_CONFIG_FILE=\"$(abs_top_srcdir)/tests/pakfire.conf\" tests_parser_test_CFLAGS = \ $(TESTSUITE_CFLAGS) diff --git a/tests/parser/test.c b/tests/parser/test.c index f7050076e..cc55aa1a6 100644 --- a/tests/parser/test.c +++ b/tests/parser/test.c @@ -26,6 +26,7 @@ #include int main(int argc, const char* argv[]) { + struct pakfire_config* config = NULL; struct pakfire_ctx* ctx = NULL; struct pakfire* pakfire = NULL; struct pakfire_parser* parser = NULL; @@ -54,8 +55,17 @@ int main(int argc, const char* argv[]) { // Log everything to the console pakfire_ctx_set_log_callback(ctx, pakfire_log_stderr, NULL); + r = pakfire_config_create(&config); + if (r < 0) + goto ERROR; + + // Load the test configuration + r = pakfire_config_read_path(config, TEST_CONFIG_FILE); + if (r < 0) + goto ERROR; + // Create a pakfire instance - r = pakfire_create(&pakfire, ctx, NULL, root, NULL, 0); + r = pakfire_create(&pakfire, ctx, config, root, NULL, 0); if (r) { fprintf(stderr, "Could not create Pakfire: %m\n"); goto ERROR; @@ -109,8 +119,15 @@ ERROR: pakfire_parser_unref(parser); if (pakfire) pakfire_unref(pakfire); - if (ctx) - pakfire_ctx_unref(ctx); + if (config) + pakfire_config_unref(config); + if (ctx) { + ctx = pakfire_ctx_unref(ctx); + if (ctx) { + fprintf(stderr, "Context was not freed\n"); + return 1; + } + } return r; }