]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
tests: Add simple create/free test for builds
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 Aug 2022 15:24:27 +0000 (15:24 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 Aug 2022 15:24:27 +0000 (15:24 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
.gitignore
Makefile.am
tests/libpakfire/build.c [new file with mode: 0644]

index 7dfc5787e3e28f05f105b742476d7d3bce85c198..0945ff6adcf3bd8b8fd66ca45779fa07fd958e16 100644 (file)
@@ -15,6 +15,7 @@
 /tests/.root
 /tests/libpakfire/arch
 /tests/libpakfire/archive
+/tests/libpakfire/build
 /tests/libpakfire/cgroup
 /tests/libpakfire/compress
 /tests/libpakfire/config
index e3468150e893cfe68febcda4c96c46500802996b..bd953cbc21d39b61a44e145b388b4a81c81185fa 100644 (file)
@@ -368,6 +368,7 @@ check_PROGRAMS += \
        tests/libpakfire/main \
        tests/libpakfire/arch \
        tests/libpakfire/archive \
+       tests/libpakfire/build \
        tests/libpakfire/cgroup \
        tests/libpakfire/compress \
        tests/libpakfire/config \
@@ -421,6 +422,18 @@ tests_libpakfire_archive_CFLAGS = \
 tests_libpakfire_archive_LDADD = \
        $(TESTSUITE_LDADD)
 
+dist_tests_libpakfire_build_SOURCES = \
+       tests/libpakfire/build.c
+
+tests_libpakfire_build_CPPFLAGS = \
+       $(TESTSUITE_CPPFLAGS)
+
+tests_libpakfire_build_CFLAGS = \
+       $(TESTSUITE_CFLAGS)
+
+tests_libpakfire_build_LDADD = \
+       $(TESTSUITE_LDADD)
+
 dist_tests_libpakfire_cgroup_SOURCES = \
        tests/libpakfire/cgroup.c
 
diff --git a/tests/libpakfire/build.c b/tests/libpakfire/build.c
new file mode 100644 (file)
index 0000000..a1a4450
--- /dev/null
@@ -0,0 +1,49 @@
+/*#############################################################################
+#                                                                             #
+# Pakfire - The IPFire package management system                              #
+# Copyright (C) 2022 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 <unistd.h>
+
+#include <pakfire/build.h>
+
+#include "../testsuite.h"
+
+static int test_create_and_free(const struct test* t) {
+       struct pakfire_build* build = NULL;
+
+       // Create a new build
+       ASSERT_SUCCESS(pakfire_build_create(&build, t->pakfire, NULL, 0));
+
+       // Check if build actually got allocated
+       ASSERT(build);
+
+       // Free the build
+       ASSERT(pakfire_build_unref(build) == NULL);
+
+       return EXIT_SUCCESS;
+
+FAIL:
+       return EXIT_FAILURE;
+}
+
+int main(int argc, char** argv) {
+       testsuite_add_test(test_create_and_free);
+
+       return testsuite_run();
+}