test/hotspot/jtreg/serviceability/sa/ClhsdbAttach.java
author sspitsyn
Tue, 26 Jun 2018 13:50:59 -0700
changeset 50802 fa380b3b2b7d
parent 50791 b1e90a8a876c
child 53596 bb40a5303c84
permissions -rw-r--r--
8205721: Problem list serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java Summary: Add the test to the ProblemList.txt Reviewed-by: dcubed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48160
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
     1
/*
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48160
diff changeset
     2
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
48160
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
     4
 *
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
     7
 * published by the Free Software Foundation.
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
     8
 *
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    13
 * accompanied this code).
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    14
 *
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    18
 *
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    21
 * questions.
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    22
 */
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    23
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    24
import java.util.HashMap;
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    25
import java.util.List;
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    26
import java.util.Map;
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    27
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    28
import jdk.test.lib.apps.LingeredApp;
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    29
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48160
diff changeset
    30
/**
48160
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    31
 * @test
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    32
 * @bug 8191658
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    33
 * @summary Test clhsdb attach, detach, reattach commands
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48160
diff changeset
    34
 * @requires vm.hasSA
48160
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    35
 * @library /test/lib
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    36
 * @run main/othervm ClhsdbAttach
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    37
 */
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    38
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    39
public class ClhsdbAttach {
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    40
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    41
    public static void main(String[] args) throws Exception {
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    42
        System.out.println("Starting ClhsdbAttach test");
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    43
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    44
        LingeredApp theApp = null;
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    45
        try {
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    46
            ClhsdbLauncher test = new ClhsdbLauncher();
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    47
            theApp = LingeredApp.startApp();
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    48
            System.out.println("Started LingeredApp with pid " + theApp.getPid());
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    49
            String attach = "attach " + theApp.getPid();
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    50
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    51
            List<String> cmds = List.of(
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    52
                    "where",
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    53
                    attach,
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    54
                    "flags MaxJavaStackTraceDepth",
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    55
                    "detach",
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    56
                    "universe",
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    57
                    "reattach",
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    58
                    "longConstant markOopDesc::locked_value");
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    59
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    60
            Map<String, List<String>> expStrMap = new HashMap<>();
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    61
            expStrMap.put("where", List.of(
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    62
                    "Command not valid until attached to a VM"));
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    63
            expStrMap.put("flags MaxJavaStackTraceDepth", List.of(
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    64
                    "MaxJavaStackTraceDepth = "));
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    65
            expStrMap.put("universe", List.of(
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    66
                    "Command not valid until attached to a VM"));
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    67
            expStrMap.put("longConstant markOopDesc::locked_value", List.of(
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    68
                    "longConstant markOopDesc::locked_value"));
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    69
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    70
            test.run(-1, cmds, expStrMap, null);
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    71
        } catch (Exception ex) {
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    72
            throw new RuntimeException("Test ERROR " + ex, ex);
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    73
        } finally {
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    74
            LingeredApp.stopApp(theApp);
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    75
        }
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    76
        System.out.println("Test PASSED");
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    77
    }
599f67f3c6d6 8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff changeset
    78
}