1 /* 2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 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 import jdk.test.lib.OutputAnalyzer; 25 import jdk.test.lib.ProcessTools; 26 27 import java.lang.management.ManagementFactory; 28 import java.lang.management.RuntimeMXBean; 29 import java.util.ArrayList; 30 import java.util.Collections; 31 import java.util.List; 32 import compiler.whitebox.CompilerWhiteBoxTest; 33 34 /** 35 * Executes given test in a separate VM with enabled Tiered Compilation for 36 * CompilationPolicyChoice 2 and 3 37 */ 38 public class TransitionsTestExecutor { 39 public static void main(String[] args) throws Throwable { 40 if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) { 41 return; 42 } 43 if (args.length != 1) { 44 throw new Error("TESTBUG: Test name should be specified"); 45 } 46 executeTestFor(2, args[0]); 47 executeTestFor(3, args[0]); 48 } 49 50 private static void executeTestFor(int compilationPolicy, String testName) throws Throwable { 51 String policy = "-XX:CompilationPolicyChoice=" + compilationPolicy; 52 53 // Get runtime arguments including VM options given to this executor 54 RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); 55 List<String> vmArgs = runtime.getInputArguments(); 56 57 // Construct execution command with compilation policy choice and test name 58 List<String> args = new ArrayList<>(vmArgs); 59 Collections.addAll(args, policy, testName); 60 61 OutputAnalyzer out = ProcessTools.executeTestJvm(args.toArray(new String[args.size()])); 62 int exitCode = out.getExitValue(); 63 if (exitCode != 0) { 64 throw new Error("Test execution failed with exit code " + exitCode); 65 } 66 } 67 }