author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 58023 | 06f3d5092832 |
permissions | -rw-r--r-- |
48138 | 1 |
/* |
57567
b000362a89a0
8202339: [TESTBUG] Consolidate the tests in runtime/SharedArchiveFile and runtime/appcds
coleenp
parents:
51990
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 Class-Path: attribute in MANIFEST file |
|
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 |
58023
06f3d5092832
8230632: [TESTBUG] appcds/NonExistClasspath.java and ClassPathAttr.java failed when running in hotspot_appcds_dynamic test group
ccheung
parents:
57898
diff
changeset
|
31 |
* @run driver/timeout=240 ClassPathAttr |
48138 | 32 |
*/ |
33 |
||
34 |
import jdk.test.lib.process.OutputAnalyzer; |
|
35 |
import java.io.File; |
|
36 |
import java.nio.file.Files; |
|
37 |
import java.nio.file.FileAlreadyExistsException; |
|
38 |
import java.nio.file.StandardCopyOption; |
|
39 |
import java.nio.file.Paths; |
|
40 |
||
41 |
||
42 |
public class ClassPathAttr { |
|
43 |
||
44 |
public static void main(String[] args) throws Exception { |
|
57898 | 45 |
testNormalOps(); |
46 |
testNonExistentJars(); |
|
47 |
} |
|
48 |
||
49 |
static void testNormalOps() throws Exception { |
|
48138 | 50 |
buildCpAttr("cpattr1", "cpattr1.mf", "CpAttr1", "CpAttr1"); |
51 |
buildCpAttr("cpattr1_long", "cpattr1_long.mf", "CpAttr1", "CpAttr1"); |
|
52 |
buildCpAttr("cpattr2", "cpattr2.mf", "CpAttr2", "CpAttr2"); |
|
53 |
buildCpAttr("cpattr3", "cpattr3.mf", "CpAttr3", "CpAttr2", "CpAttr3"); |
|
54 |
buildCpAttr("cpattr4", "cpattr4.mf", "CpAttr4", |
|
55 |
"CpAttr2", "CpAttr3", "CpAttr4", "CpAttr5"); |
|
56 |
buildCpAttr("cpattr5_123456789_223456789_323456789_423456789_523456789_623456789", "cpattr5_extra_long.mf", "CpAttr5", "CpAttr5"); |
|
57 |
||
58 |
for (int i=1; i<=2; i++) { |
|
59 |
String jar1 = TestCommon.getTestJar("cpattr1.jar"); |
|
60 |
String jar4 = TestCommon.getTestJar("cpattr4.jar"); |
|
61 |
if (i == 2) { |
|
62 |
// Test case #2 -- same as #1, except we use cpattr1_long.jar, which has a super-long |
|
63 |
// Class-Path: attribute. |
|
64 |
jar1 = TestCommon.getTestJar("cpattr1_long.jar"); |
|
65 |
} |
|
66 |
String cp = jar1 + File.pathSeparator + jar4; |
|
67 |
||
68 |
TestCommon.testDump(cp, TestCommon.list("CpAttr1", |
|
69 |
"CpAttr2", |
|
70 |
"CpAttr3", |
|
71 |
"CpAttr4", |
|
72 |
"CpAttr5")); |
|
73 |
||
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
74 |
TestCommon.run( |
48138 | 75 |
"-cp", cp, |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
76 |
"CpAttr1") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
77 |
.assertNormalExit(); |
48138 | 78 |
|
79 |
// Logging test for class+path. |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
80 |
TestCommon.run( |
48138 | 81 |
"-Xlog:class+path", |
82 |
"-cp", cp, |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
83 |
"CpAttr1") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
84 |
.assertNormalExit(output -> { |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
85 |
output.shouldMatch("checking shared classpath entry: .*cpattr2.jar"); |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
86 |
output.shouldMatch("checking shared classpath entry: .*cpattr3.jar"); |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
87 |
}); |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
88 |
|
48138 | 89 |
// Make sure aliased TraceClassPaths still works |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
90 |
TestCommon.run( |
48138 | 91 |
"-XX:+TraceClassPaths", |
92 |
"-cp", cp, |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
93 |
"CpAttr1") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
94 |
.assertNormalExit(output -> { |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
95 |
output.shouldMatch("checking shared classpath entry: .*cpattr2.jar"); |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
96 |
output.shouldMatch("checking shared classpath entry: .*cpattr3.jar"); |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
97 |
}); |
48138 | 98 |
} |
99 |
} |
|
100 |
||
57898 | 101 |
static void testNonExistentJars() throws Exception { |
102 |
buildCpAttr("cpattr6", "cpattr6.mf", "CpAttr6", "CpAttr6"); |
|
103 |
||
104 |
String cp = TestCommon.getTestJar("cpattr6.jar"); |
|
105 |
String nonExistPath = System.getProperty("test.classes") + File.separator + "cpattrX.jar"; |
|
106 |
(new File(nonExistPath)).delete(); |
|
107 |
||
108 |
TestCommon.testDump(cp, TestCommon.list("CpAttr6"), |
|
109 |
"-Xlog:class+path"); |
|
110 |
||
111 |
TestCommon.run( |
|
112 |
"-Xlog:class+path", |
|
113 |
"-cp", cp, |
|
114 |
"CpAttr6") |
|
115 |
.assertNormalExit(output -> { |
|
116 |
output.shouldMatch("should be non-existent: .*cpattrX.jar"); |
|
117 |
}); |
|
118 |
||
119 |
// Now make nonExistPath exist. CDS still loads, but archived non-system classes will not be used. |
|
120 |
Files.copy(Paths.get(cp), Paths.get(nonExistPath), |
|
121 |
StandardCopyOption.REPLACE_EXISTING); |
|
122 |
||
123 |
TestCommon.run( |
|
124 |
"-Xlog:class+path", |
|
125 |
"-cp", cp, |
|
126 |
"CpAttr6") |
|
127 |
.assertNormalExit(output -> { |
|
128 |
output.shouldMatch("Archived non-system classes are disabled because the file .*cpattrX.jar exists"); |
|
129 |
}); |
|
130 |
} |
|
131 |
||
48138 | 132 |
private static void buildCpAttr(String jarName, String manifest, String enclosingClassName, String ...testClassNames) throws Exception { |
133 |
String jarClassesDir = System.getProperty("test.classes") + File.separator + jarName + "_classes"; |
|
134 |
try { Files.createDirectory(Paths.get(jarClassesDir)); } catch (FileAlreadyExistsException e) { } |
|
135 |
||
136 |
JarBuilder.compile(jarClassesDir, System.getProperty("test.src") + File.separator + |
|
137 |
"test-classes" + File.separator + enclosingClassName + ".java"); |
|
138 |
JarBuilder.buildWithManifest(jarName, manifest, jarClassesDir, testClassNames); |
|
139 |
} |
|
140 |
} |