hotspot/test/gc/g1/mixedgc/TestLogging.java
author cjplummer
Thu, 29 Oct 2015 12:04:04 -0700
changeset 33730 30e064828045
parent 33140 7ff907b9d377
child 35061 be6025ebffea
permissions -rw-r--r--
8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests Summary: Use new external.lib.roots property in TEST.ROOT so /../../test/lib is not needed. Reviewed-by: mseledtsov, sla, iklam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33102
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
     1
/*
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
     4
 *
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
     8
 *
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    13
 * accompanied this code).
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    14
 *
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    18
 *
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    21
 * questions.
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    22
 */
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    23
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    24
/*
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    25
 * @test TestLogging
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    26
 * @summary Check that a mixed GC is reflected in the gc logs
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    27
 * @requires vm.gc=="G1" | vm.gc=="null"
33730
30e064828045 8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests
cjplummer
parents: 33140
diff changeset
    28
 * @library /testlibrary /test/lib
33140
7ff907b9d377 8138958: Quarantine gc/g1/mixedgc/TestLogging.java test
kzhaldyb
parents: 33102
diff changeset
    29
 * @ignore 8138607
33102
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    30
 * @modules java.management
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    31
 * @build sun.hotspot.WhiteBox gc.g1.mixedgc.TestLogging
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    32
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    33
 * @run driver gc.g1.mixedgc.TestLogging
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    34
 */
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    35
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    36
package gc.g1.mixedgc;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    37
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    38
import jdk.test.lib.OutputAnalyzer;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    39
import jdk.test.lib.ProcessTools;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    40
import jdk.test.lib.Asserts;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    41
import sun.hotspot.WhiteBox;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    42
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    43
import java.util.ArrayList;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    44
import java.util.List;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    45
import java.util.Collections;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    46
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    47
/**
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    48
 * Test spawns MixedGCProvoker in a separate VM and expects to find a message
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    49
 * telling that a mixed gc has happened
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    50
 */
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    51
public class TestLogging {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    52
    private static final String[] COMMON_OPTIONS = new String[]{
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    53
            "-Xbootclasspath/a:.", "-XX:+UseG1GC",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    54
            "-XX:+UnlockExperimentalVMOptions",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    55
            "-XX:+UnlockDiagnosticVMOptions",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    56
            "-XX:+WhiteBoxAPI",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    57
            "-XX:SurvivorRatio=1", // Survivor-to-eden ratio is 1:1
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    58
            "-Xms10M", "-Xmx10M",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    59
            "-XX:MaxTenuringThreshold=1", // promote objects after first gc
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    60
            "-XX:InitiatingHeapOccupancyPercent=0", // marking cycle happens
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    61
            // each time
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    62
            "-XX:G1MixedGCCountTarget=4",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    63
            "-XX:MaxGCPauseMillis=30000", // to have enough time
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    64
            "-XX:G1HeapRegionSize=1m", "-XX:G1HeapWastePercent=0",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    65
            "-XX:G1MixedGCLiveThresholdPercent=100"};
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    66
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    67
    public static final int ALLOCATION_SIZE = 20000;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    68
    public static final int ALLOCATION_COUNT = 15;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    69
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    70
    public static void main(String args[]) throws Exception {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    71
        // Test turns logging on by giving -XX:+PrintGC flag
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    72
        test("-XX:+PrintGC");
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    73
        // Test turns logging on by giving -XX:+PrintGCDetails
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    74
        test("-XX:+PrintGCDetails");
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    75
    }
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    76
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    77
    private static void test(String vmFlag) throws Exception {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    78
        System.out.println(String.format("%s: running with %s flag", TestLogging.class.getSimpleName(), vmFlag));
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    79
        OutputAnalyzer output = spawnMixedGCProvoker(vmFlag);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    80
        System.out.println(output.getStdout());
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    81
        output.shouldHaveExitValue(0);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    82
        output.shouldContain("GC pause (G1 Evacuation Pause) (mixed)");
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    83
    }
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    84
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    85
    /**
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    86
     * Method spawns MixedGCProvoker with addition flags set
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    87
     *
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    88
     * @parameter extraFlags -flags to be added to the common options set
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    89
     */
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    90
    private static OutputAnalyzer spawnMixedGCProvoker(String... extraFlags)
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    91
            throws Exception {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    92
        List<String> testOpts = new ArrayList<>();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    93
        Collections.addAll(testOpts, COMMON_OPTIONS);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    94
        Collections.addAll(testOpts, extraFlags);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    95
        testOpts.add(MixedGCProvoker.class.getName());
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    96
        System.out.println(testOpts);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    97
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false,
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    98
                testOpts.toArray(new String[testOpts.size()]));
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    99
        return new OutputAnalyzer(pb.start());
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   100
    }
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   101
}
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   102
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   103
/**
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   104
 * Utility class to guarantee a mixed GC. The class allocates several arrays and
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   105
 * promotes them to the oldgen. After that it tries to provoke mixed GC by
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   106
 * allocating new objects.
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   107
 *
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   108
 * The necessary condition for guaranteed mixed GC is running MixedGCProvoker is
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   109
 * running in VM with the following flags: -XX:MaxTenuringThreshold=1, -Xms10M,
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   110
 * -Xmx10M, -XX:G1MixedGCLiveThresholdPercent=100, -XX:G1HeapWastePercent=0,
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   111
 * -XX:G1HeapRegionSize=1m
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   112
 */
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   113
class MixedGCProvoker {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   114
    private static final WhiteBox WB = WhiteBox.getWhiteBox();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   115
    private static final List<byte[]> liveOldObjects = new ArrayList<>();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   116
    private static final List<byte[]> newObjects = new ArrayList<>();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   117
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   118
    private static void allocateOldObjects() throws Exception {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   119
        List<byte[]> deadOldObjects = new ArrayList<>();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   120
        // Allocates buffer and promotes it to the old gen. Mix live and dead old
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   121
        // objects
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   122
        for (int i = 0; i < TestLogging.ALLOCATION_COUNT; ++i) {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   123
            liveOldObjects.add(new byte[TestLogging.ALLOCATION_SIZE * 10]);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   124
            deadOldObjects.add(new byte[TestLogging.ALLOCATION_SIZE * 10]);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   125
        }
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   126
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   127
        // need only 2 promotions to promote objects to the old gen
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   128
        WB.youngGC();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   129
        WB.youngGC();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   130
        // check it is promoted & keep alive
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   131
        Asserts.assertTrue(WB.isObjectInOldGen(liveOldObjects),
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   132
                "List of the objects is suppose to be in OldGen");
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   133
        Asserts.assertTrue(WB.isObjectInOldGen(deadOldObjects),
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   134
                "List of the objects is suppose to be in OldGen");
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   135
    }
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   136
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   137
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   138
    /**
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   139
     * Waits until Concurent Mark Cycle finishes
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   140
     * @param wb  Whitebox instance
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   141
     * @param sleepTime sleep time
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   142
     */
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   143
    public static void waitTillCMCFinished(WhiteBox wb, int sleepTime) {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   144
        while (wb.g1InConcurrentMark()) {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   145
            if (sleepTime > -1) {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   146
                try {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   147
                    Thread.sleep(sleepTime);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   148
                } catch (InterruptedException e) {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   149
                    System.out.println("Got InterruptedException while waiting for ConcMarkCycle to finish");
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   150
                }
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   151
            }
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   152
        }
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   153
    }
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   154
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   155
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   156
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   157
    public static void main(String args[]) throws Exception {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   158
        // allocate old objects
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   159
        allocateOldObjects();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   160
        waitTillCMCFinished(WB, 0);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   161
        WB.g1StartConcMarkCycle();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   162
        waitTillCMCFinished(WB, 0);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   163
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   164
        WB.youngGC();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   165
        System.out.println("Allocating new objects to provoke mixed GC");
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   166
        // allocate more objects to provoke GC
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   167
        for (int i = 0; i < (TestLogging.ALLOCATION_COUNT * 20); i++) {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   168
            newObjects.add(new byte[TestLogging.ALLOCATION_SIZE]);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   169
        }
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   170
        // check that liveOldObjects still alive
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   171
        Asserts.assertTrue(WB.isObjectInOldGen(liveOldObjects),
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   172
                "List of the objects is suppose to be in OldGen");
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   173
    }
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   174
}