author | alanb |
Tue, 03 May 2016 09:11:31 +0100 | |
changeset 37827 | 09fa0c82a5f7 |
parent 34155 | 8d9e0cbf93a2 |
child 40059 | c2304140ed64 |
permissions | -rw-r--r-- |
28194
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
1 |
/* |
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
28194
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
28194
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
4 |
* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
8 |
* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
13 |
* accompanied this code). |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
14 |
* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
18 |
* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
21 |
* questions. |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
22 |
*/ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
23 |
|
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
28194
diff
changeset
|
24 |
import jdk.test.lib.OutputAnalyzer; |
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
28194
diff
changeset
|
25 |
import jdk.test.lib.ProcessTools; |
28194
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
26 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
27 |
import java.lang.management.ManagementFactory; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
28 |
import java.lang.management.RuntimeMXBean; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
29 |
import java.util.ArrayList; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
30 |
import java.util.Collections; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
31 |
import java.util.List; |
34155
8d9e0cbf93a2
8138689: use package for /compiler/whitebox common classes
dpochepk
parents:
30604
diff
changeset
|
32 |
import compiler.whitebox.CompilerWhiteBoxTest; |
28194
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
33 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
34 |
/** |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
35 |
* Executes given test in a separate VM with enabled Tiered Compilation for |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
36 |
* CompilationPolicyChoice 2 and 3 |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
37 |
*/ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
38 |
public class TransitionsTestExecutor { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
39 |
public static void main(String[] args) throws Throwable { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
40 |
if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
41 |
return; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
42 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
43 |
if (args.length != 1) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
44 |
throw new Error("TESTBUG: Test name should be specified"); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
45 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
46 |
executeTestFor(2, args[0]); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
47 |
executeTestFor(3, args[0]); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
48 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
49 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
50 |
private static void executeTestFor(int compilationPolicy, String testName) throws Throwable { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
51 |
String policy = "-XX:CompilationPolicyChoice=" + compilationPolicy; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
52 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
53 |
// Get runtime arguments including VM options given to this executor |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
54 |
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
55 |
List<String> vmArgs = runtime.getInputArguments(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
56 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
57 |
// Construct execution command with compilation policy choice and test name |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
58 |
List<String> args = new ArrayList<>(vmArgs); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
59 |
Collections.addAll(args, policy, testName); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
60 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
61 |
OutputAnalyzer out = ProcessTools.executeTestJvm(args.toArray(new String[args.size()])); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
62 |
int exitCode = out.getExitValue(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
63 |
if (exitCode != 0) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
64 |
throw new Error("Test execution failed with exit code " + exitCode); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
65 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
66 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
67 |
} |