8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
Reviewed-by: jgeorge, dholmes
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java Thu Nov 16 09:26:48 2017 +0530
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.Platform;
+import jdk.test.lib.Utils;
+
+/*
+ * @test
+ * @bug 8190198
+ * @summary Test clhsdb flags command
+ * @library /test/lib
+ * @run main/othervm ClhsdbFlags
+ */
+
+public class ClhsdbFlags {
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting ClhsdbFlags test");
+
+ LingeredApp theApp = null;
+ try {
+ ClhsdbLauncher test = new ClhsdbLauncher();
+ List<String> vmArgs = new ArrayList<String>();
+ vmArgs.add("-XX:+UnlockExperimentalVMOptions");
+ vmArgs.add("-XX:+UseJVMCICompiler");
+ vmArgs.add("-XX:-MaxFDLimit");
+ vmArgs.addAll(Utils.getVmOptions());
+ theApp = LingeredApp.startApp(vmArgs);
+ System.out.println("Started LingeredApp with pid " + theApp.getPid());
+
+ List<String> cmds = List.of(
+ "flags", "flags -nd",
+ "flags UseJVMCICompiler", "flags MaxFDLimit",
+ "flags MaxJavaStackTraceDepth");
+
+ Map<String, List<String>> expStrMap = new HashMap<>();
+ expStrMap.put("flags", List.of(
+ "UseJVMCICompiler = true",
+ "MaxFDLimit = false",
+ "MaxJavaStackTraceDepth = 1024",
+ "UseCompressedClassPointers", "VerifyMergedCPBytecodes",
+ "ConcGCThreads", "UseThreadPriorities",
+ "UseInterpreter", "StartFlightRecording",
+ "ShowHiddenFrames", "UseAppCDS"));
+ expStrMap.put("flags -nd", List.of(
+ "UseJVMCICompiler = true",
+ "MaxFDLimit = false",
+ "UseCompressedClassPointers",
+ "ConcGCThreads"));
+ expStrMap.put("flags UseJVMCICompiler", List.of(
+ "UseJVMCICompiler = true"));
+ expStrMap.put("flags MaxFDLimit", List.of(
+ "MaxFDLimit = false"));
+ expStrMap.put("flags MaxJavaStackTraceDepth", List.of(
+ "MaxJavaStackTraceDepth = 1024"));
+
+ test.run(theApp.getPid(), cmds, expStrMap, null);
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
+ } finally {
+ LingeredApp.stopApp(theApp);
+ }
+ System.out.println("Test PASSED");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java Thu Nov 16 09:26:48 2017 +0530
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.Platform;
+
+/*
+ * @test
+ * @bug 8190198
+ * @summary Test clhsdb Jstack command
+ * @library /test/lib
+ * @run main/othervm ClhsdbJstack
+ */
+
+public class ClhsdbJstack {
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting ClhsdbJstack test");
+
+ LingeredApp theApp = null;
+ try {
+ ClhsdbLauncher test = new ClhsdbLauncher();
+ theApp = LingeredApp.startApp();
+ System.out.println("Started LingeredApp with pid " + theApp.getPid());
+
+ List<String> cmds = List.of("jstack -v");
+
+ Map<String, List<String>> expStrMap = new HashMap<>();
+ expStrMap.put("jstack -v", List.of(
+ "No deadlocks found",
+ "Common-Cleaner",
+ "Signal Dispatcher",
+ "java.lang.ref.Finalizer$FinalizerThread.run",
+ "java.lang.ref.Reference",
+ "Method*",
+ "LingeredApp.main"));
+
+ test.run(theApp.getPid(), cmds, expStrMap, null);
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
+ } finally {
+ LingeredApp.stopApp(theApp);
+ }
+ System.out.println("Test PASSED");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbLauncher.java Thu Nov 16 09:26:48 2017 +0530
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.Map;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.Platform;
+import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.process.OutputAnalyzer;
+
+/**
+ * This is a framework to run 'jhsdb clhsdb' commands.
+ * See open/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java for
+ * an example of how to write a test.
+ */
+
+public class ClhsdbLauncher {
+
+ private Process toolProcess;
+
+ public void ClhsdbLauncher() {
+ toolProcess = null;
+ }
+
+ /**
+ *
+ * Launches 'jhsdb clhsdb' and attaches to the Lingered App process.
+ * @param lingeredAppPid - pid of the Lingered App or one its sub-classes.
+ */
+ private void attach(long lingeredAppPid)
+ throws IOException {
+
+ System.out.println("Starting clhsdb against " + lingeredAppPid);
+ JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
+ launcher.addToolArg("clhsdb");
+ launcher.addToolArg("--pid=" + Long.toString(lingeredAppPid));
+
+ ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
+ processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
+
+ toolProcess = processBuilder.start();
+ }
+
+ /**
+ *
+ * Runs 'jhsdb clhsdb' commands and checks for expected and unexpected strings.
+ * @param commands - clhsdb commands to execute.
+ * @param expectedStrMap - Map of expected strings per command which need to
+ * be checked in the output of the command.
+ * @param unExpectedStrMap - Map of unexpected strings per command which should
+ * not be present in the output of the command.
+ * @return Output of the commands as a String.
+ */
+ private String runCmd(List<String> commands,
+ Map<String, List<String>> expectedStrMap,
+ Map<String, List<String>> unExpectedStrMap)
+ throws IOException, InterruptedException {
+ String output;
+
+ if (commands == null) {
+ throw new RuntimeException("CLHSDB command must be provided\n");
+ }
+
+ try (OutputStream out = toolProcess.getOutputStream()) {
+ for (String cmd : commands) {
+ out.write((cmd + "\n").getBytes());
+ }
+ out.write("quit\n".getBytes());
+ out.flush();
+ }
+
+ OutputAnalyzer oa = new OutputAnalyzer(toolProcess);
+ try {
+ toolProcess.waitFor();
+ } catch (InterruptedException ie) {
+ toolProcess.destroyForcibly();
+ throw new Error("Problem awaiting the child process: " + ie);
+ }
+
+ oa.shouldHaveExitValue(0);
+ output = oa.getOutput();
+ System.out.println(output);
+
+ String[] parts = output.split("hsdb>");
+ for (String cmd : commands) {
+ int index = commands.indexOf(cmd) + 1;
+ OutputAnalyzer out = new OutputAnalyzer(parts[index]);
+
+ if (expectedStrMap != null) {
+ List<String> expectedStr = expectedStrMap.get(cmd);
+ if (expectedStr != null) {
+ for (String exp : expectedStr) {
+ out.shouldContain(exp);
+ }
+ }
+ }
+
+ if (unExpectedStrMap != null) {
+ List<String> unExpectedStr = unExpectedStrMap.get(cmd);
+ if (unExpectedStr != null) {
+ for (String unExp : unExpectedStr) {
+ out.shouldNotContain(unExp);
+ }
+ }
+ }
+ }
+ return output;
+ }
+
+ /**
+ *
+ * Launches 'jhsdb clhsdb', attaches to the Lingered App, executes the commands,
+ * checks for expected and unexpected strings.
+ * @param lingeredAppPid - pid of the Lingered App or one its sub-classes.
+ * @param commands - clhsdb commands to execute.
+ * @param expectedStrMap - Map of expected strings per command which need to
+ * be checked in the output of the command.
+ * @param unExpectedStrMap - Map of unexpected strings per command which should
+ * not be present in the output of the command.
+ * @return Output of the commands as a String.
+ */
+ public String run(long lingeredAppPid,
+ List<String> commands,
+ Map<String, List<String>> expectedStrMap,
+ Map<String, List<String>> unExpectedStrMap)
+ throws IOException, InterruptedException {
+
+ if (!Platform.shouldSAAttach()) {
+ // Silently skip the test if we don't have enough permissions to attach
+ System.out.println("SA attach not expected to work - test skipped.");
+ return null;
+ }
+
+ attach(lingeredAppPid);
+ return runCmd(commands, expectedStrMap, unExpectedStrMap);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java Thu Nov 16 09:26:48 2017 +0530
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.Platform;
+
+/*
+ * @test
+ * @bug 8190198
+ * @summary Test clhsdb longConstant command
+ * @library /test/lib
+ * @run main/othervm ClhsdbLongConstant
+ */
+
+public class ClhsdbLongConstant {
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting ClhsdbLongConstant test");
+
+ LingeredApp theApp = null;
+ try {
+ ClhsdbLauncher test = new ClhsdbLauncher();
+ theApp = LingeredApp.startApp();
+ System.out.println("Started LingeredApp with pid " + theApp.getPid());
+
+ List<String> cmds = List.of(
+ "longConstant",
+ "longConstant markOopDesc::locked_value",
+ "longConstant markOopDesc::lock_bits",
+ "longConstant jtreg::test 6",
+ "longConstant jtreg::test");
+
+ Map<String, List<String>> expStrMap = new HashMap<>();
+ expStrMap.put("longConstant", List.of(
+ "longConstant markOopDesc::locked_value",
+ "longConstant markOopDesc::lock_bits",
+ "InvocationCounter::count_increment",
+ "markOopDesc::epoch_mask_in_place"));
+ expStrMap.put("longConstant markOopDesc::locked_value", List.of(
+ "longConstant markOopDesc::locked_value"));
+ expStrMap.put("longConstant markOopDesc::lock_bits", List.of(
+ "longConstant markOopDesc::lock_bits"));
+ expStrMap.put("longConstant jtreg::test", List.of(
+ "longConstant jtreg::test 6"));
+
+ Map<String, List<String>> unExpStrMap = new HashMap<>();
+ unExpStrMap.put("longConstant jtreg::test", List.of(
+ "Error: java.lang.RuntimeException: No long constant named"));
+
+ test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
+ } finally {
+ LingeredApp.stopApp(theApp);
+ }
+ System.out.println("Test PASSED");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java Thu Nov 16 09:26:48 2017 +0530
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.Platform;
+
+/*
+ * @test
+ * @bug 8190198
+ * @summary Test clhsdb pmap command
+ * @library /test/lib
+ * @requires os.family != "mac"
+ * @run main/othervm ClhsdbPmap
+ */
+
+public class ClhsdbPmap {
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting ClhsdbPmap test");
+
+ LingeredApp theApp = null;
+ try {
+ ClhsdbLauncher test = new ClhsdbLauncher();
+ theApp = LingeredApp.startApp();
+ System.out.println("Started LingeredApp with pid " + theApp.getPid());
+
+ List<String> cmds = List.of("pmap");
+
+ Map<String, List<String>> expStrMap = new HashMap<>();
+ expStrMap.put("pmap", List.of(
+ "jvm", "java", "net", "nio",
+ "jimage", "zip", "verify"));
+
+ test.run(theApp.getPid(), cmds, expStrMap, null);
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
+ } finally {
+ LingeredApp.stopApp(theApp);
+ }
+ System.out.println("Test PASSED");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java Thu Nov 16 09:26:48 2017 +0530
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.Platform;
+
+/*
+ * @test
+ * @bug 8190198
+ * @summary Test clhsdb printstatics command
+ * @library /test/lib
+ * @run main/othervm ClhsdbPrintStatics
+ */
+
+public class ClhsdbPrintStatics {
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting ClhsdbPrintStatics test");
+
+ LingeredApp theApp = null;
+ try {
+ ClhsdbLauncher test = new ClhsdbLauncher();
+ theApp = LingeredApp.startApp();
+ System.out.println("Started LingeredApp with pid " + theApp.getPid());
+
+ List<String> cmds = List.of(
+ "printstatics", "printstatics SystemDictionary",
+ "printstatics Threads", "printstatics Universe",
+ "printstatics JvmtiExport");
+
+ Map<String, List<String>> expStrMap = new HashMap<>();
+ expStrMap.put("printstatics", List.of(
+ "All known static fields",
+ "Abstract_VM_Version::_vm_major_version",
+ "ClassLoaderDataGraph::_head", "SymbolTable::_the_table",
+ "JNIHandles::_weak_global_handles", "PerfMemory::_top",
+ "_jfr_checkpoints", "ObjectSynchronizer::gBlockList",
+ "java_lang_Class::_oop_size_offset",
+ "CodeCache::_scavenge_root_nmethods"));
+ expStrMap.put("printstatics SystemDictionary", List.of(
+ "Static fields of SystemDictionary",
+ "SystemDictionary::Class_klass_knum",
+ "SystemDictionary::ClassLoader_klass_knum",
+ "SystemDictionary::Object_klass_knum"));
+ expStrMap.put("printstatics Threads", List.of(
+ "Static fields of Threads",
+ "_number_of_threads", "_number_of_non_daemon_threads",
+ "JavaThread* Threads"));
+ expStrMap.put("printstatics Universe", List.of(
+ "Static fields of Universe",
+ "uintptr_t Universe::_verify_oop_mask",
+ "intptr_t Universe::_non_oop_bits",
+ "bool Universe::_fully_initialized",
+ "Universe::_doubleArrayKlassObj"));
+ expStrMap.put("printstatics JvmtiExport", List.of(
+ "Static fields of JvmtiExport",
+ "bool JvmtiExport::_can_access_local_variables",
+ "bool JvmtiExport::_can_hotswap_or_post_breakpoint",
+ "bool JvmtiExport::_can_post_on_exceptions"));
+
+ test.run(theApp.getPid(), cmds, expStrMap, null);
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
+ } finally {
+ LingeredApp.stopApp(theApp);
+ }
+ System.out.println("Test PASSED");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java Thu Nov 16 09:26:48 2017 +0530
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.Platform;
+
+/*
+ * @test
+ * @bug 8190198
+ * @summary Test clhsdb pstack command
+ * @library /test/lib
+ * @requires os.family != "mac"
+ * @run main/othervm ClhsdbPstack
+ */
+
+public class ClhsdbPstack {
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting ClhsdbPstack test");
+
+ LingeredApp theApp = null;
+ try {
+ ClhsdbLauncher test = new ClhsdbLauncher();
+ theApp = LingeredApp.startApp();
+ System.out.println("Started LingeredApp with pid " + theApp.getPid());
+
+ List<String> cmds = List.of("pstack -v");
+
+ Map<String, List<String>> expStrMap = new HashMap<>();
+ expStrMap.put("pstack -v", List.of(
+ "No deadlocks found", "Common-Cleaner",
+ "Signal Dispatcher", "CompilerThread",
+ "Sweeper thread", "Service Thread",
+ "Reference Handler", "Finalizer", "main"));
+
+ test.run(theApp.getPid(), cmds, expStrMap, null);
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
+ } finally {
+ LingeredApp.stopApp(theApp);
+ }
+ System.out.println("Test PASSED");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbSymbol.java Thu Nov 16 09:26:48 2017 +0530
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.Platform;
+
+/*
+ * @test
+ * @bug 8190198
+ * @summary Test clhsdb symboldump command
+ * @library /test/lib
+ * @run main/othervm ClhsdbSymbol
+ */
+
+public class ClhsdbSymbol {
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting ClhsdbSymbol test");
+
+ LingeredApp theApp = null;
+ try {
+ ClhsdbLauncher test = new ClhsdbLauncher();
+ theApp = LingeredApp.startApp();
+ System.out.println("Started LingeredApp with pid " + theApp.getPid());
+
+ List<String> cmds = List.of("symboldump");
+
+ Map<String, List<String>> expStrMap = new HashMap<>();
+ expStrMap.put("symboldump", List.of(
+ "java/lang/String", "java/util/HashMap", "UsageTracker",
+ "Ljava/io/InputStream", "LambdaMetafactory", "PerfCounter",
+ "isAnonymousClass", "JVMTI_THREAD_STATE_TERMINATED", "jdi",
+ "checkGetClassLoaderPermission", "lockCreationTime",
+ "storedAppOutput", "storedAppOutput", "getProcess",
+ "LingeredApp"));
+
+ test.run(theApp.getPid(), cmds, expStrMap, null);
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
+ } finally {
+ LingeredApp.stopApp(theApp);
+ }
+ System.out.println("Test PASSED");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbWhere.java Thu Nov 16 09:26:48 2017 +0530
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.Platform;
+
+/*
+ * @test
+ * @bug 8190198
+ * @summary Test clhsdb where command
+ * @library /test/lib
+ * @run main/othervm ClhsdbWhere
+ */
+
+public class ClhsdbWhere {
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting ClhsdbWhere test");
+
+ LingeredApp theApp = null;
+ try {
+ ClhsdbLauncher test = new ClhsdbLauncher();
+ theApp = LingeredApp.startApp();
+ System.out.println("Started LingeredApp with pid " + theApp.getPid());
+
+ List<String> cmds = List.of("where -a");
+
+ Map<String, List<String>> expStrMap = new HashMap<>();
+ expStrMap.put("where -a", List.of(
+ "Java Stack Trace for Service Thread",
+ "Java Stack Trace for Common-Cleaner",
+ "Java Stack Trace for Sweeper thread",
+ "CompilerThread",
+ "Java Stack Trace for Finalizer",
+ "java.lang.ref.Reference",
+ "private static void processPendingReferences",
+ "private static native void waitForReferencePendingList",
+ "Java Stack Trace for main",
+ "public static native void sleep"));
+
+ test.run(theApp.getPid(), cmds, expStrMap, null);
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
+ } finally {
+ LingeredApp.stopApp(theApp);
+ }
+
+ System.out.println("Test PASSED");
+ }
+}