author | mseledtsov |
Wed, 01 Aug 2018 19:07:27 -0700 | |
changeset 51279 | 5cc6acb1d6b6 |
parent 50864 | cc318277c142 |
child 51370 | fbb62267e5e9 |
permissions | -rw-r--r-- |
48138 | 1 |
/* |
49008
d777541fceba
8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents:
48469
diff
changeset
|
2 |
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
48138 | 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 options that are incompatible with use of shared strings |
|
28 |
* Also test mismatch in oops encoding between dump time and run time |
|
49008
d777541fceba
8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents:
48469
diff
changeset
|
29 |
* @requires vm.cds.archived.java.heap |
48138 | 30 |
* @requires (vm.gc=="null") |
31 |
* @library /test/lib /test/hotspot/jtreg/runtime/appcds |
|
32 |
* @modules java.base/jdk.internal.misc |
|
33 |
* @modules java.management |
|
34 |
* jdk.jartool/sun.tools.jar |
|
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
35 |
* @build sun.hotspot.WhiteBox |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
36 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission |
48138 | 37 |
* @build HelloString |
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
38 |
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. IncompatibleOptions |
51279
5cc6acb1d6b6
8185531: [TESTBUG] Improve test configuration for shared strings
mseledtsov
parents:
50864
diff
changeset
|
39 |
* @run main/othervm -XX:+UseStringDeduplication -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. IncompatibleOptions |
5cc6acb1d6b6
8185531: [TESTBUG] Improve test configuration for shared strings
mseledtsov
parents:
50864
diff
changeset
|
40 |
* @run main/othervm -XX:-CompactStrings -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. IncompatibleOptions |
48138 | 41 |
*/ |
42 |
||
43 |
import jdk.test.lib.Asserts; |
|
50864
cc318277c142
8205702: assert(UseCompressedClassPointers) failed in universe.hpp
pliden
parents:
50455
diff
changeset
|
44 |
import jdk.test.lib.Platform; |
48138 | 45 |
import jdk.test.lib.process.OutputAnalyzer; |
46 |
||
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
47 |
import sun.hotspot.code.Compiler; |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
48 |
|
48138 | 49 |
public class IncompatibleOptions { |
50 |
static final String COOPS_DUMP_WARNING = |
|
51 |
"Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off"; |
|
52 |
static final String COOPS_EXEC_WARNING = |
|
53 |
"UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces"; |
|
54 |
static final String GC_WARNING = |
|
55 |
"Archived java heap is not supported"; |
|
56 |
static final String OBJ_ALIGNMENT_MISMATCH = |
|
57 |
"The shared archive file's ObjectAlignmentInBytes of .* does not equal the current ObjectAlignmentInBytes of"; |
|
58 |
static final String COMPACT_STRING_MISMATCH = |
|
59 |
"The shared archive file's CompactStrings setting .* does not equal the current CompactStrings setting"; |
|
60 |
||
61 |
static String appJar; |
|
62 |
||
63 |
public static void main(String[] args) throws Exception { |
|
64 |
appJar = JarBuilder.build("IncompatibleOptions", "HelloString"); |
|
65 |
||
66 |
// Uncompressed OOPs |
|
67 |
testDump(1, "-XX:+UseG1GC", "-XX:-UseCompressedOops", COOPS_DUMP_WARNING, true); |
|
50864
cc318277c142
8205702: assert(UseCompressedClassPointers) failed in universe.hpp
pliden
parents:
50455
diff
changeset
|
68 |
if (Platform.isLinux() && Platform.isX64()) { |
cc318277c142
8205702: assert(UseCompressedClassPointers) failed in universe.hpp
pliden
parents:
50455
diff
changeset
|
69 |
testDump(1, "-XX:+UnlockExperimentalVMOptions", "-XX:+UseZGC", COOPS_DUMP_WARNING, true); |
cc318277c142
8205702: assert(UseCompressedClassPointers) failed in universe.hpp
pliden
parents:
50455
diff
changeset
|
70 |
} |
48138 | 71 |
|
72 |
// incompatible GCs |
|
73 |
testDump(2, "-XX:+UseParallelGC", "", GC_WARNING, false); |
|
74 |
testDump(3, "-XX:+UseSerialGC", "", GC_WARNING, false); |
|
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
75 |
if (!Compiler.isGraalEnabled()) { // Graal does not support CMS |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
76 |
testDump(4, "-XX:+UseConcMarkSweepGC", "", GC_WARNING, false); |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
77 |
} |
48138 | 78 |
|
79 |
// ======= archive with compressed oops, run w/o |
|
80 |
testDump(5, "-XX:+UseG1GC", "-XX:+UseCompressedOops", null, false); |
|
81 |
testExec(5, "-XX:+UseG1GC", "-XX:-UseCompressedOops", |
|
82 |
COOPS_EXEC_WARNING, true); |
|
83 |
||
84 |
// NOTE: No warning is displayed, by design |
|
85 |
// Still run, to ensure no crash or exception |
|
86 |
testExec(6, "-XX:+UseParallelGC", "", "", false); |
|
87 |
testExec(7, "-XX:+UseSerialGC", "", "", false); |
|
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
88 |
if (!Compiler.isGraalEnabled()) { // Graal does not support CMS |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
89 |
testExec(8, "-XX:+UseConcMarkSweepGC", "", "", false); |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
90 |
} |
48138 | 91 |
|
92 |
// Test various oops encodings, by varying ObjectAlignmentInBytes and heap sizes |
|
93 |
testDump(9, "-XX:+UseG1GC", "-XX:ObjectAlignmentInBytes=8", null, false); |
|
94 |
testExec(9, "-XX:+UseG1GC", "-XX:ObjectAlignmentInBytes=16", |
|
95 |
OBJ_ALIGNMENT_MISMATCH, true); |
|
96 |
||
97 |
// See JDK-8081416 - Oops encoding mismatch with shared strings |
|
98 |
// produces unclear or incorrect warning |
|
99 |
// Correct the test case once the above is fixed |
|
100 |
// @ignore JDK-8081416 - for tracking purposes |
|
101 |
// for now, run test as is until the proper behavior is determined |
|
102 |
testDump(10, "-XX:+UseG1GC", "-Xmx1g", null, false); |
|
103 |
testExec(10, "-XX:+UseG1GC", "-Xmx32g", null, true); |
|
104 |
||
105 |
// CompactStrings must match between dump time and run time |
|
106 |
testDump(11, "-XX:+UseG1GC", "-XX:-CompactStrings", null, false); |
|
107 |
testExec(11, "-XX:+UseG1GC", "-XX:+CompactStrings", |
|
108 |
COMPACT_STRING_MISMATCH, true); |
|
109 |
testDump(12, "-XX:+UseG1GC", "-XX:+CompactStrings", null, false); |
|
110 |
testExec(12, "-XX:+UseG1GC", "-XX:-CompactStrings", |
|
111 |
COMPACT_STRING_MISMATCH, true); |
|
112 |
} |
|
113 |
||
114 |
static void testDump(int testCaseNr, String collectorOption, String extraOption, |
|
115 |
String expectedWarning, boolean expectedToFail) throws Exception { |
|
116 |
||
117 |
System.out.println("Testcase: " + testCaseNr); |
|
118 |
OutputAnalyzer output = TestCommon.dump(appJar, TestCommon.list("Hello"), |
|
119 |
"-XX:+UseCompressedOops", |
|
120 |
collectorOption, |
|
121 |
"-XX:SharedArchiveConfigFile=" + TestCommon.getSourceFile("SharedStringsBasic.txt"), |
|
122 |
extraOption); |
|
123 |
||
124 |
if (expectedWarning != null) |
|
125 |
output.shouldContain(expectedWarning); |
|
126 |
||
127 |
if (expectedToFail) { |
|
128 |
Asserts.assertNE(output.getExitValue(), 0, |
|
129 |
"JVM is expected to fail, but did not"); |
|
130 |
} |
|
131 |
} |
|
132 |
||
133 |
static void testExec(int testCaseNr, String collectorOption, String extraOption, |
|
134 |
String expectedWarning, boolean expectedToFail) throws Exception { |
|
135 |
||
136 |
OutputAnalyzer output; |
|
137 |
System.out.println("Testcase: " + testCaseNr); |
|
138 |
||
139 |
// needed, otherwise system considers empty extra option as a |
|
140 |
// main class param, and fails with "Could not find or load main class" |
|
141 |
if (!extraOption.isEmpty()) { |
|
142 |
output = TestCommon.exec(appJar, "-XX:+UseCompressedOops", |
|
143 |
collectorOption, extraOption, "HelloString"); |
|
144 |
} else { |
|
145 |
output = TestCommon.exec(appJar, "-XX:+UseCompressedOops", |
|
146 |
collectorOption, "HelloString"); |
|
147 |
} |
|
148 |
||
149 |
if (expectedWarning != null) |
|
150 |
output.shouldMatch(expectedWarning); |
|
151 |
||
152 |
if (expectedToFail) |
|
153 |
Asserts.assertNE(output.getExitValue(), 0); |
|
154 |
else |
|
155 |
SharedStringsUtils.checkExec(output); |
|
156 |
} |
|
157 |
} |