hotspot/test/gc/whitebox/TestWBGC.java
author jwilhelm
Thu, 26 Feb 2015 21:00:03 +0100
changeset 29324 8672c9d7ae94
parent 28190 5a6b07edeb21
child 29678 dd2f3932c21e
permissions -rw-r--r--
8073883: serviceability/dcmd/gc/RunGCTest.java should not run with -XX:+ExplicitGCInvokesConcurrent Summary: Don't run test with -XX:+ExplicitGCInvokesConcurrent Reviewed-by: mgerdin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26319
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
     1
/*
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
     4
 *
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
     8
 *
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    14
 *
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    18
 *
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    21
 * questions.
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    22
 */
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    23
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    24
/*
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    25
 * @test TestWBGC
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    26
 * @bug 8055098
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    27
 * @summary Test verify that WB methods isObjectInOldGen and youngGC works correctly.
28190
5a6b07edeb21 8066433: Move Whitebox test library to top level repository
thartmann
parents: 26319
diff changeset
    28
 * @library /testlibrary /../../test/lib
26319
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    29
 * @build TestWBGC
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    30
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    31
 * @run driver TestWBGC
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    32
 */
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    33
import com.oracle.java.testlibrary.*;
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    34
import sun.hotspot.WhiteBox;
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    35
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    36
public class TestWBGC {
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    37
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    38
    public static void main(String args[]) throws Exception {
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    39
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    40
                true,
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    41
                "-Xbootclasspath/a:.",
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    42
                "-XX:+UnlockDiagnosticVMOptions",
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    43
                "-XX:+WhiteBoxAPI",
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    44
                "-XX:MaxTenuringThreshold=1",
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    45
                "-XX:+PrintGC",
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    46
                GCYoungTest.class.getName());
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    47
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    48
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    49
        System.out.println(output.getStdout());
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    50
        output.shouldHaveExitValue(0);
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    51
        output.shouldContain("WhiteBox Initiated Young GC");
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    52
        output.shouldNotContain("Full");
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    53
        // To be sure that we don't provoke Full GC additionaly to young
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    54
    }
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    55
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    56
    public static class GCYoungTest {
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    57
        static WhiteBox wb = WhiteBox.getWhiteBox();
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    58
        public static Object obj;
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    59
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    60
        public static void main(String args[]) {
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    61
            obj = new Object();
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    62
            Asserts.assertFalse(wb.isObjectInOldGen(obj));
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    63
            wb.youngGC();
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    64
            wb.youngGC();
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    65
            // 2 young GC is needed to promote object into OldGen
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    66
            Asserts.assertTrue(wb.isObjectInOldGen(obj));
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    67
        }
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    68
    }
9eebe39ee539 8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff changeset
    69
}