Java Code Examples for jdk.test.lib.process.ProcessTools#executeTestJvm()

The following examples show how to use jdk.test.lib.process.ProcessTools#executeTestJvm() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestInstrumentation.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void launchTest() throws Throwable {
    final String slash = File.separator;

    // Need to add jdk/lib/tools.jar to classpath.
    String classpath =
        System.getProperty("test.class.path", "") + File.pathSeparator +
        System.getProperty("test.jdk", ".") + slash + "lib" + slash + "tools.jar";
    String testClassDir = System.getProperty("test.classes", "") + slash;

    String[] args = {
        "-Xbootclasspath/a:" + testClassDir + "InstrumentationCallback.jar",
       /* "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",*/
        "-classpath", classpath,
        "-javaagent:" + testClassDir + "TestInstrumentation.jar",
        "jdk.jfr.event.io.TestInstrumentation$TestMain" };
    OutputAnalyzer output = ProcessTools.executeTestJvm(args);
    output.shouldHaveExitValue(0);
}
 
Example 2
Source File: TestInstrumentation.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void launchTest() throws Throwable {
    final String slash = File.separator;

    // Need to add jdk/lib/tools.jar to classpath.
    String classpath =
        System.getProperty("test.class.path", "") + File.pathSeparator +
        System.getProperty("test.jdk", ".") + slash + "lib" + slash + "tools.jar";
    String testClassDir = System.getProperty("test.classes", "") + slash;

    String[] args = {
        "-Xbootclasspath/a:" + testClassDir + "InstrumentationCallback.jar",
       /* "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",*/
        "-classpath", classpath,
        "-javaagent:" + testClassDir + "TestInstrumentation.jar",
        "jdk.jfr.event.io.TestInstrumentation$TestMain" };
    OutputAnalyzer output = ProcessTools.executeTestJvm(args);
    output.shouldHaveExitValue(0);
}
 
Example 3
Source File: TestAESIntrinsicsOnSupportedConfig.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test checks following situation: <br/>
 * UseAES flag is set to false, UseVIS flag is set to 2,
 * Platform should support UseVIS (sparc) <br/>
 * TestAESMain is executed <br/>
 * Expected result: UseAESIntrinsics flag is set to false <br/>
 * Output shouldn't contain intrinsics usage <br/>
 *
 * @throws Throwable
 */
private void testNoUseAESUseVIS2() throws Throwable {
    if (Platform.isSparc()) {
        OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
                prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
                                .USE_AES, false),
                        prepareNumericFlag(AESIntrinsicsBase.USE_VIS, 2)));
        final String errorMessage = "Case testNoUseAESUseVIS2 failed";
        verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC,
                        AESIntrinsicsBase.AES_INTRINSIC},
                errorMessage, outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage,
                outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false",
                errorMessage, outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_VIS, "2", errorMessage,
                outputAnalyzer);
    }
}
 
Example 4
Source File: TestAESIntrinsicsOnSupportedConfig.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test checks following situation: <br/>
 * UseAES flag is set to true, UseVIS flag is set to 2,
 * Platform should support UseVIS (sparc) <br/>
 * TestAESMain is executed <br/>
 * Expected result: UseAESIntrinsics flag is set to false <br/>
 * Output shouldn't contain intrinsics usage <br/>
 *
 * @throws Throwable
 */
private void testUseAESUseVIS2() throws Throwable {
    if (Platform.isSparc()) {
        OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
                prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
                                .USE_AES_INTRINSICS, true),
                        prepareNumericFlag(AESIntrinsicsBase.USE_VIS, 2)));
        final String errorMessage = "Case testUseAESUseVIS2 failed";
        verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC,
                        AESIntrinsicsBase.AES_INTRINSIC},
                errorMessage, outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_AES, "true", errorMessage,
                outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false",
                errorMessage, outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_VIS, "2", errorMessage,
                outputAnalyzer);
    }
}
 
Example 5
Source File: RandomGeneratorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies that the original output meets expectations
 * depending on the test mode. It compares the output of second execution
 * to original one.
 * @param orig original output
 * @param cmdLine command line arguments
 * @throws Throwable - Throws an exception in case test failure.
 */
