author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 57705 | 7cf02b2c1455 |
permissions | -rw-r--r-- |
48138 | 1 |
/* |
57567
b000362a89a0
8202339: [TESTBUG] Consolidate the tests in runtime/SharedArchiveFile and runtime/appcds
coleenp
parents:
55524
diff
changeset
|
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 |
|
27 |
* @summary test the -XX:+PrintSharedArchiveAndExit flag |
|
48469
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.cds |
48138 | 29 |
* @library /test/lib |
57705
7cf02b2c1455
8229267: [TESTBUG] Remove unnecessary @modules dependencies in CDS tests
iklam
parents:
57567
diff
changeset
|
30 |
* @modules jdk.jartool/sun.tools.jar |
48138 | 31 |
* @compile test-classes/Hello.java |
32 |
* @compile test-classes/HelloMore.java |
|
33 |
* @run main/othervm/timeout=3600 PrintSharedArchiveAndExit |
|
34 |
*/ |
|
35 |
||
36 |
import java.io.File; |
|
37 |
import jdk.test.lib.process.OutputAnalyzer; |
|
38 |
||
39 |
public class PrintSharedArchiveAndExit { |
|
40 |
private static void check(OutputAnalyzer output, int ret, boolean checkContain, String... matches) throws Exception { |
|
41 |
// Tests specific to this test |
|
42 |
TestCommon.checkExecReturn(output, ret, checkContain, matches); |
|
43 |
||
44 |
// In all test case, we should never print out the following due to |
|
45 |
// PrintSharedArchiveAndExit. JVM should have been terminated |
|
46 |
// before reaching these outputs. |
|
47 |
TestCommon.checkExecReturn(output, ret, false, |
|
48 |
"Usage:", // JVM help message |
|
49 |
"java version", // JVM version |
|
50 |
"Hello World"); // output from the Hello.class in hello.jar |
|
51 |
} |
|
52 |
||
53 |
private static void log(String msg) { |
|
54 |
System.out.println(">---------------------------------------------------------------------"); |
|
55 |
System.out.println(msg); |
|
56 |
System.out.println("<---------------------------------------------------------------------"); |
|
57 |
} |
|
58 |
||
59 |
public static void main(String[] args) throws Exception { |
|
60 |
String appJar = JarBuilder.getOrCreateHelloJar(); |
|
61 |
String appJar2 = JarBuilder.build("PrintSharedArchiveAndExit-more", "HelloMore"); |
|
62 |
||
63 |
String cp = appJar + File.pathSeparator + appJar2; |
|
64 |
String lastCheckMsg = "checking shared classpath entry: " + appJar2; // the last JAR to check |
|
65 |
||
51439
0517bd2a0eda
8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents:
48979
diff
changeset
|
66 |
TestCommon.testDump(cp, TestCommon.list("Hello", "HelloMore")); |
48138 | 67 |
|
68 |
log("Normal execution -- all the JAR paths should be checked"); |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
69 |
TestCommon.run( |
48138 | 70 |
"-cp", cp, |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
71 |
"-XX:+PrintSharedArchiveAndExit") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
72 |
.ifNoMappingFailure(output -> check(output, 0, true, lastCheckMsg)); |
48138 | 73 |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
74 |
TestCommon.run( |
48138 | 75 |
"-cp", cp, |
76 |
"-XX:+PrintSharedArchiveAndExit", |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
77 |
"-XX:+PrintSharedDictionary") // Test PrintSharedDictionary as well. |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
78 |
.ifNoMappingFailure(output -> check(output, 0, true, lastCheckMsg, "java.lang.Object")); |
48138 | 79 |
|
80 |
log("Normal execution -- Make sure -version, help message and app main()\n" + |
|
81 |
"class are not invoked. These are checked inside check()."); |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
82 |
TestCommon.run("-cp", cp, "-XX:+PrintSharedArchiveAndExit", "-version") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
83 |
.ifNoMappingFailure(output -> check(output, 0, true, lastCheckMsg)); |
48138 | 84 |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
85 |
TestCommon.run("-cp", cp, "-XX:+PrintSharedArchiveAndExit", "-help") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
86 |
.ifNoMappingFailure(output -> check(output, 0, true, lastCheckMsg)); |
48138 | 87 |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
88 |
TestCommon.run("-cp", cp, "-XX:+PrintSharedArchiveAndExit", "Hello") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
89 |
.ifNoMappingFailure(output -> check(output, 0, true, lastCheckMsg)); |
48138 | 90 |
|
91 |
log("Execution with simple errors -- with 'simple' errors like missing or modified\n" + |
|
92 |
"JAR files, the VM should try to continue to print the remaining information.\n" + |
|
93 |
"Use an invalid Boot CP -- all the JAR paths should be checked"); |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
94 |
TestCommon.run( |
48138 | 95 |
"-cp", cp, |
96 |
"-Xbootclasspath/a:foo.jar", |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
97 |
"-XX:+PrintSharedArchiveAndExit") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
98 |
.ifNoMappingFailure(output -> check(output, 1, true, lastCheckMsg, "[BOOT classpath mismatch, ")); |
48138 | 99 |
|
100 |
log("Use an App CP shorter than the one at dump time -- all the JAR paths should be checked"); |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
101 |
TestCommon.run( |
48138 | 102 |
"-cp", ".", |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
103 |
"-XX:+PrintSharedArchiveAndExit") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
104 |
.ifNoMappingFailure(output -> check(output, 1, true, lastCheckMsg, "Run time APP classpath is shorter than the one at dump time: .")); |
48138 | 105 |
|
55524
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
51439
diff
changeset
|
106 |
log("Use an invalid App CP -- all the JAR paths should be checked.\n" + |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
51439
diff
changeset
|
107 |
"Non-existing jar files will be ignored."); |
48138 | 108 |
String invalidCP = "non-existing-dir" + File.pathSeparator + cp; |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
109 |
TestCommon.run( |
48138 | 110 |
"-cp", invalidCP, |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
111 |
"-XX:+PrintSharedArchiveAndExit") |
55524
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
51439
diff
changeset
|
112 |
.ifNoMappingFailure(output -> check(output, 0, true, lastCheckMsg)); |
48138 | 113 |
|
114 |
log("Changed modification time of hello.jar -- all the JAR paths should be checked"); |
|
115 |
(new File(appJar)).setLastModified(System.currentTimeMillis() + 2000); |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
116 |
TestCommon.run( |
48138 | 117 |
"-cp", cp, |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
118 |
"-XX:+PrintSharedArchiveAndExit") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
119 |
.ifNoMappingFailure(output -> check(output, 1, true, lastCheckMsg, "[Timestamp mismatch]")); |
48138 | 120 |
|
121 |
log("Even if hello.jar is out of date, we should still be able to print the dictionary."); |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
122 |
TestCommon.run( |
48138 | 123 |
"-cp", cp, |
124 |
"-XX:+PrintSharedArchiveAndExit", |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
125 |
"-XX:+PrintSharedDictionary") // Test PrintSharedDictionary as well. |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
126 |
.ifNoMappingFailure(output -> check(output, 1, true, lastCheckMsg, "java.lang.Object")); |
48138 | 127 |
|
128 |
||
129 |
log("Remove hello.jar -- all the JAR paths should be checked"); |
|
130 |
(new File(appJar)).delete(); |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
131 |
TestCommon.run( |
48138 | 132 |
"-cp", cp, |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
133 |
"-XX:+PrintSharedArchiveAndExit") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
134 |
.ifNoMappingFailure(output -> check(output, 1, true, lastCheckMsg, "[Required classpath entry does not exist: " + appJar + "]")); |
48138 | 135 |
|
136 |
log("Execution with major errors -- with 'major' errors like the JSA file\n" + |
|
137 |
"is missing, we should stop immediately to avoid crashing the JVM."); |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
138 |
TestCommon.run( |
48138 | 139 |
"-cp", cp, |
140 |
"-XX:+PrintSharedArchiveAndExit", |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
141 |
"-XX:SharedArchiveFile=./no-such-fileappcds.jsa") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
142 |
.ifNoMappingFailure(output -> check(output, 1, false, lastCheckMsg)); |
48138 | 143 |
} |
144 |
} |