From c8b5e95e7e9bcf39d6bdabcce01bb17fc0100f6d Mon Sep 17 00:00:00 2001 From: tstuefe Date: Tue, 18 Nov 2025 09:12:53 +0100 Subject: [PATCH] fix TestVMConfigInHsErrFile --- .../TestVMConfigInHsErrFile.java | 87 ++++++------------- 1 file changed, 27 insertions(+), 60 deletions(-) diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestVMConfigInHsErrFile.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestVMConfigInHsErrFile.java index 4418db30c00..d6390ed1394 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestVMConfigInHsErrFile.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestVMConfigInHsErrFile.java @@ -30,7 +30,7 @@ * @requires vm.debug * @modules java.base/jdk.internal.misc * java.management - * @run driver TestVMConfigInHsErrFile coh-off + * @run driver TestVMConfigInHsErrFile false */ /* @@ -42,75 +42,42 @@ * @requires vm.debug * @modules java.base/jdk.internal.misc * java.management - * @run driver TestVMConfigInHsErrFile coh-on + * @run driver TestVMConfigInHsErrFile true */ import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import java.io.File; -import java.util.ArrayList; import java.util.regex.Pattern; public class TestVMConfigInHsErrFile { public static void main(String[] args) throws Exception { - switch (args[0]) { - case "coh-on" -> testCompactObjectHeaders(); - case "coh-off" -> testCompressedClassPointers(); + test(Boolean.parseBoolean(args[0])); + } + + private static void test(boolean coh) throws Exception { + final String argument = "-XX:%cUseCompactObjectHeaders".formatted(coh ? '+' : '-'); + final Pattern[] pattern = new Pattern[] { Pattern.compile("# Java VM: .*compact obj headers.*") }; + + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+UnlockExperimentalVMOptions", + argument, + "-Xmx100M", + "-XX:-CreateCoredumpOnCrash", + "-XX:ErrorHandlerTest=14", + "-version"); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldNotHaveExitValue(0); + + // extract hs-err file + File f = HsErrFileUtils.openHsErrFileFromOutput(output); + if (coh) { + HsErrFileUtils.checkHsErrFileContent(f, pattern, null, true, true); + } else { + HsErrFileUtils.checkHsErrFileContent(f, null, pattern, true, true); } } - - private static void testCompactObjectHeaders() throws Exception { - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+UnlockExperimentalVMOptions", - "-XX:+UseCompactObjectHeaders", - "-Xmx100M", - "-XX:-CreateCoredumpOnCrash", - "-XX:ErrorHandlerTest=14", - "-version"); - - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldNotHaveExitValue(0); - - // extract hs-err file - File f = HsErrFileUtils.openHsErrFileFromOutput(output); - - Pattern[] expectedPatterns = new Pattern[] { - Pattern.compile("# Java VM: .*compact obj headers.*") - }; - Pattern[] notExpectedPatterns = new Pattern[] { - Pattern.compile("# Java VM: .*compressed class ptrs.*") - }; - - HsErrFileUtils.checkHsErrFileContent(f, expectedPatterns, notExpectedPatterns, true, true); - - } - - private static void testCompressedClassPointers() throws Exception { - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+UnlockExperimentalVMOptions", - "-XX:-UseCompactObjectHeaders", - "-Xmx100M", - "-XX:-CreateCoredumpOnCrash", - "-XX:ErrorHandlerTest=14", - "-version"); - - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldNotHaveExitValue(0); - - // extract hs-err file - File f = HsErrFileUtils.openHsErrFileFromOutput(output); - - Pattern[] expectedPatterns = new Pattern[] { - Pattern.compile("# Java VM: .*compressed class ptrs.*") - }; - Pattern[] notExpectedPatterns = new Pattern[] { - Pattern.compile("# Java VM: .*compact obj headers.*") - }; - - HsErrFileUtils.checkHsErrFileContent(f, expectedPatterns, notExpectedPatterns, true, true); - - } }