Skip to content

Commit 9417bdb

Browse files
committed
Fix TestMisc for podman on cg v1 in rootless mode.
1 parent a2c6b16 commit 9417bdb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/hotspot/jtreg/containers/docker/TestMisc.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,24 @@
2929
* @requires !vm.asan
3030
* @library /test/lib
3131
* @modules java.base/jdk.internal.misc
32+
* java.base/jdk.internal.platform
3233
* java.management
3334
* jdk.jartool/sun.tools.jar
3435
* @build CheckContainerized jdk.test.whitebox.WhiteBox PrintContainerInfo
3536
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox
3637
* @run driver TestMisc
3738
*/
39+
import jdk.internal.platform.Metrics;
3840
import jdk.test.lib.containers.docker.Common;
3941
import jdk.test.lib.containers.docker.DockerTestUtils;
4042
import jdk.test.lib.containers.docker.DockerRunOptions;
4143
import jdk.test.lib.process.OutputAnalyzer;
4244
import jdk.test.lib.process.ProcessTools;
45+
import jtreg.SkippedException;
4346

4447

4548
public class TestMisc {
49+
private static final Metrics metrics = Metrics.systemMetrics();
4650
private static final String imageName = Common.imageName("misc");
4751

4852
public static void main(String[] args) throws Exception {
@@ -98,6 +102,14 @@ private static void testPrintContainerInfo() throws Exception {
98102
// Test the mapping function on cgroups v2. Should also pass on cgroups v1 as it's
99103
// a direct mapping there.
100104
private static void testPrintContainerInfoCPUShares() throws Exception {
105+
// Test won't work on cgv1 rootless podman since resource limits don't
106+
// work there.
107+
if ("cgroupv1".equals(metrics.getProvider()) &&
108+
DockerTestUtils.isPodman() &&
109+
DockerTestUtils.isRootless()) {
110+
throw new SkippedException("Resource limits required for testPrintContainerInfoCPUShares(). " +
111+
"This is cgv1 with podman in rootless mode. Test skipped.");
112+
}
101113
// Anything less than 1024 should return the back-mapped cpu-shares value without
102114
// rounding to next multiple of 1024 (on cg v2). Only ensure that we get
103115
// 'cpu_shares: <back-mapped-value>' over 'cpu_shares: no shares'.

0 commit comments

Comments
 (0)