Path: blob/master/test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java
41149 views
/*1* Copyright (c) 2017, 2020, 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.ArrayList;24import java.util.List;25import jdk.test.lib.apps.LingeredApp;26import jdk.test.lib.Utils;27import java.util.Map;28import java.util.HashMap;29import jtreg.SkippedException;3031/**32* @test33* @requires vm.hasSA34* @library /test/lib35* @run main/othervm TestClhsdbJstackLock36*/3738public class TestClhsdbJstackLock {3940public static void main (String... args) throws Exception {41System.out.println("Starting TestClhsdbJstackLock test");42LingeredAppWithLock app = null;43try {44ClhsdbLauncher test = new ClhsdbLauncher();4546app = new LingeredAppWithLock();47LingeredApp.startApp(app);4849System.out.println ("Started LingeredAppWithLock with pid " + app.getPid());5051List<String> cmds = List.of("jstack");5253Map<String, List<String>> expStrMap = new HashMap<>();54Map<String, List<String>> unExpStrMap = new HashMap<>();55expStrMap.put("jstack", List.of(56"^\\s+- locked <0x[0-9a-f]+> \\(a java\\.lang\\.Class for LingeredAppWithLock\\)$",57"^\\s+- waiting to lock <0x[0-9a-f]+> \\(a java\\.lang\\.Class for LingeredAppWithLock\\)$",58"^\\s+- locked <0x[0-9a-f]+> \\(a java\\.lang\\.Thread\\)$",59"^\\s+- locked <0x[0-9a-f]+> \\(a java\\.lang\\.Class for int\\)$"));60unExpStrMap.put("jstack", List.of(61"missing reason for "));62test.run(app.getPid(), cmds, expStrMap, unExpStrMap);63} catch (SkippedException se) {64throw se;65} catch (Exception ex) {66throw new RuntimeException("Test ERROR " + ex, ex);67} finally {68LingeredApp.stopApp(app);69}7071System.out.println("Test PASSED");72}73}747576