test/compiler/tiered/TransitionsTestExecutor.java

Mon, 03 Jun 2019 16:14:54 +0100

author
xliu
date
Mon, 03 Jun 2019 16:14:54 +0100
changeset 9689
89dcef434423
permissions
-rw-r--r--

8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
Summary: Includes compile_id addition from JDK-8054492
Reviewed-by: andrew

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

mercurial