author | iklam |
Fri, 09 Aug 2019 13:13:36 -0700 | |
changeset 57705 | 7cf02b2c1455 |
parent 57567 | b000362a89a0 |
child 57898 | 5ddb746d45e0 |
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 |
51990
6003e034cdd8
8209946: [TESTBUG] CDS tests should use "@run driver"
iklam
parents:
48979
diff
changeset
|
31 |
* @run driver 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 { |
|
45 |
buildCpAttr("cpattr1", "cpattr1.mf", "CpAttr1", "CpAttr1"); |
|
46 |
buildCpAttr("cpattr1_long", "cpattr1_long.mf", "CpAttr1", "CpAttr1"); |
|
47 |
buildCpAttr("cpattr2", "cpattr2.mf", "CpAttr2", "CpAttr2"); |
|
48 |
buildCpAttr("cpattr3", "cpattr3.mf", "CpAttr3", "CpAttr2", "CpAttr3"); |
|
49 |
buildCpAttr("cpattr4", "cpattr4.mf", "CpAttr4", |
|
50 |
"CpAttr2", "CpAttr3", "CpAttr4", "CpAttr5"); |
|
51 |
buildCpAttr("cpattr5_123456789_223456789_323456789_423456789_523456789_623456789", "cpattr5_extra_long.mf", "CpAttr5", "CpAttr5"); |
|
52 |
||
53 |
for (int i=1; i<=2; i++) { |
|
54 |
String jar1 = TestCommon.getTestJar("cpattr1.jar"); |
|
55 |
String jar4 = TestCommon.getTestJar("cpattr4.jar"); |
|
56 |
if (i == 2) { |
|
57 |
// Test case #2 -- same as #1, except we use cpattr1_long.jar, which has a super-long |
|
58 |
// Class-Path: attribute. |
|
59 |
jar1 = TestCommon.getTestJar("cpattr1_long.jar"); |
|
60 |
} |
|
61 |
String cp = jar1 + File.pathSeparator + jar4; |
|
62 |
||
63 |
TestCommon.testDump(cp, TestCommon.list("CpAttr1", |
|
64 |
"CpAttr2", |
|
65 |
"CpAttr3", |
|
66 |
"CpAttr4", |
|
67 |
"CpAttr5")); |
|
68 |
||
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 |
"CpAttr1") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
72 |
.assertNormalExit(); |
48138 | 73 |
|
74 |
// Logging test for class+path. |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
75 |
TestCommon.run( |
48138 | 76 |
"-Xlog:class+path", |
77 |
"-cp", cp, |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
78 |
"CpAttr1") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
79 |
.assertNormalExit(output -> { |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
80 |
output.shouldMatch("checking shared classpath entry: .*cpattr2.jar"); |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
81 |
output.shouldMatch("checking shared classpath entry: .*cpattr3.jar"); |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
82 |
}); |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
83 |
|
48138 | 84 |
// Make sure aliased TraceClassPaths still works |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
85 |
TestCommon.run( |
48138 | 86 |
"-XX:+TraceClassPaths", |
87 |
"-cp", cp, |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
88 |
"CpAttr1") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
89 |
.assertNormalExit(output -> { |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
90 |
output.shouldMatch("checking shared classpath entry: .*cpattr2.jar"); |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
91 |
output.shouldMatch("checking shared classpath entry: .*cpattr3.jar"); |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
92 |
}); |
48138 | 93 |
} |
94 |
} |
|
95 |
||
96 |
private static void buildCpAttr(String jarName, String manifest, String enclosingClassName, String ...testClassNames) throws Exception { |
|
97 |
String jarClassesDir = System.getProperty("test.classes") + File.separator + jarName + "_classes"; |
|
98 |
try { Files.createDirectory(Paths.get(jarClassesDir)); } catch (FileAlreadyExistsException e) { } |
|
99 |
||
100 |
JarBuilder.compile(jarClassesDir, System.getProperty("test.src") + File.separator + |
|
101 |
"test-classes" + File.separator + enclosingClassName + ".java"); |
|
102 |
JarBuilder.buildWithManifest(jarName, manifest, jarClassesDir, testClassNames); |
|
103 |
} |
|
104 |
} |