]> git.ipfire.org Git - people/ric9/pakfire.git/commitdiff
tests: Fix the parser tester
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Jan 2025 11:47:39 +0000 (11:47 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Jan 2025 11:47:39 +0000 (11:47 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
tests/parser/test.c

index 8856020b1ee88de6cf0d96c173b62c1cb302694e..0a4a85bfead36d09058daea581e8c102f9657692 100644 (file)
@@ -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)
index f7050076e0821e35e5ef439692d7ea233a97484e..cc55aa1a60189d951278b7f18c7eb57bc2fdfb40 100644 (file)
@@ -26,6 +26,7 @@
 #include <pakfire/util.h>
 
 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;
 }