test/hotspot/jtreg/gc/arguments/TestG1ConcRefinementThreads.java
author kbarrett
Mon, 08 Jul 2019 17:24:21 -0400
changeset 55610 47fdb5b0fa41
parent 53523 4c5184c56dc2
permissions -rw-r--r--
8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out Summary: Disable ZapUnusedHeapArea and VerifyBeforeExit for gc/arguments tests. Reviewed-by: tschatzl, tonyp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26932
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
     1
/*
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 47216
diff changeset
     2
 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
41705
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     4
 *
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     7
 * published by the Free Software Foundation.
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     8
 *
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    13
 * accompanied this code).
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    14
 *
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    18
 *
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    21
 * questions.
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    22
 */
26932
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    23
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 47216
diff changeset
    24
package gc.arguments;
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 47216
diff changeset
    25
26932
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    26
/*
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    27
 * @test TestG1ConcRefinementThreads
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    28
 * @key gc
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    29
 * @bug 8047976
39414
4adf52148100 8160088: update hotspot tests depending on GC to use @requires vm.gc.X
dfazunen
parents: 37510
diff changeset
    30
 * @requires vm.gc.G1
26932
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    31
 * @summary Tests argument processing for G1ConcRefinementThreads
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39414
diff changeset
    32
 * @library /test/lib
55610
47fdb5b0fa41 8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
kbarrett
parents: 53523
diff changeset
    33
 * @library /
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 36576
diff changeset
    34
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 26932
diff changeset
    35
 *          java.management
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 47216
diff changeset
    36
 * @run main gc.arguments.TestG1ConcRefinementThreads
26932
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    37
 */
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    38
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39414
diff changeset
    39
import jdk.test.lib.process.OutputAnalyzer;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39414
diff changeset
    40
import jdk.test.lib.process.ProcessTools;
26932
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    41
import java.util.*;
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    42
import java.util.regex.*;
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    43
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    44
public class TestG1ConcRefinementThreads {
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    45
37510
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 36851
diff changeset
    46
  static final int AUTO_SELECT_THREADS_COUNT = -1;
26932
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    47
  static final int PASSED_THREADS_COUNT = 11;
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    48
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    49
  public static void main(String args[]) throws Exception {
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    50
    // default case
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    51
    runG1ConcRefinementThreadsTest(
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    52
        new String[]{}, // automatically selected
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    53
        AUTO_SELECT_THREADS_COUNT /* use default setting */);
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    54
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    55
    // zero setting case
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    56
    runG1ConcRefinementThreadsTest(
37510
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 36851
diff changeset
    57
        new String[]{"-XX:G1ConcRefinementThreads=0"},
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 36851
diff changeset
    58
        0);
26932
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    59
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    60
    // non-zero sestting case
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    61
    runG1ConcRefinementThreadsTest(
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    62
        new String[]{"-XX:G1ConcRefinementThreads="+Integer.toString(PASSED_THREADS_COUNT)},
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    63
        PASSED_THREADS_COUNT);
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    64
  }
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    65
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    66
  private static void runG1ConcRefinementThreadsTest(String[] passedOpts,
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    67
          int expectedValue) throws Exception {
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    68
    List<String> vmOpts = new ArrayList<>();
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    69
    if (passedOpts.length > 0) {
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    70
      Collections.addAll(vmOpts, passedOpts);
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    71
    }
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    72
    Collections.addAll(vmOpts, "-XX:+UseG1GC", "-XX:+PrintFlagsFinal", "-version");
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    73
55610
47fdb5b0fa41 8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
kbarrett
parents: 53523
diff changeset
    74
    ProcessBuilder pb = GCArguments.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
26932
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    75
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    76
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    77
    output.shouldHaveExitValue(0);
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    78
    String stdout = output.getStdout();
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    79
    checkG1ConcRefinementThreadsConsistency(stdout, expectedValue);
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    80
  }
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    81
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    82
  private static void checkG1ConcRefinementThreadsConsistency(String output, int expectedValue) {
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    83
    int actualValue = getIntValue("G1ConcRefinementThreads", output);
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    84
37510
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 36851
diff changeset
    85
    if (expectedValue == AUTO_SELECT_THREADS_COUNT) {
26932
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    86
      // If expectedValue is automatically selected, set it same as ParallelGCThreads.
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    87
      expectedValue = getIntValue("ParallelGCThreads", output);
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    88
    }
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    89
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    90
    if (expectedValue != actualValue) {
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    91
      throw new RuntimeException(
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    92
            "Actual G1ConcRefinementThreads(" + Integer.toString(actualValue)
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    93
            + ") is not equal to expected value(" + Integer.toString(expectedValue) + ")");
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    94
    }
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    95
  }
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    96
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    97
  public static int getIntValue(String flag, String where) {
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    98
    Matcher m = Pattern.compile(flag + "\\s+:?=\\s+\\d+").matcher(where);
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
    99
    if (!m.find()) {
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
   100
      throw new RuntimeException("Could not find value for flag " + flag + " in output string");
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
   101
    }
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
   102
    String match = m.group();
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
   103
    return Integer.parseInt(match.substring(match.lastIndexOf(" ") + 1, match.length()));
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
   104
  }
33d6fa41d290 8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff changeset
   105
}