From: Michael Tremer Date: Tue, 13 Dec 2022 11:02:35 +0000 (+0000) Subject: tests: jail: Check for correct exit code on SEGV X-Git-Tag: 0.9.29~420 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=870f7edbe3e3b07a865f7aa320367c943ae41f0a;p=pakfire.git tests: jail: Check for correct exit code on SEGV Signed-off-by: Michael Tremer --- diff --git a/tests/libpakfire/jail.c b/tests/libpakfire/jail.c index cccaa3d8e..784e89ef1 100644 --- a/tests/libpakfire/jail.c +++ b/tests/libpakfire/jail.c @@ -80,6 +80,30 @@ FAIL: return r; } +static int test_segv(const struct test* t) { + struct pakfire_jail* jail = NULL; + int r = EXIT_FAILURE; + + const char* argv[] = { + "/command", "segv", 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) == 139); + + // 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; @@ -362,6 +386,7 @@ FAIL: int main(int argc, const char* argv[]) { testsuite_add_test(test_create); testsuite_add_test(test_exit_code); + testsuite_add_test(test_segv); testsuite_add_test(test_env); testsuite_add_test(test_exec); testsuite_add_test(test_launch_into_cgroup);