test/hotspot/jtreg/gc/ergonomics/TestInitialGCThreadLogging.java
author lkorinth
Wed, 13 Nov 2019 11:37:29 +0100
changeset 59053 ba6c248cae19
parent 57767 b3e44e1b135d
permissions -rw-r--r--
8232365: Implementation for JEP 363: Remove the Concurrent Mark Sweep (CMS) Garbage Collector Reviewed-by: kbarrett, tschatzl, erikj, coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39704
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
     1
/*
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 52925
diff changeset
     2
 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
39704
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
     4
 *
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
     7
 * published by the Free Software Foundation.
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
     8
 *
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    13
 * accompanied this code).
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    14
 *
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    18
 *
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    21
 * questions.
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    22
 */
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    23
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 52925
diff changeset
    24
package gc.ergonomics;
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 52925
diff changeset
    25
39704
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    26
/*
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    27
 * @test TestInitialGCThreadLogging
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    28
 * @bug 8157240
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    29
 * @summary Check trace logging of initial GC threads.
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    30
 * @key gc
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    31
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39704
diff changeset
    32
 * @library /test/lib
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 47216
diff changeset
    33
 * @build sun.hotspot.WhiteBox
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 47216
diff changeset
    34
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 52925
diff changeset
    35
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.ergonomics.TestInitialGCThreadLogging
39704
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    36
 */
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    37
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39704
diff changeset
    38
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39704
diff changeset
    39
import jdk.test.lib.process.OutputAnalyzer;
54638
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    40
import jtreg.SkippedException;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 47216
diff changeset
    41
import sun.hotspot.gc.GC;
39704
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    42
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    43
public class TestInitialGCThreadLogging {
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    44
  public static void main(String[] args) throws Exception {
54638
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    45
    boolean noneGCSupported = true;
39704
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    46
54638
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    47
    if (GC.G1.isSupported()) {
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    48
      noneGCSupported = false;
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    49
      testInitialGCThreadLogging("UseG1GC", "GC Thread");
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    50
    }
39704
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    51
54638
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    52
    if (GC.Parallel.isSupported()) {
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    53
      noneGCSupported = false;
57767
b3e44e1b135d 8224659: Parallel GC: Use WorkGang (1: PCRefProcTask)
lkorinth
parents: 54638
diff changeset
    54
      testInitialGCThreadLogging("UseParallelGC", "GC Thread");
54638
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    55
    }
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 47216
diff changeset
    56
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 47216
diff changeset
    57
    if (GC.Shenandoah.isSupported()) {
54638
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    58
      noneGCSupported = false;
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    59
      testInitialGCThreadLogging("UseShenandoahGC", "Shenandoah GC Thread");
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    60
    }
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    61
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53523
diff changeset
    62
    if (noneGCSupported) {
59053
ba6c248cae19 8232365: Implementation for JEP 363: Remove the Concurrent Mark Sweep (CMS) Garbage Collector
lkorinth
parents: 57767
diff changeset
    63
      throw new SkippedException("Skipping test because none of G1/Parallel/Shenandoah is supported.");
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 47216
diff changeset
    64
    }
39704
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    65
  }
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    66
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    67
  private static void verifyDynamicNumberOfGCThreads(OutputAnalyzer output, String threadName) {
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    68
    output.shouldHaveExitValue(0); // test should run succesfully
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    69
    output.shouldContain(threadName);
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    70
  }
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    71
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    72
  private static void testInitialGCThreadLogging(String gcFlag, String threadName) throws Exception {
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    73
    // UseDynamicNumberOfGCThreads and TraceDynamicGCThreads enabled
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 47216
diff changeset
    74
    String[] baseArgs = {"-XX:+UnlockExperimentalVMOptions", "-XX:+" + gcFlag, "-Xmx10M", "-XX:+UseDynamicNumberOfGCThreads", "-Xlog:gc+task=trace", "-version"};
39704
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    75
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    76
    // Base test with gc and +UseDynamicNumberOfGCThreads:
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    77
    ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder(baseArgs);
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    78
    verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()), threadName);
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    79
  }
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    80
}