From: Michael Tremer Date: Tue, 13 Dec 2022 10:53:45 +0000 (+0000) Subject: tests: jail: Check for correct exit code X-Git-Tag: 0.9.29~423 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39a10052d1747fbf4c6f7df079d475af04180e7a;p=pakfire.git tests: jail: Check for correct exit code Signed-off-by: Michael Tremer --- diff --git a/tests/libpakfire/jail.c b/tests/libpakfire/jail.c index 8de3dce26..cccaa3d8e 100644 --- a/tests/libpakfire/jail.c +++ b/tests/libpakfire/jail.c @@ -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);