hotspot/test/gc/g1/Test2GbHeap.java
author jprovino
Wed, 11 Nov 2015 23:47:42 +0000
changeset 33911 af2cff5bd523
parent 30604 b8d532cb6420
child 37253 45e69c7b0bac
child 36851 03e2f4d0a421
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22553
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 22553
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
22553
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
     4
 *
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
     7
 * published by the Free Software Foundation.
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
     8
 *
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    13
 * accompanied this code).
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    14
 *
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    18
 *
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    21
 * questions.
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    22
 */
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    23
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    24
/*
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    25
 * @test Test2GbHeap
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    26
 * @bug 8031686
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    27
 * @summary Regression test to ensure we can start G1 with 2gb heap.
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    28
 * @key gc
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    29
 * @key regression
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    30
 * @library /testlibrary
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 22553
diff changeset
    31
 * @modules java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 22553
diff changeset
    32
 *          java.management
22553
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    33
 */
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    34
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    35
import java.util.ArrayList;
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    36
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    37
import jdk.test.lib.OutputAnalyzer;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    38
import jdk.test.lib.ProcessTools;
22553
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    39
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    40
public class Test2GbHeap {
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    41
  public static void main(String[] args) throws Exception {
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    42
    ArrayList<String> testArguments = new ArrayList<String>();
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    43
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    44
    testArguments.add("-XX:+UseG1GC");
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    45
    testArguments.add("-Xmx2g");
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    46
    testArguments.add("-version");
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    47
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    48
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(testArguments.toArray(new String[0]));
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    49
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    50
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    51
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    52
    // Avoid failing test for setups not supported.
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    53
    if (output.getOutput().contains("Could not reserve enough space for 2097152KB object heap")) {
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    54
      // Will fail on machines with too little memory (and Windows 32-bit VM), ignore such failures.
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    55
      output.shouldHaveExitValue(1);
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    56
    } else if (output.getOutput().contains("G1 GC is disabled in this release")) {
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    57
      // G1 is not supported on embedded, ignore such failures.
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    58
      output.shouldHaveExitValue(1);
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    59
    } else {
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    60
      // Normally everything should be fine.
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    61
      output.shouldHaveExitValue(0);
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    62
    }
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    63
  }
12b903843ee2 8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
sjohanss
parents:
diff changeset
    64
}