public void verify(String orig, String[] cmdLine) {
    String output;
    OutputAnalyzer oa;
    try {
        oa = ProcessTools.executeTestJvm(cmdLine);
    } catch (Throwable t) {
        throw new Error("TESTBUG: Unexpedted exception during jvm execution.", t);
    }
    oa.shouldHaveExitValue(0);
    try {
        output = Utils.fileAsString(name()).trim();
    } catch (IOException ioe) {
        throw new Error("TESTBUG: Problem during IO operation with file: " + name(), ioe);
    }
    if (!isOutputExpected(orig, output)) {
        System.err.println("Initial output: " + orig);
        System.err.println("Second run output: " + output);
        throw new AssertionError("Unexpected random number sequence for mode: " + this.name());
    }
}
 
Example 6
Source File: TestAESIntrinsicsOnSupportedConfig.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test checks following situation: <br/>
 * UseAES flag is set to false, UseSSE flag is set to 2,
 * Platform should support UseSSE (x86 or x64) <br/>
 * TestAESMain is executed <br/>
 * Expected result: UseAESIntrinsics flag is set to false <br/>
 * Output shouldn't contain intrinsics usage <br/>
 *
 * @throws Throwable
 */
private void testNoUseAESUseSSE2() throws Throwable {
    if (Platform.isX86() || Platform.isX64()) {
        OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
                prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
                                .USE_AES, false),
                        prepareNumericFlag(AESIntrinsicsBase.USE_SSE, 2)));
        final String errorMessage = "Case testNoUseAESUseSSE2 failed";
        verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC,
                        AESIntrinsicsBase.AES_INTRINSIC},
                errorMessage, outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage,
                outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false",
                errorMessage, outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_SSE, "2", errorMessage,
                outputAnalyzer);
    }
}
 
Example 7
Source File: TestAESIntrinsicsOnSupportedConfig.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test checks following situation: <br/>
 * UseAES flag is set to true, UseSSE flag is set to 2,
 * Platform should support UseSSE (x86 or x64) <br/>
 * TestAESMain is executed <br/>
 * Expected result: UseAESIntrinsics flag is set to false <br/>
 * Output shouldn't contain intrinsics usage <br/>
 *
 * @throws Throwable
 */
private void testUseAESUseSSE2() throws Throwable {
    if (Platform.isX86() || Platform.isX64()) {
        OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
                prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
                                .USE_AES_INTRINSICS, true),
                        prepareNumericFlag(AESIntrinsicsBase.USE_SSE, 2)));
        final String errorMessage = "Case testUseAESUseSSE2 failed";
        verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC,
                        AESIntrinsicsBase.AES_INTRINSIC},
                errorMessage, outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_AES, "true", errorMessage,
                outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false",
                errorMessage, outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_SSE, "2", errorMessage,
                outputAnalyzer);
    }
}
 
Example 8
Source File: TestAESIntrinsicsOnSupportedConfig.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test checks following situation: <br/>
 * UseAES flag is set to true, TestAESMain is executed <br/>
 * Expected result: UseAESIntrinsics flag is set to true <br/>
 * If vm type is server then output should contain intrinsics usage <br/>
 *
 * @throws Throwable
 */
private void testUseAES() throws Throwable {
    OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
            prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
                    .USE_AES, true)));
    final String errorMessage = "Case testUseAES failed";
    if (Platform.isServer() && !Platform.isEmulatedClient()) {
        verifyOutput(new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC,
                AESIntrinsicsBase.AES_INTRINSIC}, null, errorMessage,
                outputAnalyzer);
    } else {
        verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC,
                AESIntrinsicsBase.AES_INTRINSIC}, errorMessage,
                outputAnalyzer);
    }
    verifyOptionValue(AESIntrinsicsBase.USE_AES, "true", errorMessage,
            outputAnalyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "true",
            errorMessage, outputAnalyzer);
}
 
Example 9
Source File: TestAESIntrinsicsOnSupportedConfig.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test checks following situation: <br/>
 * UseAESIntrinsics flag is set to false, TestAESMain is executed <br/>
 * Expected result: UseAES flag is set to true <br/>
 * Output shouldn't contain intrinsics usage <br/>
 *
 * @throws Throwable
 */
private void testNoUseAESIntrinsic() throws Throwable {
    OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
            prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
                    .USE_AES_INTRINSICS, false)));
    final String errorMessage = "Case testNoUseAESIntrinsic failed";
    verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC,
                    AESIntrinsicsBase.AES_INTRINSIC}, errorMessage,
            outputAnalyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES, "true", errorMessage,
            outputAnalyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false",
            errorMessage, outputAnalyzer);
}
 
