]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-cgroup: skip if /sys/fs/cgroup unknown fs
authorDan Streetman <ddstreet@canonical.com>
Sat, 21 Mar 2020 14:59:42 +0000 (10:59 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 25 Apr 2020 08:00:43 +0000 (10:00 +0200)
It's not always mounted, e.g. during the build-time tests, it's running inside
a chroot (that's how Debian/Ubuntu build packages, in chroots) so this test
always fails because /sys/fs/cgroup isn't mounted.

src/test/test-cgroup.c

index 853c6c4ab4de37fc2eb830aae75321e1beb7d0d1..4fbb186f52cfe622d1fe8af724d167fcf5c58f7c 100644 (file)
@@ -44,6 +44,13 @@ static void test_cg_split_spec(void) {
 
 static void test_cg_create(void) {
         log_info("/* %s */", __func__);
+        int r;
+
+        r = cg_unified_cached(false);
+        if (r < 0) {
+                log_info_errno(r, "Skipping %s: %m", __func__);
+                return;
+        }
 
         _cleanup_free_ char *here = NULL;
         assert_se(cg_pid_get_path_shifted(0, NULL, &here) >= 0);
@@ -53,7 +60,6 @@ static void test_cg_create(void) {
                    *test_c = prefix_roota(here, "/test-b/test-c"),
                    *test_d = prefix_roota(here, "/test-b/test-d");
         char *path;
-        int r;
 
         log_info("Paths for test:\n%s\n%s", test_a, test_b);