Path: blob/master/test/hotspot/jtreg/gc/g1/TestPrintRegionRememberedSetInfo.java
40942 views
/*1* Copyright (c) 2013, 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*/2223package gc.g1;2425/**26* @test TestPrintRegionRememberedSetInfo27* @bug 801424028* @summary Test output of G1PrintRegionRememberedSetInfo29* @requires vm.gc.G130* @library /test/lib31* @modules java.base/jdk.internal.misc32* java.management33* @run driver gc.g1.TestPrintRegionRememberedSetInfo34* @author [email protected]35*/3637import jdk.test.lib.process.OutputAnalyzer;38import jdk.test.lib.process.ProcessTools;39import java.lang.Thread;40import java.util.ArrayList;41import java.util.Arrays;4243class RunAndWaitForMarking {44public static void main(String[] args) {45System.gc();46try {47Thread.sleep(200);48} catch (InterruptedException e) {49}50}51}5253public class TestPrintRegionRememberedSetInfo {5455public static String runTest(String arg) throws Exception {56ArrayList<String> finalargs = new ArrayList<String>();57String[] defaultArgs = new String[] {58"-XX:+UseG1GC",59"-Xmx10m",60"-XX:+ExplicitGCInvokesConcurrent",61"-XX:+UnlockDiagnosticVMOptions",62"-XX:G1HeapRegionSize=1M",63"-XX:InitiatingHeapOccupancyPercent=0",64};6566finalargs.addAll(Arrays.asList(defaultArgs));67finalargs.add(arg);6869finalargs.add(RunAndWaitForMarking.class.getName());7071ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs);72OutputAnalyzer output = new OutputAnalyzer(pb.start());73output.shouldHaveExitValue(0);7475String result = output.getStdout();76return result;77}7879public static void main(String[] args) throws Exception {80String result;8182result = runTest("-Xlog:gc+liveness=trace");83// check that we got region statistics output84if (result.indexOf("PHASE") == -1) {85throw new RuntimeException("Unexpected output from -XX:+PrintRegionLivenessInfo found.");86}8788result = runTest("-Xlog:gc+liveness");89if (result.indexOf("remset") != -1) {90throw new RuntimeException("Should find remembered set information in output.");91}92}93}94959697