Example 10
Source File: TestAESIntrinsicsOnSupportedConfig.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test checks following situation: <br/>
 * UseAES flag is set to false, TestAESMain is executed <br/>
 * Expected result: UseAESIntrinsics flag is set to false <br/>
 * Output shouldn't contain intrinsics usage <br/>
 *
 * @throws Throwable
 */
private void testNoUseAES() throws Throwable {
    OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
            prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
                    .USE_AES, false)));
    final String errorMessage = "Case testNoUseAES failed";
    verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC,
                    AESIntrinsicsBase.AES_INTRINSIC},
            errorMessage, outputAnalyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage,
            outputAnalyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false",
            errorMessage, outputAnalyzer);
}
 
Example 11
Source File: TestAESIntrinsicsOnUnsupportedConfig.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test checks following situation: <br/>
 * UseAESIntrinsics flag is set to true, TestAESMain is executed <br/>
 * Expected result: UseAESIntrinsics flag is set to false <br/>
 * UseAES flag is set to false <br/>
 * Output shouldn't contain intrinsics usage <br/>
 * Output should contain message about intrinsics unavailability
 * @throws Throwable
 */
private void testUseAESIntrinsics() throws Throwable {
    OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
            AESIntrinsicsBase.prepareArguments(prepareBooleanFlag(
                    AESIntrinsicsBase.USE_AES_INTRINSICS, true)));
    final String errorMessage = "Case testUseAESIntrinsics failed";
    verifyOutput(new String[] {INTRINSICS_NOT_AVAILABLE_MSG},
            new String[] {AESIntrinsicsBase.CIPHER_INTRINSIC,
                    AESIntrinsicsBase.AES_INTRINSIC},
            errorMessage, outputAnalyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false",
            errorMessage, outputAnalyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage,
            outputAnalyzer);
}
 
Example 12
Source File: HugeDirectiveUtil.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected static OutputAnalyzer execute(String fileName) {
    OutputAnalyzer output;
    try {
        output = ProcessTools.executeTestJvm(
                "-XX:+UnlockDiagnosticVMOptions",
                "-XX:CompilerDirectivesLimit=1000",
                "-XX:CompilerDirectivesFile=" + fileName,
                "-version");
    } catch (Throwable thr) {
        throw new Error("Execution failed with: " + thr, thr);
    }
    return output;
}
 
Example 13
Source File: TransitionsTestExecutor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void executeTestFor(int compilationPolicy, String testName) throws Throwable {
    String policy = "-XX:CompilationPolicyChoice=" + compilationPolicy;

    // Get runtime arguments including VM options given to this executor
    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
    List<String> vmArgs = runtime.getInputArguments();

    // Construct execution command with compilation policy choice and test name
    List<String> args = new ArrayList<>(vmArgs);
    Collections.addAll(args, policy, testName);

    OutputAnalyzer out = ProcessTools.executeTestJvm(args.toArray(new String[args.size()]));
    out.shouldHaveExitValue(0);
}
 
Example 14
Source File: UseCountedLoopSafepointsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void check(boolean enabled) {
    OutputAnalyzer oa;
    try {
        oa = ProcessTools.executeTestJvm("-XX:+UnlockDiagnosticVMOptions", "-Xbootclasspath/a:.",
                "-XX:" + (enabled ? "+" : "-") + "UseCountedLoopSafepoints", "-XX:+WhiteBoxAPI",
                "-XX:-Inline", "-Xbatch", "-XX:+PrintIdeal", "-XX:LoopUnrollLimit=0",
                "-XX:CompileOnly=" + UseCountedLoopSafepoints.class.getName() + "::testMethod",
                UseCountedLoopSafepoints.class.getName());
    } catch (Exception e) {
        throw new Error("Exception launching child for case enabled=" + enabled + " : " + e, e);
    }
    oa.shouldHaveExitValue(0);
    // parse output in seach of SafePoint and CountedLoopEnd nodes
    List<Node> safePoints = new ArrayList<>();
    List<Node> loopEnds = new ArrayList<>();
    for (String line : oa.getOutput().split("\\n")) {
        int separatorIndex = line.indexOf("\t===");
        if (separatorIndex > -1) {
            String header = line.substring(0, separatorIndex);
            if (header.endsWith("\tSafePoint")) {
                safePoints.add(new Node("SafePoint", line));
            } else if (header.endsWith("\tCountedLoopEnd")) {
                loopEnds.add(new Node("CountedLoopEnd", line));
            }
        }
    }
    // now, find CountedLoopEnd -> SafePoint edge
    boolean found = false;
    for (Node loopEnd : loopEnds) {
        found |= loopEnd.to.stream()
                             .filter(id -> nodeListHasElementWithId(safePoints, id))
                             .findAny()
                             .isPresent();
    }
    Asserts.assertEQ(enabled, found, "Safepoint " + (found ? "" : "not ") + "found");
}
 
