hotspot/test/gc/arguments/TestArrayAllocatorMallocLimit.java
author stefank
Mon, 11 Aug 2014 14:03:06 +0200
changeset 25959 6c11a6272b60
child 29678 dd2f3932c21e
permissions -rw-r--r--
8054823: Add size_t as a valid VM flag type Reviewed-by: kvn, vlivanov, sla
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25959
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
     1
/*
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
     4
 *
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
     8
 *
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    13
 * accompanied this code).
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    14
 *
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    18
 *
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    21
 * questions.
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    22
 */
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    23
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    24
/*
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    25
 * @test TestArrayAllocatorMallocLimit
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    26
 * @summary Sanity check that the ArrayAllocatorMallocLimit flag can be set.
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    27
 * The test helps verifying that size_t flags can be set/read.
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    28
 * @bug 8054823
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    29
 * @key gc
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    30
 * @library /testlibrary
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    31
 * @run driver TestArrayAllocatorMallocLimit
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    32
 */
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    33
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    34
import com.oracle.java.testlibrary.Asserts;
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    35
import com.oracle.java.testlibrary.OutputAnalyzer;
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    36
import com.oracle.java.testlibrary.ProcessTools;
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    37
import java.math.BigInteger;
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    38
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    39
public class TestArrayAllocatorMallocLimit {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    40
  public static void main(String [] args) throws Exception {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    41
    testDefaultValue();
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    42
    testSetValue();
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    43
  }
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    44
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    45
  private static final String flagName = "ArrayAllocatorMallocLimit";
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    46
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    47
  //     size_t ArrayAllocatorMallocLimit                 = 18446744073709551615{experimental}
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    48
  private static final String printFlagsFinalPattern = " *size_t *" + flagName + " *:?= *(\\d+) *\\{experimental\\} *";
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    49
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    50
  public static void testDefaultValue()  throws Exception {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    51
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    52
      "-XX:+UnlockExperimentalVMOptions", "-XX:+PrintFlagsFinal", "-version");
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    53
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    54
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    55
    String value = output.firstMatch(printFlagsFinalPattern, 1);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    56
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    57
    try {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    58
      Asserts.assertNotNull(value, "Couldn't find size_t flag " + flagName);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    59
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    60
      // A size_t is not always parseable with Long.parseValue,
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    61
      // use BigInteger instead.
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    62
      BigInteger biValue = new BigInteger(value);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    63
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    64
      // Sanity check that we got a non-zero value.
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    65
      Asserts.assertNotEquals(biValue, "0");
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    66
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    67
      output.shouldHaveExitValue(0);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    68
    } catch (Exception e) {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    69
      System.err.println(output.getOutput());
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    70
      throw e;
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    71
    }
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    72
  }
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    73
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    74
  public static void testSetValue() throws Exception {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    75
    long flagValue = 2048;
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    76
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    77
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    78
      "-XX:+UnlockExperimentalVMOptions", "-XX:" + flagName + "=" + flagValue, "-XX:+PrintFlagsFinal", "-version");
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    79
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    80
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    81
    String value = output.firstMatch(printFlagsFinalPattern, 1);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    82
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    83
    try {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    84
      Asserts.assertNotNull("Couldn't find size_t flag " + flagName);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    85
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    86
      long longValue = Long.parseLong(value);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    87
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    88
      Asserts.assertEquals(longValue, flagValue);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    89
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    90
      output.shouldHaveExitValue(0);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    91
    } catch (Exception e) {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    92
      System.err.println(output.getOutput());
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    93
      throw e;
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    94
    }
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    95
  }
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    96
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    97
}