test/hotspot/jtreg/serviceability/sa/TestPrintMdo.java
author jgeorge
Fri, 01 Dec 2017 18:19:39 +0530
changeset 48181 61a14b5cb1c6
parent 48178 88ec5fca7726
child 50791 b1e90a8a876c
permissions -rw-r--r--
8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol Summary: Create tests for the clhsdb commands: vmstructsdump, field, symboltable and symbol Reviewed-by: sspitsyn, sballal
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43965
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
     1
/*
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
     4
 *
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
     8
 *
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    13
 * accompanied this code).
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    14
 *
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    18
 *
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    21
 * questions.
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    22
 */
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    23
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    24
import java.util.ArrayList;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    25
import java.util.Scanner;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    26
import java.util.List;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    27
import java.io.File;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    28
import java.io.IOException;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    29
import java.util.stream.Collectors;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    30
import java.io.OutputStream;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    31
import jdk.test.lib.apps.LingeredApp;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    32
import jdk.test.lib.JDKToolLauncher;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    33
import jdk.test.lib.Platform;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    34
import jdk.test.lib.process.ProcessTools;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    35
import jdk.test.lib.process.OutputAnalyzer;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    36
import jdk.test.lib.Utils;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    37
import jdk.test.lib.Asserts;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    38
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    39
/*
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    40
 * @test
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    41
 * @library /test/lib
44087
deab1e2f0ebf 8175512: new TestPrintMdo.java fails with -XX:TieredStopAtLevel=1
jgeorge
parents: 43965
diff changeset
    42
 * @requires vm.flavor == "server" & !vm.emulatedClient & !(vm.opt.TieredStopAtLevel == 1)
43965
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    43
 * @build jdk.test.lib.apps.*
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    44
 * @run main/othervm TestPrintMdo
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    45
 */
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    46
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    47
public class TestPrintMdo {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    48
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    49
    private static final String PRINTMDO_OUT_FILE = "printmdo_out.txt";
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    50
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    51
    private static void verifyPrintMdoOutput() throws Exception {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    52
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    53
        Exception unexpected = null;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    54
        File printMdoFile = new File(PRINTMDO_OUT_FILE);
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    55
        Asserts.assertTrue(printMdoFile.exists() && printMdoFile.isFile(),
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    56
                           "File with printmdo output not created: " +
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    57
                           printMdoFile.getAbsolutePath());
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    58
        try {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    59
            Scanner scanner = new Scanner(printMdoFile);
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    60
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    61
            String unexpectedMsg =
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    62
                 "One or more of 'VirtualCallData', 'CounterData', " +
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    63
                 "'ReceiverTypeData', 'bci', 'MethodData' "  +
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    64
                 "or 'java/lang/Object' not found";
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    65
            boolean knownClassFound = false;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    66
            boolean knownProfileDataTypeFound = false;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    67
            boolean knownTokensFound = false;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    68
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    69
            while (scanner.hasNextLine()) {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    70
                String line = scanner.nextLine();
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    71
                line = line.trim();
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    72
                System.out.println(line);
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    73
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    74
                if (line.contains("missing reason for ")) {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    75
                    unexpected = new RuntimeException("Unexpected msg: missing reason for ");
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    76
                    break;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    77
                }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    78
                if (line.contains("VirtualCallData")  ||
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    79
                    line.contains("CounterData")      ||
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    80
                    line.contains("ReceiverTypeData")) {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    81
                    knownProfileDataTypeFound = true;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    82
                }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    83
                if (line.contains("bci") ||
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    84
                    line.contains("MethodData")) {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    85
                    knownTokensFound = true;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    86
                }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    87
                if (line.contains("java/lang/Object")) {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    88
                    knownClassFound = true;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    89
                }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    90
            }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    91
            if ((knownClassFound           == false)  ||
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    92
                (knownTokensFound          == false)  ||
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    93
                (knownProfileDataTypeFound == false)) {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    94
                unexpected = new RuntimeException(unexpectedMsg);
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    95
            }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    96
            if (unexpected != null) {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    97
                throw unexpected;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    98
            }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    99
        } catch (Exception ex) {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   100
           throw new RuntimeException("Test ERROR " + ex, ex);
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   101
        } finally {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   102
           printMdoFile.delete();
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   103
        }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   104
    }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   105
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   106
    private static void startClhsdbForPrintMdo(long lingeredAppPid) throws Exception {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   107
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   108
        Process p;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   109
        JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   110
        launcher.addToolArg("clhsdb");
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   111
        launcher.addToolArg("--pid");
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   112
        launcher.addToolArg(Long.toString(lingeredAppPid));
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   113
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   114
        ProcessBuilder pb = new ProcessBuilder();
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   115
        pb.command(launcher.getCommand());
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   116
        System.out.println(
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   117
            pb.command().stream().collect(Collectors.joining(" ")));
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   118
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   119
        try {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   120
            p = pb.start();
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   121
        } catch (Exception attachE) {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   122
            throw new Error("Couldn't start jhsdb or attach to LingeredApp : " + attachE);
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   123
        }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   124
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   125
        // Issue the 'printmdo' input at the clhsdb prompt.
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   126
        OutputStream input = p.getOutputStream();
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   127
        String str = "printmdo -a > " + PRINTMDO_OUT_FILE + "\nquit\n";
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   128
        try {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   129
            input.write(str.getBytes());
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   130
            input.flush();
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   131
        } catch (IOException ioe) {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   132
            throw new Error("Problem issuing the printmdo command: " + str, ioe);
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   133
        }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   134
48178
88ec5fca7726 8191914: New SA test timeout on windows
jgeorge
parents: 47216
diff changeset
   135
        OutputAnalyzer output = new OutputAnalyzer(p);
88ec5fca7726 8191914: New SA test timeout on windows
jgeorge
parents: 47216
diff changeset
   136
43965
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   137
        try {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   138
            p.waitFor();
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   139
        } catch (InterruptedException ie) {
48178
88ec5fca7726 8191914: New SA test timeout on windows
jgeorge
parents: 47216
diff changeset
   140
            p.destroyForcibly();
43965
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   141
            throw new Error("Problem awaiting the child process: " + ie, ie);
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   142
        }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   143
48178
88ec5fca7726 8191914: New SA test timeout on windows
jgeorge
parents: 47216
diff changeset
   144
        output.shouldHaveExitValue(0);
43965
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   145
    }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   146
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   147
    public static void main (String... args) throws Exception {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   148
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   149
        LingeredApp app = null;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   150
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   151
        if (!Platform.shouldSAAttach()) {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   152
            System.out.println(
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   153
               "SA attach not expected to work - test skipped.");
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   154
            return;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   155
        }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   156
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   157
        try {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   158
            List<String> vmArgs = new ArrayList<String>();
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   159
            vmArgs.add("-XX:+ProfileInterpreter");
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   160
            vmArgs.addAll(Utils.getVmOptions());
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   161
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   162
            app = LingeredApp.startApp(vmArgs);
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   163
            System.out.println ("Started LingeredApp with pid " + app.getPid());
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   164
            startClhsdbForPrintMdo(app.getPid());
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   165
            verifyPrintMdoOutput();
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   166
        } finally {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   167
            LingeredApp.stopApp(app);
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   168
        }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   169
    }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
   170
}