author | ccheung |
Fri, 17 May 2019 08:29:55 -0700 | |
changeset 54927 | 1512d88b24c6 |
parent 52032 | 2f7a2e7c3221 |
permissions | -rw-r--r-- |
48138 | 1 |
/* |
54927 | 2 |
* Copyright (c) 2014, 2019, 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 CommandLineFlagCombo |
|
52032
2f7a2e7c3221
8210376: [TESTBUG] @requires vm.cds should be replaced by @requires vm.cds.archived.java.heap and documentation is required for vm.gc==null
vaibhav
parents:
50708
diff
changeset
|
27 |
* @requires vm.cds.archived.java.heap |
2f7a2e7c3221
8210376: [TESTBUG] @requires vm.cds should be replaced by @requires vm.cds.archived.java.heap and documentation is required for vm.gc==null
vaibhav
parents:
50708
diff
changeset
|
28 |
* @comment This test explicitly chooses the type of GC to be used by sub-processes. It may conflict with the GC type set |
2f7a2e7c3221
8210376: [TESTBUG] @requires vm.cds should be replaced by @requires vm.cds.archived.java.heap and documentation is required for vm.gc==null
vaibhav
parents:
50708
diff
changeset
|
29 |
* via the -vmoptions command line option of JTREG. vm.gc==null will help the test case to discard the explicitly passed |
2f7a2e7c3221
8210376: [TESTBUG] @requires vm.cds should be replaced by @requires vm.cds.archived.java.heap and documentation is required for vm.gc==null
vaibhav
parents:
50708
diff
changeset
|
30 |
* vm options. |
48469
7312ae4465d6
8193672: [test] Enhance vm.cds property to check for all conditions required to run CDS tests
iklam
parents:
48138
diff
changeset
|
31 |
* @requires (vm.gc=="null") |
48138 | 32 |
* @summary Test command line flag combinations that |
33 |
* could likely affect the behaviour of AppCDS |
|
34 |
* @library /test/lib |
|
35 |
* @modules java.base/jdk.internal.misc |
|
36 |
* java.management |
|
37 |
* jdk.jartool/sun.tools.jar |
|
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
38 |
* @build sun.hotspot.WhiteBox |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
39 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission |
48138 | 40 |
* @compile test-classes/Hello.java |
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
41 |
* @run main/othervm/timeout=240 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. CommandLineFlagCombo |
48138 | 42 |
*/ |
43 |
||
44 |
import jdk.test.lib.BuildHelper; |
|
45 |
import jdk.test.lib.Platform; |
|
46 |
import jdk.test.lib.process.OutputAnalyzer; |
|
47 |
||
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
48 |
import sun.hotspot.code.Compiler; |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
49 |
|
48138 | 50 |
public class CommandLineFlagCombo { |
51 |
||
52 |
// shared base address test table |
|
53 |
private static final String[] testTable = { |
|
54 |
"-XX:+UseG1GC", "-XX:+UseSerialGC", "-XX:+UseParallelGC", "-XX:+UseConcMarkSweepGC", |
|
55 |
"-XX:+FlightRecorder", |
|
56 |
"-XX:+UseLargePages", // may only take effect on machines with large-pages |
|
57 |
"-XX:+UseCompressedClassPointers", |
|
58 |
"-XX:+UseCompressedOops", |
|
59 |
"-XX:ObjectAlignmentInBytes=16", |
|
60 |
"-XX:ObjectAlignmentInBytes=32", |
|
61 |
"-XX:ObjectAlignmentInBytes=64" |
|
62 |
}; |
|
63 |
||
64 |
public static void main(String[] args) throws Exception { |
|
65 |
String appJar = JarBuilder.getOrCreateHelloJar(); |
|
66 |
String classList[] = {"Hello"}; |
|
67 |
||
68 |
for (String testEntry : testTable) { |
|
69 |
System.out.println("CommandLineFlagCombo = " + testEntry); |
|
70 |
||
71 |
if (skipTestCase(testEntry)) |
|
72 |
continue; |
|
73 |
||
50708 | 74 |
OutputAnalyzer dumpOutput = TestCommon.dump(appJar, classList, testEntry); |
54927 | 75 |
if (!TestCommon.isDynamicArchive()) { |
76 |
TestCommon.checkDump(dumpOutput, "Loading classes to share"); |
|
77 |
} else { |
|
78 |
if (testEntry.contains("ObjectAlignmentInBytes")) { |
|
79 |
dumpOutput.shouldHaveExitValue(1) |
|
80 |
.shouldMatch("The shared archive file's ObjectAlignmentInBytes of .* does not equal the current ObjectAlignmentInBytes of"); |
|
81 |
} else { |
|
82 |
TestCommon.checkDump(dumpOutput, "Loading classes to share"); |
|
83 |
} |
|
84 |
} |
|
48138 | 85 |
|
54927 | 86 |
if ((TestCommon.isDynamicArchive() && !testEntry.contains("ObjectAlignmentInBytes")) || |
87 |
!TestCommon.isDynamicArchive()) { |
|
88 |
OutputAnalyzer execOutput = TestCommon.exec(appJar, testEntry, "Hello"); |
|
89 |
TestCommon.checkExec(execOutput, "Hello World"); |
|
90 |
} |
|
48138 | 91 |
} |
92 |
||
93 |
for (int i=0; i<2; i++) { |
|
94 |
String g1Flag, serialFlag; |
|
95 |
||
96 |
// Interned strings are supported only with G1GC. However, we should not crash if: |
|
97 |
// 0: archive has shared strings, but run time doesn't support shared strings |
|
98 |
// 1: archive has no shared strings, but run time supports shared strings |
|
99 |
||
100 |
String dump_g1Flag = "-XX:" + (i == 0 ? "+" : "-") + "UseG1GC"; |
|
101 |
String run_g1Flag = "-XX:" + (i != 0 ? "+" : "-") + "UseG1GC"; |
|
102 |
String dump_serialFlag = "-XX:" + (i != 0 ? "+" : "-") + "UseSerialGC"; |
|
103 |
String run_serialFlag = "-XX:" + (i == 0 ? "+" : "-") + "UseSerialGC"; |
|
104 |
||
105 |
OutputAnalyzer dumpOutput = TestCommon.dump( |
|
106 |
appJar, classList, dump_g1Flag, dump_serialFlag); |
|
107 |
||
108 |
TestCommon.checkDump(dumpOutput, "Loading classes to share"); |
|
109 |
||
110 |
OutputAnalyzer execOutput = TestCommon.exec(appJar, run_g1Flag, run_serialFlag, "Hello"); |
|
111 |
TestCommon.checkExec(execOutput, "Hello World"); |
|
112 |
} |
|
113 |
} |
|
114 |
||
115 |
private static boolean skipTestCase(String testEntry) throws Exception { |
|
116 |
if (Platform.is32bit()) |
|
117 |
{ |
|
118 |
if (testEntry.equals("-XX:+UseCompressedOops") || |
|
119 |
testEntry.equals("-XX:+UseCompressedClassPointers") || |
|
120 |
testEntry.contains("ObjectAlignmentInBytes") ) |
|
121 |
{ |
|
122 |
System.out.println("Test case not applicable on 32-bit platforms"); |
|
123 |
return true; |
|
124 |
} |
|
125 |
} |
|
126 |
||
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
127 |
if (Compiler.isGraalEnabled() && testEntry.equals("-XX:+UseConcMarkSweepGC")) |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
128 |
{ |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
129 |
System.out.println("Graal does not support CMS"); |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
130 |
return true; |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
131 |
} |
48138 | 132 |
|
133 |
return false; |
|
134 |
} |
|
135 |
} |