author | prr |
Fri, 25 May 2018 12:12:24 -0700 | |
changeset 50347 | b2f046ae8eb6 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
45289
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
1 |
/* |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
4 |
* |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
8 |
* |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
13 |
* accompanied this code). |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
14 |
* |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
18 |
* |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
21 |
* questions. |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
22 |
*/ |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
23 |
|
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
24 |
/* |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
25 |
* @test |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
26 |
* @bug 4627316 6743526 |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
27 |
* @summary Test option to limit direct memory allocation, |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
28 |
* various bad values fail to launch the VM |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
29 |
* @requires (os.arch == "x86_64") | (os.arch == "amd64") | (os.arch == "sparcv9") |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
30 |
* @library /test/lib |
45466
faf1c55d2046
8181759: add explicit @build actions for jdk.test.lib classes in all :tier1 tests
iignatyev
parents:
45289
diff
changeset
|
31 |
* @build jdk.test.lib.Utils |
faf1c55d2046
8181759: add explicit @build actions for jdk.test.lib classes in all :tier1 tests
iignatyev
parents:
45289
diff
changeset
|
32 |
* jdk.test.lib.Asserts |
faf1c55d2046
8181759: add explicit @build actions for jdk.test.lib classes in all :tier1 tests
iignatyev
parents:
45289
diff
changeset
|
33 |
* jdk.test.lib.JDKToolFinder |
faf1c55d2046
8181759: add explicit @build actions for jdk.test.lib classes in all :tier1 tests
iignatyev
parents:
45289
diff
changeset
|
34 |
* jdk.test.lib.JDKToolLauncher |
faf1c55d2046
8181759: add explicit @build actions for jdk.test.lib classes in all :tier1 tests
iignatyev
parents:
45289
diff
changeset
|
35 |
* jdk.test.lib.Platform |
faf1c55d2046
8181759: add explicit @build actions for jdk.test.lib classes in all :tier1 tests
iignatyev
parents:
45289
diff
changeset
|
36 |
* jdk.test.lib.process.* |
45289
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
37 |
* |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
38 |
* @run main LimitDirectMemoryNegativeTest foo |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
39 |
* @run main LimitDirectMemoryNegativeTest 10kmt |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
40 |
* @run main LimitDirectMemoryNegativeTest -1 |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
41 |
*/ |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
42 |
|
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
43 |
import jdk.test.lib.process.ProcessTools; |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
44 |
|
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
45 |
public class LimitDirectMemoryNegativeTest { |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
46 |
|
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
47 |
private static final String ERR = "Improperly specified VM option 'MaxDirectMemorySize="; |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
48 |
|
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
49 |
public static void main(String[] args) throws Exception { |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
50 |
if (args.length != 1) { |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
51 |
throw new IllegalArgumentException("missing size argument"); |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
52 |
} |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
53 |
|
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
54 |
int exitCode = ProcessTools.executeTestJava( |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
55 |
"-XX:MaxDirectMemorySize=" + args[0], |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
56 |
LimitDirectMemoryNegativeTest.class.getName()) |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
57 |
.shouldContain(ERR + args[0]) |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
58 |
.getExitValue(); |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
59 |
if (exitCode != 1) { |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
60 |
throw new RuntimeException("Unexpected exit code: " + exitCode); |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
61 |
} |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
62 |
} |
d56bca4fdf8f
8181126: Refactor shell test java/nio/Buffer/LimitDirectMemory.sh to java
amlu
parents:
diff
changeset
|
63 |
} |