author | lkorinth |
Wed, 13 Nov 2019 11:37:29 +0100 | |
changeset 59053 | ba6c248cae19 |
parent 55610 | 47fdb5b0fa41 |
permissions | -rw-r--r-- |
30271 | 1 |
/* |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, 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 |
||
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
47216
diff
changeset
|
24 |
package gc.arguments; |
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
47216
diff
changeset
|
25 |
|
30271 | 26 |
/* |
27 |
* @test TestSelectDefaultGC |
|
28 |
* @summary Test selection of GC when no GC option is specified |
|
29 |
* @bug 8068582 |
|
30 |
* @key gc |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40015
diff
changeset
|
31 |
* @library /test/lib |
55610
47fdb5b0fa41
8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
kbarrett
parents:
54638
diff
changeset
|
32 |
* @library / |
54638
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
33 |
* @requires vm.gc.Serial & vm.gc.G1 |
36851 | 34 |
* @modules java.base/jdk.internal.misc |
30271 | 35 |
* java.management |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
47216
diff
changeset
|
36 |
* @run driver gc.arguments.TestSelectDefaultGC |
30271 | 37 |
*/ |
38 |
||
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40015
diff
changeset
|
39 |
import jdk.test.lib.process.OutputAnalyzer; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40015
diff
changeset
|
40 |
import jdk.test.lib.process.ProcessTools; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40015
diff
changeset
|
41 |
|
30271 | 42 |
public class TestSelectDefaultGC { |
43 |
public static void assertVMOption(OutputAnalyzer output, String option, boolean value) { |
|
44 |
output.shouldMatch(" " + option + " .*=.* " + value + " "); |
|
45 |
} |
|
46 |
||
37104
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
47 |
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
|
48 |
String[] args = new String[] { |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
49 |
"-XX:" + (actAsServer ? "+" : "-") + "AlwaysActAsServerClassMachine", |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
50 |
"-XX:" + (actAsServer ? "-" : "+") + "NeverActAsServerClassMachine", |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
51 |
"-XX:+PrintFlagsFinal", |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
52 |
"-version" |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
53 |
}; |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
54 |
|
30271 | 55 |
// Start VM without specifying GC |
55610
47fdb5b0fa41
8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
kbarrett
parents:
54638
diff
changeset
|
56 |
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(args); |
30271 | 57 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
58 |
output.shouldHaveExitValue(0); |
|
59 |
||
37104
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
60 |
final boolean isServer = actAsServer; |
30271 | 61 |
|
62 |
// Verify GC selection |
|
40015
524230a0f4ca
8140723: Remove source code conditionalized on JAVASE_EMBEDDED
dholmes
parents:
37297
diff
changeset
|
63 |
// G1 is default for server class machines |
524230a0f4ca
8140723: Remove source code conditionalized on JAVASE_EMBEDDED
dholmes
parents:
37297
diff
changeset
|
64 |
assertVMOption(output, "UseG1GC", isServer); |
37104
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
65 |
// 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
|
66 |
assertVMOption(output, "UseSerialGC", !isServer); |
30271 | 67 |
} |
37104
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
68 |
|
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
69 |
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
|
70 |
// Test server class machine |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
71 |
testDefaultGC(false); |
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 |
// Test non-server class machine |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
74 |
testDefaultGC(true); |
0950120451c4
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
pliden
parents:
35946
diff
changeset
|
75 |
} |
30271 | 76 |
} |