test/hotspot/jtreg/gc/TestGenerationPerfCounter.java
changeset 48117 d64722b0b371
child 50455 2b73cce96dce
equal deleted inserted replaced
48116:8a5e8cd321d9 48117:d64722b0b371
       
     1 /*
       
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 import static jdk.test.lib.Asserts.*;
       
    25 import gc.testlibrary.PerfCounter;
       
    26 import gc.testlibrary.PerfCounters;
       
    27 
       
    28 
       
    29 /* @test TestGenerationPerfCounter
       
    30  * @bug 8080345
       
    31  * @requires vm.gc=="null"
       
    32  * @library /test/lib /
       
    33  * @summary Tests that the sun.gc.policy.generations returns 2 for all GCs.
       
    34  * @modules java.base/jdk.internal.misc
       
    35  *          java.compiler
       
    36  *          java.management/sun.management
       
    37  *          jdk.internal.jvmstat/sun.jvmstat.monitor
       
    38  * @run main/othervm -XX:+UsePerfData -XX:+UseSerialGC TestGenerationPerfCounter
       
    39  * @run main/othervm -XX:+UsePerfData -XX:+UseParallelGC TestGenerationPerfCounter
       
    40  * @run main/othervm -XX:+UsePerfData -XX:+UseG1GC TestGenerationPerfCounter
       
    41  * @run main/othervm -XX:+UsePerfData -XX:+UseConcMarkSweepGC TestGenerationPerfCounter
       
    42  */
       
    43 public class TestGenerationPerfCounter {
       
    44     public static void main(String[] args) throws Exception {
       
    45         long numGenerations =
       
    46             PerfCounters.findByName("sun.gc.policy.generations").longValue();
       
    47         assertEQ(numGenerations, 2L);
       
    48     }
       
    49 }