test/hotspot/jtreg/gc/TestNumWorkerOutput.java
author lmesnik
Fri, 26 Apr 2019 11:33:32 -0700
changeset 54638 9b8926bf85c1
parent 53693 af078dd4a224
child 59053 ba6c248cae19
permissions -rw-r--r--
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X Reviewed-by: pliden, lmesnik Contributed-by: aoqi@loongson.cn
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
/*
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 50455
diff changeset
     2
 * Copyright (c) 2016, 2019, 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
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 50455
diff changeset
    24
package gc;
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 50455
diff changeset
    25
40922
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    26
/*
54638
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53693
diff changeset
    27
 * @test TestNumWorkerOutputG1
40922
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    28
 * @bug 8165292
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    29
 * @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
    30
 * @key gc
54638
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53693
diff changeset
    31
 * @requires vm.gc.G1
40922
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    32
 * @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
    33
 * @library /test/lib
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    34
 * @build sun.hotspot.WhiteBox
48791
6e079ff6c83c 8186635: ClassFileInstaller should be run as a driver
iignatyev
parents: 47216
diff changeset
    35
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 50455
diff changeset
    36
 * @run main/othervm -XX:+UseG1GC gc.TestNumWorkerOutput UseG1GC
50455
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
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    39
/*
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    40
 * @test TestNumWorkerOutputCMS
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    41
 * @bug 8165292
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    42
 * @key gc
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    43
 * @comment Graal does not support CMS
54638
9b8926bf85c1 8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents: 53693
diff changeset
    44
 * @requires vm.gc.ConcMarkSweep & !vm.graal.enabled
50455
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    45
 * @modules java.base/jdk.internal.misc
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    46
 * @library /test/lib
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    47
 * @build sun.hotspot.WhiteBox
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 48791
diff changeset
    48
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 50455
diff changeset
    49
 * @run main/othervm -XX:+UseConcMarkSweepGC gc.TestNumWorkerOutput UseConcMarkSweepGC
40922
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    50
 */
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 sun.hotspot.WhiteBox;
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    53
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    54
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
    55
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
    56
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.OutputAnalyzer;
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    58
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
    59
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    60
public class TestNumWorkerOutput {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    61
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    62
    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
    63
        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
    64
        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
    65
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    66
        if (!m.find()) {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    67
            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
    68
        }
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    69
        if (m.find()) {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    70
            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
    71
        }
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
    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
    75
        final String[] arguments = {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    76
            "-Xbootclasspath/a:.",
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    77
            "-XX:+UnlockExperimentalVMOptions",
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    78
            "-XX:+UnlockDiagnosticVMOptions",
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    79
            "-XX:+WhiteBoxAPI",
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    80
            "-XX:+" + gcArg,
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    81
            "-Xmx10M",
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    82
            "-XX:+PrintGCDetails",
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    83
            GCTest.class.getName()
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    84
            };
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
        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
    87
        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
    88
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    89
        output.shouldHaveExitValue(0);
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    90
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    91
        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
    92
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    93
        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
    94
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
    95
        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
    96
    }
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
    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
    99
        runTest(args[0]);
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   100
    }
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
    static class GCTest {
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   103
        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
   104
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   105
        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
   106
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   107
        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
   108
            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
   109
            WB.youngGC();
d9f1eaf18f9a 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info
tschatzl
parents:
diff changeset
   110
            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
   111
        }
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