hotspot/test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java
author dcubed
Tue, 05 Jul 2016 14:00:21 -0700
changeset 39696 80c9894e18f9
parent 39438 206a712f8f16
child 40059 c2304140ed64
permissions -rw-r--r--
8160739: quarantine tests failing due to -XX:TieredStopAtLevel=1 8160743: quarantine tests that can't attach symbolicator to the process on MacOS X Reviewed-by: sspitsyn, dholmes, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
     1
/*
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
     4
 *
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
     8
 *
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    13
 * accompanied this code).
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    14
 *
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    18
 *
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    21
 * questions.
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    22
 */
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    23
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    24
/*
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    25
 * @test
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    26
 * @bug 8137167
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    27
 * @summary Tests jcmd to be able to add a directive to compile only specified methods
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 38038
diff changeset
    28
 * @modules java.base/jdk.internal.misc
39438
206a712f8f16 8132920: use package in compiler testlibraries
iignatyev
parents: 39428
diff changeset
    29
 * @library /testlibrary /test/lib ../share /
39428
24cb2cb4ae0b 8159149: Several compiler tests fail with minimal VM
iignatyev
parents: 38152
diff changeset
    30
 * @requires vm.flavor != "minimal"
35597
0174e7c4489f 8148136: compile control tests have incorrect @build directives
iignatyev
parents: 34216
diff changeset
    31
 * @build compiler.compilercontrol.jcmd.PrintDirectivesTest
0174e7c4489f 8148136: compile control tests have incorrect @build directives
iignatyev
parents: 34216
diff changeset
    32
 *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    33
 *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
36796
c751f445f5d4 8150054: Make compilercontrol test ignore xcomp
neliasso
parents: 35833
diff changeset
    34
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
39438
206a712f8f16 8132920: use package in compiler testlibraries
iignatyev
parents: 39428
diff changeset
    35
 *                                sun.hotspot.WhiteBox$WhiteBoxPermission
36796
c751f445f5d4 8150054: Make compilercontrol test ignore xcomp
neliasso
parents: 35833
diff changeset
    36
 * @run driver compiler.compilercontrol.jcmd.PrintDirectivesTest
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    37
 */
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    38
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    39
package compiler.compilercontrol.jcmd;
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    40
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    41
import compiler.compilercontrol.share.AbstractTestBase;
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    42
import compiler.compilercontrol.share.method.MethodDescriptor;
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    43
import compiler.compilercontrol.share.scenario.Command;
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    44
import compiler.compilercontrol.share.scenario.CommandGenerator;
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    45
import compiler.compilercontrol.share.scenario.CompileCommand;
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    46
import compiler.compilercontrol.share.scenario.JcmdCommand;
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    47
import compiler.compilercontrol.share.scenario.Scenario;
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    48
import jdk.test.lib.Utils;
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    49
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    50
import java.lang.reflect.Executable;
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    51
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    52
public class PrintDirectivesTest extends AbstractTestBase {
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    53
    private static final int AMOUNT = Utils.getRandomInstance().nextInt(
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    54
            Integer.getInteger("compiler.compilercontrol.jcmd."
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    55
                    + "PrintDirectivesTest.amount", 20));
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    56
    private final CommandGenerator cmdGen = new CommandGenerator();
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    57
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    58
    public static void main(String[] args) {
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    59
        new PrintDirectivesTest().test();
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    60
    }
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    61
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    62
    @Override
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    63
    public void test() {
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    64
        Scenario.Builder builder = Scenario.getBuilder();
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    65
        // Add some commands with directives file
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    66
        for (int i = 0; i < AMOUNT; i++) {
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    67
            Executable exec = Utils.getRandomElement(METHODS).first;
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    68
            MethodDescriptor methodDescriptor = getValidMethodDescriptor(exec);
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    69
            Command command = cmdGen.generateCommand();
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    70
            if (command == Command.NONEXISTENT) {
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    71
                // skip invalid command
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    72
                command = Command.COMPILEONLY;
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    73
            }
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    74
            CompileCommand compileCommand = new CompileCommand(command,
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    75
                    methodDescriptor, cmdGen.generateCompiler(),
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    76
                    Scenario.Type.DIRECTIVE);
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    77
            compileCommand.print();
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    78
            builder.add(compileCommand);
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    79
        }
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    80
        // print all directives
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    81
        builder.add(new JcmdCommand(Command.NONEXISTENT, null, null,
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    82
                Scenario.Type.JCMD, Scenario.JcmdType.PRINT));
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    83
        Scenario scenario = builder.build();
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    84
        scenario.execute();
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
diff changeset
    85
    }
35597
0174e7c4489f 8148136: compile control tests have incorrect @build directives
iignatyev
parents: 34216
diff changeset
    86
}