author | jiangli |
Fri, 02 Nov 2018 19:30:31 -0400 | |
changeset 52397 | 1322829d1501 |
parent 51949 | 2a1e47af3c6b |
child 52466 | 3b1d026699fc |
permissions | -rw-r--r-- |
48154
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
1 |
/* |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
4 |
* |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
8 |
* |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
13 |
* accompanied this code). |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
14 |
* |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
18 |
* |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
21 |
* questions. |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
22 |
*/ |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
23 |
|
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
24 |
/* @test TestAllocateHeapAtMultiple.java |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
25 |
* @key gc |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
26 |
* @summary Test to check allocation of Java Heap with AllocateHeapAt option. Has multiple sub-tests to cover different code paths. |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
27 |
* @library /test/lib |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
28 |
* @modules java.base/jdk.internal.misc |
51949
2a1e47af3c6b
8211208: make AllocateHeapAt an unsupported option on AIX
mbaesken
parents:
50525
diff
changeset
|
29 |
* @requires vm.bits == "64" & vm.gc != "Z" & os.family != "aix" |
48154
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
30 |
*/ |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
31 |
|
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
32 |
import jdk.test.lib.JDKToolFinder; |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
33 |
import jdk.test.lib.process.ProcessTools; |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
34 |
import jdk.test.lib.process.OutputAnalyzer; |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
35 |
import java.util.ArrayList; |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
36 |
import java.util.Collections; |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
37 |
|
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
38 |
public class TestAllocateHeapAtMultiple { |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
39 |
public static void main(String args[]) throws Exception { |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
40 |
ArrayList<String> vmOpts = new ArrayList(); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
41 |
String[] testVmOpts = null; |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
42 |
|
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
43 |
String test_dir = System.getProperty("test.dir", "."); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
44 |
|
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
45 |
String testVmOptsStr = System.getProperty("test.java.opts"); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
46 |
if (!testVmOptsStr.isEmpty()) { |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
47 |
testVmOpts = testVmOptsStr.split(" "); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
48 |
} |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
49 |
|
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
50 |
// Extra options for each of the sub-tests |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
51 |
String[] extraOptsList = new String[] { |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
52 |
"-Xmx32m -Xms32m -XX:+UseCompressedOops", // 1. With compressedoops enabled. |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
53 |
"-Xmx32m -Xms32m -XX:-UseCompressedOops", // 2. With compressedoops disabled. |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
54 |
"-Xmx32m -Xms32m -XX:HeapBaseMinAddress=3g", // 3. With user specified HeapBaseMinAddress. |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
55 |
"-Xmx4g -Xms4g", // 4. With larger heap size (UnscaledNarrowOop not possible). |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
56 |
"-Xmx4g -Xms4g -XX:+UseLargePages", // 5. Set UseLargePages. |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
57 |
"-Xmx4g -Xms4g -XX:+UseNUMA" // 6. Set UseNUMA. |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
58 |
}; |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
59 |
|
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
60 |
for(String extraOpts : extraOptsList) { |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
61 |
vmOpts.clear(); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
62 |
if(testVmOpts != null) { |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
63 |
Collections.addAll(vmOpts, testVmOpts); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
64 |
} |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
65 |
// Add extra options specific to the sub-test. |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
66 |
String[] extraOptsArray = extraOpts.split(" "); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
67 |
if(extraOptsArray != null) { |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
68 |
Collections.addAll(vmOpts, extraOptsArray); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
69 |
} |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
70 |
// Add common options |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
71 |
Collections.addAll(vmOpts, new String[] {"-XX:AllocateHeapAt=" + test_dir, |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
72 |
"-Xlog:gc+heap=info", |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
73 |
"-version"}); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
74 |
|
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
75 |
System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java")); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
76 |
for (int i = 0; i < vmOpts.size(); i += 1) { |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
77 |
System.out.print(" " + vmOpts.get(i)); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
78 |
} |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
79 |
System.out.println(); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
80 |
|
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
81 |
ProcessBuilder pb = |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
82 |
ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()])); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
83 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
84 |
|
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
85 |
System.out.println("Output:\n" + output.getOutput()); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
86 |
|
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
87 |
output.shouldContain("Successfully allocated Java heap at location"); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
88 |
output.shouldHaveExitValue(0); |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
89 |
} |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
90 |
} |
dea4d68f1340
8190980: Develop test cases and collect test pass rate
kkharbas
parents:
diff
changeset
|
91 |
} |