Java Code Examples for jdk.testlibrary.ProcessTools#getProcessId()

The following examples show how to use jdk.testlibrary.ProcessTools#getProcessId() . 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: Events.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static Path makeCopy(Recording recording) throws IOException {
    Path p = recording.getDestination();
    int pid = 0;
    try {
        pid = ProcessTools.getProcessId();
    } catch (Exception e) {
        //do nothing, let's use 0
    }

    if (p == null) {
        File directory = new File(".");
        // FIXME: Must come up with a way to give human-readable name
        // this will at least not clash when running parallel.
        p = new File(directory.getAbsolutePath(), "recording-" + recording.getId() + "-pid" + pid + ".jfr").toPath();
        recording.dump(p);
    }
    return p;
}
 
Example 2
Source File: TestApplication.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    // Some tests require the application to exit immediately
    if (args.length > 0 && args[0].equals("-exit")) {
        return;
    }

    // bind to a random port
    ServerSocket ss = new ServerSocket(0);
    int port = ss.getLocalPort();

    int pid = -1;
    try {
        pid = ProcessTools.getProcessId();
    } catch (Exception e) {
        e.printStackTrace();
    }

    // signal test that we are started - do not remove these lines!!
    System.out.println("port:" + port);
    System.out.println("pid:" + pid);
    System.out.println("waiting for the manager ...");
    System.out.flush();

    // wait for manager to connect
    Socket s = ss.accept();
    s.close();
    ss.close();
}
 
Example 3
Source File: Application.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    // bind to a random port
    if (args.length < 1) {
        System.err.println("First argument should be path to output file.");
    }
    String outFileName = args[0];

    ServerSocket ss = new ServerSocket(0);
    int port = ss.getLocalPort();
    int pid = ProcessTools.getProcessId();

    System.out.println("shutdownPort=" + port);
    System.out.println("pid=" + pid);
    System.out.flush();

    try (PrintWriter writer = new PrintWriter(outFileName)) {
        writer.println("shutdownPort=" + port);
        writer.println("pid=" + pid);
        writer.println("done");
        writer.flush();
    }

    // wait for test harness to connect
    Socket s = ss.accept();
    s.close();
    ss.close();
}
 
Example 4
Source File: TestApplication.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    // Some tests require the application to exit immediately
    if (args.length > 0 && args[0].equals("-exit")) {
        return;
    }

    // bind to a random port
    ServerSocket ss = new ServerSocket(0);
    int port = ss.getLocalPort();

    int pid = -1;
    try {
        pid = ProcessTools.getProcessId();
    } catch (Exception e) {
        e.printStackTrace();
    }

    // signal test that we are started - do not remove these lines!!
    System.out.println("port:" + port);
    System.out.println("pid:" + pid);
    System.out.println("waiting for the manager ...");
    System.out.flush();

    // wait for manager to connect
    Socket s = ss.accept();
    s.close();
    ss.close();
}
 
Example 5
Source File: DumpHeap.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    List<HotSpotDiagnosticMXBean> list = ManagementFactory.getPlatformMXBeans(HotSpotDiagnosticMXBean.class);
    File dump = new File(ProcessTools.getProcessId() + ".hprof");
    if (dump.exists()) {
        dump.delete();
    }
    System.out.println("Dumping to file: " + dump.getAbsolutePath());
    list.get(0).dumpHeap(dump.getAbsolutePath(), true);

    verifyDumpFile(dump);

    dump.delete();
}
 
Example 6
Source File: Application.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    // bind to a random port
    if (args.length < 1) {
        System.err.println("First argument should be path to output file.");
    }
    String outFileName = args[0];

    ServerSocket ss = new ServerSocket(0);
    int port = ss.getLocalPort();
    int pid = ProcessTools.getProcessId();

    System.out.println("shutdownPort=" + port);
    System.out.println("pid=" + pid);
    System.out.flush();

    try (PrintWriter writer = new PrintWriter(outFileName)) {
        writer.println("shutdownPort=" + port);
        writer.println("pid=" + pid);
        writer.println("done");
        writer.flush();
    }

    // wait for test harness to connect
    Socket s = ss.accept();
    s.close();
    ss.close();
}
 
