Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java
41149 views
/*1* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.nio.file.Files;24import java.nio.file.Path;25import java.nio.file.Paths;26import java.util.HashMap;27import java.util.List;28import java.util.Map;2930import jdk.test.lib.apps.LingeredApp;31import jtreg.SkippedException;3233/**34* @test35* @bug 819282336* @summary Test clhsdb source command37* @requires vm.hasSA38* @library /test/lib39* @run main/othervm ClhsdbSource40*/4142public class ClhsdbSource {4344public static void main(String[] args) throws Exception {45System.out.println("Starting ClhsdbSource test");4647LingeredApp theApp = null;48try {49ClhsdbLauncher test = new ClhsdbLauncher();50theApp = LingeredApp.startApp();51System.out.println("Started LingeredApp with pid " + theApp.getPid());5253Path file = Paths.get("clhsdb_cmd_file");54Files.write(file, "jstack -v\nhelp".getBytes());55List<String> cmds = List.of("source clhsdb_cmd_file");5657Map<String, List<String>> expStrMap = new HashMap<>();58expStrMap.put("source clhsdb_cmd_file", List.of(59"No deadlocks found",60"Common\\-Cleaner",61"Signal Dispatcher",62"java.lang.ref.Finalizer\\$FinalizerThread.run",63"java.lang.ref.Reference",64"Method\\*",65"LingeredApp.steadyState",66"Available commands:",67"attach pid \\| exec core",68"intConstant \\[ name \\[ value \\] \\]",69"type \\[ type \\[ name super isOop isInteger isUnsigned size \\] \\]"));7071Map<String, List<String>> unExpStrMap = new HashMap<>();72unExpStrMap.put("source clhsdb_cmd_file", List.of(73"No such file or directory"));7475test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);76Files.delete(file);77} catch (SkippedException se) {78throw se;79} catch (Exception ex) {80throw new RuntimeException("Test ERROR " + ex, ex);81} finally {82LingeredApp.stopApp(theApp);83}84System.out.println("Test PASSED");85}86}878889