test/hotspot/jtreg/serviceability/sa/TestPrintMdo.java
author jgeorge
Tue, 05 Feb 2019 00:43:38 +0530
changeset 53635 247e5ca412f5
parent 50791 b1e90a8a876c
permissions -rw-r--r--
8215568: Refactor SA clhsdb tests to use ClhsdbLauncher Summary: Refactoring the SA tests which test clhsdb commands to use ClhsdbLauncher for uniformity and ease of maintainence Reviewed-by: jcbeyler, dholmes
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
/*
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
     2
 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
43965
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.List;
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    26
import java.util.Map;
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    27
import java.util.HashMap;
43965
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    28
import jdk.test.lib.apps.LingeredApp;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    29
import jdk.test.lib.Utils;
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    30
import jtreg.SkippedException;
43965
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    31
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48178
diff changeset
    32
/**
43965
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    33
 * @test
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    34
 * @library /test/lib
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48178
diff changeset
    35
 * @requires vm.hasSAandCanAttach
44087
deab1e2f0ebf 8175512: new TestPrintMdo.java fails with -XX:TieredStopAtLevel=1
jgeorge
parents: 43965
diff changeset
    36
 * @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
    37
 * @build jdk.test.lib.apps.*
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    38
 * @run main/othervm TestPrintMdo
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
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    41
public class TestPrintMdo {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    42
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    43
    public static void main (String... args) throws Exception {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    44
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    45
        System.out.println("Starting TestPrintMdo test");
43965
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    46
        LingeredApp app = null;
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    47
        try {
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    48
            ClhsdbLauncher test = new ClhsdbLauncher();
43965
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    49
            List<String> vmArgs = new ArrayList<String>();
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    50
            vmArgs.add("-XX:+ProfileInterpreter");
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    51
            vmArgs.addAll(Utils.getVmOptions());
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
            app = LingeredApp.startApp(vmArgs);
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    54
            System.out.println ("Started LingeredApp with pid " + app.getPid());
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    55
            List<String> cmds = List.of("printmdo -a");
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    56
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    57
            Map<String, List<String>> expStrMap = new HashMap<>();
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    58
            Map<String, List<String>> unExpStrMap = new HashMap<>();
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    59
            expStrMap.put("printmdo -a", List.of(
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    60
                "VirtualCallData",
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    61
                "CounterData",
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    62
                "ReceiverTypeData",
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    63
                "bci",
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    64
                "MethodData",
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    65
                "java/lang/Object"));
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    66
            unExpStrMap.put("printmdo -a", List.of(
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    67
                            "missing reason for "));
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    68
            test.run(app.getPid(), cmds, expStrMap, unExpStrMap);
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    69
        } catch (SkippedException se) {
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    70
            throw se;
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    71
        } catch (Exception ex) {
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    72
            throw new RuntimeException("Test ERROR " + ex, ex);
43965
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    73
        } finally {
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    74
            LingeredApp.stopApp(app);
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    75
        }
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    76
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 50791
diff changeset
    77
        System.out.println("Test PASSED");
43965
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    78
    }
d9ba85f5cb9d 8175054: Move new TestPrintMdo.java to hotspot/test directory
jgeorge
parents:
diff changeset
    79
}