Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.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.util.HashMap;24import java.util.List;25import java.util.Map;2627import jdk.test.lib.apps.LingeredApp;28import jtreg.SkippedException;2930/**31* @test32* @bug 819019833* @summary Test clhsdb Jstack command34* @requires vm.hasSA35* @library /test/lib36* @run main/othervm/timeout=480 ClhsdbJstack true37*/3839/**40* @test41* @bug 819019842* @requires vm.compMode != "Xcomp"43* @summary Test clhsdb Jstack command44* @requires vm.hasSA45* @library /test/lib46* @run main/othervm/timeout=480 ClhsdbJstack false47*/4849public class ClhsdbJstack {5051private static void testJstack(boolean withXcomp) throws Exception {52LingeredApp theApp = null;53try {54ClhsdbLauncher test = new ClhsdbLauncher();55theApp = withXcomp ? LingeredApp.startApp("-Xcomp")56: LingeredApp.startApp();57System.out.print("Started LingeredApp ");58if (withXcomp) {59System.out.print("(-Xcomp) ");60}61System.out.println("with pid " + theApp.getPid());6263List<String> cmds = List.of("jstack -v");6465Map<String, List<String>> expStrMap = new HashMap<>();66expStrMap.put("jstack -v", List.of(67"No deadlocks found",68"Common\\-Cleaner",69"Signal Dispatcher",70"java.lang.ref.Finalizer\\$FinalizerThread.run",71"java.lang.ref.Reference",72"Method\\*",73"LingeredApp.steadyState"));7475test.run(theApp.getPid(), cmds, expStrMap, null);76} catch (SkippedException se) {77throw se;78} catch (Exception ex) {79throw new RuntimeException("Test ERROR (with -Xcomp=" + withXcomp + ") " + ex, ex);80} finally {81LingeredApp.stopApp(theApp);82}83}8485public static void main(String[] args) throws Exception {86boolean xComp = Boolean.parseBoolean(args[0]);87System.out.println("Starting ClhsdbJstack test");88testJstack(xComp);89System.out.println("Test PASSED");90}91}929394