From: Luca Boccassi Date: Wed, 6 Aug 2025 11:48:34 +0000 (+0100) Subject: test: fix assert when running test-cgroup in container X-Git-Tag: v258-rc3~74^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14cb1fba9130ccb6b8ed315211fe46e5e3f9cc88;p=thirdparty%2Fsystemd.git test: fix assert when running test-cgroup in container When running in nspawn and thus from the namespaced root cgroup: Paths for test: //test-a //test-b src/test/test-cgroup.c:77: Assertion failed: Expected "path == test_b", got "/test-b != //test-b" Use path_simplify() in the test like the code does, so that the results always match --- diff --git a/src/test/test-cgroup.c b/src/test/test-cgroup.c index d32b119d26c..e67887a004d 100644 --- a/src/test/test-cgroup.c +++ b/src/test/test-cgroup.c @@ -51,10 +51,12 @@ TEST(cg_create) { _cleanup_free_ char *here = NULL; ASSERT_OK(cg_pid_get_path_shifted(0, NULL, &here)); - _cleanup_free_ char *test_a = ASSERT_NOT_NULL(path_join(here, "/test-a")), - *test_b = ASSERT_NOT_NULL(path_join(here, "/test-b")), - *test_c = ASSERT_NOT_NULL(path_join(here, "/test-b/test-c")), - *test_d = ASSERT_NOT_NULL(path_join(here, "/test-b/test-d")); + /* cg_* will use path_simplify(), so use it here too otherwise when running in a container at the + * root it asserts with "/test-b != //test-b" */ + _cleanup_free_ char *test_a = ASSERT_NOT_NULL(path_simplify(path_join(here, "/test-a"))), + *test_b = ASSERT_NOT_NULL(path_simplify(path_join(here, "/test-b"))), + *test_c = ASSERT_NOT_NULL(path_simplify(path_join(here, "/test-b/test-c"))), + *test_d = ASSERT_NOT_NULL(path_simplify(path_join(here, "/test-b/test-d"))); char *path; log_info("Paths for test:\n%s\n%s", test_a, test_b);