Path: blob/master/test/hotspot/jtreg/containers/cgroup/CgroupSubsystemFactory.java
66644 views
/*1* Copyright (c) 2020, 2022, Red Hat Inc.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test CgroupSubsystemFactory25* @bug 828710726* @key cgroups27* @requires os.family == "linux"28* @library /testlibrary /test/lib29* @build sun.hotspot.WhiteBox30* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox31* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI CgroupSubsystemFactory32*/3334import java.io.IOException;35import java.nio.charset.StandardCharsets;36import java.nio.file.Files;37import java.nio.file.Path;38import java.nio.file.Paths;3940import jdk.test.lib.Asserts;41import jdk.test.lib.Utils;42import jdk.test.lib.util.FileUtils;43import sun.hotspot.WhiteBox;4445/*46* Verify hotspot's detection heuristics of CgroupSubsystemFactory::create()47*/48public class CgroupSubsystemFactory {4950// Mirrored from src/hotspot/os/linux/cgroupSubsystem_linux.hpp51private static final int CGROUPS_V1 = 1;52private static final int CGROUPS_V2 = 2;53private static final int INVALID_CGROUPS_V2 = 3;54private static final int INVALID_CGROUPS_V1 = 4;55private static final int INVALID_CGROUPS_NO_MOUNT = 5;56private Path existingDirectory;57private Path cgroupv1CgroupsJoinControllers;58private Path cgroupv1SelfCgroupsJoinControllers;59private Path cgroupv1MountInfoJoinControllers;60private Path cgroupv1CgInfoZeroHierarchy;61private Path cgroupv1MntInfoZeroHierarchy;62private Path cgroupv2CgInfoZeroHierarchy;63private Path cgroupv2MntInfoZeroHierarchy;64private Path cgroupv1CgInfoNonZeroHierarchy;65private Path cgroupv1MntInfoNonZeroHierarchyOtherOrder;66private Path cgroupv1MntInfoNonZeroHierarchy;67private Path cgroupv1MntInfoDoubleCpuset;68private Path cgroupv1MntInfoDoubleCpuset2;69private Path cgroupv1MntInfoSystemdOnly;70private String mntInfoEmpty = "";71private Path cgroupV1SelfCgroup;72private Path cgroupV2SelfCgroup;73private Path cgroupV2MntInfoMissingCgroupv2;74private Path cgroupv1MntInfoMissingMemoryController;75private Path cgroupv2CgInfoNoZeroHierarchyOnlyFreezer;76private Path cgroupv2MntInfoNoZeroHierarchyOnlyFreezer;77private Path cgroupv2SelfNoZeroHierarchyOnlyFreezer;78private String procSelfCgroupHybridContent = "11:hugetlb:/\n" +79"10:devices:/user.slice\n" +80"9:pids:/user.slice/user-15263.slice/[email protected]\n" +81"8:cpu,cpuacct:/\n" +82"7:perf_event:/\n" +83"6:freezer:/\n" +84"5:blkio:/\n" +85"4:net_cls,net_prio:/\n" +86"3:cpuset:/\n" +87"2:memory:/user.slice/user-15263.slice/[email protected]\n" +88"1:name=systemd:/user.slice/user-15263.slice/[email protected]/gnome-terminal-server.service\n" +89"0::/user.slice/user-15263.slice/[email protected]/gnome-terminal-server.service";90private String procSelfCgroupV2UnifiedContent = "0::/user.slice/user-1000.slice/session-3.scope";91private String procSelfCgroupV1JoinControllers =92"9:freezer:/\n" +93"8:rdma:/\n" +94"7:blkio:/user.slice\n" +95"6:devices:/user.slice\n" +96"5:pids:/user.slice/user-1000.slice/session-2.scope\n" +97"4:cpu,cpuacct,memory,net_cls,net_prio,hugetlb:/user.slice/user-1000.slice/session-2.scope\n" +98"3:cpuset:/\n" +99"2:perf_event:/\n" +100"1:name=systemd:/user.slice/user-1000.slice/session-2.scope\n" +101"0::/user.slice/user-1000.slice/session-2.scope\n";102private String cgroupsZeroHierarchy =103"#subsys_name hierarchy num_cgroups enabled\n" +104"cpuset 0 1 1\n" +105"cpu 0 1 1\n" +106"cpuacct 0 1 1\n" +107"memory 0 1 1\n" +108"devices 0 1 1\n" +109"freezer 0 1 1\n" +110"net_cls 0 1 1\n" +111"pids 0 1 1\n" +112"blkio 0 1 1\n" +113"perf_event 0 1 1 ";114private String cgroupsNonZeroJoinControllers =115"#subsys_name hierarchy num_cgroups enabled\n" +116"cpuset\t3\t1\t1\n" +117"cpu\t4\t153\t1\n" +118"cpuacct\t4\t153\t1\n" +119"blkio\t7\t87\t1\n" +120"memory\t4\t153\t1\n" +121"devices\t6\t87\t1\n" +122"freezer\t9\t1\t1\n" +123"net_cls\t4\t153\t1\n" +124"perf_event\t2\t1\t1\n" +125"net_prio\t4\t153\t1\n" +126"hugetlb\t4\t153\t1\n" +127"pids\t5\t95\t1\n" +128"rdma\t8\t1\t1\n";129private String cgroupV2LineHybrid = "31 30 0:27 / /sys/fs/cgroup/unified rw,nosuid,nodev,noexec,relatime shared:5 - cgroup2 none rw,seclabel,nsdelegate\n";130private String cgroupv1MountInfoLineMemory = "35 30 0:31 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:7 - cgroup none rw,seclabel,memory\n";131private String mntInfoHybridStub =132"30 23 0:26 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:4 - tmpfs tmpfs ro,seclabel,mode=755\n" +133"32 30 0:28 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:6 - cgroup none rw,seclabel,xattr,name=systemd\n" +134"36 30 0:32 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:8 - cgroup none rw,seclabel,pids\n" +135"37 30 0:33 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:9 - cgroup none rw,seclabel,perf_event\n" +136"38 30 0:34 / /sys/fs/cgroup/net_cls,net_prio rw,nosuid,nodev,noexec,relatime shared:10 - cgroup none rw,seclabel,net_cls,net_prio\n" +137"39 30 0:35 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:11 - cgroup none rw,seclabel,hugetlb\n" +138"40 30 0:36 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:12 - cgroup none rw,seclabel,cpu,cpuacct\n" +139"41 30 0:37 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:13 - cgroup none rw,seclabel,devices\n" +140"42 30 0:38 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:14 - cgroup none rw,seclabel,cpuset\n" +141"43 30 0:39 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:15 - cgroup none rw,seclabel,blkio\n" +142"44 30 0:40 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:16 - cgroup none rw,seclabel,freezer\n";143private String mntInfoHybridRest = cgroupv1MountInfoLineMemory + mntInfoHybridStub;144private String mntInfoHybridMissingMemory = mntInfoHybridStub;145private String mntInfoHybrid = cgroupV2LineHybrid + mntInfoHybridRest;146private String mntInfoHybridFlippedOrder = mntInfoHybridRest + cgroupV2LineHybrid;147private String mntInfoCgroupv1JoinControllers =148"31 22 0:26 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:9 - tmpfs tmpfs ro,mode=755\n" +149"32 31 0:27 / /sys/fs/cgroup/unified rw,nosuid,nodev,noexec,relatime shared:10 - cgroup2 cgroup2 rw,nsdelegate\n" +150"33 31 0:28 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:11 - cgroup cgroup rw,xattr,name=systemd\n" +151"36 31 0:31 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,perf_event\n" +152"37 31 0:32 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,cpuset\n" +153"38 31 0:33 / /sys/fs/cgroup/cpu,cpuacct,net_cls,net_prio,hugetlb,memory rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,cpu,cpuacct,memory,net_cls,net_prio,hugetlb\n" +154"39 31 0:34 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,pids\n" +155"40 31 0:35 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,devices\n" +156"41 31 0:36 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:20 - cgroup cgroup rw,blkio\n" +157"42 31 0:37 / /sys/fs/cgroup/rdma rw,nosuid,nodev,noexec,relatime shared:21 - cgroup cgroup rw,rdma\n" +158"43 31 0:38 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:22 - cgroup cgroup rw,freezer\n";159private String mntInfoCgroupv1MoreCpusetLine = "121 32 0:37 / /cpusets rw,relatime shared:69 - cgroup none rw,cpuset\n";160private String mntInfoCgroupv1DoubleCpuset = mntInfoCgroupv1MoreCpusetLine + mntInfoHybrid;161private String mntInfoCgroupv1DoubleCpuset2 = mntInfoHybrid + mntInfoCgroupv1MoreCpusetLine;162private String cgroupsNonZeroHierarchy =163"#subsys_name hierarchy num_cgroups enabled\n" +164"cpuset 3 1 1\n" +165"cpu 8 1 1\n" +166"cpuacct 8 1 1\n" +167"blkio 10 1 1\n" +168"memory 2 90 1\n" +169"devices 8 74 1\n" +170"freezer 11 1 1\n" +171"net_cls 5 1 1\n" +172"perf_event 4 1 1\n" +173"net_prio 5 1 1\n" +174"hugetlb 6 1 1\n" +175"pids 9 80 1"; // hierarchy has to match procSelfCgroupHybridContent176private String mntInfoCgroupsV2Only =177"28 21 0:25 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime shared:4 - cgroup2 none rw,seclabel,nsdelegate";178private String mntInfoCgroupsV1SystemdOnly =179"35 26 0:26 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup systemd rw,name=systemd\n" +180"26 18 0:19 / /sys/fs/cgroup rw,relatime - tmpfs none rw,size=4k,mode=755\n";181182// We have a mix of V1 and V2 controllers, but none of the V1 controllers183// are used by Java, so the JDK should start in V2 mode.184private String cgroupsNonZeroHierarchyOnlyFreezer =185"#subsys_name hierarchy num_cgroups enabled\n" +186"cpuset 0 171 1\n" +187"cpu 0 171 1\n" +188"cpuacct 0 171 1\n" +189"blkio 0 171 1\n" +190"memory 0 171 1\n" +191"devices 0 171 1\n" +192"freezer 1 1 1\n" +193"net_cls 0 171 1\n" +194"perf_event 0 171 1\n" +195"net_prio 0 171 1\n" +196"hugetlb 0 171 1\n" +197"pids 0 171 1\n" +198"rdma 0 171 1\n" +199"misc 0 171 1\n";200private String cgroupv1SelfOnlyFreezerContent = "1:freezer:/\n" +201"0::/user.slice/user-1000.slice/session-2.scope";202private String mntInfoOnlyFreezerInV1 =203"32 23 0:27 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime shared:9 - cgroup2 cgroup2 rw,nsdelegate,memory_recursiveprot\n" +204"911 32 0:47 / /sys/fs/cgroup/freezer rw,relatime shared:476 - cgroup freezer rw,freezer\n";205206private void setup() {207try {208existingDirectory = Utils.createTempDirectory(CgroupSubsystemFactory.class.getSimpleName());209Path cgroupsZero = Paths.get(existingDirectory.toString(), "cgroups_zero");210Files.writeString(cgroupsZero, cgroupsZeroHierarchy, StandardCharsets.UTF_8);211cgroupv1CgInfoZeroHierarchy = cgroupsZero;212cgroupv2CgInfoZeroHierarchy = cgroupsZero;213cgroupv1MntInfoZeroHierarchy = Paths.get(existingDirectory.toString(), "mountinfo_empty");214Files.writeString(cgroupv1MntInfoZeroHierarchy, mntInfoEmpty);215216cgroupv2MntInfoZeroHierarchy = Paths.get(existingDirectory.toString(), "mountinfo_cgroupv2");217Files.writeString(cgroupv2MntInfoZeroHierarchy, mntInfoCgroupsV2Only);218219cgroupv1CgInfoNonZeroHierarchy = Paths.get(existingDirectory.toString(), "cgroups_non_zero");220Files.writeString(cgroupv1CgInfoNonZeroHierarchy, cgroupsNonZeroHierarchy);221222cgroupv1MntInfoNonZeroHierarchy = Paths.get(existingDirectory.toString(), "mountinfo_non_zero");223Files.writeString(cgroupv1MntInfoNonZeroHierarchy, mntInfoHybrid);224225cgroupv1MntInfoNonZeroHierarchyOtherOrder = Paths.get(existingDirectory.toString(), "mountinfo_non_zero_cgroupv2_last");226Files.writeString(cgroupv1MntInfoNonZeroHierarchyOtherOrder, mntInfoHybridFlippedOrder);227228cgroupV1SelfCgroup = Paths.get(existingDirectory.toString(), "cgroup_self_hybrid");229Files.writeString(cgroupV1SelfCgroup, procSelfCgroupHybridContent);230231cgroupV2SelfCgroup = Paths.get(existingDirectory.toString(), "cgroup_self_v2");232Files.writeString(cgroupV2SelfCgroup, procSelfCgroupV2UnifiedContent);233234cgroupv1MntInfoMissingMemoryController = Paths.get(existingDirectory.toString(), "mnt_info_missing_memory");235Files.writeString(cgroupv1MntInfoMissingMemoryController, mntInfoHybridMissingMemory);236237cgroupV2MntInfoMissingCgroupv2 = Paths.get(existingDirectory.toString(), "mnt_info_missing_cgroup2");238Files.writeString(cgroupV2MntInfoMissingCgroupv2, mntInfoHybridStub);239240cgroupv1MntInfoDoubleCpuset = Paths.get(existingDirectory.toString(), "mnt_info_cgroupv1_double_cpuset");241Files.writeString(cgroupv1MntInfoDoubleCpuset, mntInfoCgroupv1DoubleCpuset);242243cgroupv1MntInfoDoubleCpuset2 = Paths.get(existingDirectory.toString(), "mnt_info_cgroupv1_double_cpuset2");244Files.writeString(cgroupv1MntInfoDoubleCpuset2, mntInfoCgroupv1DoubleCpuset2);245246cgroupv1MntInfoSystemdOnly = Paths.get(existingDirectory.toString(), "mnt_info_cgroupv1_systemd_only");247Files.writeString(cgroupv1MntInfoSystemdOnly, mntInfoCgroupsV1SystemdOnly);248249cgroupv1CgroupsJoinControllers = Paths.get(existingDirectory.toString(), "cgroups_cgv1_join_controllers");250Files.writeString(cgroupv1CgroupsJoinControllers, cgroupsNonZeroJoinControllers);251252cgroupv1SelfCgroupsJoinControllers = Paths.get(existingDirectory.toString(), "self_cgroup_cgv1_join_controllers");253Files.writeString(cgroupv1SelfCgroupsJoinControllers, procSelfCgroupV1JoinControllers);254255cgroupv1MountInfoJoinControllers = Paths.get(existingDirectory.toString(), "mntinfo_cgv1_join_controllers");256Files.writeString(cgroupv1MountInfoJoinControllers, mntInfoCgroupv1JoinControllers);257258cgroupv2CgInfoNoZeroHierarchyOnlyFreezer = Paths.get(existingDirectory.toString(), "cgroups_cgv2_non_zero_only_freezer");259Files.writeString(cgroupv2CgInfoNoZeroHierarchyOnlyFreezer, cgroupsNonZeroHierarchyOnlyFreezer);260261cgroupv2SelfNoZeroHierarchyOnlyFreezer = Paths.get(existingDirectory.toString(), "self_cgroup_non_zero_only_freezer");262Files.writeString(cgroupv2SelfNoZeroHierarchyOnlyFreezer, cgroupv1SelfOnlyFreezerContent);263264cgroupv2MntInfoNoZeroHierarchyOnlyFreezer = Paths.get(existingDirectory.toString(), "self_mountinfo_cgv2_non_zero_only_freezer");265Files.writeString(cgroupv2MntInfoNoZeroHierarchyOnlyFreezer, mntInfoOnlyFreezerInV1);266} catch (IOException e) {267throw new RuntimeException(e);268}269}270271private void teardown() {272try {273FileUtils.deleteFileTreeWithRetry(existingDirectory);274} catch (IOException e) {275System.err.println("Teardown failed. " + e.getMessage());276}277}278279private boolean isValidCgroup(int value) {280return value == CGROUPS_V1 || value == CGROUPS_V2;281}282283public void testCgroupv1JoinControllerCombo(WhiteBox wb) {284String procCgroups = cgroupv1CgroupsJoinControllers.toString();285String procSelfCgroup = cgroupv1SelfCgroupsJoinControllers.toString();286String procSelfMountinfo = cgroupv1MountInfoJoinControllers.toString();287int retval = wb.validateCgroup(procCgroups, procSelfCgroup, procSelfMountinfo);288Asserts.assertEQ(CGROUPS_V1, retval, "Join controllers should be properly detected");289Asserts.assertTrue(isValidCgroup(retval));290System.out.println("testCgroupv1JoinControllerMounts PASSED!");291}292293public void testCgroupv1MultipleCpusetMounts(WhiteBox wb, Path mountInfo) {294String procCgroups = cgroupv1CgInfoNonZeroHierarchy.toString();295String procSelfCgroup = cgroupV1SelfCgroup.toString();296String procSelfMountinfo = mountInfo.toString();297int retval = wb.validateCgroup(procCgroups, procSelfCgroup, procSelfMountinfo);298Asserts.assertEQ(CGROUPS_V1, retval, "Multiple cpuset controllers, but only one in /sys/fs/cgroup");299Asserts.assertTrue(isValidCgroup(retval));300System.out.println("testCgroupv1MultipleCpusetMounts PASSED!");301}302303public void testCgroupv1SystemdOnly(WhiteBox wb) {304String procCgroups = cgroupv1CgInfoZeroHierarchy.toString();305String procSelfCgroup = cgroupV1SelfCgroup.toString();306String procSelfMountinfo = cgroupv1MntInfoSystemdOnly.toString();307int retval = wb.validateCgroup(procCgroups, procSelfCgroup, procSelfMountinfo);308Asserts.assertEQ(INVALID_CGROUPS_NO_MOUNT, retval, "Only systemd mounted. Invalid");309Asserts.assertFalse(isValidCgroup(retval));310System.out.println("testCgroupv1SystemdOnly PASSED!");311}312313public void testCgroupv1NoMounts(WhiteBox wb) {314String procCgroups = cgroupv1CgInfoZeroHierarchy.toString();315String procSelfCgroup = cgroupV1SelfCgroup.toString();316String procSelfMountinfo = cgroupv1MntInfoZeroHierarchy.toString();317int retval = wb.validateCgroup(procCgroups, procSelfCgroup, procSelfMountinfo);318Asserts.assertEQ(INVALID_CGROUPS_NO_MOUNT, retval, "No cgroups mounted in /proc/self/mountinfo. Invalid.");319Asserts.assertFalse(isValidCgroup(retval));320System.out.println("testCgroupv1NoMounts PASSED!");321}322323public void testCgroupv2NoCgroup2Fs(WhiteBox wb) {324String procCgroups = cgroupv2CgInfoZeroHierarchy.toString();325String procSelfCgroup = cgroupV2SelfCgroup.toString();326String procSelfMountinfo = cgroupV2MntInfoMissingCgroupv2.toString();327int retval = wb.validateCgroup(procCgroups, procSelfCgroup, procSelfMountinfo);328Asserts.assertEQ(INVALID_CGROUPS_V2, retval, "No cgroup2 filesystem in /proc/self/mountinfo. Invalid.");329Asserts.assertFalse(isValidCgroup(retval));330System.out.println("testCgroupv2NoCgroup2Fs PASSED!");331}332333public void testCgroupv1MissingMemoryController(WhiteBox wb) {334String procCgroups = cgroupv1CgInfoNonZeroHierarchy.toString();335String procSelfCgroup = cgroupV1SelfCgroup.toString();336String procSelfMountinfo = cgroupv1MntInfoMissingMemoryController.toString();337int retval = wb.validateCgroup(procCgroups, procSelfCgroup, procSelfMountinfo);338Asserts.assertEQ(INVALID_CGROUPS_V1, retval, "Required memory controller path missing in mountinfo. Invalid.");339Asserts.assertFalse(isValidCgroup(retval));340System.out.println("testCgroupv1MissingMemoryController PASSED!");341}342343public void testCgroupv2(WhiteBox wb) {344String procCgroups = cgroupv2CgInfoZeroHierarchy.toString();345String procSelfCgroup = cgroupV2SelfCgroup.toString();346String procSelfMountinfo = cgroupv2MntInfoZeroHierarchy.toString();347int retval = wb.validateCgroup(procCgroups, procSelfCgroup, procSelfMountinfo);348Asserts.assertEQ(CGROUPS_V2, retval, "Expected");349Asserts.assertTrue(isValidCgroup(retval));350System.out.println("testCgroupv2 PASSED!");351}352353public void testCgroupV1Hybrid(WhiteBox wb) {354String procCgroups = cgroupv1CgInfoNonZeroHierarchy.toString();355String procSelfCgroup = cgroupV1SelfCgroup.toString();356String procSelfMountinfo = cgroupv1MntInfoNonZeroHierarchy.toString();357int retval = wb.validateCgroup(procCgroups, procSelfCgroup, procSelfMountinfo);358Asserts.assertEQ(CGROUPS_V1, retval, "Hybrid cgroups expected as cgroups v1");359Asserts.assertTrue(isValidCgroup(retval));360System.out.println("testCgroupv1Hybrid PASSED!");361}362363public void testCgroupV1HybridMntInfoOrder(WhiteBox wb) {364String procCgroups = cgroupv1CgInfoNonZeroHierarchy.toString();365String procSelfCgroup = cgroupV1SelfCgroup.toString();366String procSelfMountinfo = cgroupv1MntInfoNonZeroHierarchyOtherOrder.toString();367int retval = wb.validateCgroup(procCgroups, procSelfCgroup, procSelfMountinfo);368Asserts.assertEQ(CGROUPS_V1, retval, "Hybrid cgroups expected as cgroups v1");369Asserts.assertTrue(isValidCgroup(retval));370System.out.println("testCgroupv1HybridMntInfoOrder PASSED!");371}372373public void testNonZeroHierarchyOnlyFreezer(WhiteBox wb) {374String cgroups = cgroupv2CgInfoNoZeroHierarchyOnlyFreezer.toString();375String mountInfo = cgroupv2MntInfoNoZeroHierarchyOnlyFreezer.toString();376String selfCgroup = cgroupv2SelfNoZeroHierarchyOnlyFreezer.toString();377int retval = wb.validateCgroup(cgroups, selfCgroup, mountInfo);378Asserts.assertEQ(CGROUPS_V2, retval, "All V1 controllers are ignored");379Asserts.assertTrue(isValidCgroup(retval));380System.out.println("testNonZeroHierarchyOnlyFreezer PASSED!");381}382383public static void main(String[] args) throws Exception {384WhiteBox wb = WhiteBox.getWhiteBox();385CgroupSubsystemFactory test = new CgroupSubsystemFactory();386test.setup();387try {388test.testCgroupv1SystemdOnly(wb);389test.testCgroupv1NoMounts(wb);390test.testCgroupv2(wb);391test.testCgroupV1Hybrid(wb);392test.testCgroupV1HybridMntInfoOrder(wb);393test.testCgroupv1MissingMemoryController(wb);394test.testCgroupv2NoCgroup2Fs(wb);395test.testCgroupv1MultipleCpusetMounts(wb, test.cgroupv1MntInfoDoubleCpuset);396test.testCgroupv1MultipleCpusetMounts(wb, test.cgroupv1MntInfoDoubleCpuset2);397test.testCgroupv1JoinControllerCombo(wb);398test.testNonZeroHierarchyOnlyFreezer(wb);399} finally {400test.teardown();401}402}403}404405406