|
| 1 | +/* |
| 2 | + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | + * accompanied this code). |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License version |
| 16 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | + * |
| 19 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | + * or visit www.oracle.com if you need additional information or have any |
| 21 | + * questions. |
| 22 | + */ |
| 23 | + |
| 24 | + |
| 25 | +/* |
| 26 | + * @test |
| 27 | + * @summary Test that we see VM configs reported correctly in hs_err file |
| 28 | + * @library /test/lib |
| 29 | + * @requires vm.flagless |
| 30 | + * @requires vm.debug |
| 31 | + * @modules java.base/jdk.internal.misc |
| 32 | + * java.management |
| 33 | + * @run driver TestVMConfigInHsErrFile |
| 34 | + */ |
| 35 | + |
| 36 | +import jdk.test.lib.process.OutputAnalyzer; |
| 37 | +import jdk.test.lib.process.ProcessTools; |
| 38 | +import java.io.File; |
| 39 | +import java.util.ArrayList; |
| 40 | +import java.util.regex.Pattern; |
| 41 | + |
| 42 | +public class TestVMConfigInHsErrFile { |
| 43 | + |
| 44 | + public static void main(String[] args) throws Exception { |
| 45 | + testCompactObjectHeaders(); |
| 46 | + testCompressedClassPointers(); |
| 47 | + } |
| 48 | + |
| 49 | + private static void testCompactObjectHeaders() throws Exception { |
| 50 | + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( |
| 51 | + "-XX:+UnlockDiagnosticVMOptions", |
| 52 | + "-XX:+UnlockExperimentalVMOptions", |
| 53 | + "-XX:+UseCompactObjectHeaders", |
| 54 | + "-Xmx100M", |
| 55 | + "-XX:-CreateCoredumpOnCrash", |
| 56 | + "-XX:ErrorHandlerTest=14", |
| 57 | + "-version"); |
| 58 | + |
| 59 | + OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
| 60 | + output.shouldNotHaveExitValue(0); |
| 61 | + |
| 62 | + // extract hs-err file |
| 63 | + File f = HsErrFileUtils.openHsErrFileFromOutput(output); |
| 64 | + |
| 65 | + Pattern[] expectedPatterns = new Pattern[] { |
| 66 | + Pattern.compile("# Java VM: .*compact obj headers.*") |
| 67 | + }; |
| 68 | + Pattern[] notExpectedPatterns = new Pattern[] { |
| 69 | + Pattern.compile("# Java VM: .*compressed class ptrs.*") |
| 70 | + }; |
| 71 | + |
| 72 | + HsErrFileUtils.checkHsErrFileContent(f, expectedPatterns, notExpectedPatterns, true, true); |
| 73 | + |
| 74 | + } |
| 75 | + |
| 76 | + private static void testCompressedClassPointers() throws Exception { |
| 77 | + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( |
| 78 | + "-XX:+UnlockDiagnosticVMOptions", |
| 79 | + "-XX:+UnlockExperimentalVMOptions", |
| 80 | + "-XX:-UseCompactObjectHeaders", |
| 81 | + "-XX:+UseCompressedClassPointers", |
| 82 | + "-Xmx100M", |
| 83 | + "-XX:-CreateCoredumpOnCrash", |
| 84 | + "-XX:ErrorHandlerTest=14", |
| 85 | + "-version"); |
| 86 | + |
| 87 | + OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
| 88 | + output.shouldNotHaveExitValue(0); |
| 89 | + |
| 90 | + // extract hs-err file |
| 91 | + File f = HsErrFileUtils.openHsErrFileFromOutput(output); |
| 92 | + |
| 93 | + Pattern[] expectedPatterns = new Pattern[] { |
| 94 | + Pattern.compile("# Java VM: .*compressed class ptrs.*") |
| 95 | + }; |
| 96 | + Pattern[] notExpectedPatterns = new Pattern[] { |
| 97 | + Pattern.compile("# Java VM: .*compact obj headers.*") |
| 98 | + }; |
| 99 | + |
| 100 | + HsErrFileUtils.checkHsErrFileContent(f, expectedPatterns, notExpectedPatterns, true, true); |
| 101 | + |
| 102 | + } |
| 103 | +} |
0 commit comments