Path: blob/master/test/hotspot/jtreg/resourcehogs/serviceability/sa/ClhsdbRegionDetailsScanOopsForG1.java
41153 views
/*1* Copyright (c) 2018, 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*/2223/**24* @test25* @bug 817531226* @summary Test clhsdb 'g1regiondetails' and 'scanoops' commands for G1GC27* @requires vm.gc.G128* @requires vm.hasSA & (vm.bits == "64" & os.maxMemory > 8g)29* @library /test/lib /test/hotspot/jtreg/serviceability/sa30* @run main/othervm/timeout=2400 ClhsdbRegionDetailsScanOopsForG131*/3233import java.util.HashMap;34import java.util.List;35import java.util.ArrayList;36import java.util.Map;37import jdk.test.lib.apps.LingeredApp;38import jtreg.SkippedException;3940public class ClhsdbRegionDetailsScanOopsForG1 {4142public static void main(String[] args) throws Exception {43System.out.println("Starting ClhsdbRegionDetailsScanOopsForG1 test");4445LingeredAppWithLargeStringArray theApp = null;46try {47ClhsdbLauncher test = new ClhsdbLauncher();4849theApp = new LingeredAppWithLargeStringArray();50LingeredApp.startApp(theApp,51"-XX:+UseG1GC",52"-Xmx8g",53"-XX:G1HeapRegionSize=2m");54System.out.println("Started LingeredAppWithLargeStringArray with pid " + theApp.getPid());5556List<String> cmds = List.of("g1regiondetails");57Map<String, List<String>> expStrMap = new HashMap<>();58Map<String, List<String>> unExpStrMap = new HashMap<>();5960// Test that the various types of regions are listed with the61// 'g1regiondetails' command62expStrMap.put("g1regiondetails", List.of(63"Region",64"Eden",65"Survivor",66"StartsHumongous",67"ContinuesHumongous",68"Free"));69unExpStrMap.put("g1regiondetails", List.of("Unknown Region Type"));70String regionDetailsOutput = test.run(theApp.getPid(), cmds,71expStrMap, unExpStrMap);72// Test the output of 'scanoops' -- get the start and end addresses73// from the StartsHumongous region. Ensure that it contains an74// array of Strings.75String[] snippets = regionDetailsOutput.split(":StartsHumongous");76snippets = snippets[0].split("Region: ");77String[] words = snippets[snippets.length - 1].split(",");78// words[0] and words[1] represent the start and end addresses79String cmd = "scanoops " + words[0] + " " + words[1];80expStrMap = new HashMap<>();81expStrMap.put(cmd, List.of("\\[Ljava/lang/String"));82test.run(theApp.getPid(), List.of(cmd), expStrMap, null);83} catch (SkippedException e) {84throw e;85} catch (Exception ex) {86throw new RuntimeException("Test ERROR " + ex, ex);87} finally {88LingeredApp.stopApp(theApp);89}90System.out.println("Test PASSED");91}92}939495