author | lana |
Thu, 12 May 2016 15:15:02 +0000 | |
changeset 37915 | be4ff50b6cb6 |
parent 33144 | c56850e328fc |
child 38152 | 80e5da81fb2c |
permissions | -rw-r--r-- |
18999
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
27886
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
18999
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
4 |
* |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
8 |
* |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
13 |
* accompanied this code). |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
14 |
* |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
18 |
* |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
21 |
* questions. |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
22 |
*/ |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
23 |
|
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
24 |
/* |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
25 |
* @test TestG1HeapRegionSize |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
26 |
* @key gc |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
27 |
* @bug 8021879 |
33144
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
28 |
* @requires vm.gc=="null" | vm.gc=="G1" |
18999
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
29 |
* @summary Verify that the flag G1HeapRegionSize is updated properly |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
27886
diff
changeset
|
30 |
* @modules java.management/sun.management |
33144
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
31 |
* @library /testlibrary |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
32 |
* @run main TestG1HeapRegionSize |
18999
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
33 |
*/ |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
34 |
|
33144
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
35 |
import java.util.regex.Matcher; |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
36 |
import java.util.regex.Pattern; |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
37 |
|
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
38 |
import java.util.ArrayList; |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
39 |
import java.util.Arrays; |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
40 |
|
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
41 |
import jdk.test.lib.*; |
18999
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
42 |
|
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
43 |
public class TestG1HeapRegionSize { |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
44 |
|
33144
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
45 |
private static void checkG1HeapRegionSize(String[] flags, int expectedValue, int exitValue) throws Exception { |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
46 |
ArrayList<String> flagList = new ArrayList<String>(); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
47 |
flagList.addAll(Arrays.asList(flags)); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
48 |
flagList.add("-XX:+UseG1GC"); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
49 |
flagList.add("-XX:+PrintFlagsFinal"); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
50 |
flagList.add("-version"); |
18999
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
51 |
|
33144
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
52 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flagList.toArray(new String[0])); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
53 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
54 |
output.shouldHaveExitValue(exitValue); |
27886
79c703ddca55
8065749: [TESTBUG]: gc/arguments/TestG1HeapRegionSize.java fails at nightly
eistepan
parents:
27692
diff
changeset
|
55 |
|
33144
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
56 |
if (exitValue == 0) { |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
57 |
String stdout = output.getStdout(); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
58 |
int flagValue = getFlagValue("G1HeapRegionSize", stdout); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
59 |
if (flagValue != expectedValue) { |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
60 |
throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + flagValue); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
61 |
} |
18999
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
62 |
} |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
63 |
} |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
64 |
|
33144
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
65 |
private static int getFlagValue(String flag, String where) { |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
66 |
Matcher m = Pattern.compile(flag + "\\s+:?=\\s+\\d+").matcher(where); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
67 |
if (!m.find()) { |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
68 |
throw new RuntimeException("Could not find value for flag " + flag + " in output string"); |
18999
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
69 |
} |
33144
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
70 |
String match = m.group(); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
71 |
return Integer.parseInt(match.substring(match.lastIndexOf(" ") + 1, match.length())); |
18999
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
72 |
} |
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
73 |
|
33144
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
74 |
public static void main(String args[]) throws Exception { |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
75 |
final int M = 1024 * 1024; |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
76 |
|
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
77 |
checkG1HeapRegionSize(new String[] { "-Xmx64m" /* default is 1m */ }, 1*M, 0); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
78 |
checkG1HeapRegionSize(new String[] { "-Xmx64m", "-XX:G1HeapRegionSize=2m" }, 2*M, 0); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
79 |
checkG1HeapRegionSize(new String[] { "-Xmx64m", "-XX:G1HeapRegionSize=3m" }, 2*M, 0); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
80 |
checkG1HeapRegionSize(new String[] { "-Xmx256m", "-XX:G1HeapRegionSize=32m" }, 32*M, 0); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
81 |
checkG1HeapRegionSize(new String[] { "-Xmx256m", "-XX:G1HeapRegionSize=64m" }, 32*M, 1); |
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
82 |
} |
18999
a05f689a6c0c
8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff
changeset
|
83 |
} |