author | jiangli |
Fri, 02 Nov 2018 19:30:31 -0400 | |
changeset 52397 | 1322829d1501 |
parent 51949 | 2a1e47af3c6b |
child 53523 | 4c5184c56dc2 |
permissions | -rw-r--r-- |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
1 |
/* |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
4 |
* |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
8 |
* |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
13 |
* accompanied this code). |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
14 |
* |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
18 |
* |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
21 |
* questions. |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
22 |
*/ |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
23 |
|
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
24 |
/* @test TestAllocateHeapAt.java |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
25 |
* @key gc |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
26 |
* @summary Test to check allocation of Java Heap with AllocateHeapAt option |
51949
2a1e47af3c6b
8211208: make AllocateHeapAt an unsupported option on AIX
mbaesken
parents:
50525
diff
changeset
|
27 |
* @requires vm.gc != "Z" & os.family != "aix" |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
28 |
* @library /test/lib |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
29 |
* @modules java.base/jdk.internal.misc |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
30 |
*/ |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
31 |
|
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
32 |
import jdk.test.lib.JDKToolFinder; |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
33 |
import jdk.test.lib.process.ProcessTools; |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
34 |
import jdk.test.lib.process.OutputAnalyzer; |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
35 |
import java.util.ArrayList; |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
36 |
import java.util.Collections; |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
37 |
|
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
38 |
public class TestAllocateHeapAt { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
39 |
public static void main(String args[]) throws Exception { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
40 |
ArrayList<String> vmOpts = new ArrayList(); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
41 |
|
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
42 |
String testVmOptsStr = System.getProperty("test.java.opts"); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
43 |
if (!testVmOptsStr.isEmpty()) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
44 |
String[] testVmOpts = testVmOptsStr.split(" "); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
45 |
Collections.addAll(vmOpts, testVmOpts); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
46 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
47 |
String test_dir = System.getProperty("test.dir", "."); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
48 |
Collections.addAll(vmOpts, new String[] {"-XX:AllocateHeapAt=" + test_dir, |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
49 |
"-Xlog:gc+heap=info", |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
50 |
"-Xmx32m", |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
51 |
"-Xms32m", |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
52 |
"-version"}); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
53 |
|
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
54 |
System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java")); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
55 |
for (int i = 0; i < vmOpts.size(); i += 1) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
56 |
System.out.print(" " + vmOpts.get(i)); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
57 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
58 |
System.out.println(); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
59 |
|
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
60 |
ProcessBuilder pb = |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
61 |
ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()])); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
62 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
63 |
|
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
64 |
System.out.println("Output:\n" + output.getOutput()); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
65 |
|
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
66 |
output.shouldContain("Successfully allocated Java heap at location"); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
67 |
output.shouldHaveExitValue(0); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
68 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
diff
changeset
|
69 |
} |