test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java
author coleenp
Tue, 03 Jul 2018 13:41:18 -0400
changeset 50929 ef57cfcd22ff
parent 50791 b1e90a8a876c
child 53596 bb40a5303c84
permissions -rw-r--r--
8205534: Remove SymbolTable dependency from serviceability agent Reviewed-by: gziemski, poonam, jgeorge, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48296
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
     1
/*
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48296
diff changeset
     2
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
48296
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
     4
 *
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
     8
 *
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    13
 * accompanied this code).
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    14
 *
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    18
 *
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    21
 * questions.
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    22
 */
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    23
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    24
import java.nio.file.Files;
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    25
import java.nio.file.Path;
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    26
import java.nio.file.Paths;
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    27
import java.util.HashMap;
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    28
import java.util.List;
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    29
import java.util.Map;
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    30
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    31
import jdk.test.lib.apps.LingeredApp;
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    32
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48296
diff changeset
    33
/**
48296
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    34
 * @test
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    35
 * @bug 8192823
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    36
 * @summary Test clhsdb source command
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48296
diff changeset
    37
 * @requires vm.hasSA
48296
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    38
 * @library /test/lib
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    39
 * @run main/othervm ClhsdbSource
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    40
 */
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    41
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    42
public class ClhsdbSource {
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    43
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    44
    public static void main(String[] args) throws Exception {
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    45
        System.out.println("Starting ClhsdbSource test");
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    46
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    47
        LingeredApp theApp = null;
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    48
        try {
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    49
            ClhsdbLauncher test = new ClhsdbLauncher();
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    50
            theApp = LingeredApp.startApp();
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    51
            System.out.println("Started LingeredApp with pid " + theApp.getPid());
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    52
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    53
            Path file = Paths.get("clhsdb_cmd_file");
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    54
            Files.write(file, "jstack -v\nhelp".getBytes());
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    55
            List<String> cmds = List.of("source clhsdb_cmd_file");
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    56
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    57
            Map<String, List<String>> expStrMap = new HashMap<>();
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    58
            expStrMap.put("source clhsdb_cmd_file", List.of(
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    59
                    "No deadlocks found",
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    60
                    "Common-Cleaner",
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    61
                    "Signal Dispatcher",
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    62
                    "java.lang.ref.Finalizer$FinalizerThread.run",
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    63
                    "java.lang.ref.Reference",
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    64
                    "Method*",
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    65
                    "LingeredApp.main",
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    66
                    "Available commands:",
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    67
                    "attach pid | exec core",
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    68
                    "intConstant [ name [ value ] ]",
50929
ef57cfcd22ff 8205534: Remove SymbolTable dependency from serviceability agent
coleenp
parents: 50791
diff changeset
    69
                    "type [ type [ name super isOop isInteger isUnsigned size ] ]"));
48296
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    70
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    71
            Map<String, List<String>> unExpStrMap = new HashMap<>();
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    72
            unExpStrMap.put("source clhsdb_cmd_file", List.of(
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    73
                        "No such file or directory"));
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    74
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    75
            test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    76
            Files.delete(file);
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    77
        } catch (Exception ex) {
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    78
            throw new RuntimeException("Test ERROR " + ex, ex);
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    79
        } finally {
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    80
            LingeredApp.stopApp(theApp);
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    81
        }
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    82
        System.out.println("Test PASSED");
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    83
    }
3212e9bc5be7 8192823: SA: Testcase for 'clhsdb source' command
sballal
parents:
diff changeset
    84
}