--- old/test/hotspot/jtreg/containers/docker/TestCPUAwareness.java 2019-09-19 13:59:33.993458899 +0200 +++ new/test/hotspot/jtreg/containers/docker/TestCPUAwareness.java 2019-09-19 13:59:33.865458651 +0200 @@ -33,10 +33,12 @@ * @run driver TestCPUAwareness */ import java.util.List; +import java.util.Optional; import jdk.test.lib.containers.docker.Common; import jdk.test.lib.containers.docker.DockerRunOptions; import jdk.test.lib.containers.docker.DockerTestUtils; import jdk.test.lib.containers.cgroup.CPUSetsReader; +import jdk.test.lib.process.OutputAnalyzer; public class TestCPUAwareness { private static final String imageName = Common.imageName("cpu"); @@ -202,8 +204,28 @@ DockerRunOptions opts = Common.newOpts(imageName) .addDockerOpts("--cpu-shares=" + shares); - Common.run(opts) - .shouldMatch("CPU Shares is.*" + shares) - .shouldMatch("active_processor_count.*" + expectedAPC); + OutputAnalyzer out = Common.run(opts); + String cgroupVer = getDetectedCgroupVersion(out); + if (cgroupVer != null ) { + if ("cgroupv1".equals(cgroupVer)) { + out.shouldMatch("CPU Shares is.*" + shares); + } else if ("cgroupsv2".equals(cgroupVer)) { + out.shouldMatch("Scaled CPU Shares value is:.*"); + } + } + out.shouldMatch("active_processor_count.*" + expectedAPC); } + + private static String getDetectedCgroupVersion(OutputAnalyzer out) throws Exception { + Optional cgroupVersString = out.asLines() + .stream() + .filter( l -> l.startsWith("Detected CGroups version is:") ) + .findFirst(); + if (cgroupVersString.isPresent()) { // only non-product builds have this + return cgroupVersString.get().split(": ")[1].trim(); + } else { + return null; + } + } + }