author | iignatyev |
Fri, 18 Aug 2017 14:54:43 -0700 | |
changeset 46826 | dae7992b1615 |
parent 46804 | db2cd95b294c |
permissions | -rw-r--r-- |
42650 | 1 |
/* |
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42650
diff
changeset
|
2 |
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
42650 | 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 |
package compiler.aot.cli.jaotc; |
|
25 |
||
46826
dae7992b1615
8183337: hotspot/compiler/aot tests fail due to missed tools
iignatyev
parents:
46804
diff
changeset
|
26 |
import compiler.aot.AotCompiler; |
dae7992b1615
8183337: hotspot/compiler/aot tests fail due to missed tools
iignatyev
parents:
46804
diff
changeset
|
27 |
|
42650 | 28 |
import java.io.File; |
29 |
import java.io.IOException; |
|
46826
dae7992b1615
8183337: hotspot/compiler/aot tests fail due to missed tools
iignatyev
parents:
46804
diff
changeset
|
30 |
|
42650 | 31 |
import jdk.test.lib.process.ExitCode; |
46804
db2cd95b294c
8174202: jtreg AOT tests should not assume library extension of .so
iignatyev
parents:
46289
diff
changeset
|
32 |
import jdk.test.lib.Platform; |
42650 | 33 |
import jdk.test.lib.JDKToolLauncher; |
34 |
import jdk.test.lib.Utils; |
|
35 |
import jdk.test.lib.cli.CommandLineOptionTest; |
|
36 |
import jdk.test.lib.process.OutputAnalyzer; |
|
46826
dae7992b1615
8183337: hotspot/compiler/aot tests fail due to missed tools
iignatyev
parents:
46804
diff
changeset
|
37 |
import jdk.test.lib.process.ProcessTools; |
42650 | 38 |
|
39 |
public class JaotcTestHelper { |
|
46804
db2cd95b294c
8174202: jtreg AOT tests should not assume library extension of .so
iignatyev
parents:
46289
diff
changeset
|
40 |
public static final String DEFAULT_LIB_PATH = "./unnamed." + Platform.sharedLibraryExt(); |
42650 | 41 |
public static final String DEFAULT_LIBRARY_LOAD_MESSAGE = "loaded " + DEFAULT_LIB_PATH |
42 |
+ " aot library"; |
|
43 |
private static final String ENABLE_AOT = "-XX:+UseAOT"; |
|
44 |
private static final String AOT_LIBRARY = "-XX:AOTLibrary=" + DEFAULT_LIB_PATH; |
|
45 |
private static final String PRINT_AOT = "-XX:+PrintAOT"; |
|
46 |
||
47 |
public static OutputAnalyzer compileLibrary(String... args) { |
|
48 |
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jaotc"); |
|
49 |
for (String vmOpt : Utils.getTestJavaOpts()) { |
|
50 |
launcher.addVMArg(vmOpt); |
|
51 |
} |
|
43425
c5dc48e6d9e6
8172054: Aot tests should include Java assertions into AOT compiled code
kvn
parents:
42650
diff
changeset
|
52 |
launcher.addToolArg("--compile-with-assertions"); |
42650 | 53 |
for (String arg : args) { |
54 |
launcher.addToolArg(arg); |
|
55 |
} |
|
46826
dae7992b1615
8183337: hotspot/compiler/aot tests fail due to missed tools
iignatyev
parents:
46804
diff
changeset
|
56 |
String linker = AotCompiler.resolveLinker(); |
dae7992b1615
8183337: hotspot/compiler/aot tests fail due to missed tools
iignatyev
parents:
46804
diff
changeset
|
57 |
if (linker != null) { |
dae7992b1615
8183337: hotspot/compiler/aot tests fail due to missed tools
iignatyev
parents:
46804
diff
changeset
|
58 |
launcher.addToolArg("--linker-path"); |
dae7992b1615
8183337: hotspot/compiler/aot tests fail due to missed tools
iignatyev
parents:
46804
diff
changeset
|
59 |
launcher.addToolArg(linker); |
dae7992b1615
8183337: hotspot/compiler/aot tests fail due to missed tools
iignatyev
parents:
46804
diff
changeset
|
60 |
} |
42650 | 61 |
String[] cmd = launcher.getCommand(); |
62 |
try { |
|
46826
dae7992b1615
8183337: hotspot/compiler/aot tests fail due to missed tools
iignatyev
parents:
46804
diff
changeset
|
63 |
return ProcessTools.executeCommand(cmd); |
dae7992b1615
8183337: hotspot/compiler/aot tests fail due to missed tools
iignatyev
parents:
46804
diff
changeset
|
64 |
} catch (Throwable e) { |
42650 | 65 |
throw new Error("Can't start test process: " + e, e); |
66 |
} |
|
67 |
} |
|
68 |
||
69 |
public static void checkLibraryUsage(String classToRun) { |
|
70 |
checkLibraryUsage(classToRun, new String[]{DEFAULT_LIBRARY_LOAD_MESSAGE}, null); |
|
71 |
} |
|
72 |
||
73 |
public static void checkLibraryUsage(String classToRun, String[] expectedOutput, |
|
74 |
String[] unexpectedOutput) { |
|
75 |
try { |
|
76 |
CommandLineOptionTest.verifyJVMStartup(expectedOutput, unexpectedOutput, |
|
77 |
"Unexpected exit code", "Unexpected output", ExitCode.OK, |
|
78 |
/* addTestVMOpts */ true, ENABLE_AOT, AOT_LIBRARY, PRINT_AOT, classToRun); |
|
79 |
} catch (Throwable t) { |
|
80 |
throw new Error("Library usage verification failed: " + t, t); |
|
81 |
} |
|
82 |
} |
|
83 |
||
43464
f38fde4a6b52
8169588: [AOT] jaotc --classpath option is confusing
rbackman
parents:
43425
diff
changeset
|
84 |
public static String getClassAotCompilationFilename(Class<?> classToCompile) { |
46289 | 85 |
return classToCompile.getName().replaceAll("\\.","/") + ".class"; |
42650 | 86 |
} |
43464
f38fde4a6b52
8169588: [AOT] jaotc --classpath option is confusing
rbackman
parents:
43425
diff
changeset
|
87 |
|
42650 | 88 |
public static String getClassAotCompilationName(Class<?> classToCompile) { |
43464
f38fde4a6b52
8169588: [AOT] jaotc --classpath option is confusing
rbackman
parents:
43425
diff
changeset
|
89 |
return classToCompile.getName(); |
42650 | 90 |
} |
91 |
} |