hotspot/test/gc/arguments/TestHeapFreeRatio.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:
20723
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 20723
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
20723
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
     4
 *
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
     7
 * published by the Free Software Foundation.
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
     8
 *
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    13
 * accompanied this code).
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    14
 *
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    18
 *
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    21
 * questions.
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    22
 */
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    23
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    24
/*
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    25
 * @test TestHeapFreeRatio
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    26
 * @key gc
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    27
 * @bug 8025661
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    28
 * @summary Test parsing of -Xminf and -Xmaxf
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    29
 * @library /testlibrary
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 20723
diff changeset
    30
 * @modules java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 20723
diff changeset
    31
 *          java.management
20723
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    32
 * @run main/othervm TestHeapFreeRatio
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    33
 */
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    34
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    35
import com.oracle.java.testlibrary.*;
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    36
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    37
public class TestHeapFreeRatio {
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    38
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    39
  enum Validation {
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    40
    VALID,
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    41
    MIN_INVALID,
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    42
    MAX_INVALID,
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    43
    COMBINATION_INVALID
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    44
  }
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    45
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    46
  private static void testMinMaxFreeRatio(String min, String max, Validation type) throws Exception {
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    47
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    48
        "-Xminf" + min,
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    49
        "-Xmaxf" + max,
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    50
        "-version");
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    51
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    52
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    53
    switch (type) {
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    54
    case VALID:
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    55
      output.shouldNotContain("Error");
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    56
      output.shouldHaveExitValue(0);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    57
      break;
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    58
    case MIN_INVALID:
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    59
      output.shouldContain("Bad min heap free percentage size: -Xminf" + min);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    60
      output.shouldContain("Error");
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    61
      output.shouldHaveExitValue(1);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    62
      break;
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    63
    case MAX_INVALID:
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    64
      output.shouldContain("Bad max heap free percentage size: -Xmaxf" + max);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    65
      output.shouldContain("Error");
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    66
      output.shouldHaveExitValue(1);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    67
      break;
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    68
    case COMBINATION_INVALID:
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    69
      output.shouldContain("must be less than or equal to MaxHeapFreeRatio");
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    70
      output.shouldContain("Error");
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    71
      output.shouldHaveExitValue(1);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    72
      break;
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    73
    default:
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    74
      throw new IllegalStateException("Must specify expected validation type");
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    75
    }
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    76
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    77
    System.out.println(output.getOutput());
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    78
  }
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    79
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    80
  public static void main(String args[]) throws Exception {
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    81
    testMinMaxFreeRatio( "0.1", "0.5", Validation.VALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    82
    testMinMaxFreeRatio(  ".1",  ".5", Validation.VALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    83
    testMinMaxFreeRatio( "0.5", "0.5", Validation.VALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    84
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    85
    testMinMaxFreeRatio("-0.1", "0.5", Validation.MIN_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    86
    testMinMaxFreeRatio( "1.1", "0.5", Validation.MIN_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    87
    testMinMaxFreeRatio("=0.1", "0.5", Validation.MIN_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    88
    testMinMaxFreeRatio("0.1f", "0.5", Validation.MIN_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    89
    testMinMaxFreeRatio(
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    90
                     "INVALID", "0.5", Validation.MIN_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    91
    testMinMaxFreeRatio(
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    92
                  "2147483647", "0.5", Validation.MIN_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    93
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    94
    testMinMaxFreeRatio( "0.1", "-0.5", Validation.MAX_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    95
    testMinMaxFreeRatio( "0.1",  "1.5", Validation.MAX_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    96
    testMinMaxFreeRatio( "0.1", "0.5f", Validation.MAX_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    97
    testMinMaxFreeRatio( "0.1", "=0.5", Validation.MAX_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    98
    testMinMaxFreeRatio(
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    99
                     "0.1",  "INVALID", Validation.MAX_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   100
    testMinMaxFreeRatio(
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   101
                   "0.1", "2147483647", Validation.MAX_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   102
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   103
    testMinMaxFreeRatio( "0.5",  "0.1", Validation.COMBINATION_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   104
    testMinMaxFreeRatio(  ".5",  ".10", Validation.COMBINATION_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   105
    testMinMaxFreeRatio("0.12","0.100", Validation.COMBINATION_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   106
  }
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   107
}