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 |
/* |
54927 | 2 |
* Copyright (c) 2016, 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 |
/* |
|
27 |
* @test |
|
28 |
* @summary Test case sensitive aspect of comparing class paths |
|
29 |
* between dump time and archive use time |
|
48469
7312ae4465d6
8193672: [test] Enhance vm.cds property to check for all conditions required to run CDS tests
iklam
parents:
48138
diff
changeset
|
30 |
* @requires vm.cds |
48138 | 31 |
* @library /test/lib |
57705
7cf02b2c1455
8229267: [TESTBUG] Remove unnecessary @modules dependencies in CDS tests
iklam
parents:
57567
diff
changeset
|
32 |
* @modules jdk.jartool/sun.tools.jar |
48138 | 33 |
* @requires os.family != "mac" |
34 |
* @compile test-classes/Hello.java |
|
51990
6003e034cdd8
8209946: [TESTBUG] CDS tests should use "@run driver"
iklam
parents:
48979
diff
changeset
|
35 |
* @run driver CaseSensitiveClassPath |
48138 | 36 |
*/ |
37 |
||
38 |
import java.nio.file.FileAlreadyExistsException; |
|
39 |
import java.nio.file.Files; |
|
40 |
import java.nio.file.Path; |
|
41 |
import java.nio.file.Paths; |
|
42 |
import java.nio.file.StandardCopyOption; |
|
43 |
import jdk.test.lib.Platform; |
|
44 |
import jdk.test.lib.process.OutputAnalyzer; |
|
45 |
||
46 |
||
47 |
// Excluded from running on MAC: a more comprehensive case sensitivity detection |
|
48 |
// and fix mechanism is needed, which is planned to be implemented in the future. |
|
49 |
public class CaseSensitiveClassPath { |
|
50 |
public static void main(String[] args) throws Exception { |
|
51 |
String appJar = JarBuilder.getOrCreateHelloJar(); |
|
52 |
String appJarUpper = appJar.replace("hello", "Hello"); |
|
53 |
||
54 |
OutputAnalyzer out = TestCommon.dump(appJar, TestCommon.list("Hello")); |
|
55 |
TestCommon.checkDump(out); |
|
56 |
||
57 |
Path jarPath = Paths.get(appJar); |
|
58 |
Path jarPathUpper = null; |
|
59 |
||
60 |
boolean fileExists = false; |
|
61 |
try { |
|
62 |
jarPathUpper = Files.createFile(Paths.get(appJarUpper)); |
|
63 |
} catch (FileAlreadyExistsException faee) { |
|
64 |
fileExists = true; |
|
65 |
} |
|
66 |
||
67 |
if (!fileExists) { |
|
68 |
try { |
|
69 |
Files.copy(jarPath, jarPathUpper, StandardCopyOption.REPLACE_EXISTING); |
|
70 |
} catch (Exception e) { |
|
71 |
throw new java.lang.RuntimeException( |
|
72 |
"Failed copying file from " + appJar + " to " + appJarUpper + ".", e); |
|
73 |
} |
|
74 |
} else { |
|
75 |
jarPathUpper = Paths.get(appJarUpper); |
|
76 |
} |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
77 |
boolean isSameFile = Files.isSameFile(jarPath, jarPathUpper); |
48138 | 78 |
|
54927 | 79 |
TestCommon.run("-Xlog:class+path=info,cds", "-cp", appJarUpper, "Hello") |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
80 |
.ifNoMappingFailure(output -> { |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
81 |
if (isSameFile) { |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
82 |
output.shouldContain("Hello World"); |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
83 |
} else { |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
84 |
output.shouldContain("shared class paths mismatch"); |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
85 |
output.shouldHaveExitValue(1); |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
86 |
} |
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 |
} |