test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 40631 hotspot/test/gc/g1/mixedgc/TestLogging.java@ed82623d7831
child 48791 6e079ff6c83c
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
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
/*
38006
65a10510697a 8138607: gc/g1/mixedgc/TestLogging.java - G1 Evacuation Pause missing from output
kzhaldyb
parents: 35061
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
33102
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
39414
4adf52148100 8160088: update hotspot tests depending on GC to use @requires vm.gc.X
dfazunen
parents: 38930
diff changeset
    27
 * @requires vm.gc.G1
38930
469cfb0d7eb3 8157954: [TESTBUG] G1 tests fail with defined MaxGCPauseMillis
mchernov
parents: 38152
diff changeset
    28
 * @requires vm.opt.MaxGCPauseMillis == "null"
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39414
diff changeset
    29
 * @library /test/lib
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 38006
diff changeset
    30
 * @modules java.base/jdk.internal.misc
33102
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    31
 * @modules java.management
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39414
diff changeset
    32
 * @build sun.hotspot.WhiteBox
33102
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    33
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    34
 * @run driver gc.g1.mixedgc.TestLogging
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
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    37
package gc.g1.mixedgc;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    38
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39414
diff changeset
    39
import jdk.test.lib.process.OutputAnalyzer;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39414
diff changeset
    40
import jdk.test.lib.process.ProcessTools;
33102
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    41
import jdk.test.lib.Asserts;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    42
import sun.hotspot.WhiteBox;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    43
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    44
import java.util.ArrayList;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    45
import java.util.List;
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    46
import java.util.Collections;
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
/**
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    49
 * 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
    50
 * 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
    51
 */
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    52
public class TestLogging {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    53
    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
    54
            "-Xbootclasspath/a:.", "-XX:+UseG1GC",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    55
            "-XX:+UnlockExperimentalVMOptions",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    56
            "-XX:+UnlockDiagnosticVMOptions",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    57
            "-XX:+WhiteBoxAPI",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    58
            "-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
    59
            "-Xms10M", "-Xmx10M",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    60
            "-XX:MaxTenuringThreshold=1", // promote objects after first gc
38006
65a10510697a 8138607: gc/g1/mixedgc/TestLogging.java - G1 Evacuation Pause missing from output
kzhaldyb
parents: 35061
diff changeset
    61
            "-XX:InitiatingHeapOccupancyPercent=100", // set initial CMC threshold and disable adaptive IHOP
65a10510697a 8138607: gc/g1/mixedgc/TestLogging.java - G1 Evacuation Pause missing from output
kzhaldyb
parents: 35061
diff changeset
    62
            "-XX:-G1UseAdaptiveIHOP",                 // to avoid additional concurrent cycles caused by ergonomics
33102
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    63
            "-XX:G1MixedGCCountTarget=4",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    64
            "-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
    65
            "-XX:G1HeapRegionSize=1m", "-XX:G1HeapWastePercent=0",
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    66
            "-XX:G1MixedGCLiveThresholdPercent=100"};
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    67
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    68
    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
    69
    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
    70
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    71
    public static void main(String args[]) throws Exception {
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33730
diff changeset
    72
        // Test turns logging on by giving -Xlog:gc flag
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33730
diff changeset
    73
        test("-Xlog:gc");
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33730
diff changeset
    74
        // Test turns logging on by giving -Xlog:gc=debug flag
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33730
diff changeset
    75
        test("-Xlog:gc=debug");
33102
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
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    78
    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
    79
        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
    80
        OutputAnalyzer output = spawnMixedGCProvoker(vmFlag);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    81
        System.out.println(output.getStdout());
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    82
        output.shouldHaveExitValue(0);
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33730
diff changeset
    83
        output.shouldContain("Pause Mixed (G1 Evacuation Pause)");
33102
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
    /**
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    87
     * 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
    88
     *
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    89
     * @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
    90
     */
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    91
    private static OutputAnalyzer spawnMixedGCProvoker(String... extraFlags)
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    92
            throws Exception {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    93
        List<String> testOpts = new ArrayList<>();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    94
        Collections.addAll(testOpts, COMMON_OPTIONS);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    95
        Collections.addAll(testOpts, extraFlags);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    96
        testOpts.add(MixedGCProvoker.class.getName());
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    97
        System.out.println(testOpts);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    98
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false,
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
    99
                testOpts.toArray(new String[testOpts.size()]));
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   100
        return new OutputAnalyzer(pb.start());
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
/**
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   105
 * 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
   106
 * 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
   107
 * allocating new objects.
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   108
 *
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   109
 * 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
   110
 * 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
   111
 * -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
   112
 * -XX:G1HeapRegionSize=1m
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   113
 */
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   114
class MixedGCProvoker {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   115
    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
   116
    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
   117
    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
   118
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   119
    private static void allocateOldObjects() throws Exception {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   120
        List<byte[]> deadOldObjects = new ArrayList<>();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   121
        // 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
   122
        // objects
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   123
        for (int i = 0; i < TestLogging.ALLOCATION_COUNT; ++i) {
38006
65a10510697a 8138607: gc/g1/mixedgc/TestLogging.java - G1 Evacuation Pause missing from output
kzhaldyb
parents: 35061
diff changeset
   124
            liveOldObjects.add(new byte[TestLogging.ALLOCATION_SIZE * 5]);
65a10510697a 8138607: gc/g1/mixedgc/TestLogging.java - G1 Evacuation Pause missing from output
kzhaldyb
parents: 35061
diff changeset
   125
            deadOldObjects.add(new byte[TestLogging.ALLOCATION_SIZE * 5]);
33102
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
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   128
        // 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
   129
        WB.youngGC();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   130
        WB.youngGC();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   131
        // check it is promoted & keep alive
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   132
        Asserts.assertTrue(WB.isObjectInOldGen(liveOldObjects),
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   133
                "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
   134
        Asserts.assertTrue(WB.isObjectInOldGen(deadOldObjects),
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   135
                "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
   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
    /**
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   140
     * Waits until Concurent Mark Cycle finishes
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   141
     * @param wb  Whitebox instance
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   142
     * @param sleepTime sleep time
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   143
     */
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   144
    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
   145
        while (wb.g1InConcurrentMark()) {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   146
            if (sleepTime > -1) {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   147
                try {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   148
                    Thread.sleep(sleepTime);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   149
                } catch (InterruptedException e) {
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   150
                    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
   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
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   158
    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
   159
        // allocate old objects
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   160
        allocateOldObjects();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   161
        waitTillCMCFinished(WB, 0);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   162
        WB.g1StartConcMarkCycle();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   163
        waitTillCMCFinished(WB, 0);
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   164
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   165
        WB.youngGC();
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   166
        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
   167
        // allocate more objects to provoke GC
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   168
        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
   169
            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
   170
        }
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   171
        // check that liveOldObjects still alive
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   172
        Asserts.assertTrue(WB.isObjectInOldGen(liveOldObjects),
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   173
                "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
   174
    }
81a6fd1ab98d 8136398: Create test that checks that G1 MixedGC produces correct output to logfile
kzhaldyb
parents:
diff changeset
   175
}