author | iklam |
Tue, 02 Oct 2018 14:32:33 -0700 | |
changeset 51990 | 6003e034cdd8 |
parent 51616 | b071f4fff1f1 |
child 52032 | 2f7a2e7c3221 |
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 |
|
51527
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
32 |
* @modules jdk.jartool/sun.tools.jar |
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
33 |
* @build sun.hotspot.WhiteBox |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
34 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission |
48138 | 35 |
* @build HelloString |
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
36 |
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. IncompatibleOptions |
48138 | 37 |
*/ |
38 |
||
39 |
import jdk.test.lib.Asserts; |
|
50864
cc318277c142
8205702: assert(UseCompressedClassPointers) failed in universe.hpp
pliden
parents:
50455
diff
changeset
|
40 |
import jdk.test.lib.Platform; |
48138 | 41 |
import jdk.test.lib.process.OutputAnalyzer; |
42 |
||
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
43 |
import sun.hotspot.code.Compiler; |
51616
b071f4fff1f1
8210259: [testbug] IncompatibleOptions.java fails if VM configured without ZGC
goetz
parents:
51527
diff
changeset
|
44 |
import sun.hotspot.gc.GC; |
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
45 |
|
48138 | 46 |
public class IncompatibleOptions { |
47 |
static final String COOPS_DUMP_WARNING = |
|
48 |
"Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off"; |
|
49 |
static final String COOPS_EXEC_WARNING = |
|
50 |
"UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces"; |
|
51 |
static final String GC_WARNING = |
|
52 |
"Archived java heap is not supported"; |
|
53 |
static final String OBJ_ALIGNMENT_MISMATCH = |
|
54 |
"The shared archive file's ObjectAlignmentInBytes of .* does not equal the current ObjectAlignmentInBytes of"; |
|
55 |
static final String COMPACT_STRING_MISMATCH = |
|
56 |
"The shared archive file's CompactStrings setting .* does not equal the current CompactStrings setting"; |
|
57 |
||
58 |
static String appJar; |
|
51527
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
59 |
static String[] globalVmOptions; |
48138 | 60 |
|
61 |
public static void main(String[] args) throws Exception { |
|
51527
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
62 |
globalVmOptions = args; // specified by "@run main" in IncompatibleOptions_*.java |
48138 | 63 |
appJar = JarBuilder.build("IncompatibleOptions", "HelloString"); |
64 |
||
65 |
// Uncompressed OOPs |
|
66 |
testDump(1, "-XX:+UseG1GC", "-XX:-UseCompressedOops", COOPS_DUMP_WARNING, true); |
|
51616
b071f4fff1f1
8210259: [testbug] IncompatibleOptions.java fails if VM configured without ZGC
goetz
parents:
51527
diff
changeset
|
67 |
if (GC.Z.isSupported()) { // ZGC is included in build. |
50864
cc318277c142
8205702: assert(UseCompressedClassPointers) failed in universe.hpp
pliden
parents:
50455
diff
changeset
|
68 |
testDump(1, "-XX:+UnlockExperimentalVMOptions", "-XX:+UseZGC", COOPS_DUMP_WARNING, true); |
cc318277c142
8205702: assert(UseCompressedClassPointers) failed in universe.hpp
pliden
parents:
50455
diff
changeset
|
69 |
} |
48138 | 70 |
|
71 |
// incompatible GCs |
|
72 |
testDump(2, "-XX:+UseParallelGC", "", GC_WARNING, false); |
|
73 |
testDump(3, "-XX:+UseSerialGC", "", GC_WARNING, false); |
|
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
74 |
if (!Compiler.isGraalEnabled()) { // Graal does not support CMS |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
75 |
testDump(4, "-XX:+UseConcMarkSweepGC", "", GC_WARNING, false); |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
76 |
} |
48138 | 77 |
|
78 |
// ======= archive with compressed oops, run w/o |
|
79 |
testDump(5, "-XX:+UseG1GC", "-XX:+UseCompressedOops", null, false); |
|
80 |
testExec(5, "-XX:+UseG1GC", "-XX:-UseCompressedOops", |
|
81 |
COOPS_EXEC_WARNING, true); |
|
82 |
||
83 |
// NOTE: No warning is displayed, by design |
|
84 |
// Still run, to ensure no crash or exception |
|
85 |
testExec(6, "-XX:+UseParallelGC", "", "", false); |
|
86 |
testExec(7, "-XX:+UseSerialGC", "", "", false); |
|
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
87 |
if (!Compiler.isGraalEnabled()) { // Graal does not support CMS |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
88 |
testExec(8, "-XX:+UseConcMarkSweepGC", "", "", false); |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
49008
diff
changeset
|
89 |
} |
48138 | 90 |
|
91 |
// Test various oops encodings, by varying ObjectAlignmentInBytes and heap sizes |
|
92 |
testDump(9, "-XX:+UseG1GC", "-XX:ObjectAlignmentInBytes=8", null, false); |
|
93 |
testExec(9, "-XX:+UseG1GC", "-XX:ObjectAlignmentInBytes=16", |
|
94 |
OBJ_ALIGNMENT_MISMATCH, true); |
|
95 |
||
96 |
// See JDK-8081416 - Oops encoding mismatch with shared strings |
|
97 |
// produces unclear or incorrect warning |
|
98 |
// Correct the test case once the above is fixed |
|
99 |
// @ignore JDK-8081416 - for tracking purposes |
|
100 |
// for now, run test as is until the proper behavior is determined |
|
101 |
testDump(10, "-XX:+UseG1GC", "-Xmx1g", null, false); |
|
102 |
testExec(10, "-XX:+UseG1GC", "-Xmx32g", null, true); |
|
103 |
||
104 |
// CompactStrings must match between dump time and run time |
|
105 |
testDump(11, "-XX:+UseG1GC", "-XX:-CompactStrings", null, false); |
|
106 |
testExec(11, "-XX:+UseG1GC", "-XX:+CompactStrings", |
|
107 |
COMPACT_STRING_MISMATCH, true); |
|
108 |
testDump(12, "-XX:+UseG1GC", "-XX:+CompactStrings", null, false); |
|
109 |
testExec(12, "-XX:+UseG1GC", "-XX:-CompactStrings", |
|
110 |
COMPACT_STRING_MISMATCH, true); |
|
111 |
} |
|
112 |
||
113 |
static void testDump(int testCaseNr, String collectorOption, String extraOption, |
|
114 |
String expectedWarning, boolean expectedToFail) throws Exception { |
|
115 |
||
116 |
System.out.println("Testcase: " + testCaseNr); |
|
117 |
OutputAnalyzer output = TestCommon.dump(appJar, TestCommon.list("Hello"), |
|
51527
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
118 |
TestCommon.concat(globalVmOptions, |
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
119 |
"-XX:+UseCompressedOops", |
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
120 |
collectorOption, |
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
121 |
"-XX:SharedArchiveConfigFile=" + TestCommon.getSourceFile("SharedStringsBasic.txt"), |
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
122 |
"-Xlog:cds,cds+hashtables", |
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
123 |
extraOption)); |
48138 | 124 |
|
51527
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
125 |
if (expectedWarning != null) { |
48138 | 126 |
output.shouldContain(expectedWarning); |
51527
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
127 |
} |
48138 | 128 |
|
129 |
if (expectedToFail) { |
|
130 |
Asserts.assertNE(output.getExitValue(), 0, |
|
131 |
"JVM is expected to fail, but did not"); |
|
132 |
} |
|
133 |
} |
|
134 |
||
135 |
static void testExec(int testCaseNr, String collectorOption, String extraOption, |
|
136 |
String expectedWarning, boolean expectedToFail) throws Exception { |
|
137 |
||
138 |
OutputAnalyzer output; |
|
139 |
System.out.println("Testcase: " + testCaseNr); |
|
140 |
||
141 |
// needed, otherwise system considers empty extra option as a |
|
142 |
// main class param, and fails with "Could not find or load main class" |
|
143 |
if (!extraOption.isEmpty()) { |
|
51527
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
144 |
output = TestCommon.exec(appJar, |
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
145 |
TestCommon.concat(globalVmOptions, |
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
146 |
"-XX:+UseCompressedOops", |
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
147 |
collectorOption, "-Xlog:cds", extraOption, "HelloString")); |
48138 | 148 |
} else { |
51527
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
149 |
output = TestCommon.exec(appJar, |
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
150 |
TestCommon.concat(globalVmOptions, |
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
151 |
"-XX:+UseCompressedOops", |
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
152 |
collectorOption, "-Xlog:cds", "HelloString")); |
48138 | 153 |
} |
154 |
||
51527
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
155 |
if (expectedWarning != null) { |
48138 | 156 |
output.shouldMatch(expectedWarning); |
51527
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
157 |
} |
48138 | 158 |
|
51527
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
159 |
if (expectedToFail) { |
48138 | 160 |
Asserts.assertNE(output.getExitValue(), 0); |
51527
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
161 |
} else { |
48138 | 162 |
SharedStringsUtils.checkExec(output); |
51527
dda0f219dafa
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51491
diff
changeset
|
163 |
} |
48138 | 164 |
} |
165 |
} |