Example 7
Source File: TestApplication.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    // Some tests require the application to exit immediately
    if (args.length > 0 && args[0].equals("-exit")) {
        return;
    }

    // bind to a random port
    ServerSocket ss = new ServerSocket(0);
    int port = ss.getLocalPort();

    int pid = -1;
    try {
        pid = ProcessTools.getProcessId();
    } catch (Exception e) {
        e.printStackTrace();
    }

    // signal test that we are started - do not remove these lines!!
    System.out.println("port:" + port);
    System.out.println("pid:" + pid);
    System.out.println("waiting for the manager ...");
    System.out.flush();

    // wait for manager to connect
    Socket s = ss.accept();
    s.close();
    ss.close();
}
 
Example 8
Source File: TestApplication.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    // Some tests require the application to exit immediately
    if (args.length > 0 && args[0].equals("-exit")) {
        return;
    }

    // bind to a random port
    ServerSocket ss = new ServerSocket(0);
    int port = ss.getLocalPort();

    int pid = -1;
    try {
        pid = ProcessTools.getProcessId();
    } catch (Exception e) {
        e.printStackTrace();
    }

    // signal test that we are started - do not remove these lines!!
    System.out.println("port:" + port);
    System.out.println("pid:" + pid);
    System.out.println("waiting for the manager ...");
    System.out.flush();

    // wait for manager to connect
    Socket s = ss.accept();
    s.close();
    ss.close();
}
 
Example 9
Source File: Application.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    // bind to a random port
    if (args.length < 1) {
        System.err.println("First argument should be path to output file.");
    }
    String outFileName = args[0];

    ServerSocket ss = new ServerSocket(0);
    int port = ss.getLocalPort();
    int pid = ProcessTools.getProcessId();

    System.out.println("shutdownPort=" + port);
    System.out.println("pid=" + pid);
    System.out.flush();

    try (PrintWriter writer = new PrintWriter(outFileName)) {
        writer.println("shutdownPort=" + port);
        writer.println("pid=" + pid);
        writer.println("done");
        writer.flush();
    }

    // wait for test harness to connect
    Socket s = ss.accept();
    s.close();
    ss.close();
}
 
Example 10
Source File: Application.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    // bind to a random port
    if (args.length < 1) {
        System.err.println("First argument should be path to output file.");
    }
    String outFileName = args[0];

    ServerSocket ss = new ServerSocket(0);
    int port = ss.getLocalPort();
    int pid = ProcessTools.getProcessId();

    System.out.println("shutdownPort=" + port);
    System.out.println("pid=" + pid);
    System.out.flush();

    try (PrintWriter writer = new PrintWriter(outFileName)) {
        writer.println("shutdownPort=" + port);
        writer.println("pid=" + pid);
        writer.println("done");
        writer.flush();
    }

    // wait for test harness to connect
    Socket s = ss.accept();
    s.close();
    ss.close();
}
 
Example 11
Source File: TestApplication.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    // Some tests require the application to exit immediately
    if (args.length > 0 && args[0].equals("-exit")) {
        return;
    }

    // bind to a random port
    ServerSocket ss = new ServerSocket(0);
    int port = ss.getLocalPort();

    int pid = -1;
    try {
        pid = ProcessTools.getProcessId();
    } catch (Exception e) {
        e.printStackTrace();
    }

    // signal test that we are started - do not remove these lines!!
    System.out.println("port:" + port);
    System.out.println("pid:" + pid);
    System.out.println("waiting for the manager ...");
    System.out.flush();

    // wait for manager to connect
    Socket s = ss.accept();
    s.close();
    ss.close();
}
 
Example 12
Source File: TestApplication.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    // Some tests require the application to exit immediately
    if (args.length > 0 && args[0].equals("-exit")) {
        return;
    }

    // bind to a random port
    ServerSocket ss = new ServerSocket(0);
    int port = ss.getLocalPort();

    int pid = -1;
    try {
        pid = ProcessTools.getProcessId();
    } catch (Exception e) {
        e.printStackTrace();
    }

    // signal test that we are started - do not remove these lines!!
    System.out.println("port:" + port);
    System.out.println("pid:" + pid);
    System.out.println("waiting for the manager ...");
    System.out.flush();

    // wait for manager to connect
    Socket s = ss.accept();
    s.close();
    ss.close();
}
 
