|
1 /* |
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
|
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 import com.oracle.java.testlibrary.*; |
|
25 |
|
26 /* |
|
27 * @test |
|
28 * @bug 8006997 |
|
29 * @summary ContendedPaddingWidth should be range-checked |
|
30 * |
|
31 * @library /testlibrary |
|
32 * @run main Options |
|
33 */ |
|
34 public class Options { |
|
35 |
|
36 public static void main(String[] args) throws Exception { |
|
37 ProcessBuilder pb; |
|
38 OutputAnalyzer output; |
|
39 |
|
40 pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=-128", "-version"); |
|
41 output = new OutputAnalyzer(pb.start()); |
|
42 output.shouldContain("ContendedPaddingWidth"); |
|
43 output.shouldContain("must be in between"); |
|
44 output.shouldHaveExitValue(1); |
|
45 |
|
46 pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=-8", "-version"); |
|
47 output = new OutputAnalyzer(pb.start()); |
|
48 output.shouldContain("ContendedPaddingWidth"); |
|
49 output.shouldContain("must be in between"); |
|
50 output.shouldHaveExitValue(1); |
|
51 |
|
52 pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=-1", "-version"); |
|
53 output = new OutputAnalyzer(pb.start()); |
|
54 output.shouldContain("ContendedPaddingWidth"); |
|
55 output.shouldContain("must be in between"); |
|
56 output.shouldContain("must be a multiple of 8"); |
|
57 output.shouldHaveExitValue(1); |
|
58 |
|
59 pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=0", "-version"); |
|
60 output = new OutputAnalyzer(pb.start()); |
|
61 output.shouldHaveExitValue(0); |
|
62 |
|
63 pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=1", "-version"); |
|
64 output = new OutputAnalyzer(pb.start()); |
|
65 output.shouldContain("ContendedPaddingWidth"); |
|
66 output.shouldContain("must be a multiple of 8"); |
|
67 output.shouldHaveExitValue(1); |
|
68 |
|
69 pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=8", "-version"); |
|
70 output = new OutputAnalyzer(pb.start()); |
|
71 output.shouldHaveExitValue(0); |
|
72 |
|
73 pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=8184", "-version"); // 8192-8 = 8184 |
|
74 output = new OutputAnalyzer(pb.start()); |
|
75 output.shouldHaveExitValue(0); |
|
76 |
|
77 pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=8191", "-version"); |
|
78 output = new OutputAnalyzer(pb.start()); |
|
79 output.shouldContain("ContendedPaddingWidth"); |
|
80 output.shouldContain("must be a multiple of 8"); |
|
81 output.shouldHaveExitValue(1); |
|
82 |
|
83 pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=8192", "-version"); |
|
84 output = new OutputAnalyzer(pb.start()); |
|
85 output.shouldHaveExitValue(0); |
|
86 |
|
87 pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=8193", "-version"); |
|
88 output = new OutputAnalyzer(pb.start()); |
|
89 output.shouldContain("ContendedPaddingWidth"); |
|
90 output.shouldContain("must be in between"); |
|
91 output.shouldContain("must be a multiple of 8"); |
|
92 output.shouldHaveExitValue(1); |
|
93 |
|
94 pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=8200", "-version"); // 8192+8 = 8200 |
|
95 output = new OutputAnalyzer(pb.start()); |
|
96 output.shouldContain("ContendedPaddingWidth"); |
|
97 output.shouldContain("must be in between"); |
|
98 output.shouldHaveExitValue(1); |
|
99 |
|
100 } |
|
101 |
|
102 } |
|
103 |