annotate test/compiler/rtm/cli/RTMLockingAwareTest.java @ 17872:100f2b109432

8039496: Add sanity tests on RTM-related command line options Reviewed-by: kvn, iignatyev Contributed-by: filipp.zhinkin@oracle.com
author iignatyev
date Mon, 14 Apr 2014 19:29:34 +0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17872
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
1 /*
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
4 *
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
7 * published by the Free Software Foundation.
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
8 *
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
13 * accompanied this code).
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
14 *
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
18 *
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
21 * questions.
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
22 *
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
23 */
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
24
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
25 import java.util.Collections;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
26 import java.util.List;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
27 import java.util.LinkedList;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
28
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
29 import com.oracle.java.testlibrary.ExitCode;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
30 import com.oracle.java.testlibrary.cli.*;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
31 import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
32 import rtm.predicate.SupportedCPU;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
33 import rtm.predicate.SupportedVM;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
34
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
35 /**
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
36 * Base for all RTM-related CLI tests on options whose processing depends
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
37 * on UseRTMLocking value.
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
38 *
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
39 * Since UseRTMLocking option could be used when both CPU and VM supports RTM
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
40 * locking, this test will be skipped on all unsupported configurations.
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
41 */
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
42 public abstract class RTMLockingAwareTest
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
43 extends RTMGenericCommandLineOptionTest {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
44 protected final String warningMessage;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
45 protected final String[] correctValues;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
46 protected final String[] incorrectValues;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
47 /**
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
48 * Constructs new test for option {@code optionName} that should be executed
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
49 * only on CPU with RTM support.
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
50 * Test will be executed using set of correct values from
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
51 * {@code correctValues} and set of incorrect values from
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
52 * {@code incorrectValues}.
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
53 *
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
54 * @param optionName name of option to be tested
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
55 * @param isBoolean {@code true} if tested option is binary
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
56 * @param isExperimental {@code true} if tested option is experimental
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
57 * @param defaultValue default value of tested option
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
58 * @param correctValues array with correct values, that should not emit
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
59 * {@code warningMessage} to VM output
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
60 * @param incorrectValues array with incorrect values, that should emit
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
61 * {@code waningMessage} to VM output
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
62 * @param warningMessage warning message associated with tested option
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
63 */
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
64 protected RTMLockingAwareTest(String optionName, boolean isBoolean,
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
65 boolean isExperimental, String defaultValue,
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
66 String[] correctValues, String[] incorrectValues,
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
67 String warningMessage) {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
68 super(new AndPredicate(new SupportedCPU(), new SupportedVM()),
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
69 optionName, isBoolean, isExperimental, defaultValue);
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
70 this.correctValues = correctValues;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
71 this.incorrectValues = incorrectValues;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
72 this.warningMessage = warningMessage;
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
73 }
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
74
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
75 @Override
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
76 protected void verifyJVMStartup() throws Throwable {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
77 // Run generic sanity checks
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
78 super.verifyJVMStartup();
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
79 // Verify how option values will be processed depending on
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
80 // UseRTMLocking value.
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
81 if (correctValues != null) {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
82 for (String correctValue : correctValues) {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
83 // For correct values it is expected to see no warnings
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
84 // regardless to UseRTMLocking
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
85 verifyStartupWarning(correctValue, true, false);
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
86 verifyStartupWarning(correctValue, false, false);
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
87 }
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
88 }
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
89
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
90 if (incorrectValues != null) {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
91 for (String incorrectValue : incorrectValues) {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
92 // For incorrect values it is expected to see warning
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
93 // only with -XX:+UseRTMLocking
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
94 verifyStartupWarning(incorrectValue, true, true);
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
95 verifyStartupWarning(incorrectValue, false, false);
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
96 }
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
97 }
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
98 }
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
99
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
100 @Override
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
101 protected void verifyOptionValues() throws Throwable {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
102 super.verifyOptionValues();
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
103 // Verify how option values will be setup after processing
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
104 // depending on UseRTMLocking value
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
105 if (correctValues != null) {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
106 for (String correctValue : correctValues) {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
107 // Correct value could be set up regardless to UseRTMLocking
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
108 verifyOptionValues(correctValue, false, correctValue);
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
109 verifyOptionValues(correctValue, true, correctValue);
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
110 }
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
111 }
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
112
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
113 if (incorrectValues != null) {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
114 for (String incorrectValue : incorrectValues) {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
115 // With -XX:+UseRTMLocking, incorrect value will be changed to
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
116 // default value.
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
117 verifyOptionValues(incorrectValue, false, incorrectValue);
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
118 verifyOptionValues(incorrectValue, true, defaultValue);
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
119 }
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
120 }
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
121 }
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
122
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
123 private void verifyStartupWarning(String value, boolean useRTMLocking,
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
124 boolean isWarningExpected) throws Throwable {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
125 String warnings[] = new String[] { warningMessage };
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
126 List<String> options = new LinkedList<>();
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
127 Collections.addAll(options,
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
128 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
129 CommandLineOptionTest.prepareBooleanFlag("UseRTMLocking",
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
130 useRTMLocking));
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
131
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
132 options.add(prepareOptionValue(value));
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
133
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
134 CommandLineOptionTest.verifySameJVMStartup(
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
135 (isWarningExpected ? warnings : null),
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
136 (isWarningExpected ? null : warnings),
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
137 ExitCode.OK, options.toArray(new String[options.size()]));
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
138 }
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
139
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
140 private void verifyOptionValues(String value, boolean useRTMLocking,
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
141 String expectedValue) throws Throwable {
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
142 List<String> options = new LinkedList<>();
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
143 Collections.addAll(options,
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
144 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
145 CommandLineOptionTest.prepareBooleanFlag("UseRTMLocking",
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
146 useRTMLocking));
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
147
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
148 options.add(prepareOptionValue(value));
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
149
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
150 CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
151 expectedValue, options.toArray(new String[options.size()]));
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
152 }
100f2b109432 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
153 }