author | jjg |
Fri, 07 Nov 2014 14:51:35 -0800 | |
changeset 27547 | d07b3dcbc707 |
parent 26688 | bb0cdd873e51 |
child 29678 | dd2f3932c21e |
permissions | -rw-r--r-- |
26688
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
1 |
/* |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
4 |
* |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
8 |
* |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
13 |
* accompanied this code). |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
14 |
* |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
18 |
* |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
21 |
* questions. |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
22 |
*/ |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
23 |
|
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
24 |
/* |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
25 |
* @test |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
26 |
* @bug 8022865 |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
27 |
* @summary Tests for the -XX:ObjectAlignmentInBytes command line option |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
28 |
* @library /testlibrary |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
29 |
* @run main ObjectAlignment |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
30 |
*/ |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
31 |
import com.oracle.java.testlibrary.*; |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
32 |
|
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
33 |
public class ObjectAlignment { |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
34 |
|
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
35 |
public static void main(String[] args) throws Exception { |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
36 |
|
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
37 |
if (Platform.is64bit()) { |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
38 |
// Minimum alignment should be 8 |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
39 |
testObjectAlignment(4) |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
40 |
.shouldContain("error: ObjectAlignmentInBytes=4 must be greater or equal 8") |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
41 |
.shouldHaveExitValue(1); |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
42 |
|
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
43 |
// Alignment has to be a power of 2 |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
44 |
testObjectAlignment(9) |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
45 |
.shouldContain("error: ObjectAlignmentInBytes=9 must be power of 2") |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
46 |
.shouldHaveExitValue(1); |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
47 |
|
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
48 |
testObjectAlignment(-1) |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
49 |
.shouldContain("error: ObjectAlignmentInBytes=-1 must be power of 2") |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
50 |
.shouldHaveExitValue(1); |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
51 |
|
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
52 |
// Maximum alignment allowed is 256 |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
53 |
testObjectAlignment(512) |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
54 |
.shouldContain("error: ObjectAlignmentInBytes=512 must not be greater than 256") |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
55 |
.shouldHaveExitValue(1); |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
56 |
|
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
57 |
// Valid alignments should work |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
58 |
testObjectAlignment(8).shouldHaveExitValue(0); |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
59 |
testObjectAlignment(16).shouldHaveExitValue(0); |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
60 |
testObjectAlignment(256).shouldHaveExitValue(0); |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
61 |
|
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
62 |
} else { |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
63 |
// For a 32bit JVM the option isn't there, make sure it's not silently ignored |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
64 |
testObjectAlignment(8) |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
65 |
.shouldContain("Unrecognized VM option 'ObjectAlignmentInBytes=8'") |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
66 |
.shouldHaveExitValue(1); |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
67 |
} |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
68 |
} |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
69 |
|
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
70 |
private static OutputAnalyzer testObjectAlignment(int alignment) throws Exception { |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
71 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:ObjectAlignmentInBytes=" + alignment, |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
72 |
"-version"); |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
73 |
return new OutputAnalyzer(pb.start()); |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
74 |
} |
bb0cdd873e51
8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff
changeset
|
75 |
} |