hotspot/test/gc/arguments/TestParallelGCThreads.java
author mlarsson
Thu, 02 Oct 2014 11:22:02 +0200
changeset 26939 93633340028d
child 29678 dd2f3932c21e
permissions -rw-r--r--
8059527: Disallow ParallelGCThreads=0 for G1 Reviewed-by: ehelin, brutisso
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26939
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
     1
/*
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
     2
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
     3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
     4
*
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
     5
* This code is free software; you can redistribute it and/or modify it
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
     6
* under the terms of the GNU General Public License version 2 only, as
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
     7
* published by the Free Software Foundation.
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
     8
*
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
     9
* This code is distributed in the hope that it will be useful, but WITHOUT
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    11
* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    12
* version 2 for more details (a copy is included in the LICENSE file that
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    13
* accompanied this code).
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    14
*
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    15
* You should have received a copy of the GNU General Public License version
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    16
* 2 along with this work; if not, write to the Free Software Foundation,
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    18
*
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    20
* or visit www.oracle.com if you need additional information or have any
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    21
* questions.
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    22
*/
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    23
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    24
/*
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    25
 * @test TestParallelGCThreads
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    26
 * @key gc
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    27
 * @bug 8059527
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    28
 * @summary Tests argument processing for ParallelGCThreads
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    29
 * @library /testlibrary
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    30
 * @run driver TestParallelGCThreads
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    31
 */
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    32
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    33
import com.oracle.java.testlibrary.*;
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    34
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    35
public class TestParallelGCThreads {
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    36
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    37
  public static void main(String args[]) throws Exception {
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    38
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    39
    // For each parallel collector (G1, Parallel, ParNew/CMS)
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    40
    for (String gc : new String[] {"G1", "Parallel", "ConcMarkSweep"}) {
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    41
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    42
      // Make sure the VM does not allow ParallelGCThreads set to 0
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    43
      String[] flags = new String[] {"-XX:+Use" + gc + "GC", "-XX:ParallelGCThreads=0", "-XX:+PrintFlagsFinal", "-version"};
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    44
      ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flags);
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    45
      OutputAnalyzer output = new OutputAnalyzer(pb.start());
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    46
      output.shouldHaveExitValue(1);
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    47
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    48
      // Do some basic testing to ensure the flag updates the count
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    49
      for (long i = 1; i <= 3; i++) {
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    50
        flags = new String[] {"-XX:+Use" + gc + "GC", "-XX:ParallelGCThreads=" + i, "-XX:+PrintFlagsFinal", "-version"};
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    51
        long count = getParallelGCThreadCount(flags);
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    52
        Asserts.assertEQ(count, i, "Specifying ParallelGCThreads=" + i + " for " + gc + "GC does not set the thread count properly!");
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    53
      }
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    54
    }
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    55
  }
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    56
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    57
  public static long getParallelGCThreadCount(String flags[]) throws Exception {
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    58
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flags);
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    59
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    60
    output.shouldHaveExitValue(0);
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    61
    String stdout = output.getStdout();
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    62
    return FlagsValue.getFlagLongValue("ParallelGCThreads", stdout);
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    63
  }
93633340028d 8059527: Disallow ParallelGCThreads=0 for G1
mlarsson
parents:
diff changeset
    64
}