Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -70,7 +70,7 @@ private static void testMemoryFailCount() {

// We need swap to execute this test or will SEGV
if (memAndSwapLimit <= memLimit) {
System.out.println("No swap memory limits, test case skipped");
System.out.println("No swap memory limits. Ignoring test!");
} else {
long count = Metrics.systemMetrics().getMemoryFailCount();

Expand Down
16 changes: 10 additions & 6 deletions test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -27,6 +27,7 @@
import jdk.test.lib.containers.docker.DockerRunOptions;
import jdk.test.lib.containers.docker.DockerTestUtils;
import jdk.test.lib.process.OutputAnalyzer;
import jtreg.SkippedException;

/*
* @test
Expand Down Expand Up @@ -111,18 +112,22 @@ private static void testMemoryFailCount(String value) throws Exception {

// Check whether swapping really works for this test
// On some systems there is no swap space enabled. And running
// 'java -Xms{mem-limit} -Xmx{mem-limit} -version' would fail due to swap space size being 0.
// 'java -Xms{mem-limit} -Xmx{mem-limit} -XX:+AlwaysPreTouch -version'
// would fail due to swap space size being 0. Note that when swap is
// properly enabled on the system the container gets the same amount
// of swap as is configured for memory. Thus, 2x{mem-limit} is the actual
// memory and swap bound for this pre-test.
DockerRunOptions preOpts =
new DockerRunOptions(imageName, "/jdk/bin/java", "-version");
preOpts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/")
.addDockerOpts("--memory=" + value)
.addJavaOpts("-XX:+AlwaysPreTouch")
.addJavaOpts("-Xms" + value)
.addJavaOpts("-Xmx" + value);
OutputAnalyzer oa = DockerTestUtils.dockerRunJava(preOpts);
String output = oa.getOutput();
if (!output.contains("version")) {
System.out.println("Swapping doesn't work for this test.");
return;
throw new SkippedException("Swapping doesn't work for this test.");
}

DockerRunOptions opts =
Expand All @@ -136,8 +141,7 @@ private static void testMemoryFailCount(String value) throws Exception {
oa = DockerTestUtils.dockerRunJava(opts);
output = oa.getOutput();
if (output.contains("Ignoring test")) {
System.out.println("Ignored by the tester");
return;
throw new SkippedException("Ignored by the tester");
}
oa.shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
}
Expand Down