Example 13
Source File: PidJcmdExecutor.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Instantiates a new PidJcmdExecutor targeting the current VM
 */
public PidJcmdExecutor() {
    super();
    try {
        pid = ProcessTools.getProcessId();
    } catch (Exception e) {
        throw new CommandExecutorException("Could not determine own pid", e);
    }
}
 
Example 14
Source File: Application.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    // bind to a random port
    if (args.length < 1) {
        System.err.println("First argument should be path to output file.");
    }
    String outFileName = args[0];

    ServerSocket ss = new ServerSocket(0);
    int port = ss.getLocalPort();
    int pid = ProcessTools.getProcessId();

    System.out.println("shutdownPort=" + port);
    System.out.println("pid=" + pid);
    System.out.flush();

    try (PrintWriter writer = new PrintWriter(outFileName)) {
        writer.println("shutdownPort=" + port);
        writer.println("pid=" + pid);
        writer.println("done");
        writer.flush();
    }

    // wait for test harness to connect
    Socket s = ss.accept();
    s.close();
    ss.close();
}
 
Example 15
Source File: Application.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    // bind to a random port
    if (args.length < 1) {
        System.err.println("First argument should be path to output file.");
    }
    String outFileName = args[0];

    ServerSocket ss = new ServerSocket(0);
    int port = ss.getLocalPort();
    int pid = ProcessTools.getProcessId();

    System.out.println("shutdownPort=" + port);
    System.out.println("pid=" + pid);
    System.out.flush();

    try (PrintWriter writer = new PrintWriter(outFileName)) {
        writer.println("shutdownPort=" + port);
        writer.println("pid=" + pid);
        writer.println("done");
        writer.flush();
    }

    // wait for test harness to connect
    Socket s = ss.accept();
    s.close();
    ss.close();
}
 
Example 16
Source File: JpsBase.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    int pid = ProcessTools.getProcessId();

    List<List<JpsHelper.JpsArg>> combinations = JpsHelper.JpsArg.generateCombinations();
    for (List<JpsHelper.JpsArg> combination : combinations) {
        OutputAnalyzer output = JpsHelper.jps(JpsHelper.JpsArg.asCmdArray(combination));
        output.shouldHaveExitValue(0);

        boolean isQuiet = false;
        boolean isFull = false;
        String pattern;
        for (JpsHelper.JpsArg jpsArg : combination) {
            switch (jpsArg) {
            case q:
                // If '-q' is specified output should contain only a list of local VM identifiers:
                // 30673
                isQuiet = true;
                JpsHelper.verifyJpsOutput(output, "^\\d+$");
                output.shouldContain(Integer.toString(pid));
                break;
            case l:
                // If '-l' is specified output should contain the full package name for the application's main class
                // or the full path name to the application's JAR file:
                // 30673 /tmp/jtreg/jtreg-workdir/scratch/JpsBase.jar ...
                isFull = true;
                pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*";
                output.shouldMatch(pattern);
                break;
            case m:
                // If '-m' is specified output should contain the arguments passed to the main method:
                // 30673 JpsBase monkey ...
                for (String arg : args) {
                    pattern = "^" + pid + ".*" + replaceSpecialChars(arg) + ".*";
                    output.shouldMatch(pattern);
                }
                break;
            case v:
                // If '-v' is specified output should contain VM arguments:
                // 30673 JpsBase -Xmx512m -XX:+UseParallelGC -XX:Flags=/tmp/jtreg/jtreg-workdir/scratch/vmflags ...
                for (String vmArg : JpsHelper.getVmArgs()) {
                    pattern = "^" + pid + ".*" + replaceSpecialChars(vmArg) + ".*";
                    output.shouldMatch(pattern);
                }
                break;
            case V:
                // If '-V' is specified output should contain VM flags:
                // 30673 JpsBase +DisableExplicitGC ...
                pattern = "^" + pid + ".*" + replaceSpecialChars(JpsHelper.VM_FLAG) + ".*";
                output.shouldMatch(pattern);
                break;
            }

            if (isQuiet) {
                break;
            }
        }

        if (!isQuiet) {
            // Verify output line by line.
            // Output should only contain lines with pids after the first line with pid.
            JpsHelper.verifyJpsOutput(output, "^\\d+\\s+.*");
            if (!isFull) {
                pattern = "^" + pid + "\\s+" + replaceSpecialChars(shortProcessName);
                if (combination.isEmpty()) {
                    // If no arguments are specified output should only contain
                    // pid and process name
                    pattern += "$";
                } else {
                    pattern += ".*";
                }
                output.shouldMatch(pattern);
            }
        }
    }
}
 
