]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
tests: jail: Check for correct exit code
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 13 Dec 2022 10:53:45 +0000 (10:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 13 Dec 2022 10:53:45 +0000 (10:53 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/libpakfire/jail.c

index 8de3dce26df0bf4679218d5d5f4c7f8b03ab0f01..cccaa3d8e024a6460cc89b9077c536e7466cd781 100644 (file)
@@ -56,6 +56,30 @@ FAIL:
        return EXIT_FAILURE;
 }
 
+static int test_exit_code(const struct test* t) {
+       struct pakfire_jail* jail = NULL;
+       int r = EXIT_FAILURE;
+
+       const char* argv[] = {
+               "/command", "exit-with-code", "123", NULL,
+       };
+
+       // Create a new jail
+       ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire, 0));
+
+       // Check if we receive the correct exit code
+       ASSERT(pakfire_jail_exec(jail, argv, NULL, NULL, NULL) == 123);
+
+       // Success
+       r = EXIT_SUCCESS;
+
+FAIL:
+       if (jail)
+               pakfire_jail_unref(jail);
+
+       return r;
+}
+
 static int test_env(const struct test* t) {
        struct pakfire_jail* jail = NULL;
 
@@ -337,6 +361,7 @@ FAIL:
 
 int main(int argc, const char* argv[]) {
        testsuite_add_test(test_create);
+       testsuite_add_test(test_exit_code);
        testsuite_add_test(test_env);
        testsuite_add_test(test_exec);
        testsuite_add_test(test_launch_into_cgroup);