]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
tests: Add a simple test for jails
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 2 Aug 2022 08:13:22 +0000 (08:13 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 2 Aug 2022 08:13:22 +0000 (08:13 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
.gitignore
Makefile.am
tests/libpakfire/jail.c [new file with mode: 0644]

index 4ac99f2b4d810c336a44b1a495ace27ac70739ae..7dfc5787e3e28f05f105b742476d7d3bce85c198 100644 (file)
@@ -22,6 +22,7 @@
 /tests/libpakfire/dependencies
 /tests/libpakfire/downloader
 /tests/libpakfire/execute
+/tests/libpakfire/jail
 /tests/libpakfire/key
 /tests/libpakfire/main
 /tests/libpakfire/makefile
index 5b10ba5cec25bc028d2d7358702f11b99537e2a0..b76567f562587c534ba972e47614d9606c22506a 100644 (file)
@@ -377,6 +377,7 @@ check_PROGRAMS += \
        tests/libpakfire/dependencies \
        tests/libpakfire/downloader \
        tests/libpakfire/execute \
+       tests/libpakfire/jail \
        tests/libpakfire/key \
        tests/libpakfire/makefile \
        tests/libpakfire/packager \
@@ -506,6 +507,18 @@ tests_libpakfire_execute_CFLAGS = \
 
 tests_libpakfire_execute_LDADD = \
        $(TESTSUITE_LDADD)
+       
+dist_tests_libpakfire_jail_SOURCES = \
+       tests/libpakfire/jail.c
+
+tests_libpakfire_jail_CPPFLAGS = \
+       $(TESTSUITE_CPPFLAGS)
+
+tests_libpakfire_jail_CFLAGS = \
+       $(TESTSUITE_CFLAGS)
+
+tests_libpakfire_jail_LDADD = \
+       $(TESTSUITE_LDADD)
 
 tests_libpakfire_key_SOURCES = \
        tests/libpakfire/key.c \
diff --git a/tests/libpakfire/jail.c b/tests/libpakfire/jail.c
new file mode 100644 (file)
index 0000000..d75c5c8
--- /dev/null
@@ -0,0 +1,48 @@
+/*#############################################################################
+#                                                                             #
+# 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 <pakfire/jail.h>
+
+#include "../testsuite.h"
+
+static const char* cmd[2] = {
+       "/usr/bin/does-not-exist",
+};
+
+static int test_create(const struct test* t) {
+       struct pakfire_jail* jail = NULL;
+
+       // Create a new jail
+       ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+
+       // Destroy it
+       ASSERT_NULL(pakfire_jail_unref(jail));
+
+       return EXIT_SUCCESS;
+
+FAIL:
+       return EXIT_FAILURE;
+}
+
+int main(int argc, char** argv) {
+       testsuite_add_test(test_create);
+
+       return testsuite_run();
+}