author | lana |
Thu, 12 May 2016 15:15:02 +0000 | |
changeset 37915 | be4ff50b6cb6 |
parent 37297 | d65d53a0ecc7 |
child 40015 | 524230a0f4ca |
permissions | -rw-r--r-- |
30271 | 1 |
/* |
37104
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
30271 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test TestSelectDefaultGC |
|
26 |
* @summary Test selection of GC when no GC option is specified |
|
27 |
* @bug 8068582 |
|
28 |
* @key gc |
|
29 |
* @library /testlibrary |
|
37104
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
30 |
* @requires vm.gc=="null" |
36851 | 31 |
* @modules java.base/jdk.internal.misc |
30271 | 32 |
* java.management |
33 |
* @run driver TestSelectDefaultGC |
|
34 |
*/ |
|
35 |
||
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
30271
diff
changeset
|
36 |
import jdk.test.lib.*; |
30271 | 37 |
import java.util.regex.*; |
38 |
||
39 |
public class TestSelectDefaultGC { |
|
40 |
public static void assertVMOption(OutputAnalyzer output, String option, boolean value) { |
|
41 |
output.shouldMatch(" " + option + " .*=.* " + value + " "); |
|
42 |
} |
|
43 |
||
37104
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
44 |
public static void testDefaultGC(boolean actAsServer) throws Exception { |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
45 |
String[] args = new String[] { |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
46 |
"-XX:" + (actAsServer ? "+" : "-") + "AlwaysActAsServerClassMachine", |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
47 |
"-XX:" + (actAsServer ? "-" : "+") + "NeverActAsServerClassMachine", |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
48 |
"-XX:+PrintFlagsFinal", |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
49 |
"-version" |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
50 |
}; |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
51 |
|
30271 | 52 |
// Start VM without specifying GC |
37104
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
53 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); |
30271 | 54 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
55 |
output.shouldHaveExitValue(0); |
|
56 |
||
37104
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
57 |
final boolean isServer = actAsServer; |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
58 |
final boolean isEmbedded = Platform.isEmbedded(); |
30271 | 59 |
|
60 |
// Verify GC selection |
|
37104
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
61 |
// G1 is default for non-embedded server class machines |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
62 |
assertVMOption(output, "UseG1GC", isServer && !isEmbedded); |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
63 |
// Parallel is default for embedded server class machines |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
64 |
assertVMOption(output, "UseParallelGC", isServer && isEmbedded); |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
65 |
assertVMOption(output, "UseParallelOldGC", isServer && isEmbedded); |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
66 |
// Serial is default for non-server class machines |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
67 |
assertVMOption(output, "UseSerialGC", !isServer); |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
68 |
// CMS is never default |
30271 | 69 |
assertVMOption(output, "UseConcMarkSweepGC", false); |
70 |
assertVMOption(output, "UseParNewGC", false); |
|
71 |
} |
|
37104
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
72 |
|
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
73 |
public static void main(String[] args) throws Exception { |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
74 |
// Test server class machine |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
75 |
testDefaultGC(false); |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
76 |
|
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
77 |
// Test non-server class machine |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
78 |
testDefaultGC(true); |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
79 |
} |
30271 | 80 |
} |