author | jiefu |
Wed, 06 Nov 2019 13:43:25 +0800 | |
changeset 58944 | bb2a436e616c |
parent 57705 | 7cf02b2c1455 |
child 59053 | ba6c248cae19 |
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 |
|
57705
7cf02b2c1455
8229267: [TESTBUG] Remove unnecessary @modules dependencies in CDS tests
iklam
parents:
57567
diff
changeset
|
35 |
* @modules jdk.jartool/sun.tools.jar |
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
36 |
* @build sun.hotspot.WhiteBox |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
37 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission |
48138 | 38 |
* @compile test-classes/Hello.java |
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
39 |
* @run main/othervm/timeout=240 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. CommandLineFlagCombo |
48138 | 40 |
*/ |
41 |
||
42 |
import jdk.test.lib.BuildHelper; |
|
43 |
import jdk.test.lib.Platform; |
|
44 |
import jdk.test.lib.process.OutputAnalyzer; |
|
45 |
||
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
46 |
import sun.hotspot.code.Compiler; |
58944
bb2a436e616c
8233659: [TESTBUG] runtime/cds/appcds/CommandLineFlagCombo.java fails when jfr is disabled
jiefu
parents:
57705
diff
changeset
|
47 |
import sun.hotspot.WhiteBox; |
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
48 |
|
48138 | 49 |
public class CommandLineFlagCombo { |
50 |
||
51 |
// shared base address test table |
|
52 |
private static final String[] testTable = { |
|
53 |
"-XX:+UseG1GC", "-XX:+UseSerialGC", "-XX:+UseParallelGC", "-XX:+UseConcMarkSweepGC", |
|
54 |
"-XX:+FlightRecorder", |
|
55 |
"-XX:+UseLargePages", // may only take effect on machines with large-pages |
|
56 |
"-XX:+UseCompressedClassPointers", |
|
57 |
"-XX:+UseCompressedOops", |
|
58 |
"-XX:ObjectAlignmentInBytes=16", |
|
59 |
"-XX:ObjectAlignmentInBytes=32", |
|
60 |
"-XX:ObjectAlignmentInBytes=64" |
|
61 |
}; |
|
62 |
||
63 |
public static void main(String[] args) throws Exception { |
|
64 |
String appJar = JarBuilder.getOrCreateHelloJar(); |
|
65 |
String classList[] = {"Hello"}; |
|
66 |
||
67 |
for (String testEntry : testTable) { |
|
68 |
System.out.println("CommandLineFlagCombo = " + testEntry); |
|
69 |
||
70 |
if (skipTestCase(testEntry)) |
|
71 |
continue; |
|
72 |
||
50708 | 73 |
OutputAnalyzer dumpOutput = TestCommon.dump(appJar, classList, testEntry); |
54927 | 74 |
if (!TestCommon.isDynamicArchive()) { |
75 |
TestCommon.checkDump(dumpOutput, "Loading classes to share"); |
|
76 |
} else { |
|
77 |
if (testEntry.contains("ObjectAlignmentInBytes")) { |
|
78 |
dumpOutput.shouldHaveExitValue(1) |
|
79 |
.shouldMatch("The shared archive file's ObjectAlignmentInBytes of .* does not equal the current ObjectAlignmentInBytes of"); |
|
80 |
} else { |
|
81 |
TestCommon.checkDump(dumpOutput, "Loading classes to share"); |
|
82 |
} |
|
83 |
} |
|
48138 | 84 |
|
54927 | 85 |
if ((TestCommon.isDynamicArchive() && !testEntry.contains("ObjectAlignmentInBytes")) || |
86 |
!TestCommon.isDynamicArchive()) { |
|
87 |
OutputAnalyzer execOutput = TestCommon.exec(appJar, testEntry, "Hello"); |
|
88 |
TestCommon.checkExec(execOutput, "Hello World"); |
|
89 |
} |
|
48138 | 90 |
} |
91 |
||
92 |
for (int i=0; i<2; i++) { |
|
93 |
String g1Flag, serialFlag; |
|
94 |
||
95 |
// Interned strings are supported only with G1GC. However, we should not crash if: |
|
96 |
// 0: archive has shared strings, but run time doesn't support shared strings |
|
97 |
// 1: archive has no shared strings, but run time supports shared strings |
|
98 |
||
99 |
String dump_g1Flag = "-XX:" + (i == 0 ? "+" : "-") + "UseG1GC"; |
|
100 |
String run_g1Flag = "-XX:" + (i != 0 ? "+" : "-") + "UseG1GC"; |
|
101 |
String dump_serialFlag = "-XX:" + (i != 0 ? "+" : "-") + "UseSerialGC"; |
|
102 |
String run_serialFlag = "-XX:" + (i == 0 ? "+" : "-") + "UseSerialGC"; |
|
103 |
||
104 |
OutputAnalyzer dumpOutput = TestCommon.dump( |
|
105 |
appJar, classList, dump_g1Flag, dump_serialFlag); |
|
106 |
||
107 |
TestCommon.checkDump(dumpOutput, "Loading classes to share"); |
|
108 |
||
109 |
OutputAnalyzer execOutput = TestCommon.exec(appJar, run_g1Flag, run_serialFlag, "Hello"); |
|
110 |
TestCommon.checkExec(execOutput, "Hello World"); |
|
111 |
} |
|
112 |
} |
|
113 |
||
114 |
private static boolean skipTestCase(String testEntry) throws Exception { |
|
115 |
if (Platform.is32bit()) |
|
116 |
{ |
|
117 |
if (testEntry.equals("-XX:+UseCompressedOops") || |
|
118 |
testEntry.equals("-XX:+UseCompressedClassPointers") || |
|
119 |
testEntry.contains("ObjectAlignmentInBytes") ) |
|
120 |
{ |
|
121 |
System.out.println("Test case not applicable on 32-bit platforms"); |
|
122 |
return true; |
|
123 |
} |
|
124 |
} |
|
125 |
||
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
126 |
if (Compiler.isGraalEnabled() && testEntry.equals("-XX:+UseConcMarkSweepGC")) |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
127 |
{ |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
128 |
System.out.println("Graal does not support CMS"); |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
129 |
return true; |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48469
diff
changeset
|
130 |
} |
48138 | 131 |
|
58944
bb2a436e616c
8233659: [TESTBUG] runtime/cds/appcds/CommandLineFlagCombo.java fails when jfr is disabled
jiefu
parents:
57705
diff
changeset
|
132 |
if (!WhiteBox.getWhiteBox().isJFRIncludedInVmBuild() && testEntry.equals("-XX:+FlightRecorder")) |
bb2a436e616c
8233659: [TESTBUG] runtime/cds/appcds/CommandLineFlagCombo.java fails when jfr is disabled
jiefu
parents:
57705
diff
changeset
|
133 |
{ |
bb2a436e616c
8233659: [TESTBUG] runtime/cds/appcds/CommandLineFlagCombo.java fails when jfr is disabled
jiefu
parents:
57705
diff
changeset
|
134 |
System.out.println("JFR does not exist"); |
bb2a436e616c
8233659: [TESTBUG] runtime/cds/appcds/CommandLineFlagCombo.java fails when jfr is disabled
jiefu
parents:
57705
diff
changeset
|
135 |
return true; |
bb2a436e616c
8233659: [TESTBUG] runtime/cds/appcds/CommandLineFlagCombo.java fails when jfr is disabled
jiefu
parents:
57705
diff
changeset
|
136 |
} |
bb2a436e616c
8233659: [TESTBUG] runtime/cds/appcds/CommandLineFlagCombo.java fails when jfr is disabled
jiefu
parents:
57705
diff
changeset
|
137 |
|
48138 | 138 |
return false; |
139 |
} |
|
140 |
} |