@@ -62,11 +62,19 @@ public class CgroupSubsystemFactory {
6262 private Path cgroupv1MntInfoZeroHierarchy ;
6363 private Path cgroupv2CgInfoZeroHierarchy ;
6464 private Path cgroupv2MntInfoZeroHierarchy ;
65+ private Path cgroupv2MntInfoDouble ;
66+ private Path cgroupv2MntInfoDouble2 ;
6567 private Path cgroupv1CgInfoNonZeroHierarchy ;
6668 private Path cgroupv1MntInfoNonZeroHierarchyOtherOrder ;
6769 private Path cgroupv1MntInfoNonZeroHierarchy ;
6870 private Path cgroupv1MntInfoDoubleCpuset ;
6971 private Path cgroupv1MntInfoDoubleCpuset2 ;
72+ private Path cgroupv1MntInfoDoubleMemory ;
73+ private Path cgroupv1MntInfoDoubleMemory2 ;
74+ private Path cgroupv1MntInfoDoubleCpu ;
75+ private Path cgroupv1MntInfoDoubleCpu2 ;
76+ private Path cgroupv1MntInfoDoublePids ;
77+ private Path cgroupv1MntInfoDoublePids2 ;
7078 private Path cgroupv1MntInfoSystemdOnly ;
7179 private String mntInfoEmpty = "" ;
7280 private Path cgroupV1SelfCgroup ;
@@ -160,6 +168,15 @@ public class CgroupSubsystemFactory {
160168 private String mntInfoCgroupv1MoreCpusetLine = "121 32 0:37 / /cpusets rw,relatime shared:69 - cgroup none rw,cpuset\n " ;
161169 private String mntInfoCgroupv1DoubleCpuset = mntInfoCgroupv1MoreCpusetLine + mntInfoHybrid ;
162170 private String mntInfoCgroupv1DoubleCpuset2 = mntInfoHybrid + mntInfoCgroupv1MoreCpusetLine ;
171+ private String mntInfoCgroupv1MoreMemoryLine = "1100 1098 0:28 / /memory rw,nosuid,nodev,noexec,relatime master:6 - cgroup cgroup rw,memory\n " ;
172+ private String mntInfoCgroupv1DoubleMemory = mntInfoCgroupv1MoreMemoryLine + mntInfoHybrid ;
173+ private String mntInfoCgroupv1DoubleMemory2 = mntInfoHybrid + mntInfoCgroupv1MoreMemoryLine ;
174+ private String mntInfoCgroupv1DoubleCpuLine = "1101 1098 0:29 / /cpu,cpuacct rw,nosuid,nodev,noexec,relatime master:7 - cgroup cgroup rw,cpu,cpuacct\n " ;
175+ private String mntInfoCgroupv1DoubleCpu = mntInfoCgroupv1DoubleCpuLine + mntInfoHybrid ;
176+ private String mntInfoCgroupv1DoubleCpu2 = mntInfoHybrid + mntInfoCgroupv1DoubleCpuLine ;
177+ private String mntInfoCgroupv1DoublePidsLine = "1107 1098 0:35 / /pids rw,nosuid,nodev,noexec,relatime master:13 - cgroup cgroup rw,pids\n " ;
178+ private String mntInfoCgroupv1DoublePids = mntInfoCgroupv1DoublePidsLine + mntInfoHybrid ;
179+ private String mntInfoCgroupv1DoublePids2 = mntInfoHybrid + mntInfoCgroupv1DoublePidsLine ;
163180 private String cgroupsNonZeroHierarchy =
164181 "#subsys_name hierarchy num_cgroups enabled\n " +
165182 "cpuset 3 1 1\n " +
@@ -175,7 +192,11 @@ public class CgroupSubsystemFactory {
175192 "hugetlb 6 1 1\n " +
176193 "pids 9 80 1" ; // hierarchy has to match procSelfCgroupHybridContent
177194 private String mntInfoCgroupsV2Only =
178- "28 21 0:25 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime shared:4 - cgroup2 none rw,seclabel,nsdelegate" ;
195+ "28 21 0:25 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime shared:4 - cgroup2 none rw,seclabel,nsdelegate\n " ;
196+ private String mntInfoCgroupsV2MoreLine =
197+ "240 232 0:24 /../.. /cgroup-in ro,relatime - cgroup2 cgroup2 rw,nsdelegate\n " ;
198+ private String mntInfoCgroupsV2Double = mntInfoCgroupsV2MoreLine + mntInfoCgroupsV2Only ;
199+ private String mntInfoCgroupsV2Double2 = mntInfoCgroupsV2Only + mntInfoCgroupsV2MoreLine ;
179200 private String mntInfoCgroupsV1SystemdOnly =
180201 "35 26 0:26 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup systemd rw,name=systemd\n " +
181202 "26 18 0:19 / /sys/fs/cgroup rw,relatime - tmpfs none rw,size=4k,mode=755\n " ;
@@ -217,6 +238,12 @@ private void setup() {
217238 cgroupv2MntInfoZeroHierarchy = Paths .get (existingDirectory .toString (), "mountinfo_cgroupv2" );
218239 Files .writeString (cgroupv2MntInfoZeroHierarchy , mntInfoCgroupsV2Only );
219240
241+ cgroupv2MntInfoDouble = Paths .get (existingDirectory .toString (), "mountinfo_cgroupv2_double" );
242+ Files .writeString (cgroupv2MntInfoDouble , mntInfoCgroupsV2Double );
243+
244+ cgroupv2MntInfoDouble2 = Paths .get (existingDirectory .toString (), "mountinfo_cgroupv2_double2" );
245+ Files .writeString (cgroupv2MntInfoDouble2 , mntInfoCgroupsV2Double2 );
246+
220247 cgroupv1CgInfoNonZeroHierarchy = Paths .get (existingDirectory .toString (), "cgroups_non_zero" );
221248 Files .writeString (cgroupv1CgInfoNonZeroHierarchy , cgroupsNonZeroHierarchy );
222249
@@ -244,6 +271,24 @@ private void setup() {
244271 cgroupv1MntInfoDoubleCpuset2 = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_cpuset2" );
245272 Files .writeString (cgroupv1MntInfoDoubleCpuset2 , mntInfoCgroupv1DoubleCpuset2 );
246273
274+ cgroupv1MntInfoDoubleMemory = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_memory" );
275+ Files .writeString (cgroupv1MntInfoDoubleMemory , mntInfoCgroupv1DoubleMemory );
276+
277+ cgroupv1MntInfoDoubleMemory2 = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_memory2" );
278+ Files .writeString (cgroupv1MntInfoDoubleMemory2 , mntInfoCgroupv1DoubleMemory2 );
279+
280+ cgroupv1MntInfoDoubleCpu = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_cpu" );
281+ Files .writeString (cgroupv1MntInfoDoubleCpu , mntInfoCgroupv1DoubleCpu );
282+
283+ cgroupv1MntInfoDoubleCpu2 = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_cpu2" );
284+ Files .writeString (cgroupv1MntInfoDoubleCpu2 , mntInfoCgroupv1DoubleCpu2 );
285+
286+ cgroupv1MntInfoDoublePids = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_pids" );
287+ Files .writeString (cgroupv1MntInfoDoublePids , mntInfoCgroupv1DoublePids );
288+
289+ cgroupv1MntInfoDoublePids2 = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_pids2" );
290+ Files .writeString (cgroupv1MntInfoDoublePids2 , mntInfoCgroupv1DoublePids2 );
291+
247292 cgroupv1MntInfoSystemdOnly = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_systemd_only" );
248293 Files .writeString (cgroupv1MntInfoSystemdOnly , mntInfoCgroupsV1SystemdOnly );
249294
@@ -291,14 +336,14 @@ public void testCgroupv1JoinControllerCombo(WhiteBox wb) {
291336 System .out .println ("testCgroupv1JoinControllerMounts PASSED!" );
292337 }
293338
294- public void testCgroupv1MultipleCpusetMounts (WhiteBox wb , Path mountInfo ) {
339+ public void testCgroupv1MultipleControllerMounts (WhiteBox wb , Path mountInfo ) {
295340 String procCgroups = cgroupv1CgInfoNonZeroHierarchy .toString ();
296341 String procSelfCgroup = cgroupV1SelfCgroup .toString ();
297342 String procSelfMountinfo = mountInfo .toString ();
298343 int retval = wb .validateCgroup (procCgroups , procSelfCgroup , procSelfMountinfo );
299- Asserts .assertEQ (CGROUPS_V1 , retval , "Multiple cpuset controllers, but only one in /sys/fs/cgroup" );
344+ Asserts .assertEQ (CGROUPS_V1 , retval , "Multiple controllers, but only one in /sys/fs/cgroup" );
300345 Asserts .assertTrue (isValidCgroup (retval ));
301- System .out .println ("testCgroupv1MultipleCpusetMounts PASSED!" );
346+ System .out .println ("testCgroupv1MultipleControllerMounts PASSED!" );
302347 }
303348
304349 public void testCgroupv1SystemdOnly (WhiteBox wb ) {
@@ -341,10 +386,10 @@ public void testCgroupv1MissingMemoryController(WhiteBox wb) {
341386 System .out .println ("testCgroupv1MissingMemoryController PASSED!" );
342387 }
343388
344- public void testCgroupv2 (WhiteBox wb ) {
389+ public void testCgroupv2 (WhiteBox wb , Path mountInfo ) {
345390 String procCgroups = cgroupv2CgInfoZeroHierarchy .toString ();
346391 String procSelfCgroup = cgroupV2SelfCgroup .toString ();
347- String procSelfMountinfo = cgroupv2MntInfoZeroHierarchy .toString ();
392+ String procSelfMountinfo = mountInfo .toString ();
348393 int retval = wb .validateCgroup (procCgroups , procSelfCgroup , procSelfMountinfo );
349394 Asserts .assertEQ (CGROUPS_V2 , retval , "Expected" );
350395 Asserts .assertTrue (isValidCgroup (retval ));
@@ -388,13 +433,21 @@ public static void main(String[] args) throws Exception {
388433 try {
389434 test .testCgroupv1SystemdOnly (wb );
390435 test .testCgroupv1NoMounts (wb );
391- test .testCgroupv2 (wb );
436+ test .testCgroupv2 (wb , test .cgroupv2MntInfoZeroHierarchy );
437+ test .testCgroupv2 (wb , test .cgroupv2MntInfoDouble );
438+ test .testCgroupv2 (wb , test .cgroupv2MntInfoDouble2 );
392439 test .testCgroupV1Hybrid (wb );
393440 test .testCgroupV1HybridMntInfoOrder (wb );
394441 test .testCgroupv1MissingMemoryController (wb );
395442 test .testCgroupv2NoCgroup2Fs (wb );
396- test .testCgroupv1MultipleCpusetMounts (wb , test .cgroupv1MntInfoDoubleCpuset );
397- test .testCgroupv1MultipleCpusetMounts (wb , test .cgroupv1MntInfoDoubleCpuset2 );
443+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleCpuset );
444+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleCpuset2 );
445+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleMemory );
446+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleMemory2 );
447+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleCpu );
448+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleCpu2 );
449+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoublePids );
450+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoublePids2 );
398451 test .testCgroupv1JoinControllerCombo (wb );
399452 test .testNonZeroHierarchyOnlyFreezer (wb );
400453 } finally {
0 commit comments