author | neugens |
Mon, 10 Aug 2015 14:42:07 +0200 (2015-08-10) | |
changeset 32281 | 99ae1f6dd69b |
parent 30604 | b8d532cb6420 |
child 35061 | be6025ebffea |
permissions | -rw-r--r-- |
18497 | 1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
18497
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
18497 | 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 TestUnrecognizedVMOptionsHandling |
|
26 |
* @key gc |
|
27 |
* @bug 8017611 |
|
28 |
* @summary Tests handling unrecognized VM options |
|
29 |
* @library /testlibrary |
|
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
18497
diff
changeset
|
30 |
* @modules java.base/sun.misc |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
18497
diff
changeset
|
31 |
* java.management |
18497 | 32 |
* @run main/othervm TestUnrecognizedVMOptionsHandling |
33 |
*/ |
|
34 |
||
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
35 |
import jdk.test.lib.*; |
18497 | 36 |
|
37 |
public class TestUnrecognizedVMOptionsHandling { |
|
38 |
||
39 |
public static void main(String args[]) throws Exception { |
|
40 |
// The first two JAVA processes are expected to fail, but with a correct VM option suggestion |
|
41 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
|
42 |
"-XX:+PrintGc", |
|
43 |
"-version" |
|
44 |
); |
|
45 |
OutputAnalyzer outputWithError = new OutputAnalyzer(pb.start()); |
|
46 |
outputWithError.shouldContain("Did you mean '(+/-)PrintGC'?"); |
|
47 |
if (outputWithError.getExitValue() == 0) { |
|
48 |
throw new RuntimeException("Not expected to get exit value 0"); |
|
49 |
} |
|
50 |
||
51 |
pb = ProcessTools.createJavaProcessBuilder( |
|
52 |
"-XX:MaxiumHeapSize=500m", |
|
53 |
"-version" |
|
54 |
); |
|
55 |
outputWithError = new OutputAnalyzer(pb.start()); |
|
56 |
outputWithError.shouldContain("Did you mean 'MaxHeapSize=<value>'?"); |
|
57 |
if (outputWithError.getExitValue() == 0) { |
|
58 |
throw new RuntimeException("Not expected to get exit value 0"); |
|
59 |
} |
|
60 |
||
61 |
// The last JAVA process should run successfully for the purpose of sanity check |
|
62 |
pb = ProcessTools.createJavaProcessBuilder( |
|
63 |
"-XX:+PrintGC", |
|
64 |
"-version" |
|
65 |
); |
|
66 |
OutputAnalyzer outputWithNoError = new OutputAnalyzer(pb.start()); |
|
67 |
outputWithNoError.shouldNotContain("Did you mean '(+/-)PrintGC'?"); |
|
68 |
outputWithNoError.shouldHaveExitValue(0); |
|
69 |
} |
|
70 |
} |
|
71 |