hotspot/test/compiler/compilercontrol/share/scenario/Executor.java
author ppunegov
Tue, 24 Nov 2015 20:55:46 +0300
changeset 34216 2818af1ce748
parent 34215 ae6ba67d6420
child 34226 db9dea22fbfc
permissions -rw-r--r--
8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command Summary: Test Compiler.directive_print command Reviewed-by: iignatyev, neliasso
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;
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
    50
    private OutputAnalyzer[] jcmdOutputAnalyzers;
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    51
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    52
    /**
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    53
     * Constructor
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
     * @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
    56
     *                     VM shouldn't fail
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    57
     * @param vmOptions    a list of VM input options
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    58
     * @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
    59
     * @param jcmdCommands a list of diagnostic commands to be preformed
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    60
     *                     on test VM
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    61
     */
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    62
    public Executor(boolean isValid, List<String> vmOptions,
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    63
            Map<Executable, State> states, List<String> jcmdCommands) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    64
        this.isValid = isValid;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    65
        if (vmOptions == null) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    66
            this.vmOptions = new ArrayList<>();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    67
        } else {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    68
            this.vmOptions = vmOptions;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    69
        }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    70
        this.states = states;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    71
        this.jcmdCommands = jcmdCommands;
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
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    74
    /**
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    75
     * 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
    76
     * of execution
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    77
     */
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
    78
    public List<OutputAnalyzer> execute() {
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    79
        // Add class name that would be executed in a separate VM
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    80
        String classCmd = BaseAction.class.getName();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    81
        vmOptions.add(classCmd);
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    82
        OutputAnalyzer output;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    83
        try (ServerSocket serverSocket = new ServerSocket(0)) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    84
            if (isValid) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    85
                // Get port test VM will connect to
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    86
                int port = serverSocket.getLocalPort();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    87
                if (port == -1) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    88
                    throw new Error("Socket is not bound: " + port);
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    89
                }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    90
                vmOptions.add(String.valueOf(port));
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    91
                if (states != null) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    92
                    // 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
    93
                    vmOptions.add("states");
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    94
                }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    95
                // Start separate thread to connect with test VM
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    96
                new Thread(() -> connectTestVM(serverSocket)).start();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    97
            }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    98
            // Start test VM
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    99
            output = ProcessTools.executeTestJvmAllArgs(
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   100
                    vmOptions.toArray(new String[vmOptions.size()]));
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   101
        } catch (Throwable thr) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   102
            throw new Error("Execution failed: " + thr.getMessage(), thr);
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   103
        }
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   104
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   105
        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
   106
        outputList.add(output);
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   107
        if (jcmdOutputAnalyzers != null) {
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   108
            Collections.addAll(outputList, jcmdOutputAnalyzers);
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   109
        }
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   110
        return outputList;
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   111
    }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   112
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
     * 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
   115
     * JCMD operations on a test VM.
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   116
     */
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   117
    private void connectTestVM(ServerSocket serverSocket) {
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
         * 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
   120
         * test VM that connects to this serverSocket. Connection timeout is
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   121
         * enough
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   122
         */
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   123
        try (
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   124
                Socket socket = serverSocket.accept();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   125
                PrintWriter pw = new PrintWriter(socket.getOutputStream(),
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   126
                        true);
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   127
                BufferedReader in = new BufferedReader(new InputStreamReader(
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   128
                        socket.getInputStream()))) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   129
            // Get pid of the executed process
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   130
            int pid = Integer.parseInt(in.readLine());
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   131
            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
   132
            jcmdOutputAnalyzers = executeJCMD(pid);
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   133
            if (states != null) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   134
                // serialize and send state map
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   135
                states.forEach((executable, state) -> {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   136
                    pw.println("{");
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   137
                    pw.println(executable.toGenericString());
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   138
                    pw.println(state.toString());
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   139
                    pw.println("}");
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   140
                });
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   141
            } else {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   142
                pw.println();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   143
            }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   144
        } catch (IOException e) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   145
            throw new Error("Failed to write data: " + e.getMessage(), e);
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   146
        }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   147
    }
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
    // 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
   150
    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
   151
        int size = jcmdCommands.size();
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   152
        OutputAnalyzer[] outputArray = new OutputAnalyzer[size];
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   153
        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
   154
        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
   155
            outputArray[i] = jcmdExecutor.execute(jcmdCommands.get(i));
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   156
        }
34216
2818af1ce748 8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents: 34215
diff changeset
   157
        return outputArray;
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   158
    }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
   159
}