test/hotspot/jtreg/gc/metaspace/TestMetaspaceCMSCancel.java
author kvn
Thu, 07 Jun 2018 17:38:34 -0700
changeset 50455 2b73cce96dce
parent 48791 6e079ff6c83c
child 53523 4c5184c56dc2
permissions -rw-r--r--
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal Reviewed-by: iignatyev, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39270
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
     1
/*
50455
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
39270
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
     4
 *
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
     8
 *
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    13
 * accompanied this code).
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    14
 *
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    18
 *
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    21
 * questions.
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    22
 */
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    23
import jdk.test.lib.process.ProcessTools;
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    24
import jdk.test.lib.process.OutputAnalyzer;
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    25
import jdk.test.lib.Asserts;
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    26
import sun.hotspot.WhiteBox;
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    27
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    28
/* @test TestMetaspaceCMSCancel
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    29
 * @bug 8026752
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    30
 * @summary Tests cancel of CMS concurrent cycle for Metaspace after a full GC
50455
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    31
 * @requires !vm.graal.enabled
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39270
diff changeset
    32
 * @library /test/lib
39270
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    33
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39270
diff changeset
    34
 * @build sun.hotspot.WhiteBox
48791
6e079ff6c83c 8186635: ClassFileInstaller should be run as a driver
iignatyev
parents: 47216
diff changeset
    35
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
39270
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    36
 * @run main/othervm TestMetaspaceCMSCancel
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    37
 */
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    38
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    39
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    40
public class TestMetaspaceCMSCancel {
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    41
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    42
    public static void main(String[] args) throws Exception {
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    43
        // Set a small MetaspaceSize so that a CMS concurrent collection will be
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    44
        // scheduled.  Set CMSWaitDuration to 5s so that the concurrent collection
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    45
        // start may be delayed.  It does not guarantee 5s before the start of the
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    46
        // concurrent collection but does increase the probability that it will
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    47
        // be started later.  System.gc() is used to invoke a full collection.  Set
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    48
        // ExplicitGCInvokesConcurrent to off so it is a STW collection.
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    49
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:.",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    50
                                                                  "-XX:+UnlockDiagnosticVMOptions",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    51
                                                                  "-XX:+WhiteBoxAPI",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    52
                                                                  "-XX:+UseConcMarkSweepGC",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    53
                                                                  "-XX:MetaspaceSize=2m",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    54
                                                                  "-XX:CMSWaitDuration=5000",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    55
                                                                  "-XX:-ExplicitGCInvokesConcurrent",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    56
                                                                  "-Xlog:gc*=debug",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    57
                                                                  MetaspaceGCTest.class.getName());
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    58
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    59
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    60
        output.shouldNotContain("Concurrent Reset");
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    61
        output.shouldHaveExitValue(0);
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    62
    }
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    63
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    64
    static class MetaspaceGCTest {
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    65
        public static void main(String [] args) {
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    66
            WhiteBox wb = WhiteBox.getWhiteBox();
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    67
            System.gc();
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    68
            Asserts.assertFalse(wb.metaspaceShouldConcurrentCollect());
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    69
        }
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    70
    }
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    71
}