author | jiefu |
Wed, 06 Nov 2019 13:43:25 +0800 | |
changeset 58944 | bb2a436e616c |
parent 57705 | 7cf02b2c1455 |
child 58679 | 9c3209ff7550 |
child 59129 | d8eddc0ba770 |
permissions | -rw-r--r-- |
48138 | 1 |
/* |
57567
b000362a89a0
8202339: [TESTBUG] Consolidate the tests in runtime/SharedArchiveFile and runtime/appcds
coleenp
parents:
52596
diff
changeset
|
2 |
* Copyright (c) 2017, 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 |
|
27 |
* @summary Similar to GCDuringDumping.java, this test adds the -XX:SharedArchiveConfigFile |
|
28 |
* option for testing the interaction with GC and shared strings. |
|
57567
b000362a89a0
8202339: [TESTBUG] Consolidate the tests in runtime/SharedArchiveFile and runtime/appcds
coleenp
parents:
52596
diff
changeset
|
29 |
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes |
49008
d777541fceba
8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents:
48979
diff
changeset
|
30 |
* @requires vm.cds.archived.java.heap |
57705
7cf02b2c1455
8229267: [TESTBUG] Remove unnecessary @modules dependencies in CDS tests
iklam
parents:
57567
diff
changeset
|
31 |
* @modules jdk.jartool/sun.tools.jar |
48138 | 32 |
* @build sun.hotspot.WhiteBox GCDuringDumpTransformer GCSharedStringsDuringDumpWb |
48791
6e079ff6c83c
8186635: ClassFileInstaller should be run as a driver
iignatyev
parents:
48469
diff
changeset
|
33 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
48138 | 34 |
* @run main/othervm/timeout=480 GCSharedStringsDuringDump |
35 |
*/ |
|
36 |
||
37 |
import java.io.File; |
|
38 |
import java.io.FileOutputStream; |
|
39 |
import java.io.OutputStreamWriter; |
|
40 |
import java.io.PrintWriter; |
|
41 |
import jdk.test.lib.cds.CDSOptions; |
|
42 |
import jdk.test.lib.process.OutputAnalyzer; |
|
43 |
import jdk.test.lib.process.ProcessTools; |
|
44 |
import sun.hotspot.WhiteBox; |
|
45 |
||
46 |
public class GCSharedStringsDuringDump { |
|
47 |
public static String appClasses[] = { |
|
48 |
"GCSharedStringsDuringDumpWb", |
|
49 |
}; |
|
50 |
public static String agentClasses[] = { |
|
51 |
"GCDuringDumpTransformer", |
|
52 |
}; |
|
53 |
||
54 |
public static void main(String[] args) throws Throwable { |
|
55 |
String agentJar = |
|
56 |
ClassFileInstaller.writeJar("GCDuringDumpTransformer.jar", |
|
57 |
ClassFileInstaller.Manifest.fromSourceFile("GCDuringDumpTransformer.mf"), |
|
58 |
agentClasses); |
|
59 |
||
60 |
String appJar = |
|
61 |
ClassFileInstaller.writeJar("GCSharedStringsDuringDumpApp.jar", appClasses); |
|
62 |
||
51507
3e3764f8fe36
8207211: [TESTBUG] Remove excessive output from CDS/AppCDS tests
ccheung
parents:
49008
diff
changeset
|
63 |
String gcLog = Boolean.getBoolean("test.cds.verbose.gc") ? |
3e3764f8fe36
8207211: [TESTBUG] Remove excessive output from CDS/AppCDS tests
ccheung
parents:
49008
diff
changeset
|
64 |
"-Xlog:gc*=info,gc+region=trace,gc+alloc+region=debug" : "-showversion"; |
48138 | 65 |
|
66 |
String sharedArchiveCfgFile = |
|
67 |
System.getProperty("user.dir") + File.separator + "GCSharedStringDuringDump_gen.txt"; |
|
68 |
try (FileOutputStream fos = new FileOutputStream(sharedArchiveCfgFile)) { |
|
69 |
PrintWriter out = new PrintWriter(new OutputStreamWriter(fos)); |
|
70 |
out.println("VERSION: 1.0"); |
|
71 |
out.println("@SECTION: String"); |
|
72 |
out.println("31: shared_test_string_unique_14325"); |
|
73 |
for (int i=0; i<100000; i++) { |
|
74 |
String s = "generated_string " + i; |
|
75 |
out.println(s.length() + ": " + s); |
|
76 |
} |
|
77 |
out.close(); |
|
78 |
} |
|
79 |
||
80 |
JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox"); |
|
81 |
String whiteBoxJar = TestCommon.getTestJar("WhiteBox.jar"); |
|
82 |
String bootClassPath = "-Xbootclasspath/a:" + whiteBoxJar; |
|
83 |
||
84 |
for (int i=0; i<2; i++) { |
|
85 |
// i = 0 -- run without agent = no extra GCs |
|
86 |
// i = 1 -- run with agent = cause extra GCs |
|
87 |
||
88 |
String extraArg = (i == 0) ? "-showversion" : "-javaagent:" + agentJar; |
|
52596
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
51507
diff
changeset
|
89 |
String extraOption = (i == 0) ? "-showversion" : "-XX:+AllowArchivingWithJavaAgent"; |
48138 | 90 |
OutputAnalyzer output = TestCommon.dump( |
91 |
appJar, TestCommon.list("GCSharedStringsDuringDumpWb"), |
|
92 |
bootClassPath, extraArg, "-Xmx32m", gcLog, |
|
52596
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
51507
diff
changeset
|
93 |
"-XX:SharedArchiveConfigFile=" + sharedArchiveCfgFile, |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
51507
diff
changeset
|
94 |
"-XX:+UnlockDiagnosticVMOptions", extraOption); |
48138 | 95 |
|
96 |
if (output.getStdout().contains("Too many string space regions") || |
|
97 |
output.getStderr().contains("Unable to write archive heap memory regions") || |
|
98 |
output.getStdout().contains("Try increasing NewSize") || |
|
48201
d0d30e5d1f3b
8193065: [TESTBUG] [TESTBUG]GCSharedStringsDuringDump.java: Exception in thread "main" java.lang.RuntimeException: String is not shared.
jiangli
parents:
48138
diff
changeset
|
99 |
!output.getStdout().contains("oa0 space:") || |
48138 | 100 |
output.getExitValue() != 0) { |
101 |
// Try again with larger heap and NewSize, this should increase the |
|
102 |
// G1 heap region size to 2M |
|
103 |
TestCommon.testDump( |
|
104 |
appJar, TestCommon.list("GCSharedStringsDuringDumpWb"), |
|
105 |
bootClassPath, extraArg, "-Xmx8g", "-XX:NewSize=8m", gcLog, |
|
52596
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
51507
diff
changeset
|
106 |
"-XX:SharedArchiveConfigFile=" + sharedArchiveCfgFile, |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
51507
diff
changeset
|
107 |
"-XX:+UnlockDiagnosticVMOptions", extraOption); |
48138 | 108 |
} |
109 |
||
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48791
diff
changeset
|
110 |
TestCommon.run( |
48138 | 111 |
"-cp", appJar, |
112 |
bootClassPath, |
|
52596
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
51507
diff
changeset
|
113 |
extraArg, |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
51507
diff
changeset
|
114 |
"-Xlog:cds=info,class+path=info", |
48138 | 115 |
"-Xmx32m", |
116 |
"-XX:+PrintSharedSpaces", |
|
117 |
"-XX:+UnlockDiagnosticVMOptions", |
|
52596
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
51507
diff
changeset
|
118 |
extraOption, |
48138 | 119 |
"-XX:+WhiteBoxAPI", |
120 |
"-XX:SharedReadOnlySize=30m", |
|
121 |
gcLog, |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48791
diff
changeset
|
122 |
"GCSharedStringsDuringDumpWb") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48791
diff
changeset
|
123 |
.assertNormalExit(); |
48138 | 124 |
} |
125 |
} |
|
126 |
} |
|
127 |