Mercurial > hg > graal-compiler
comparison 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 |
comparison
equal
deleted
inserted
replaced
17871:665bbe93823f | 17872:100f2b109432 |
---|---|
1 /* | |
2 * Copyright (c) 2014, 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 | |
25 import java.util.Collections; | |
26 import java.util.List; | |
27 import java.util.LinkedList; | |
28 | |
29 import com.oracle.java.testlibrary.ExitCode; | |
30 import com.oracle.java.testlibrary.cli.*; | |
31 import com.oracle.java.testlibrary.cli.predicate.AndPredicate; | |
32 import rtm.predicate.SupportedCPU; | |
33 import rtm.predicate.SupportedVM; | |
34 | |
35 /** | |
36 * Base for all RTM-related CLI tests on options whose processing depends | |
37 * on UseRTMLocking value. | |
38 * | |
39 * Since UseRTMLocking option could be used when both CPU and VM supports RTM | |
40 * locking, this test will be skipped on all unsupported configurations. | |
41 */ | |
42 public abstract class RTMLockingAwareTest | |
43 extends RTMGenericCommandLineOptionTest { | |
44 protected final String warningMessage; | |
45 protected final String[] correctValues; | |
46 protected final String[] incorrectValues; | |
47 /** | |
48 * Constructs new test for option {@code optionName} that should be executed | |
49 * only on CPU with RTM support. | |
50 * Test will be executed using set of correct values from | |
51 * {@code correctValues} and set of incorrect values from | |
52 * {@code incorrectValues}. | |
53 * | |
54 * @param optionName name of option to be tested | |
55 * @param isBoolean {@code true} if tested option is binary | |
56 * @param isExperimental {@code true} if tested option is experimental | |
57 * @param defaultValue default value of tested option | |
58 * @param correctValues array with correct values, that should not emit | |
59 * {@code warningMessage} to VM output | |
60 * @param incorrectValues array with incorrect values, that should emit | |
61 * {@code waningMessage} to VM output | |
62 * @param warningMessage warning message associated with tested option | |
63 */ | |
64 protected RTMLockingAwareTest(String optionName, boolean isBoolean, | |
65 boolean isExperimental, String defaultValue, | |
66 String[] correctValues, String[] incorrectValues, | |
67 String warningMessage) { | |
68 super(new AndPredicate(new SupportedCPU(), new SupportedVM()), | |
69 optionName, isBoolean, isExperimental, defaultValue); | |
70 this.correctValues = correctValues; | |
71 this.incorrectValues = incorrectValues; | |
72 this.warningMessage = warningMessage; | |
73 } | |
74 | |
75 @Override | |
76 protected void verifyJVMStartup() throws Throwable { | |
77 // Run generic sanity checks | |
78 super.verifyJVMStartup(); | |
79 // Verify how option values will be processed depending on | |
80 // UseRTMLocking value. | |
81 if (correctValues != null) { | |
82 for (String correctValue : correctValues) { | |
83 // For correct values it is expected to see no warnings | |
84 // regardless to UseRTMLocking | |
85 verifyStartupWarning(correctValue, true, false); | |
86 verifyStartupWarning(correctValue, false, false); | |
87 } | |
88 } | |
89 | |
90 if (incorrectValues != null) { | |
91 for (String incorrectValue : incorrectValues) { | |
92 // For incorrect values it is expected to see warning | |
93 // only with -XX:+UseRTMLocking | |
94 verifyStartupWarning(incorrectValue, true, true); | |
95 verifyStartupWarning(incorrectValue, false, false); | |
96 } | |
97 } | |
98 } | |
99 | |
100 @Override | |
101 protected void verifyOptionValues() throws Throwable { | |
102 super.verifyOptionValues(); | |
103 // Verify how option values will be setup after processing | |
104 // depending on UseRTMLocking value | |
105 if (correctValues != null) { | |
106 for (String correctValue : correctValues) { | |
107 // Correct value could be set up regardless to UseRTMLocking | |
108 verifyOptionValues(correctValue, false, correctValue); | |
109 verifyOptionValues(correctValue, true, correctValue); | |
110 } | |
111 } | |
112 | |
113 if (incorrectValues != null) { | |
114 for (String incorrectValue : incorrectValues) { | |
115 // With -XX:+UseRTMLocking, incorrect value will be changed to | |
116 // default value. | |
117 verifyOptionValues(incorrectValue, false, incorrectValue); | |
118 verifyOptionValues(incorrectValue, true, defaultValue); | |
119 } | |
120 } | |
121 } | |
122 | |
123 private void verifyStartupWarning(String value, boolean useRTMLocking, | |
124 boolean isWarningExpected) throws Throwable { | |
125 String warnings[] = new String[] { warningMessage }; | |
126 List<String> options = new LinkedList<>(); | |
127 Collections.addAll(options, | |
128 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, | |
129 CommandLineOptionTest.prepareBooleanFlag("UseRTMLocking", | |
130 useRTMLocking)); | |
131 | |
132 options.add(prepareOptionValue(value)); | |
133 | |
134 CommandLineOptionTest.verifySameJVMStartup( | |
135 (isWarningExpected ? warnings : null), | |
136 (isWarningExpected ? null : warnings), | |
137 ExitCode.OK, options.toArray(new String[options.size()])); | |
138 } | |
139 | |
140 private void verifyOptionValues(String value, boolean useRTMLocking, | |
141 String expectedValue) throws Throwable { | |
142 List<String> options = new LinkedList<>(); | |
143 Collections.addAll(options, | |
144 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, | |
145 CommandLineOptionTest.prepareBooleanFlag("UseRTMLocking", | |
146 useRTMLocking)); | |
147 | |
148 options.add(prepareOptionValue(value)); | |
149 | |
150 CommandLineOptionTest.verifyOptionValueForSameVM(optionName, | |
151 expectedValue, options.toArray(new String[options.size()])); | |
152 } | |
153 } |