test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java
author jgeorge
Tue, 05 Feb 2019 00:43:38 +0530
changeset 53635 247e5ca412f5
parent 53596 bb40a5303c84
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:
48949
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
     1
/*
53596
bb40a5303c84 8217473: SA: Tests using ClhsdbLauncher fail on SAP docker containers
jgeorge
parents: 50791
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
48949
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
     4
 *
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
     8
 *
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    13
 * accompanied this code).
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    14
 *
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    18
 *
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    21
 * questions.
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    22
 */
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    23
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    24
import java.util.HashMap;
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    25
import java.util.List;
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    26
import java.util.Map;
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    27
import jdk.test.lib.apps.LingeredApp;
53596
bb40a5303c84 8217473: SA: Tests using ClhsdbLauncher fail on SAP docker containers
jgeorge
parents: 50791
diff changeset
    28
import jtreg.SkippedException;
48949
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    29
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48949
diff changeset
    30
/**
48949
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    31
 * @test
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    32
 * @bug 8175384
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    33
 * @summary Test clhsdb 'printall' command
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48949
diff changeset
    34
 * @requires vm.hasSA
48949
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    35
 * @library /test/lib
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    36
 * @run main/othervm/timeout=2400 -Xmx1g ClhsdbPrintAll
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    37
 */
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    38
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    39
public class ClhsdbPrintAll {
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    40
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    41
    public static void main(String[] args) throws Exception {
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    42
        System.out.println("Starting ClhsdbPrintAll test");
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    43
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    44
        LingeredAppWithEnum theApp = null;
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    45
        try {
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    46
            ClhsdbLauncher test = new ClhsdbLauncher();
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    47
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    48
            theApp = new LingeredAppWithEnum();
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    49
            LingeredApp.startApp(null, theApp);
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    50
            System.out.println("Started LingeredAppWithEnum with pid " + theApp.getPid());
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    51
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    52
            List<String> cmds = List.of("printall");
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    53
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    54
            Map<String, List<String>> expStrMap = new HashMap<>();
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    55
            Map<String, List<String>> unExpStrMap = new HashMap<>();
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    56
            expStrMap.put("printall", List.of(
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    57
                "aload_0",
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    58
                "Constant Pool of",
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 53596
diff changeset
    59
                "public static void main\\(java.lang.String\\[\\]\\)",
48949
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    60
                "Bytecode",
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 53596
diff changeset
    61
                "\\[enum\\] class Song \\[signature Ljava/lang/Enum\\<LSong;\\>;\\]",
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 53596
diff changeset
    62
                "Method java.lang.Object clone\\(\\)",
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 53596
diff changeset
    63
                "public static Song\\[\\] values\\(\\)",
48949
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    64
                "invokevirtual",
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    65
                "checkcast",
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    66
                "Field Song HAVANA",
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    67
                "Exception Table",
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    68
                "invokedynamic"));
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    69
            unExpStrMap.put("printall", List.of(
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    70
                "cannot be cast to"));
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    71
            test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);
53596
bb40a5303c84 8217473: SA: Tests using ClhsdbLauncher fail on SAP docker containers
jgeorge
parents: 50791
diff changeset
    72
        } catch (SkippedException se) {
bb40a5303c84 8217473: SA: Tests using ClhsdbLauncher fail on SAP docker containers
jgeorge
parents: 50791
diff changeset
    73
            throw se;
48949
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    74
        } catch (Exception ex) {
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    75
            throw new RuntimeException("Test ERROR " + ex, ex);
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    76
        } finally {
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    77
            LingeredApp.stopApp(theApp);
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    78
        }
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    79
        System.out.println("Test PASSED");
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    80
    }
d2a860bc50a3 8175384: SA: clhsdb 'printall' throws ClassCastException while printing out the bytecodes
jgeorge
parents:
diff changeset
    81
}