Example 17
Source File: JpsBase.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    int pid = ProcessTools.getProcessId();

    List<List<JpsHelper.JpsArg>> combinations = JpsHelper.JpsArg.generateCombinations();
    for (List<JpsHelper.JpsArg> combination : combinations) {
        OutputAnalyzer output = JpsHelper.jps(JpsHelper.JpsArg.asCmdArray(combination));
        output.shouldHaveExitValue(0);

        boolean isQuiet = false;
        boolean isFull = false;
        String pattern;
        for (JpsHelper.JpsArg jpsArg : combination) {
            switch (jpsArg) {
            case q:
                // If '-q' is specified output should contain only a list of local VM identifiers:
                // 30673
                isQuiet = true;
                JpsHelper.verifyJpsOutput(output, "^\\d+$");
                output.shouldContain(Integer.toString(pid));
                break;
            case l:
                // If '-l' is specified output should contain the full package name for the application's main class
                // or the full path name to the application's JAR file:
                // 30673 /tmp/jtreg/jtreg-workdir/scratch/JpsBase.jar ...
                isFull = true;
                pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*";
                output.shouldMatch(pattern);
                break;
            case m:
                // If '-m' is specified output should contain the arguments passed to the main method:
                // 30673 JpsBase monkey ...
                for (String arg : args) {
                    pattern = "^" + pid + ".*" + replaceSpecialChars(arg) + ".*";
                    output.shouldMatch(pattern);
                }
                break;
            case v:
                // If '-v' is specified output should contain VM arguments:
                // 30673 JpsBase -Xmx512m -XX:+UseParallelGC -XX:Flags=/tmp/jtreg/jtreg-workdir/scratch/vmflags ...
                for (String vmArg : JpsHelper.getVmArgs()) {
                    pattern = "^" + pid + ".*" + replaceSpecialChars(vmArg) + ".*";
                    output.shouldMatch(pattern);
                }
                break;
            case V:
                // If '-V' is specified output should contain VM flags:
                // 30673 JpsBase +DisableExplicitGC ...
                pattern = "^" + pid + ".*" + replaceSpecialChars(JpsHelper.VM_FLAG) + ".*";
                output.shouldMatch(pattern);
                break;
            }

            if (isQuiet) {
                break;
            }
        }

        if (!isQuiet) {
            // Verify output line by line.
            // Output should only contain lines with pids after the first line with pid.
            JpsHelper.verifyJpsOutput(output, "^\\d+\\s+.*");
            if (!isFull) {
                pattern = "^" + pid + "\\s+" + replaceSpecialChars(shortProcessName);
                if (combination.isEmpty()) {
                    // If no arguments are specified output should only contain
                    // pid and process name
                    pattern += "$";
                } else {
                    pattern += ".*";
                }
                output.shouldMatch(pattern);
            }
        }
    }
}
 
