@@ -63,11 +63,19 @@ public class CgroupSubsystemFactory {
6363 private Path cgroupv1MntInfoZeroHierarchy ;
6464 private Path cgroupv2CgInfoZeroHierarchy ;
6565 private Path cgroupv2MntInfoZeroHierarchy ;
66+ private Path cgroupv2MntInfoDouble ;
67+ private Path cgroupv2MntInfoDouble2 ;
6668 private Path cgroupv1CgInfoNonZeroHierarchy ;
6769 private Path cgroupv1MntInfoNonZeroHierarchyOtherOrder ;
6870 private Path cgroupv1MntInfoNonZeroHierarchy ;
6971 private Path cgroupv1MntInfoDoubleCpuset ;
7072 private Path cgroupv1MntInfoDoubleCpuset2 ;
73+ private Path cgroupv1MntInfoDoubleMemory ;
74+ private Path cgroupv1MntInfoDoubleMemory2 ;
75+ private Path cgroupv1MntInfoDoubleCpu ;
76+ private Path cgroupv1MntInfoDoubleCpu2 ;
77+ private Path cgroupv1MntInfoDoublePids ;
78+ private Path cgroupv1MntInfoDoublePids2 ;
7179 private Path cgroupv1MntInfoSystemdOnly ;
7280 private String mntInfoEmpty = "" ;
7381 private Path cgroupV1SelfCgroup ;
@@ -161,6 +169,15 @@ public class CgroupSubsystemFactory {
161169 private String mntInfoCgroupv1MoreCpusetLine = "121 32 0:37 / /cpusets rw,relatime shared:69 - cgroup none rw,cpuset\n " ;
162170 private String mntInfoCgroupv1DoubleCpuset = mntInfoCgroupv1MoreCpusetLine + mntInfoHybrid ;
163171 private String mntInfoCgroupv1DoubleCpuset2 = mntInfoHybrid + mntInfoCgroupv1MoreCpusetLine ;
172+ private String mntInfoCgroupv1MoreMemoryLine = "1100 1098 0:28 / /memory rw,nosuid,nodev,noexec,relatime master:6 - cgroup cgroup rw,memory\n " ;
173+ private String mntInfoCgroupv1DoubleMemory = mntInfoCgroupv1MoreMemoryLine + mntInfoHybrid ;
174+ private String mntInfoCgroupv1DoubleMemory2 = mntInfoHybrid + mntInfoCgroupv1MoreMemoryLine ;
175+ private String mntInfoCgroupv1DoubleCpuLine = "1101 1098 0:29 / /cpu,cpuacct rw,nosuid,nodev,noexec,relatime master:7 - cgroup cgroup rw,cpu,cpuacct\n " ;
176+ private String mntInfoCgroupv1DoubleCpu = mntInfoCgroupv1DoubleCpuLine + mntInfoHybrid ;
177+ private String mntInfoCgroupv1DoubleCpu2 = mntInfoHybrid + mntInfoCgroupv1DoubleCpuLine ;
178+ private String mntInfoCgroupv1DoublePidsLine = "1107 1098 0:35 / /pids rw,nosuid,nodev,noexec,relatime master:13 - cgroup cgroup rw,pids\n " ;
179+ private String mntInfoCgroupv1DoublePids = mntInfoCgroupv1DoublePidsLine + mntInfoHybrid ;
180+ private String mntInfoCgroupv1DoublePids2 = mntInfoHybrid + mntInfoCgroupv1DoublePidsLine ;
164181 private String cgroupsNonZeroHierarchy =
165182 "#subsys_name hierarchy num_cgroups enabled\n " +
166183 "cpuset 3 1 1\n " +
@@ -176,7 +193,11 @@ public class CgroupSubsystemFactory {
176193 "hugetlb 6 1 1\n " +
177194 "pids 9 80 1" ; // hierarchy has to match procSelfCgroupHybridContent
178195 private String mntInfoCgroupsV2Only =
179- "28 21 0:25 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime shared:4 - cgroup2 none rw,seclabel,nsdelegate" ;
196+ "28 21 0:25 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime shared:4 - cgroup2 none rw,seclabel,nsdelegate\n " ;
197+ private String mntInfoCgroupsV2MoreLine =
198+ "240 232 0:24 /../.. /cgroup-in ro,relatime - cgroup2 cgroup2 rw,nsdelegate\n " ;
199+ private String mntInfoCgroupsV2Double = mntInfoCgroupsV2MoreLine + mntInfoCgroupsV2Only ;
200+ private String mntInfoCgroupsV2Double2 = mntInfoCgroupsV2Only + mntInfoCgroupsV2MoreLine ;
180201 private String mntInfoCgroupsV1SystemdOnly =
181202 "35 26 0:26 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup systemd rw,name=systemd\n " +
182203 "26 18 0:19 / /sys/fs/cgroup rw,relatime - tmpfs none rw,size=4k,mode=755\n " ;
@@ -218,6 +239,12 @@ private void setup() {
218239 cgroupv2MntInfoZeroHierarchy = Paths .get (existingDirectory .toString (), "mountinfo_cgroupv2" );
219240 Files .writeString (cgroupv2MntInfoZeroHierarchy , mntInfoCgroupsV2Only );
220241
242+ cgroupv2MntInfoDouble = Paths .get (existingDirectory .toString (), "mountinfo_cgroupv2_double" );
243+ Files .writeString (cgroupv2MntInfoDouble , mntInfoCgroupsV2Double );
244+
245+ cgroupv2MntInfoDouble2 = Paths .get (existingDirectory .toString (), "mountinfo_cgroupv2_double2" );
246+ Files .writeString (cgroupv2MntInfoDouble2 , mntInfoCgroupsV2Double2 );
247+
221248 cgroupv1CgInfoNonZeroHierarchy = Paths .get (existingDirectory .toString (), "cgroups_non_zero" );
222249 Files .writeString (cgroupv1CgInfoNonZeroHierarchy , cgroupsNonZeroHierarchy );
223250
@@ -245,6 +272,24 @@ private void setup() {
245272 cgroupv1MntInfoDoubleCpuset2 = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_cpuset2" );
246273 Files .writeString (cgroupv1MntInfoDoubleCpuset2 , mntInfoCgroupv1DoubleCpuset2 );
247274
275+ cgroupv1MntInfoDoubleMemory = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_memory" );
276+ Files .writeString (cgroupv1MntInfoDoubleMemory , mntInfoCgroupv1DoubleMemory );
277+
278+ cgroupv1MntInfoDoubleMemory2 = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_memory2" );
279+ Files .writeString (cgroupv1MntInfoDoubleMemory2 , mntInfoCgroupv1DoubleMemory2 );
280+
281+ cgroupv1MntInfoDoubleCpu = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_cpu" );
282+ Files .writeString (cgroupv1MntInfoDoubleCpu , mntInfoCgroupv1DoubleCpu );
283+
284+ cgroupv1MntInfoDoubleCpu2 = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_cpu2" );
285+ Files .writeString (cgroupv1MntInfoDoubleCpu2 , mntInfoCgroupv1DoubleCpu2 );
286+
287+ cgroupv1MntInfoDoublePids = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_pids" );
288+ Files .writeString (cgroupv1MntInfoDoublePids , mntInfoCgroupv1DoublePids );
289+
290+ cgroupv1MntInfoDoublePids2 = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_pids2" );
291+ Files .writeString (cgroupv1MntInfoDoublePids2 , mntInfoCgroupv1DoublePids2 );
292+
248293 cgroupv1MntInfoSystemdOnly = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_systemd_only" );
249294 Files .writeString (cgroupv1MntInfoSystemdOnly , mntInfoCgroupsV1SystemdOnly );
250295
@@ -292,14 +337,14 @@ public void testCgroupv1JoinControllerCombo(WhiteBox wb) {
292337 System .out .println ("testCgroupv1JoinControllerMounts PASSED!" );
293338 }
294339
295- public void testCgroupv1MultipleCpusetMounts (WhiteBox wb , Path mountInfo ) {
340+ public void testCgroupv1MultipleControllerMounts (WhiteBox wb , Path mountInfo ) {
296341 String procCgroups = cgroupv1CgInfoNonZeroHierarchy .toString ();
297342 String procSelfCgroup = cgroupV1SelfCgroup .toString ();
298343 String procSelfMountinfo = mountInfo .toString ();
299344 int retval = wb .validateCgroup (procCgroups , procSelfCgroup , procSelfMountinfo );
300- Asserts .assertEQ (CGROUPS_V1 , retval , "Multiple cpuset controllers, but only one in /sys/fs/cgroup" );
345+ Asserts .assertEQ (CGROUPS_V1 , retval , "Multiple controllers, but only one in /sys/fs/cgroup" );
301346 Asserts .assertTrue (isValidCgroup (retval ));
302- System .out .println ("testCgroupv1MultipleCpusetMounts PASSED!" );
347+ System .out .println ("testCgroupv1MultipleControllerMounts PASSED!" );
303348 }
304349
305350 public void testCgroupv1SystemdOnly (WhiteBox wb ) {
@@ -342,10 +387,10 @@ public void testCgroupv1MissingMemoryController(WhiteBox wb) {
342387 System .out .println ("testCgroupv1MissingMemoryController PASSED!" );
343388 }
344389
345- public void testCgroupv2 (WhiteBox wb ) {
390+ public void testCgroupv2 (WhiteBox wb , Path mountInfo ) {
346391 String procCgroups = cgroupv2CgInfoZeroHierarchy .toString ();
347392 String procSelfCgroup = cgroupV2SelfCgroup .toString ();
348- String procSelfMountinfo = cgroupv2MntInfoZeroHierarchy .toString ();
393+ String procSelfMountinfo = mountInfo .toString ();
349394 int retval = wb .validateCgroup (procCgroups , procSelfCgroup , procSelfMountinfo );
350395 Asserts .assertEQ (CGROUPS_V2 , retval , "Expected" );
351396 Asserts .assertTrue (isValidCgroup (retval ));
@@ -389,13 +434,21 @@ public static void main(String[] args) throws Exception {
389434 try {
390435 test .testCgroupv1SystemdOnly (wb );
391436 test .testCgroupv1NoMounts (wb );
392- test .testCgroupv2 (wb );
437+ test .testCgroupv2 (wb , test .cgroupv2MntInfoZeroHierarchy );
438+ test .testCgroupv2 (wb , test .cgroupv2MntInfoDouble );
439+ test .testCgroupv2 (wb , test .cgroupv2MntInfoDouble2 );
393440 test .testCgroupV1Hybrid (wb );
394441 test .testCgroupV1HybridMntInfoOrder (wb );
395442 test .testCgroupv1MissingMemoryController (wb );
396443 test .testCgroupv2NoCgroup2Fs (wb );
397- test .testCgroupv1MultipleCpusetMounts (wb , test .cgroupv1MntInfoDoubleCpuset );
398- test .testCgroupv1MultipleCpusetMounts (wb , test .cgroupv1MntInfoDoubleCpuset2 );
444+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleCpuset );
445+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleCpuset2 );
446+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleMemory );
447+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleMemory2 );
448+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleCpu );
449+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleCpu2 );
450+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoublePids );
451+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoublePids2 );
399452 test .testCgroupv1JoinControllerCombo (wb );
400453 test .testNonZeroHierarchyOnlyFreezer (wb );
401454 } finally {
0 commit comments