hotspot/test/gc/ergonomics/TestInitialGCThreadLogging.java
author jmasa
Thu, 19 May 2016 13:59:50 -0700
changeset 39704 157f39705057
child 40631 ed82623d7831
permissions -rw-r--r--
8157240: GC task trace logging is incomprehensible Reviewed-by: tschatzl, redestad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39704
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
     1
/*
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
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
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    24
/*
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    25
 * @test TestInitialGCThreadLogging
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    26
 * @bug 8157240
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    27
 * @summary Check trace logging of initial GC threads.
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    28
 * @requires vm.gc=="null"
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    29
 * @key gc
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    30
 * @modules java.base/jdk.internal.misc
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    31
 * @library /testlibrary
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    32
 */
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    33
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    34
import jdk.test.lib.ProcessTools;
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    35
import jdk.test.lib.OutputAnalyzer;
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
public class TestInitialGCThreadLogging {
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    38
  public static void main(String[] args) throws Exception {
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    39
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    40
    testInitialGCThreadLogging("UseConcMarkSweepGC", "GC Thread");
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    41
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    42
    testInitialGCThreadLogging("UseG1GC", "GC Thread");
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    43
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    44
    testInitialGCThreadLogging("UseParallelGC", "ParGC Thread");
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    45
  }
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    46
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    47
  private static void verifyDynamicNumberOfGCThreads(OutputAnalyzer output, String threadName) {
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    48
    output.shouldHaveExitValue(0); // test should run succesfully
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    49
    output.shouldContain(threadName);
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    50
  }
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    51
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    52
  private static void testInitialGCThreadLogging(String gcFlag, String threadName) throws Exception {
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    53
    // UseDynamicNumberOfGCThreads and TraceDynamicGCThreads enabled
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    54
    String[] baseArgs = {"-XX:+" + gcFlag, "-Xmx10M", "-XX:+UseDynamicNumberOfGCThreads", "-Xlog:gc+task=trace", "-version"};
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    55
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    56
    // Base test with gc and +UseDynamicNumberOfGCThreads:
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    57
    ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder(baseArgs);
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    58
    verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()), threadName);
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    59
  }
157f39705057 8157240: GC task trace logging is incomprehensible
jmasa
parents:
diff changeset
    60
}