Example 18
Source File: JpsBase.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    int pid = ProcessTools.getProcessId();

    List<List<JpsHelper.JpsArg>> combinations = JpsHelper.JpsArg.generateCombinations();
    for (List<JpsHelper.JpsArg> combination : combinations) {
        OutputAnalyzer output = JpsHelper.jps(JpsHelper.JpsArg.asCmdArray(combination));
        output.shouldHaveExitValue(0);

        boolean isQuiet = false;
        boolean isFull = false;
        String pattern;
        for (JpsHelper.JpsArg jpsArg : combination) {
            switch (jpsArg) {
            case q:
                // If '-q' is specified output should contain only a list of local VM identifiers:
                // 30673
                isQuiet = true;
                JpsHelper.verifyJpsOutput(output, "^\\d+$");
                output.shouldContain(Integer.toString(pid));
                break;
            case l:
                // If '-l' is specified output should contain the full package name for the application's main class
                // or the full path name to the application's JAR file:
                // 30673 /tmp/jtreg/jtreg-workdir/scratch/JpsBase.jar ...
                isFull = true;
                pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*";
                output.shouldMatch(pattern);
                break;
            case m:
                // If '-m' is specified output should contain the arguments passed to the main method:
                // 30673 JpsBase monkey ...
                for (String arg : args) {
                    pattern = "^" + pid + ".*" + replaceSpecialChars(arg) + ".*";
                    output.shouldMatch(pattern);
                }
                break;
            case v:
                // If '-v' is specified output should contain VM arguments:
                // 30673 JpsBase -Xmx512m -XX:+UseParallelGC -XX:Flags=/tmp/jtreg/jtreg-workdir/scratch/vmflags ...
                for (String vmArg : JpsHelper.getVmArgs()) {
                    pattern = "^" + pid + ".*" + replaceSpecialChars(vmArg) + ".*";
                    output.shouldMatch(pattern);
                }
                break;
            case V:
                // If '-V' is specified output should contain VM flags:
                // 30673 JpsBase +DisableExplicitGC ...
                pattern = "^" + pid + ".*" + replaceSpecialChars(JpsHelper.VM_FLAG) + ".*";
                output.shouldMatch(pattern);
                break;
            }

            if (isQuiet) {
                break;
            }
        }

        if (!isQuiet) {
            // Verify output line by line.
            // Output should only contain lines with pids after the first line with pid.
            JpsHelper.verifyJpsOutput(output, "^\\d+\\s+.*");
            if (!isFull) {
                pattern = "^" + pid + "\\s+" + replaceSpecialChars(shortProcessName);
                if (combination.isEmpty()) {
                    // If no arguments are specified output should only contain
                    // pid and process name
                    pattern += "$";
                } else {
                    pattern += ".*";
                }
                output.shouldMatch(pattern);
            }
        }
    }
}
 
Example 19
Source File: JpsBase.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    int pid = ProcessTools.getProcessId();

    List<List<JpsHelper.JpsArg>> combinations = JpsHelper.JpsArg.generateCombinations();
    for (List<JpsHelper.JpsArg> combination : combinations) {
        OutputAnalyzer output = JpsHelper.jps(JpsHelper.JpsArg.asCmdArray(combination));
        output.shouldHaveExitValue(0);

        boolean isQuiet = false;
        boolean isFull = false;
        String pattern;
        for (JpsHelper.JpsArg jpsArg : combination) {
            switch (jpsArg) {
            case q:
                // If '-q' is specified output should contain only a list of local VM identifiers:
                // 30673
                isQuiet = true;
                JpsHelper.verifyJpsOutput(output, "^\\d+$");
                output.shouldContain(Integer.toString(pid));
                break;
            case l:
                // If '-l' is specified output should contain the full package name for the application's main class
                // or the full path name to the application's JAR file:
                // 30673 /tmp/jtreg/jtreg-workdir/scratch/JpsBase.jar ...
                isFull = true;
                pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*";
                output.shouldMatch(pattern);
                break;
            case m:
                // If '-m' is specified output should contain the arguments passed to the main method:
                // 30673 JpsBase monkey ...
                for (String arg : args) {
                    pattern = "^" + pid + ".*" + replaceSpecialChars(arg) + ".*";
                    output.shouldMatch(pattern);
                }
                break;
            case v:
                // If '-v' is specified output should contain VM arguments:
                // 30673 JpsBase -Xmx512m -XX:+UseParallelGC -XX:Flags=/tmp/jtreg/jtreg-workdir/scratch/vmflags ...
                for (String vmArg : JpsHelper.getVmArgs()) {
                    pattern = "^" + pid + ".*" + replaceSpecialChars(vmArg) + ".*";
                    output.shouldMatch(pattern);
                }
                break;
            case V:
                // If '-V' is specified output should contain VM flags:
                // 30673 JpsBase +DisableExplicitGC ...
                pattern = "^" + pid + ".*" + replaceSpecialChars(JpsHelper.VM_FLAG) + ".*";
                output.shouldMatch(pattern);
                break;
            }

            if (isQuiet) {
                break;
            }
        }

        if (!isQuiet) {
            // Verify output line by line.
            // Output should only contain lines with pids after the first line with pid.
            JpsHelper.verifyJpsOutput(output, "^\\d+\\s+.*");
            if (!isFull) {
                pattern = "^" + pid + "\\s+" + replaceSpecialChars(shortProcessName);
                if (combination.isEmpty()) {
                    // If no arguments are specified output should only contain
                    // pid and process name
                    pattern += "$";
                } else {
                    pattern += ".*";
                }
                output.shouldMatch(pattern);
            }
        }
    }
}
 
