]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-cgroup: cleanup test cgroup
authorLuca Boccassi <luca.boccassi@gmail.com>
Tue, 12 Aug 2025 22:59:15 +0000 (23:59 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 13 Aug 2025 01:00:33 +0000 (10:00 +0900)
One test cgroup gets left behind by the test, as it moves itself
into it. Move itself and back to the original cgroup at the end
and clean up.

This fixes a failure when running the test first as root, and then
as unprivileged (initial cleanup fails as the leftover test cgroup
is owned by root).

src/test/test-cgroup.c

index e67887a004d604c31bc73aae467fb298792d337e..a14043442f7cfb3f1bf8cb609f89feaa1d1ba92e 100644 (file)
@@ -61,7 +61,7 @@ TEST(cg_create) {
 
         log_info("Paths for test:\n%s\n%s", test_a, test_b);
 
-        /* Possibly clean up left-overs from aboted previous runs */
+        /* Possibly clean up left-overs from aborted previous runs */
         (void) cg_trim(test_a, /* delete_root= */ true);
         (void) cg_trim(test_b, /* delete_root= */ true);
 
@@ -113,6 +113,9 @@ TEST(cg_create) {
 
         ASSERT_OK(cg_trim(test_a, true));
         ASSERT_ERROR(cg_trim(test_b, true), EBUSY);
+
+        ASSERT_OK_ZERO(cg_attach(here, 0));
+        ASSERT_OK(cg_trim(test_b, true));
 }
 
 TEST(id) {