8371320: runtime/ErrorHandling/PrintVMInfoAtExitTest.java fails with unexpected amount for Java Heap reserved memory

Reviewed-by: azafari, jsikstro
This commit is contained in:
Paul Hübner 2025-11-14 08:29:57 +00:00 committed by Afshin Zafari
parent f4305923fb
commit 81e0c87f28

View File

@ -27,17 +27,13 @@
* @test
* @summary Test PrintVMInfoAtExit
* @library /test/lib
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @modules java.base/jdk.internal.misc
* @requires vm.flagless
* @requires vm.bits == "64"
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI PrintVMInfoAtExitTest
* @run driver PrintVMInfoAtExitTest
*/
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import jdk.test.whitebox.WhiteBox;
public class PrintVMInfoAtExitTest {
@ -52,18 +48,20 @@ public class PrintVMInfoAtExitTest {
"-XX:CompressedClassSpaceSize=256m",
"-version");
// How many kb of committed memory we expect in the NMT summary.
int committed_kb = 65536;
OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
output_detail.shouldContain("# JRE version:");
output_detail.shouldContain("-- S U M M A R Y --");
output_detail.shouldContain("Command Line: -Xmx64M -Xms64M -XX:-CreateCoredumpOnCrash -XX:+UnlockDiagnosticVMOptions -XX:+PrintVMInfoAtExit -XX:NativeMemoryTracking=summary -XX:CompressedClassSpaceSize=256m");
output_detail.shouldContain("Native Memory Tracking:");
WhiteBox wb = WhiteBox.getWhiteBox();
if (wb.isAsanEnabled()) {
// the reserved value can be influenced by asan
output_detail.shouldContain("Java Heap (reserved=");
output_detail.shouldContain(", committed=65536KB)");
} else {
output_detail.shouldContain("Java Heap (reserved=65536KB, committed=65536KB)");
// Make sure the heap summary is present.
output_detail.shouldMatch("Java Heap \\(reserved=[0-9]+KB, committed=" + committed_kb + "KB\\)");
// Check reserved >= committed.
String reserved_kb_string = output_detail.firstMatch("Java Heap \\(reserved=([0-9]+)KB, committed=" + committed_kb + "KB\\)", 1);
int reserved_kb = Integer.parseInt(reserved_kb_string);
if (reserved_kb < committed_kb) {
throw new RuntimeException("committed more memory than reserved");
}
}
}