hotspot/test/compiler/compilercontrol/share/scenario/Executor.java
author ppunegov
Thu, 26 Nov 2015 03:05:19 +0300
changeset 34226 db9dea22fbfc
parent 34216 2818af1ce748
child 40631 ed82623d7831
permissions -rw-r--r--
8143308: Add inline checks and tests Summary: Fix inlining state creation Reviewed-by: twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     1
/*
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     4
 *
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     8
 *
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    13
 * accompanied this code).
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    14
 *
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    18
 *
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    21
 * questions.
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    22
 */
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    23
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    24
package compiler.compilercontrol.share.scenario;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    25
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    26
import compiler.compilercontrol.share.actions.BaseAction;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    27
import jdk.test.lib.Asserts;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    28
import jdk.test.lib.OutputAnalyzer;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    29
import jdk.test.lib.ProcessTools;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    30
import jdk.test.lib.dcmd.CommandExecutor;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    31
import jdk.test.lib.dcmd.PidJcmdExecutor;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    32
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    33
import java.io.BufferedReader;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    34
import java.io.IOException;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    35
import java.io.InputStreamReader;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    36
import java.io.PrintWriter;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    37
import java.lang.reflect.Executable;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    38
import java.net.ServerSocket;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    39
import java.net.Socket;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    40
import java.util.ArrayList;
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
    41
import java.util.Collections;
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    42
import java.util.List;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    43
import java.util.Map;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    44
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    45
public class Executor {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    46
    private final boolean isValid;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    47
    private final List<String> vmOptions;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    48
    private final Map<Executable, State> states;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    49
    private final List<String> jcmdCommands;
34226
db9dea22fbfc 8143308: Add inline checks and tests
ppunegov
parents: 34216
diff changeset
    50
    private final String execClass = System.getProperty("compiler."
db9dea22fbfc 8143308: Add inline checks and tests
ppunegov
parents: 34216
diff changeset
    51
            + "compilercontrol.share.executor.executeClass",
db9dea22fbfc 8143308: Add inline checks and tests
ppunegov
parents: 34216
diff changeset
    52
            BaseAction.class.getName());
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
    53
    private OutputAnalyzer[] jcmdOutputAnalyzers;
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    54
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    55
    /**
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    56
     * Constructor
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    57
     *
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    58
     * @param isValid      shows that the input given to the VM is valid and
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    59
     *                     VM shouldn't fail
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    60
     * @param vmOptions    a list of VM input options
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    61
     * @param states       a state map, or null for the non-checking execution
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    62
     * @param jcmdCommands a list of diagnostic commands to be preformed
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    63
     *                     on test VM
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    64
     */
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    65
    public Executor(boolean isValid, List<String> vmOptions,
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    66
            Map<Executable, State> states, List<String> jcmdCommands) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    67
        this.isValid = isValid;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    68
        if (vmOptions == null) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    69
            this.vmOptions = new ArrayList<>();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    70
        } else {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    71
            this.vmOptions = vmOptions;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    72
        }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    73
        this.states = states;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    74
        this.jcmdCommands = jcmdCommands;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    75
    }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    76
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    77
    /**
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    78
     * Executes separate VM a gets an OutputAnalyzer instance with the results
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    79
     * of execution
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    80
     */
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
    81
    public List<OutputAnalyzer> execute() {
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    82
        // Add class name that would be executed in a separate VM
34226
db9dea22fbfc 8143308: Add inline checks and tests
ppunegov
parents: 34216
diff changeset
    83
        vmOptions.add(execClass);
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    84
        OutputAnalyzer output;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    85
        try (ServerSocket serverSocket = new ServerSocket(0)) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    86
            if (isValid) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    87
                // Get port test VM will connect to
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    88
                int port = serverSocket.getLocalPort();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    89
                if (port == -1) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    90
                    throw new Error("Socket is not bound: " + port);
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    91
                }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    92
                vmOptions.add(String.valueOf(port));
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    93
                if (states != null) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    94
                    // add flag to show that there should be state map passed
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    95
                    vmOptions.add("states");
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    96
                }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    97
                // Start separate thread to connect with test VM
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    98
                new Thread(() -> connectTestVM(serverSocket)).start();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    99
            }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   100
            // Start test VM
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   101
            output = ProcessTools.executeTestJvmAllArgs(
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   102
                    vmOptions.toArray(new String[vmOptions.size()]));
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   103
        } catch (Throwable thr) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   104
            throw new Error("Execution failed: " + thr.getMessage(), thr);
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   105
        }
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   106
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   107
        List<OutputAnalyzer> outputList = new ArrayList<>();
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   108
        outputList.add(output);
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   109
        if (jcmdOutputAnalyzers != null) {
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   110
            Collections.addAll(outputList, jcmdOutputAnalyzers);
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   111
        }
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   112
        return outputList;
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   113
    }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   114
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   115
    /*
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   116
     * Performs connection with a test VM, sends method states and performs
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   117
     * JCMD operations on a test VM.
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   118
     */
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   119
    private void connectTestVM(ServerSocket serverSocket) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   120
        /*
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   121
         * There are no way to prove that accept was invoked before we started
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   122
         * test VM that connects to this serverSocket. Connection timeout is
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   123
         * enough
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   124
         */
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   125
        try (
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   126
                Socket socket = serverSocket.accept();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   127
                PrintWriter pw = new PrintWriter(socket.getOutputStream(),
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   128
                        true);
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   129
                BufferedReader in = new BufferedReader(new InputStreamReader(
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   130
                        socket.getInputStream()))) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   131
            // Get pid of the executed process
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   132
            int pid = Integer.parseInt(in.readLine());
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   133
            Asserts.assertNE(pid, 0, "Got incorrect pid");
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   134
            jcmdOutputAnalyzers = executeJCMD(pid);
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   135
            if (states != null) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   136
                // serialize and send state map
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   137
                states.forEach((executable, state) -> {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   138
                    pw.println("{");
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   139
                    pw.println(executable.toGenericString());
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   140
                    pw.println(state.toString());
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   141
                    pw.println("}");
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   142
                });
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   143
            } else {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   144
                pw.println();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   145
            }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   146
        } catch (IOException e) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   147
            throw new Error("Failed to write data: " + e.getMessage(), e);
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   148
        }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   149
    }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   150
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   151
    // Executes all diagnostic commands
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   152
    protected OutputAnalyzer[] executeJCMD(int pid) {
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   153
        int size = jcmdCommands.size();
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   154
        OutputAnalyzer[] outputArray = new OutputAnalyzer[size];
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   155
        CommandExecutor jcmdExecutor = new PidJcmdExecutor(String.valueOf(pid));
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   156
        for (int i = 0; i < size; i++) {
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   157
            outputArray[i] = jcmdExecutor.execute(jcmdCommands.get(i));
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   158
        }
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   159
        return outputArray;
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   160
    }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   161
}