test/hotspot/jtreg/gc/TestNumWorkerOutput.java
author jcbeyler
Mon, 13 Aug 2018 09:19:21 -0700
changeset 51396 38ec0cea438e
parent 50455 2b73cce96dce
child 53523 4c5184c56dc2
permissions -rw-r--r--
8061467: Add UseLargePages to TestNUMAPageSize Summary: Add flag to test for all architectures to be tested Reviewed-by: phh, pliden, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40922
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
     1
/*
50455
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
40922
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
     4
 *
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
     8
 *
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    14
 *
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    18
 *
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    21
 * questions.
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    22
 */
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    23
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    24
/*
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    25
 * @test TestNumWorkerOutput
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    26
 * @bug 8165292
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    27
 * @summary Check that when PrintGCDetails is enabled, gc,task output is printed only once per collection.
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    28
 * @key gc
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    29
 * @requires vm.gc=="null"
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    30
 * @modules java.base/jdk.internal.misc
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    31
 * @library /test/lib
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    32
 * @build sun.hotspot.WhiteBox
48791
6e079ff6c83c 8186635: ClassFileInstaller should be run as a driver
iignatyev
parents: 47216
diff changeset
    33
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
50455
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    34
 * @run main/othervm -XX:+UseG1GC TestNumWorkerOutput UseG1GC
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    35
 */
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    36
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    37
/*
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    38
 * @test TestNumWorkerOutputCMS
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    39
 * @bug 8165292
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    40
 * @key gc
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    41
 * @comment Graal does not support CMS
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    42
 * @requires vm.gc=="null" & !vm.graal.enabled
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    43
 * @modules java.base/jdk.internal.misc
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    44
 * @library /test/lib
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    45
 * @build sun.hotspot.WhiteBox
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    46
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
40922
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    47
 * @run main/othervm -XX:+UseConcMarkSweepGC TestNumWorkerOutput UseConcMarkSweepGC
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    48
 */
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    49
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    50
import sun.hotspot.WhiteBox;
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    51
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    52
import java.util.regex.Matcher;
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    53
import java.util.regex.Pattern;
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    54
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    55
import jdk.test.lib.Platform;
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    56
import jdk.test.lib.process.OutputAnalyzer;
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    57
import jdk.test.lib.process.ProcessTools;
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    58
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    59
import static jdk.test.lib.Asserts.*;
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    60
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    61
public class TestNumWorkerOutput {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    62
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    63
    public static void checkPatternOnce(String pattern, String what) throws Exception {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    64
        Pattern r = Pattern.compile(pattern);
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    65
        Matcher m = r.matcher(what);
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    66
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    67
        if (!m.find()) {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    68
            throw new RuntimeException("Could not find pattern " + pattern + " in output");
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    69
        }
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    70
        if (m.find()) {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    71
            throw new RuntimeException("Could find pattern " + pattern + " in output more than once");
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    72
        }
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    73
    }
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    74
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    75
    public static void runTest(String gcArg) throws Exception {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    76
        final String[] arguments = {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    77
            "-Xbootclasspath/a:.",
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    78
            "-XX:+UnlockExperimentalVMOptions",
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    79
            "-XX:+UnlockDiagnosticVMOptions",
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    80
            "-XX:+WhiteBoxAPI",
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    81
            "-XX:+" + gcArg,
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    82
            "-Xmx10M",
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    83
            "-XX:+PrintGCDetails",
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    84
            GCTest.class.getName()
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    85
            };
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    86
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    87
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    88
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    89
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    90
        output.shouldHaveExitValue(0);
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    91
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    92
        System.out.println(output.getStdout());
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    93
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    94
        String stdout = output.getStdout();
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    95
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    96
        checkPatternOnce(".*[info.*].*[gc,task.*].*GC\\(0\\) .*Using \\d+ workers of \\d+ for evacuation.*", stdout);
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    97
    }
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    98
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    99
    public static void main(String[] args) throws Exception {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   100
        runTest(args[0]);
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   101
    }
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   102
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   103
    static class GCTest {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   104
        private static final WhiteBox WB = WhiteBox.getWhiteBox();
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   105
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   106
        public static Object holder;
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   107
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   108
        public static void main(String [] args) {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   109
            holder = new byte[100];
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   110
            WB.youngGC();
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   111
            System.out.println(holder);
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   112
        }
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   113
    }
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   114
}
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   115