test/hotspot/jtreg/gc/metaspace/TestMetaspaceCMSCancel.java
author lmesnik
Fri, 26 Apr 2019 11:33:32 -0700
changeset 54638 9b8926bf85c1
parent 53523 4c5184c56dc2
permissions -rw-r--r--
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X Reviewed-by: pliden, lmesnik Contributed-by: aoqi@loongson.cn
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
/*
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 50455
diff changeset
     2
 * Copyright (c) 2016, 2019, 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
 */
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 50455
diff changeset
    23
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 50455
diff changeset
    24
package gc.metaspace;
39270
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    25
import jdk.test.lib.process.ProcessTools;
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    26
import jdk.test.lib.process.OutputAnalyzer;
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    27
import jdk.test.lib.Asserts;
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    28
import sun.hotspot.WhiteBox;
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    29
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    30
/* @test TestMetaspaceCMSCancel
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    31
 * @bug 8026752
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    32
 * @summary Tests cancel of CMS concurrent cycle for Metaspace after a full GC
54638
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    33
 * @requires vm.gc.ConcMarkSweep & !vm.graal.enabled
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39270
diff changeset
    34
 * @library /test/lib
39270
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    35
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39270
diff changeset
    36
 * @build sun.hotspot.WhiteBox
48791
6e079ff6c83c 8186635: ClassFileInstaller should be run as a driver
iignatyev
parents: 47216
diff changeset
    37
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 50455
diff changeset
    38
 * @run main/othervm gc.metaspace.TestMetaspaceCMSCancel
39270
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
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 class TestMetaspaceCMSCancel {
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    43
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    44
    public static void main(String[] args) throws Exception {
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    45
        // 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
    46
        // 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
    47
        // 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
    48
        // 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
    49
        // 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
    50
        // 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
    51
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:.",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    52
                                                                  "-XX:+UnlockDiagnosticVMOptions",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    53
                                                                  "-XX:+WhiteBoxAPI",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    54
                                                                  "-XX:+UseConcMarkSweepGC",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    55
                                                                  "-XX:MetaspaceSize=2m",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    56
                                                                  "-XX:CMSWaitDuration=5000",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    57
                                                                  "-XX:-ExplicitGCInvokesConcurrent",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    58
                                                                  "-Xlog:gc*=debug",
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    59
                                                                  MetaspaceGCTest.class.getName());
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    60
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    61
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    62
        output.shouldNotContain("Concurrent Reset");
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    63
        output.shouldHaveExitValue(0);
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    64
    }
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    65
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    66
    static class MetaspaceGCTest {
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    67
        public static void main(String [] args) {
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    68
            WhiteBox wb = WhiteBox.getWhiteBox();
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    69
            System.gc();
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    70
            Asserts.assertFalse(wb.metaspaceShouldConcurrentCollect());
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    71
        }
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    72
    }
9b12d5739295 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
jmasa
parents:
diff changeset
    73
}