author | iignatyev |
Tue, 06 Jun 2017 19:54:08 -0700 | |
changeset 45393 | de4e1efc8eec |
parent 44672 | 1359e7ce8945 |
permissions | -rw-r--r-- |
44672
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
1 |
/* |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
4 |
* |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
10 |
* |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
15 |
* accompanied this code). |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
16 |
* |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
20 |
* |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
23 |
* questions. |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
24 |
*/ |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
25 |
|
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
26 |
import java.io.File; |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
27 |
import java.nio.file.Files; |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
28 |
import java.nio.file.Path; |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
29 |
import java.nio.file.Paths; |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
30 |
import java.nio.file.StandardCopyOption; |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
31 |
import java.util.ArrayList; |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
32 |
import java.util.List; |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
33 |
import java.util.stream.Stream; |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
34 |
|
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
35 |
import jdk.testlibrary.JDKToolFinder; |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
36 |
|
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
37 |
import static jdk.testlibrary.ProcessTools.executeCommand; |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
38 |
|
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
39 |
/* |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
40 |
* @test |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
41 |
* @modules jdk.compiler |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
42 |
* @summary Test cases which run against customized image, check the situation where |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
43 |
* 1. logger providers are in unnamed module, |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
44 |
* 2. clients are in named/unnamed module, image, |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
45 |
* patched system module, or Xbootclasspath |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
46 |
* This test does not require existence of java.logging module, |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
47 |
* but require jdk.compiler module |
45393 | 48 |
* @library /lib/testlibrary /test/lib |
49 |
* @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.* |
|
44672
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
50 |
* @run main/othervm UnnamedLoggerForImageTest |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
51 |
*/ |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
52 |
|
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
53 |
public class UnnamedLoggerForImageTest extends Base { |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
54 |
|
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
55 |
public static void main(String args[]) throws Throwable { |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
56 |
UnnamedLoggerForImageTest t = new UnnamedLoggerForImageTest(); |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
57 |
t.setup(); |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
58 |
t.test(); |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
59 |
} |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
60 |
|
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
61 |
private void setup() throws Throwable { |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
62 |
setupAllClient(); |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
63 |
|
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
64 |
setupUnnamedLogger(); |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
65 |
|
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
66 |
setupJavaBaseImage(); |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
67 |
setupClientImage(); |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
68 |
} |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
69 |
|
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
70 |
private void test() throws Throwable { |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
71 |
if (!checkJMODS()) { |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
72 |
return; |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
73 |
} |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
74 |
|
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
75 |
// logger client is in unnamed module |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
76 |
runTest(IMAGE, |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
77 |
"--class-path", DEST_UNNAMED_LOGGER.toString() |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
78 |
+ File.pathSeparator + DEST_UNNAMED_CLIENT.toString(), |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
79 |
CLIENT_B, "unnamed", LOGGER_B); |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
80 |
// logger client is in named module m.t.a |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
81 |
runTest(IMAGE, |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
82 |
"--class-path", DEST_UNNAMED_LOGGER.toString(), |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
83 |
"--module-path", DEST_NAMED_CLIENT.toString(), |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
84 |
"-m", CLIENT_A, "unnamed", LOGGER_B); |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
85 |
// logger client is in named module m.t.a which is in customized image |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
86 |
runTest(IMAGE_CLIENT, |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
87 |
"--class-path", DEST_UNNAMED_LOGGER.toString(), |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
88 |
"-m", CLIENT_A, "unnamed", LOGGER_B); |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
89 |
// logger client gets logger through boot class BootUsage |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
90 |
runTest(IMAGE, |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
91 |
"--class-path", DEST_UNNAMED_LOGGER.toString() |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
92 |
+ File.pathSeparator + DEST_BOOT_CLIENT.toString(), |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
93 |
"-Xbootclasspath/a:" + DEST_BOOT_USAGE.toString(), |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
94 |
BOOT_CLIENT, "system", LAZY_LOGGER, LOGGER_B); |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
95 |
// logger client gets logger through patched class |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
96 |
// java.base/java.lang.PatchedUsage |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
97 |
runTest(IMAGE, |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
98 |
"--class-path", DEST_UNNAMED_LOGGER.toString() |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
99 |
+ File.pathSeparator + DEST_PATCHED_CLIENT.toString(), |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
100 |
"--patch-module", "java.base=" + DEST_PATCHED_USAGE.toString(), |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
101 |
PATCHED_CLIENT, "system", LAZY_LOGGER, LOGGER_B); |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
102 |
} |
1359e7ce8945
8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff
changeset
|
103 |
} |