hotspot/test/gc/arguments/TestArrayAllocatorMallocLimit.java
author ddmitriev
Wed, 08 Apr 2015 15:49:29 +0300
changeset 30169 736fe315ddcb
parent 29678 dd2f3932c21e
child 30604 b8d532cb6420
permissions -rw-r--r--
8076311: Java 9 process negative MaxTenuringThreshold in different way than Java 8 Summary: Corrected processing of invalid MaXTenuringThreshold Reviewed-by: jmasa, dholmes, kbarrett
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
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 25959
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
25959
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
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 25959
diff changeset
    31
 * @modules java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 25959
diff changeset
    32
 *          java.management
25959
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    33
 * @run driver TestArrayAllocatorMallocLimit
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    34
 */
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    35
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    36
import com.oracle.java.testlibrary.Asserts;
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    37
import com.oracle.java.testlibrary.OutputAnalyzer;
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    38
import com.oracle.java.testlibrary.ProcessTools;
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    39
import java.math.BigInteger;
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    40
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    41
public class TestArrayAllocatorMallocLimit {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    42
  public static void main(String [] args) throws Exception {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    43
    testDefaultValue();
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    44
    testSetValue();
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    45
  }
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
  private static final String flagName = "ArrayAllocatorMallocLimit";
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    48
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    49
  //     size_t ArrayAllocatorMallocLimit                 = 18446744073709551615{experimental}
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    50
  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
    51
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    52
  public static void testDefaultValue()  throws Exception {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    53
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    54
      "-XX:+UnlockExperimentalVMOptions", "-XX:+PrintFlagsFinal", "-version");
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    55
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    56
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    57
    String value = output.firstMatch(printFlagsFinalPattern, 1);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    58
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    59
    try {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    60
      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
    61
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    62
      // 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
    63
      // use BigInteger instead.
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    64
      BigInteger biValue = new BigInteger(value);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    65
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    66
      // Sanity check that we got a non-zero value.
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    67
      Asserts.assertNotEquals(biValue, "0");
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    68
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    69
      output.shouldHaveExitValue(0);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    70
    } catch (Exception e) {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    71
      System.err.println(output.getOutput());
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    72
      throw e;
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
  }
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    75
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    76
  public static void testSetValue() throws Exception {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    77
    long flagValue = 2048;
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    78
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    79
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    80
      "-XX:+UnlockExperimentalVMOptions", "-XX:" + flagName + "=" + flagValue, "-XX:+PrintFlagsFinal", "-version");
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    81
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    82
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    83
    String value = output.firstMatch(printFlagsFinalPattern, 1);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    84
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    85
    try {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    86
      Asserts.assertNotNull("Couldn't find size_t flag " + flagName);
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
      long longValue = Long.parseLong(value);
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
      Asserts.assertEquals(longValue, flagValue);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    91
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    92
      output.shouldHaveExitValue(0);
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    93
    } catch (Exception e) {
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    94
      System.err.println(output.getOutput());
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    95
      throw e;
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
  }
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    98
6c11a6272b60 8054823: Add size_t as a valid VM flag type
stefank
parents:
diff changeset
    99
}