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