From: Michael Tremer Date: Thu, 6 Feb 2025 20:59:23 +0000 (+0000) Subject: tests: Add a simple test to create a daemon X-Git-Tag: 0.9.30~106 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f7d8a356740dec57555a0039abf912485e6de1ad;p=pakfire.git tests: Add a simple test to create a daemon Signed-off-by: Michael Tremer --- diff --git a/.gitignore b/.gitignore index 5cc5981a..8dd48191 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ /tests/libpakfire/cgroup /tests/libpakfire/compress /tests/libpakfire/config +/tests/libpakfire/daemon /tests/libpakfire/db /tests/libpakfire/deps /tests/libpakfire/digest diff --git a/Makefile.am b/Makefile.am index bde75856..f099809c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -574,6 +574,7 @@ check_PROGRAMS += \ tests/libpakfire/cgroup \ tests/libpakfire/compress \ tests/libpakfire/config \ + tests/libpakfire/daemon \ tests/libpakfire/db \ tests/libpakfire/deps \ tests/libpakfire/env \ @@ -700,6 +701,21 @@ tests_libpakfire_config_LDFLAGS = \ tests_libpakfire_config_LDADD = \ $(TESTSUITE_LDADD) +tests_libpakfire_daemon_SOURCES = \ + tests/libpakfire/daemon.c + +tests_libpakfire_daemon_CPPFLAGS = \ + $(TESTSUITE_CPPFLAGS) + +tests_libpakfire_daemon_CFLAGS = \ + $(TESTSUITE_CFLAGS) + +tests_libpakfire_daemon_LDFLAGS = \ + $(TESTSUITE_LDFLAGS) + +tests_libpakfire_daemon_LDADD = \ + $(TESTSUITE_LDADD) + tests_libpakfire_db_SOURCES = \ tests/libpakfire/db.c diff --git a/tests/libpakfire/daemon.c b/tests/libpakfire/daemon.c new file mode 100644 index 00000000..6b031826 --- /dev/null +++ b/tests/libpakfire/daemon.c @@ -0,0 +1,51 @@ +/*############################################################################# +# # +# Pakfire - The IPFire package management system # +# Copyright (C) 2025 Pakfire development team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +#############################################################################*/ + +#include + +#include "../testsuite.h" + +static int test_daemon(const struct test* t) { + struct pakfire_daemon* daemon = NULL; + const char* url = NULL; + int r = EXIT_FAILURE; + + // We can only create the daemon + ASSERT_SUCCESS(pakfire_daemon_create(&daemon, t->ctx)); + + // Fetch the URL + ASSERT(url = pakfire_daemon_url(daemon)); + ASSERT_STRING_EQUALS(url, "https://pakfire.ipfire.org/"); + + // Everything passed + r = EXIT_SUCCESS; + +FAIL: + if (daemon) + pakfire_daemon_unref(daemon); + + return r; +} + +int main(int argc, const char* argv[]) { + testsuite_add_test(test_daemon, 0); + + return testsuite_run(argc, argv); +} diff --git a/tests/pakfire.conf b/tests/pakfire.conf index b97f35fc..a2cf6599 100644 --- a/tests/pakfire.conf +++ b/tests/pakfire.conf @@ -18,3 +18,7 @@ memory_limit = 1G # PID limit for the build environment pid_limit = 512 + +[daemon] +# Build Daemon Configuration +url = https://pakfire.ipfire.org/