hotspot/test/gc/arguments/TestHeapFreeRatio.java
author jwilhelm
Fri, 03 Oct 2014 00:21:49 +0200
changeset 26940 b5b002c2980b
parent 20723 929cc8568f8e
child 29678 dd2f3932c21e
permissions -rw-r--r--
Merge
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
/*
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
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
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    30
 * @run main/othervm TestHeapFreeRatio
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    31
 */
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    32
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    33
import com.oracle.java.testlibrary.*;
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
public class TestHeapFreeRatio {
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
  enum Validation {
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    38
    VALID,
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    39
    MIN_INVALID,
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    40
    MAX_INVALID,
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    41
    COMBINATION_INVALID
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    42
  }
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    43
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    44
  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
    45
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    46
        "-Xminf" + min,
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    47
        "-Xmaxf" + max,
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    48
        "-version");
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    49
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    50
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    51
    switch (type) {
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    52
    case VALID:
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    53
      output.shouldNotContain("Error");
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    54
      output.shouldHaveExitValue(0);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    55
      break;
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    56
    case MIN_INVALID:
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    57
      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
    58
      output.shouldContain("Error");
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    59
      output.shouldHaveExitValue(1);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    60
      break;
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    61
    case MAX_INVALID:
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    62
      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
    63
      output.shouldContain("Error");
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    64
      output.shouldHaveExitValue(1);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    65
      break;
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    66
    case COMBINATION_INVALID:
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    67
      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
    68
      output.shouldContain("Error");
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    69
      output.shouldHaveExitValue(1);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    70
      break;
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    71
    default:
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    72
      throw new IllegalStateException("Must specify expected validation type");
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    73
    }
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    74
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    75
    System.out.println(output.getOutput());
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
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    78
  public static void main(String args[]) throws Exception {
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    79
    testMinMaxFreeRatio( "0.1", "0.5", Validation.VALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    80
    testMinMaxFreeRatio(  ".1",  ".5", Validation.VALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    81
    testMinMaxFreeRatio( "0.5", "0.5", Validation.VALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    82
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    83
    testMinMaxFreeRatio("-0.1", "0.5", Validation.MIN_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    84
    testMinMaxFreeRatio( "1.1", "0.5", Validation.MIN_INVALID);
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("0.1f", "0.5", Validation.MIN_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    87
    testMinMaxFreeRatio(
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    88
                     "INVALID", "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
                  "2147483647", "0.5", Validation.MIN_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    91
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    92
    testMinMaxFreeRatio( "0.1", "-0.5", Validation.MAX_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    93
    testMinMaxFreeRatio( "0.1",  "1.5", Validation.MAX_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    94
    testMinMaxFreeRatio( "0.1", "0.5f", Validation.MAX_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    95
    testMinMaxFreeRatio( "0.1", "=0.5", Validation.MAX_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    96
    testMinMaxFreeRatio(
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
    97
                     "0.1",  "INVALID", 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", "2147483647", Validation.MAX_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   100
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   101
    testMinMaxFreeRatio( "0.5",  "0.1", Validation.COMBINATION_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   102
    testMinMaxFreeRatio(  ".5",  ".10", Validation.COMBINATION_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   103
    testMinMaxFreeRatio("0.12","0.100", Validation.COMBINATION_INVALID);
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   104
  }
929cc8568f8e 8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff changeset
   105
}