annotate test/compiler/testlibrary/rtm/RTMTestBase.java @ 18408:2c3666f44855

Truffle: initial commit of object API implementation
author Andreas Woess <andreas.woess@jku.at>
date Tue, 18 Nov 2014 23:19:43 +0100
parents 665bbe93823f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17871
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
1 /*
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
4 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
7 * published by the Free Software Foundation.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
8 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
13 * accompanied this code).
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
14 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
18 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
21 * questions.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
22 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
23 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
24
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
25 package rtm;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
26
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
27 import java.io.IOException;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
28 import java.nio.file.Files;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
29 import java.nio.file.Paths;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
30 import java.util.List;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
31 import java.util.LinkedList;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
32 import java.util.Arrays;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
33 import java.util.Collections;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
34 import java.util.regex.Matcher;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
35 import java.util.regex.Pattern;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
36
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
37 import com.oracle.java.testlibrary.OutputAnalyzer;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
38 import com.oracle.java.testlibrary.ProcessTools;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
39 import com.oracle.java.testlibrary.Utils;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
40 import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
41
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
42 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
43 * Auxiliary methods used for RTM testing.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
44 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
45 public class RTMTestBase {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
46 private static final String RTM_STATE_CHANGE_REASON = "rtm_state_change";
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
47 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
48 * We don't parse compilation log as XML-document and use regular
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
49 * expressions instead, because in some cases it could be
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
50 * malformed.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
51 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
52 private static final String FIRED_UNCOMMON_TRAP_PATTERN_TEMPLATE
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
53 = "<uncommon_trap thread='[0-9]+' reason='%s'";
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
54 private static final String INSTALLED_UNCOMMON_TRAP_PATTERN_TEMPLATE
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
55 = "<uncommon_trap bci='[0-9]+' reason='%s'";
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
56
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
57 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
58 * Executes RTM test in a new JVM started with {@code options} cli options.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
59 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
60 * @param test test case to execute.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
61 * @param options additional options for VM
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
62 * @throws Exception when something went wrong.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
63 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
64 public static OutputAnalyzer executeRTMTest(CompilableTest test,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
65 String... options) throws Exception {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
66 ProcessBuilder processBuilder
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
67 = ProcessTools.createJavaProcessBuilder(
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
68 RTMTestBase.prepareTestOptions(test, options));
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
69 OutputAnalyzer outputAnalyzer
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
70 = new OutputAnalyzer(processBuilder.start());
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
71 System.out.println(outputAnalyzer.getOutput());
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
72 return outputAnalyzer;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
73 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
74
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
75 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
76 * Executes test case and save compilation log to {@code logFileName}.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
77 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
78 * @param logFileName a name of compilation log file
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
79 * @param test a test case to execute case to execute
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
80 * @param options additional options to VM
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
81 * @return OutputAnalyzer for started test case
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
82 * @throws Exception when something went wrong
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
83 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
84 public static OutputAnalyzer executeRTMTest(String logFileName,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
85 CompilableTest test, String... options) throws Exception {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
86 ProcessBuilder processBuilder
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
87 = ProcessTools.createJavaProcessBuilder(
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
88 RTMTestBase.prepareTestOptions(logFileName, test, options));
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
89 OutputAnalyzer outputAnalyzer
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
90 = new OutputAnalyzer(processBuilder.start());
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
91
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
92 System.out.println(outputAnalyzer.getOutput());
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
93
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
94 return outputAnalyzer;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
95 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
96
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
97 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
98 * Finds count of uncommon traps with reason {@code reason} installed
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
99 * during compilation.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
100 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
101 * @param compilationLogFile a path to file with LogCompilation output.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
102 * @param reason reason of installed uncommon traps.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
103 * @return count of installed uncommon traps with reason {@code reason}.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
104 * @throws IOException
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
105 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
106 public static int installedUncommonTraps(String compilationLogFile,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
107 String reason)throws IOException {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
108 String pattern = String.format(
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
109 RTMTestBase.INSTALLED_UNCOMMON_TRAP_PATTERN_TEMPLATE,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
110 reason);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
111 return RTMTestBase.findTraps(compilationLogFile, pattern);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
112 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
113
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
114 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
115 * Finds count of uncommon traps with reason <i>rtm_state_change</i>
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
116 * installed during compilation.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
117 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
118 * @param compilationLogFile a path to file with LogCompilation output.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
119 * @return count of installed uncommon traps with reason
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
120 * <i>rtm_state_change</i>.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
121 * @throws IOException
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
122 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
123 public static int installedRTMStateChangeTraps(String compilationLogFile)
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
124 throws IOException {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
125 return RTMTestBase.installedUncommonTraps(compilationLogFile,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
126 RTMTestBase.RTM_STATE_CHANGE_REASON);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
127 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
128
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
129 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
130 * Finds count of fired uncommon traps with reason {@code reason}.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
131 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
132 * @param compilationLogFile a path to file with LogCompilation output.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
133 * @param reason a reason of fired uncommon traps.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
134 * @return count of fired uncommon traps with reason {@code reason}.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
135 * @throws IOException
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
136 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
137 public static int firedUncommonTraps(String compilationLogFile,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
138 String reason) throws IOException {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
139 String pattern = String.format(
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
140 RTMTestBase.FIRED_UNCOMMON_TRAP_PATTERN_TEMPLATE,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
141 reason);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
142 return RTMTestBase.findTraps(compilationLogFile, pattern);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
143 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
144
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
145 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
146 * Finds count of fired uncommon traps with reason <i>rtm_state_change</i>.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
147 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
148 * @param compilationLogFile a path to file with LogCompilation output.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
149 * @return count of fired uncommon traps with reason
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
150 * <i>rtm_state_change</i>.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
151 * @throws IOException
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
152 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
153 public static int firedRTMStateChangeTraps(String compilationLogFile)
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
154 throws IOException {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
155 return RTMTestBase.firedUncommonTraps(compilationLogFile,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
156 RTMTestBase.RTM_STATE_CHANGE_REASON);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
157 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
158
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
159 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
160 * Finds count of uncommon traps that matches regular
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
161 * expression in {@code re}.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
162 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
163 * @param compilationLogFile a path to file with LogCompilation output.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
164 * @param re regular expression to match uncommon traps.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
165 * @throws IOException
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
166 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
167 private static int findTraps(String compilationLogFile, String re)
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
168 throws IOException {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
169 String compilationLog = RTMTestBase.fileAsString(compilationLogFile);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
170 Pattern pattern = Pattern.compile(re);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
171 Matcher matcher = pattern.matcher(compilationLog);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
172 int traps = 0;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
173 while (matcher.find()) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
174 traps++;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
175 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
176 return traps;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
177 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
178
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
179 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
180 * Returns file's content as a string.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
181 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
182 * @param path a path to file to operate on.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
183 * @return string with content of file.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
184 * @throws IOException
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
185 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
186 private static String fileAsString(String path) throws IOException {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
187 byte[] fileAsBytes = Files.readAllBytes(Paths.get(path));
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
188 return new String(fileAsBytes);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
189 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
190
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
191 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
192 * Prepares VM options for test execution.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
193 * This method get test java options, filter out all RTM-related options,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
194 * adds CompileCommand=compileonly,method_name options for each method
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
195 * from {@code methodToCompile} and finally appends all {@code vmOpts}.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
196 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
197 * @param test test case whose methods that should be compiled.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
198 * If {@code null} then no additional <i>compileonly</i>
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
199 * commands will be added to VM options.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
200 * @param vmOpts additional options to pass to VM.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
201 * @return Array with VM options.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
202 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
203 private static String[] prepareTestOptions(CompilableTest test,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
204 String... vmOpts) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
205 return RTMTestBase.prepareFilteredTestOptions(test, null, vmOpts);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
206 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
207
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
208 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
209 * Prepares VM options for test execution.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
210 * This method get test java options, filter out all RTM-related options
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
211 * and all options that matches regexps in {@code additionalFilters},
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
212 * adds CompileCommand=compileonly,method_name options for each method
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
213 * from {@code methodToCompile} and finally appends all {@code vmOpts}.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
214 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
215 * @param test test case whose methods that should be compiled.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
216 * If {@code null} then no additional <i>compileonly</i>
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
217 * commands will be added to VM options.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
218 * @param additionalFilters array with regular expression that will be
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
219 * used to filter out test java options.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
220 * If {@code null} then no additional filters
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
221 * will be used.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
222 * @param vmOpts additional options to pass to VM.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
223 * @return array with VM options.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
224 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
225 private static String[] prepareFilteredTestOptions(CompilableTest test,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
226 String[] additionalFilters, String... vmOpts) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
227 List<String> finalVMOpts = new LinkedList<>();
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
228 String[] filters;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
229
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
230 if (additionalFilters != null) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
231 filters = Arrays.copyOf(additionalFilters,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
232 additionalFilters.length + 1);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
233 } else {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
234 filters = new String[1];
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
235 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
236
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
237 filters[filters.length - 1] = "RTM";
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
238 String[] filteredVMOpts = Utils.getFilteredTestJavaOpts(filters);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
239 Collections.addAll(finalVMOpts, filteredVMOpts);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
240 Collections.addAll(finalVMOpts, "-Xcomp", "-server",
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
241 "-XX:-TieredCompilation",
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
242 CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
243 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
244 "-XX:+UseRTMLocking");
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
245
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
246 if (test != null) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
247 for (String method : test.getMethodsToCompileNames()) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
248 finalVMOpts.add("-XX:CompileCommand=compileonly," + method);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
249 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
250 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
251 Collections.addAll(finalVMOpts, vmOpts);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
252 return finalVMOpts.toArray(new String[finalVMOpts.size()]);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
253 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
254
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
255 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
256 * Adds additional options for VM required for successful execution of test.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
257 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
258 * @param logFileName a name of compilation log file
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
259 * @param test a test case to execute
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
260 * @param options additional options to VM
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
261 * @return an array with VM options
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
262 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
263 private static String[] prepareTestOptions(String logFileName,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
264 CompilableTest test, String... options) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
265 String[] preparedOptions = RTMTestBase.prepareFilteredTestOptions(
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
266 test,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
267 new String[] {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
268 "LogCompilation",
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
269 "LogFile"
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
270 });
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
271 List<String> updatedOptions = new LinkedList<>();
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
272 Collections.addAll(updatedOptions, preparedOptions);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
273 Collections.addAll(updatedOptions,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
274 "-XX:+LogCompilation",
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
275 "-XX:LogFile=" + logFileName);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
276 Collections.addAll(updatedOptions, options);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
277
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
278 return updatedOptions.toArray(new String[updatedOptions.size()]);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
279 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
280 }