return pakfire_cgroup_write(cgroup, "cgroup.kill", "1");
}
+int pakfire_cgroup_child(struct pakfire_cgroup** child,
+ struct pakfire_cgroup* cgroup, const char* path, int flags) {
+ return pakfire_cgroup_open(child, cgroup->ctx, cgroup, path, flags);
+}
+
/*
Immediately destroys this cgroup
*/
return r;
}
+static int test_child(const struct test* t) {
+ struct pakfire_cgroup* cgroup = NULL;
+ struct pakfire_cgroup* child = NULL;
+ int r = EXIT_FAILURE;
+
+ // Open a new cgroup
+ ASSERT_SUCCESS(pakfire_cgroup_create(&cgroup, t->ctx, NULL, "pakfire-test", 0));
+
+ // Create a child
+ ASSERT_SUCCESS(pakfire_cgroup_child(&child, cgroup, "child-group", 0));
+
+ // Destroy the cgroups again
+ ASSERT_SUCCESS(pakfire_cgroup_destroy(child));
+ ASSERT_SUCCESS(pakfire_cgroup_destroy(cgroup));
+
+ // Success
+ r = EXIT_SUCCESS;
+
+FAIL:
+ if (child)
+ pakfire_cgroup_unref(child);
+ if (cgroup)
+ pakfire_cgroup_unref(cgroup);
+
+ return r;
+}
+
static int test_stats(const struct test* t) {
struct pakfire_cgroup* cgroup = NULL;
struct pakfire_jail* jail = NULL;
int main(int argc, const char* argv[]) {
testsuite_add_test(test_create_and_destroy, 0);
+ testsuite_add_test(test_child, 0);
testsuite_add_test(test_stats, TEST_WANTS_PAKFIRE);
return testsuite_run(argc, argv);