annotate test/gc/arguments/TestSurvivorAlignmentInBytesOption.java @ 20717:4b7c96fba3d8

8037968: Add tests on alignment of objects copied to survivor space Reviewed-by: jmasa, dfazunen
author fzhinkin
date Wed, 26 Nov 2014 14:17:06 +0400
parents
children 75d8afb5d37a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20717
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
1 /*
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
4 *
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
7 * published by the Free Software Foundation.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
8 *
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
13 * accompanied this code).
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
14 *
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
18 *
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
21 * questions.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
22 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
23
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
24 import com.oracle.java.testlibrary.ExitCode;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
25 import com.oracle.java.testlibrary.Utils;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
26 import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
27
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
28 import java.util.Collections;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
29 import java.util.LinkedList;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
30 import java.util.List;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
31
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
32 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
33 * @test
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
34 * @bug 8031323
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
35 * @summary Verify SurvivorAlignmentInBytes option processing.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
36 * @library /testlibrary
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
37 * @run main TestSurvivorAlignmentInBytesOption
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
38 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
39 public class TestSurvivorAlignmentInBytesOption {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
40 private static final String[] FILTERED_VM_OPTIONS
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
41 = Utils.getFilteredTestJavaOpts(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
42 "UnlockExperimentalVMOptions",
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
43 "SurvivorAlignmentInBytes",
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
44 "ObjectAlignmentInBytes");
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
45
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
46 public static void main(String args[]) throws Throwable {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
47 String optionName = "SurvivorAlignmentInBytes";
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
48 String optionIsExperimental
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
49 = CommandLineOptionTest.getExperimentalOptionErrorMessage(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
50 optionName);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
51 String valueIsTooSmall= ".*SurvivorAlignmentInBytes=.*must be greater"
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
52 + " than ObjectAlignmentInBytes.*";
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
53 String mustBePowerOf2 = ".*SurvivorAlignmentInBytes=.*must be "
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
54 + "power of 2.*";
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
55
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
56 // Verify that without -XX:+UnlockExperimentalVMOptions usage of
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
57 // SurvivorAlignmentInBytes option will cause JVM startup failure
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
58 // with the warning message saying that that option is experimental.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
59 CommandLineOptionTest.verifyJVMStartup(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
60 new String[]{optionIsExperimental}, null, ExitCode.FAIL, false,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
61 TestSurvivorAlignmentInBytesOption.prepareOptions(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
62 "-XX:-UnlockExperimentalVMOptions",
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
63 CommandLineOptionTest.prepareNumericFlag(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
64 optionName, 64)));
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
65
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
66 // Verify that with -XX:+UnlockExperimentalVMOptions passed to JVM
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
67 // usage of SurvivorAlignmentInBytes option won't cause JVM startup
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
68 // failure.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
69 CommandLineOptionTest.verifyJVMStartup(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
70 null, new String[]{optionIsExperimental}, ExitCode.OK, false,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
71 TestSurvivorAlignmentInBytesOption.prepareOptions(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
72 CommandLineOptionTest.prepareNumericFlag(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
73 optionName, 64)));
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
74
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
75 // Verify that if specified SurvivorAlignmentInBytes is lower then
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
76 // ObjectAlignmentInBytes, then the JVM startup will fail with
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
77 // appropriate error message.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
78 CommandLineOptionTest.verifyJVMStartup(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
79 new String[]{valueIsTooSmall}, null, ExitCode.FAIL, false,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
80 TestSurvivorAlignmentInBytesOption.prepareOptions(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
81 CommandLineOptionTest.prepareNumericFlag(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
82 optionName, 2)));
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
83
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
84 // Verify that if specified SurvivorAlignmentInBytes value is not
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
85 // a power of 2 then the JVM startup will fail with appropriate error
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
86 // message.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
87 CommandLineOptionTest.verifyJVMStartup(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
88 new String[]{mustBePowerOf2}, null, ExitCode.FAIL, false,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
89 TestSurvivorAlignmentInBytesOption.prepareOptions(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
90 CommandLineOptionTest.prepareNumericFlag(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
91 optionName, 127)));
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
92
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
93 // Verify that if SurvivorAlignmentInBytes has correct value, then
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
94 // the JVM will be started without errors.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
95 CommandLineOptionTest.verifyJVMStartup(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
96 null, new String[]{".*SurvivorAlignmentInBytes.*"},
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
97 ExitCode.OK, false,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
98 TestSurvivorAlignmentInBytesOption.prepareOptions(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
99 CommandLineOptionTest.prepareNumericFlag(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
100 optionName, 128)));
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
101
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
102 // Verify that we can setup different SurvivorAlignmentInBytes values.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
103 for (int alignment = 32; alignment <= 128; alignment *= 2) {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
104 CommandLineOptionTest.verifyOptionValue(optionName,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
105 Integer.toString(alignment), false,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
106 TestSurvivorAlignmentInBytesOption.prepareOptions(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
107 CommandLineOptionTest.prepareNumericFlag(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
108 optionName, alignment)));
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
109 }
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
110 }
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
111
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
112 private static String[] prepareOptions(String... options) {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
113 List<String> finalOptions = new LinkedList<>();
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
114 Collections.addAll(finalOptions,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
115 TestSurvivorAlignmentInBytesOption.FILTERED_VM_OPTIONS);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
116 finalOptions.add(CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
117 Collections.addAll(finalOptions, options);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
118 return finalOptions.toArray(new String[finalOptions.size()]);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
119 }
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
120 }