]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-cgroup-util: Ignore LXC group 36024/head
authorMichal Koutný <mkoutny@suse.com>
Mon, 3 Feb 2025 16:02:09 +0000 (17:02 +0100)
committerMichal Koutný <mkoutny@suse.com>
Wed, 12 Mar 2025 10:46:19 +0000 (11:46 +0100)
LXC helper processes hide themselve in .lxc cgroup, we don't have to
deal with the inside tests (and the error in conversion to unit is handled).
Skip those but keep iterating over remaining processes to detect what
can be created around us.

src/test/test-cgroup-util.c

index 8743bd1cc744bab5aaeb868f19924f4c7e220352..cdf2ea83d7e3cb5f156f487e5e26aa3c214d107b 100644 (file)
@@ -198,6 +198,13 @@ TEST(get_paths, .sd_booted = true) {
         log_info("Root = %s", a);
 }
 
+static inline bool hidden_cgroup(const char *p) {
+        assert(p);
+
+        /* Consider top-level cgroup hidden from us */
+        return p[0] == '/' && p[strspn(p, "/")] == '.';
+}
+
 TEST(proc, .sd_booted = true) {
         _cleanup_closedir_ DIR *d = NULL;
         int r;
@@ -219,6 +226,10 @@ TEST(proc, .sd_booted = true) {
                         continue;
 
                 ASSERT_OK_ZERO(cg_pidref_get_path(SYSTEMD_CGROUP_CONTROLLER, &pid, &path));
+                /* Test may run in a container with supervising/monitor processes that don't belong to our
+                 * cgroup tree (slices/leaves) */
+                if (hidden_cgroup(path))
+                        continue;
                 ASSERT_OK_ZERO(cg_pid_get_path_shifted(pid.pid, NULL, &path_shifted));
                 ASSERT_OK_ZERO(cg_pidref_get_unit(&pid, &unit));
                 ASSERT_OK_ZERO(cg_pid_get_slice(pid.pid, &slice));