"/command", "echo", "Hello World!", NULL,
};
+static const char* cmd_exhaust_memory[] = {
+ "/command", "exhaust-memory", NULL,
+};
+
+static const char* cmd_fork_bomb[] = {
+ "/command", "fork-bomb", NULL,
+};
+
static int test_create(const struct test* t) {
struct pakfire_jail* jail = NULL;
struct pakfire_jail* jail = NULL;
int r = EXIT_FAILURE;
- const char* argv[] = {
- "/command", "exhaust-memory", NULL,
- };
// Create cgroup
ASSERT_SUCCESS(pakfire_cgroup_open(&cgroup, t->pakfire, "pakfire-test", 0));
ASSERT_SUCCESS(pakfire_cgroup_set_memory_limit(cgroup, 100 * 1024 * 1024));
// Try to exhaust all memory
- ASSERT_FAILURE(pakfire_jail_exec(jail, argv, NULL));
+ ASSERT_FAILURE(pakfire_jail_exec(jail, cmd_exhaust_memory, NULL));
+
+ // A fork bomb should also exhaust all memory
+ ASSERT_FAILURE(pakfire_jail_exec(jail, cmd_fork_bomb, NULL));
// Success
r = EXIT_SUCCESS;
struct pakfire_jail* jail = NULL;
int r = EXIT_FAILURE;
- const char* argv[] = {
- "/command", "fork-bomb", NULL,
- };
// Create cgroup
ASSERT_SUCCESS(pakfire_cgroup_open(&cgroup, t->pakfire, "pakfire-test", 0));
ASSERT_SUCCESS(pakfire_cgroup_set_pid_limit(cgroup, 100));
// Try to fork as many processes as possible
- ASSERT_FAILURE(pakfire_jail_exec(jail, argv, NULL));
+ ASSERT_FAILURE(pakfire_jail_exec(jail, cmd_fork_bomb, NULL));
// Success
r = EXIT_SUCCESS;