@@ -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 ;
@@ -157,6 +165,15 @@ public class CgroupSubsystemFactory {
157165 private String mntInfoCgroupv1MoreCpusetLine = "121 32 0:37 / /cpusets rw,relatime shared:69 - cgroup none rw,cpuset\n " ;
158166 private String mntInfoCgroupv1DoubleCpuset = mntInfoCgroupv1MoreCpusetLine + mntInfoHybrid ;
159167 private String mntInfoCgroupv1DoubleCpuset2 = mntInfoHybrid + mntInfoCgroupv1MoreCpusetLine ;
168+ private String mntInfoCgroupv1MoreMemoryLine = "1100 1098 0:28 / /memory rw,nosuid,nodev,noexec,relatime master:6 - cgroup cgroup rw,memory\n " ;
169+ private String mntInfoCgroupv1DoubleMemory = mntInfoCgroupv1MoreMemoryLine + mntInfoHybrid ;
170+ private String mntInfoCgroupv1DoubleMemory2 = mntInfoHybrid + mntInfoCgroupv1MoreMemoryLine ;
171+ private String mntInfoCgroupv1DoubleCpuLine = "1101 1098 0:29 / /cpu,cpuacct rw,nosuid,nodev,noexec,relatime master:7 - cgroup cgroup rw,cpu,cpuacct\n " ;
172+ private String mntInfoCgroupv1DoubleCpu = mntInfoCgroupv1DoubleCpuLine + mntInfoHybrid ;
173+ private String mntInfoCgroupv1DoubleCpu2 = mntInfoHybrid + mntInfoCgroupv1DoubleCpuLine ;
174+ private String mntInfoCgroupv1DoublePidsLine = "1107 1098 0:35 / /pids rw,nosuid,nodev,noexec,relatime master:13 - cgroup cgroup rw,pids\n " ;
175+ private String mntInfoCgroupv1DoublePids = mntInfoCgroupv1DoublePidsLine + mntInfoHybrid ;
176+ private String mntInfoCgroupv1DoublePids2 = mntInfoHybrid + mntInfoCgroupv1DoublePidsLine ;
160177 private String cgroupsNonZeroHierarchy =
161178 "#subsys_name hierarchy num_cgroups enabled\n " +
162179 "cpuset 3 1 1\n " +
@@ -172,7 +189,11 @@ public class CgroupSubsystemFactory {
172189 "hugetlb 6 1 1\n " +
173190 "pids 3 80 1" ;
174191 private String mntInfoCgroupsV2Only =
175- "28 21 0:25 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime shared:4 - cgroup2 none rw,seclabel,nsdelegate" ;
192+ "28 21 0:25 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime shared:4 - cgroup2 none rw,seclabel,nsdelegate\n " ;
193+ private String mntInfoCgroupsV2MoreLine =
194+ "240 232 0:24 /../.. /cgroup-in ro,relatime - cgroup2 cgroup2 rw,nsdelegate\n " ;
195+ private String mntInfoCgroupsV2Double = mntInfoCgroupsV2MoreLine + mntInfoCgroupsV2Only ;
196+ private String mntInfoCgroupsV2Double2 = mntInfoCgroupsV2Only + mntInfoCgroupsV2MoreLine ;
176197 private String mntInfoCgroupsV1SystemdOnly =
177198 "35 26 0:26 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup systemd rw,name=systemd\n " +
178199 "26 18 0:19 / /sys/fs/cgroup rw,relatime - tmpfs none rw,size=4k,mode=755\n " ;
@@ -190,6 +211,12 @@ private void setup() {
190211 cgroupv2MntInfoZeroHierarchy = Paths .get (existingDirectory .toString (), "mountinfo_cgroupv2" );
191212 Files .write (cgroupv2MntInfoZeroHierarchy , mntInfoCgroupsV2Only .getBytes ());
192213
214+ cgroupv2MntInfoDouble = Paths .get (existingDirectory .toString (), "mountinfo_cgroupv2_double" );
215+ Files .write (cgroupv2MntInfoDouble , mntInfoCgroupsV2Double .getBytes ());
216+
217+ cgroupv2MntInfoDouble2 = Paths .get (existingDirectory .toString (), "mountinfo_cgroupv2_double2" );
218+ Files .write (cgroupv2MntInfoDouble2 , mntInfoCgroupsV2Double2 .getBytes ());
219+
193220 cgroupv1CgInfoNonZeroHierarchy = Paths .get (existingDirectory .toString (), "cgroups_non_zero" );
194221 Files .write (cgroupv1CgInfoNonZeroHierarchy , cgroupsNonZeroHierarchy .getBytes ());
195222
@@ -217,6 +244,24 @@ private void setup() {
217244 cgroupv1MntInfoDoubleCpuset2 = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_cpuset2" );
218245 Files .write (cgroupv1MntInfoDoubleCpuset2 , mntInfoCgroupv1DoubleCpuset2 .getBytes ());
219246
247+ cgroupv1MntInfoDoubleMemory = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_memory" );
248+ Files .write (cgroupv1MntInfoDoubleMemory , mntInfoCgroupv1DoubleMemory .getBytes ());
249+
250+ cgroupv1MntInfoDoubleMemory2 = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_memory2" );
251+ Files .write (cgroupv1MntInfoDoubleMemory2 , mntInfoCgroupv1DoubleMemory2 .getBytes ());
252+
253+ cgroupv1MntInfoDoubleCpu = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_cpu" );
254+ Files .write (cgroupv1MntInfoDoubleCpu , mntInfoCgroupv1DoubleCpu .getBytes ());
255+
256+ cgroupv1MntInfoDoubleCpu2 = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_cpu2" );
257+ Files .write (cgroupv1MntInfoDoubleCpu2 , mntInfoCgroupv1DoubleCpu2 .getBytes ());
258+
259+ cgroupv1MntInfoDoublePids = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_pids" );
260+ Files .write (cgroupv1MntInfoDoublePids , mntInfoCgroupv1DoublePids .getBytes ());
261+
262+ cgroupv1MntInfoDoublePids2 = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_double_pids2" );
263+ Files .write (cgroupv1MntInfoDoublePids2 , mntInfoCgroupv1DoublePids2 .getBytes ());
264+
220265 cgroupv1MntInfoSystemdOnly = Paths .get (existingDirectory .toString (), "mnt_info_cgroupv1_systemd_only" );
221266 Files .write (cgroupv1MntInfoSystemdOnly , mntInfoCgroupsV1SystemdOnly .getBytes ());
222267
@@ -274,14 +319,14 @@ public void testCgroupv1JoinControllerCombo(WhiteBox wb) {
274319 System .out .println ("testCgroupv1JoinControllerMounts PASSED!" );
275320 }
276321
277- public void testCgroupv1MultipleCpusetMounts (WhiteBox wb , Path mountInfo ) {
322+ public void testCgroupv1MultipleControllerMounts (WhiteBox wb , Path mountInfo ) {
278323 String procCgroups = cgroupv1CgInfoNonZeroHierarchy .toString ();
279324 String procSelfCgroup = cgroupV1SelfCgroup .toString ();
280325 String procSelfMountinfo = mountInfo .toString ();
281326 int retval = wb .validateCgroup (procCgroups , procSelfCgroup , procSelfMountinfo );
282- Asserts .assertEQ (CGROUPS_V1 , retval , "Multiple cpuset controllers, but only one in /sys/fs/cgroup" );
327+ Asserts .assertEQ (CGROUPS_V1 , retval , "Multiple controllers, but only one in /sys/fs/cgroup" );
283328 Asserts .assertTrue (isValidCgroup (retval ));
284- System .out .println ("testCgroupv1MultipleCpusetMounts PASSED!" );
329+ System .out .println ("testCgroupv1MultipleControllerMounts PASSED!" );
285330 }
286331
287332 public void testCgroupv1SystemdOnly (WhiteBox wb ) {
@@ -324,10 +369,10 @@ public void testCgroupv1MissingMemoryController(WhiteBox wb) {
324369 System .out .println ("testCgroupv1MissingMemoryController PASSED!" );
325370 }
326371
327- public void testCgroupv2 (WhiteBox wb ) {
372+ public void testCgroupv2 (WhiteBox wb , Path mountInfo ) {
328373 String procCgroups = cgroupv2CgInfoZeroHierarchy .toString ();
329374 String procSelfCgroup = cgroupV2SelfCgroup .toString ();
330- String procSelfMountinfo = cgroupv2MntInfoZeroHierarchy .toString ();
375+ String procSelfMountinfo = mountInfo .toString ();
331376 int retval = wb .validateCgroup (procCgroups , procSelfCgroup , procSelfMountinfo );
332377 Asserts .assertEQ (CGROUPS_V2 , retval , "Expected" );
333378 Asserts .assertTrue (isValidCgroup (retval ));
@@ -362,13 +407,21 @@ public static void main(String[] args) throws Exception {
362407 try {
363408 test .testCgroupv1SystemdOnly (wb );
364409 test .testCgroupv1NoMounts (wb );
365- test .testCgroupv2 (wb );
410+ test .testCgroupv2 (wb , test .cgroupv2MntInfoZeroHierarchy );
411+ test .testCgroupv2 (wb , test .cgroupv2MntInfoDouble );
412+ test .testCgroupv2 (wb , test .cgroupv2MntInfoDouble2 );
366413 test .testCgroupV1Hybrid (wb );
367414 test .testCgroupV1HybridMntInfoOrder (wb );
368415 test .testCgroupv1MissingMemoryController (wb );
369416 test .testCgroupv2NoCgroup2Fs (wb );
370- test .testCgroupv1MultipleCpusetMounts (wb , test .cgroupv1MntInfoDoubleCpuset );
371- test .testCgroupv1MultipleCpusetMounts (wb , test .cgroupv1MntInfoDoubleCpuset2 );
417+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleCpuset );
418+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleCpuset2 );
419+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleMemory );
420+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleMemory2 );
421+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleCpu );
422+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoubleCpu2 );
423+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoublePids );
424+ test .testCgroupv1MultipleControllerMounts (wb , test .cgroupv1MntInfoDoublePids2 );
372425 test .testCgroupv1JoinControllerCombo (wb );
373426 } finally {
374427 test .teardown ();
0 commit comments