Example 20
Source File: JpsBase.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    int pid = ProcessTools.getProcessId();

    List<List<JpsHelper.JpsArg>> combinations = JpsHelper.JpsArg.generateCombinations();
    for (List<JpsHelper.JpsArg> combination : combinations) {
        OutputAnalyzer output = JpsHelper.jps(JpsHelper.JpsArg.asCmdArray(combination));
        output.shouldHaveExitValue(0);

        boolean isQuiet = false;
        boolean isFull = false;
        String pattern;
        for (JpsHelper.JpsArg jpsArg : combination) {
            switch (jpsArg) {
            case q:
                // If '-q' is specified output should contain only a list of local VM identifiers:
                // 30673
                isQuiet = true;
                JpsHelper.verifyJpsOutput(output, "^\\d+$");
                output.shouldContain(Integer.toString(pid));
                break;
            case l:
                // If '-l' is specified output should contain the full package name for the application's main class
                // or the full path name to the application's JAR file:
                // 30673 /tmp/jtreg/jtreg-workdir/scratch/JpsBase.jar ...
                isFull = true;
                pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*";
                output.shouldMatch(pattern);
                break;
            case m:
                // If '-m' is specified output should contain the arguments passed to the main method:
                // 30673 JpsBase monkey ...
                for (String arg : args) {
                    pattern = "^" + pid + ".*" + replaceSpecialChars(arg) + ".*";
                    output.shouldMatch(pattern);
                }
                break;
            case v:
                // If '-v' is specified output should contain VM arguments:
                // 30673 JpsBase -Xmx512m -XX:+UseParallelGC -XX:Flags=/tmp/jtreg/jtreg-workdir/scratch/vmflags ...
                for (String vmArg : JpsHelper.getVmArgs()) {
                    pattern = "^" + pid + ".*" + replaceSpecialChars(vmArg) + ".*";
                    output.shouldMatch(pattern);
                }
                break;
            case V:
                // If '-V' is specified output should contain VM flags:
                // 30673 JpsBase +DisableExplicitGC ...
                pattern = "^" + pid + ".*" + replaceSpecialChars(JpsHelper.VM_FLAG) + ".*";
                output.shouldMatch(pattern);
                break;
            }

            if (isQuiet) {
                break;
            }
        }

        if (!isQuiet) {
            // Verify output line by line.
            // Output should only contain lines with pids after the first line with pid.
            JpsHelper.verifyJpsOutput(output, "^\\d+\\s+.*");
            if (!isFull) {
                pattern = "^" + pid + "\\s+" + replaceSpecialChars(shortProcessName);
                if (combination.isEmpty()) {
                    // If no arguments are specified output should only contain
                    // pid and process name
                    pattern += "$";
                } else {
                    pattern += ".*";
                }
                output.shouldMatch(pattern);
            }
        }
    }
}