]> git.ipfire.org Git - pakfire.git/commitdiff
tests: Add a simple test to create a daemon
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Feb 2025 20:59:23 +0000 (20:59 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Feb 2025 20:59:23 +0000 (20:59 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
.gitignore
Makefile.am
tests/libpakfire/daemon.c [new file with mode: 0644]
tests/pakfire.conf

index 5cc5981aec6d69ff1d6ee3ee5d3f0606a8708d69..8dd481914c55ad5d08f2083dd20ffa95241c2ad8 100644 (file)
@@ -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
index bde758569f03053ba19cc042a088af2471097b93..f099809ccea8439695dd0af698b6887a0977cd60 100644 (file)
@@ -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 (file)
index 0000000..6b03182
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#include <pakfire/daemon.h>
+
+#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);
+}
index b97f35fcb57216d8ebe2fe52c28ba97994126026..a2cf659916c2458be81e30d1a1a8bd931bb8c56e 100644 (file)
@@ -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/