Example 15
Source File: Test6857159.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
    String className = Test.class.getName();
    OutputAnalyzer analyzer = ProcessTools.executeTestJvm("-Xbatch",
            "-XX:+PrintCompilation",
            "-XX:CompileOnly="+ className + "$ct::run",
            className);
    analyzer.shouldNotContain("COMPILE SKIPPED");
    analyzer.shouldContain(className + "$ct0::run (16 bytes)");
    analyzer.shouldHaveExitValue(0);
}
 
Example 16
Source File: TestRedefineWithUnresolvedClass.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void launchTest() throws Throwable {
    String[] args = {
        "-javaagent:" + testClasses + "UnresolvedClassAgent.jar",
        "-Dtest.classes=" + testClasses,
        "UnresolvedClassAgent" };
    OutputAnalyzer output = ProcessTools.executeTestJvm(args);
    output.shouldHaveExitValue(0);
}
 
Example 17
Source File: TestIHOPErgo.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static OutputAnalyzer executeTest(List<String> options) throws Throwable, RuntimeException {
    OutputAnalyzer out;
    out = ProcessTools.executeTestJvm(options.toArray(new String[options.size()]));
    if (out.getExitValue() != 0) {
        System.out.println(out.getOutput());
        throw new RuntimeException("AppIHOP failed with exit code" + out.getExitValue());
    }
    return out;
}
 
Example 18
Source File: TestG1LoggingFailure.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void startVM(List<String> options) throws Throwable, RuntimeException {
    OutputAnalyzer out = ProcessTools.executeTestJvm(options.toArray(new String[options.size()]));

    out.shouldNotContain("pure virtual method called");

    if (out.getExitValue() == 0) {
        System.out.println(out.getOutput());
        throw new RuntimeException("Expects Alloc failure.");
    }
}
 
Example 19
Source File: BMITestRunner.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Execute tests on methods implemented by <b>expr</b> in new VM
 * started in <b>testVMMode</b> mode.
 *
 * @param expr operation that should be tested
 * @param testVMMode VM mode for test
 * @param additionalVMOpts additional options for VM
 * @param seed for RNG used it tests
 * @param iterations that will be used to invoke <b>expr</b>'s methods.
 *
 * @return OutputAnalyzer for executed test.
 * @throws Throwable when something goes wrong.
 */
public static OutputAnalyzer runTest(Class<? extends Expr> expr,
                                     VMMode testVMMode,
                                     String additionalVMOpts[],
                                     int seed, int iterations)
                              throws Throwable {

    List<String> vmOpts = new LinkedList<String>();

    Collections.addAll(vmOpts, additionalVMOpts);

    //setup mode-specific options
    switch (testVMMode) {
    case INT:
        Collections.addAll(vmOpts, new String[] { "-Xint" });
        break;
    case COMP:
        Collections.addAll(vmOpts, new String[] {
                "-Xcomp",
                "-XX:-TieredCompilation",
                String.format("-XX:CompileCommand=compileonly,%s::*",
                              expr.getName())
            });
        break;
    }

    Collections.addAll(vmOpts, new String[] {
            "-XX:+DisplayVMOutputToStderr",
            "-D" + Utils.SEED_PROPERTY_NAME + "=" + seed,
            Executor.class.getName(),
            expr.getName(),
            new Integer(iterations).toString()
        });

    OutputAnalyzer outputAnalyzer = ProcessTools.
        executeTestJvm(vmOpts.toArray(new String[vmOpts.size()]));

    outputAnalyzer.shouldHaveExitValue(0);

    return outputAnalyzer;
}
 
Example 20
Source File: TestLambdaFormRetransformation.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Throwable {
    Path agent = TestLambdaFormRetransformation.buildAgent();
    OutputAnalyzer oa = ProcessTools.executeTestJvm("-javaagent:" +
                            agent.toAbsolutePath().toString(), "-version");
    oa.shouldHaveExitValue(ExitCode.OK.value);
}