hotspot/test/gc/g1/TestPrintRegionRememberedSetInfo.java
author brutisso
Thu, 10 Dec 2015 14:57:55 +0100
changeset 35061 be6025ebffea
parent 30604 b8d532cb6420
child 36851 03e2f4d0a421
permissions -rw-r--r--
8145092: Use Unified Logging for the GC logging Summary: JEP-271. VM changes contributed by brutisso, test changes contributed by david. Reviewed-by: sjohanss, david, brutisso Contributed-by: bengt.rutisson@oracle.com, david.lindholm@oralce.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17395
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 18993
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
17395
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     4
 *
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     8
 *
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    14
 *
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    18
 *
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    21
 * questions.
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    22
 */
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    23
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    24
/**
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    25
 * @test TestPrintRegionRememberedSetInfo
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    26
 * @key gc
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    27
 * @bug 8014240
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    28
 * @summary Test output of G1PrintRegionRememberedSetInfo
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    29
 * @library /testlibrary
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 18993
diff changeset
    30
 * @modules java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 18993
diff changeset
    31
 *          java.management
18993
58423218a3f6 8020123: Test gc/g1/TestPrintRegionRememberedSetInfo.java fails with "test result: Error. No action after @build"
tschatzl
parents: 17395
diff changeset
    32
 * @run main TestPrintRegionRememberedSetInfo
17395
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    33
 * @author thomas.schatzl@oracle.com
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    34
 */
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    35
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    36
import jdk.test.lib.*;
17395
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    37
import java.lang.Thread;
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    38
import java.util.ArrayList;
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    39
import java.util.Arrays;
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    40
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    41
class RunAndWaitForMarking {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    42
    public static void main(String[] args) {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    43
        System.gc();
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    44
        try {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    45
            Thread.sleep(200);
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    46
        } catch (InterruptedException e) {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    47
        }
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    48
    }
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    49
}
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    50
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    51
public class TestPrintRegionRememberedSetInfo {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    52
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    53
    public static String runTest(String arg) throws Exception {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    54
        ArrayList<String> finalargs = new ArrayList<String>();
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    55
        String[] defaultArgs = new String[] {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    56
            "-XX:+UseG1GC",
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    57
            "-Xmx10m",
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    58
            "-XX:+ExplicitGCInvokesConcurrent",
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    59
            "-XX:+UnlockDiagnosticVMOptions",
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    60
            "-XX:G1HeapRegionSize=1M",
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    61
            "-XX:InitiatingHeapOccupancyPercent=0",
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    62
        };
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    63
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    64
        finalargs.addAll(Arrays.asList(defaultArgs));
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    65
        finalargs.add(arg);
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    66
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    67
        finalargs.add(RunAndWaitForMarking.class.getName());
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    68
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    69
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    70
            finalargs.toArray(new String[0]));
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    71
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    72
        output.shouldHaveExitValue(0);
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    73
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    74
        String result = output.getStdout();
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    75
        return result;
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    76
    }
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    77
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    78
    public static void main(String[] args) throws Exception {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    79
        String result;
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    80
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    81
        result = runTest("-Xlog:gc+liveness=trace");
17395
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    82
        // check that we got region statistics output
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    83
        if (result.indexOf("PHASE") == -1) {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    84
            throw new RuntimeException("Unexpected output from -XX:+PrintRegionLivenessInfo found.");
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    85
        }
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    86
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    87
        result = runTest("-Xlog:gc+liveness");
17395
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    88
        if (result.indexOf("remset") != -1) {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    89
            throw new RuntimeException("Should find remembered set information in output.");
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    90
        }
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    91
    }
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    92
}
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    93