test/hotspot/jtreg/gc/logging/TestGCId.java
changeset 54638 9b8926bf85c1
parent 53523 4c5184c56dc2
child 59053 ba6c248cae19
equal deleted inserted replaced
54637:b71940f7fa96 54638:9b8926bf85c1
    25 
    25 
    26 /*
    26 /*
    27  * @test TestGCId
    27  * @test TestGCId
    28  * @bug 8043607
    28  * @bug 8043607
    29  * @summary Ensure that the GCId is logged
    29  * @summary Ensure that the GCId is logged
    30  * @requires vm.gc=="null"
       
    31  * @key gc
    30  * @key gc
    32  * @library /test/lib
    31  * @library /test/lib
    33  * @modules java.base/jdk.internal.misc
    32  * @modules java.base/jdk.internal.misc
    34  *          java.management
    33  *          java.management
    35  * @build sun.hotspot.WhiteBox
    34  * @build sun.hotspot.WhiteBox
    37  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.logging.TestGCId
    36  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.logging.TestGCId
    38  */
    37  */
    39 
    38 
    40 import jdk.test.lib.process.OutputAnalyzer;
    39 import jdk.test.lib.process.OutputAnalyzer;
    41 import jdk.test.lib.process.ProcessTools;
    40 import jdk.test.lib.process.ProcessTools;
       
    41 import jtreg.SkippedException;
    42 import sun.hotspot.gc.GC;
    42 import sun.hotspot.gc.GC;
    43 
    43 
    44 public class TestGCId {
    44 public class TestGCId {
    45   public static void main(String[] args) throws Exception {
    45   public static void main(String[] args) throws Exception {
    46     testGCId("UseParallelGC");
    46     boolean noneGCSupported = true;
    47     testGCId("UseG1GC");
    47 
    48     testGCId("UseConcMarkSweepGC");
    48     if (GC.Parallel.isSupported()) {
    49     testGCId("UseSerialGC");
    49       noneGCSupported = false;
       
    50       testGCId("UseParallelGC");
       
    51     }
       
    52     if (GC.G1.isSupported()) {
       
    53       noneGCSupported = false;
       
    54       testGCId("UseG1GC");
       
    55     }
       
    56     if (GC.ConcMarkSweep.isSupported()) {
       
    57       noneGCSupported = false;
       
    58       testGCId("UseConcMarkSweepGC");
       
    59     }
       
    60     if (GC.Serial.isSupported()) {
       
    61       noneGCSupported = false;
       
    62       testGCId("UseSerialGC");
       
    63     }
    50     if (GC.Shenandoah.isSupported()) {
    64     if (GC.Shenandoah.isSupported()) {
    51         testGCId("UseShenandoahGC");
    65       noneGCSupported = false;
       
    66       testGCId("UseShenandoahGC");
       
    67     }
       
    68 
       
    69     if (noneGCSupported) {
       
    70       throw new SkippedException("Skipping test because none of Parallel/G1/ConcMarkSweep/Serial/Shenandoah is supported.");
    52     }
    71     }
    53   }
    72   }
    54 
    73 
    55   private static void verifyContainsGCIDs(OutputAnalyzer output) {
    74   private static void verifyContainsGCIDs(OutputAnalyzer output) {
    56     output.shouldMatch("\\[.*\\]\\[.*\\]\\[.*\\] GC\\(0\\) ");
    75     output.shouldMatch("\\[.*\\]\\[.*\\]\\[.*\\] GC\\(0\\) ");