tschatzl@5122: /* tschatzl@5122: * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. tschatzl@5122: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. tschatzl@5122: * tschatzl@5122: * This code is free software; you can redistribute it and/or modify it tschatzl@5122: * under the terms of the GNU General Public License version 2 only, as tschatzl@5122: * published by the Free Software Foundation. tschatzl@5122: * tschatzl@5122: * This code is distributed in the hope that it will be useful, but WITHOUT tschatzl@5122: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or tschatzl@5122: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License tschatzl@5122: * version 2 for more details (a copy is included in the LICENSE file that tschatzl@5122: * accompanied this code). tschatzl@5122: * tschatzl@5122: * You should have received a copy of the GNU General Public License version tschatzl@5122: * 2 along with this work; if not, write to the Free Software Foundation, tschatzl@5122: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. tschatzl@5122: * tschatzl@5122: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA tschatzl@5122: * or visit www.oracle.com if you need additional information or have any tschatzl@5122: * questions. tschatzl@5122: */ tschatzl@5122: tschatzl@5122: /** tschatzl@5122: * @test TestPrintRegionRememberedSetInfo tschatzl@5122: * @key gc tschatzl@5122: * @bug 8014240 tschatzl@5122: * @summary Test output of G1PrintRegionRememberedSetInfo tschatzl@5122: * @library /testlibrary tschatzl@5458: * @run main TestPrintRegionRememberedSetInfo tschatzl@5122: * @author thomas.schatzl@oracle.com tschatzl@5122: */ tschatzl@5122: tschatzl@5122: import com.oracle.java.testlibrary.*; tschatzl@5122: import java.lang.Thread; tschatzl@5122: import java.util.ArrayList; tschatzl@5122: import java.util.Arrays; tschatzl@5122: tschatzl@5122: class RunAndWaitForMarking { tschatzl@5122: public static void main(String[] args) { tschatzl@5122: System.gc(); tschatzl@5122: try { tschatzl@5122: Thread.sleep(200); tschatzl@5122: } catch (InterruptedException e) { tschatzl@5122: } tschatzl@5122: } tschatzl@5122: } tschatzl@5122: tschatzl@5122: public class TestPrintRegionRememberedSetInfo { tschatzl@5122: tschatzl@5122: public static String runTest(String arg) throws Exception { tschatzl@5122: ArrayList finalargs = new ArrayList(); tschatzl@5122: String[] defaultArgs = new String[] { tschatzl@5122: "-XX:+UseG1GC", tschatzl@5122: "-Xmx10m", tschatzl@5122: "-XX:+ExplicitGCInvokesConcurrent", tschatzl@5122: "-XX:+UnlockDiagnosticVMOptions", tschatzl@5122: "-XX:+G1PrintRegionLivenessInfo", tschatzl@5122: "-XX:G1HeapRegionSize=1M", tschatzl@5122: "-XX:InitiatingHeapOccupancyPercent=0", tschatzl@5122: }; tschatzl@5122: tschatzl@5122: finalargs.addAll(Arrays.asList(defaultArgs)); tschatzl@5122: finalargs.add(arg); tschatzl@5122: tschatzl@5122: finalargs.add(RunAndWaitForMarking.class.getName()); tschatzl@5122: tschatzl@5122: ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( tschatzl@5122: finalargs.toArray(new String[0])); tschatzl@5122: OutputAnalyzer output = new OutputAnalyzer(pb.start()); tschatzl@5122: output.shouldHaveExitValue(0); tschatzl@5122: tschatzl@5122: String result = output.getStdout(); tschatzl@5122: return result; tschatzl@5122: } tschatzl@5122: tschatzl@5122: public static void main(String[] args) throws Exception { tschatzl@5122: String result; tschatzl@5122: tschatzl@5122: result = runTest("-XX:+G1PrintRegionLivenessInfo"); tschatzl@5122: // check that we got region statistics output tschatzl@5122: if (result.indexOf("PHASE") == -1) { tschatzl@5122: throw new RuntimeException("Unexpected output from -XX:+PrintRegionLivenessInfo found."); tschatzl@5122: } tschatzl@5122: tschatzl@5122: result = runTest("-XX:-G1PrintRegionLivenessInfo"); tschatzl@5122: if (result.indexOf("remset") != -1) { tschatzl@5122: throw new RuntimeException("Should find remembered set information in output."); tschatzl@5122: } tschatzl@5122: } tschatzl@5122: } tschatzl@5122: