test/hotspot/jtreg/runtime/InvocationTests/invocationGraalTests.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58312 ce960527ecee
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55552
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
     1
/*
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
     4
 *
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
     8
 *
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    13
 * accompanied this code).
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    14
 *
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    18
 *
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    21
 * questions.
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    22
 *
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    23
 */
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    24
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    25
/*
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    26
 * @test
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    27
 * @bug 8226956
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    28
 * @requires vm.jvmci
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    29
 * @summary Run invocation tests against Graal compiler
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    30
 * @library /test/lib
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    31
 * @modules java.base/jdk.internal.org.objectweb.asm
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    32
 *          java.base/jdk.internal.misc
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    33
 * @compile shared/AbstractGenerator.java shared/AccessCheck.java shared/AccessType.java
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    34
 *          shared/Caller.java shared/ExecutorGenerator.java shared/Utils.java
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    35
 *          shared/ByteArrayClassLoader.java shared/Checker.java shared/GenericClassGenerator.java
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    36
 * @compile invokespecial/Checker.java invokespecial/ClassGenerator.java invokespecial/Generator.java
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    37
 *          invokevirtual/Checker.java invokevirtual/ClassGenerator.java invokevirtual/Generator.java
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    38
 *          invokeinterface/Checker.java invokeinterface/ClassGenerator.java invokeinterface/Generator.java
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    39
 *
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    40
 * @run main/othervm/timeout=1800 invocationGraalTests
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    41
 */
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    42
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    43
import jdk.test.lib.process.ProcessTools;
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    44
import jdk.test.lib.process.OutputAnalyzer;
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    45
import jdk.test.lib.compiler.InMemoryJavaCompiler;
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    46
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    47
public class invocationGraalTests {
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    48
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    49
    public static void runTest(String whichTests, String classFileVersion) throws Exception {
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    50
        System.out.println("\nGraal invocation tests, Tests: " + whichTests +
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    51
                           ", class file version: " + classFileVersion);
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    52
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M",
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    53
            "-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCI", "-XX:+UseJVMCICompiler",
58312
ce960527ecee 8231413: Several test/hotspot/jtreg/runtime tests updates to run with --illegal-access=deny
alanb
parents: 55552
diff changeset
    54
            "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",
55552
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    55
            whichTests, "--classfile_version=" + classFileVersion);
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    56
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    57
        try {
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    58
            output.shouldContain("EXECUTION STATUS: PASSED");
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    59
            output.shouldHaveExitValue(0);
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    60
        } catch (Throwable e) {
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    61
            System.out.println(
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    62
                "\nNote that an entry such as 'B.m/C.m' in the failure chart means that" +
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    63
                " the test case failed because method B.m was invoked but the test " +
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    64
                "expected method C.m to be invoked. Similarly, a result such as 'AME/C.m'" +
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    65
                " means that an AbstractMethodError exception was thrown but the test" +
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    66
                " case expected method C.m to be invoked.");
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    67
            System.out.println(
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    68
                "\nAlso note that passing --dump to invoke*.Generator will" +
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    69
                " dump the generated classes (for debugging purposes).\n");
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    70
            System.exit(1);
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    71
        }
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    72
    }
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    73
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    74
    public static void main(String args[]) throws Throwable {
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    75
        // Get current major class file version and test with it.
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    76
        byte klassbuf[] = InMemoryJavaCompiler.compile("blah", "public class blah { }");
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    77
        int major_version = klassbuf[6] << 8 | klassbuf[7];
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    78
        runTest("invokevirtual.Generator", String.valueOf(major_version));
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    79
        runTest("invokespecial.Generator", String.valueOf(major_version));
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    80
        runTest("invokeinterface.Generator", String.valueOf(major_version));
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    81
    }
9bd13d6dea77 8226956: Add invocation tests for Graal and C1
hseigel
parents:
diff changeset
    82
}