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 * @test CompilerQueueTest
26 * @bug 8054889
27 * @build DcmdUtil CompilerQueueTest
28 * @run main CompilerQueueTest
29 * @summary Test of diagnostic command Compiler.queue
30 */
31
32 import java.io.BufferedReader;
33 import java.io.StringReader;
34
35 public class CompilerQueueTest {
36
37 /**
38 * This test calls Jcmd (diagnostic command tool) Compiler.queue and
39 * then parses the output, making sure that the output look ok.
40 *
41 *
42 * Output example:
43 *
44 * Contents of C1 compile queue
45 * ----------------------------
46 * 73 3 java.lang.AbstractStringBuilder::append (50 bytes)
47 * 74 1 java.util.TreeMap::size (5 bytes)
48 * 75 3 java.lang.StringBuilder::append (8 bytes)
49 * 83 3 java.util.TreeMap$ValueIterator::next (8 bytes)
50 * 84 1 javax.management.MBeanFeatureInfo::getName (5 bytes)
51 * ----------------------------
52 * Contents of C2 compile queue
53 * ----------------------------
54 * Empty
55 * ----------------------------
56 *
57 **/
58
59 public static void main(String arg[]) throws Exception {
60
61 // Get output from dcmd (diagnostic command)
62 String result = DcmdUtil.executeDcmd("Compiler.queue");
63 BufferedReader r = new BufferedReader(new StringReader(result));
64
65 String line;
66 match(r.readLine(), "Contents of C1 compile queue");
67 match(r.readLine(), "----------------------------");
68 String str = r.readLine();
69 if (!str.equals("Empty")) {
70 while (str.charAt(0) != '-') {
71 validateMethodLine(str);
72 str = r.readLine();
73 }
74 } else {
75 str = r.readLine();
76 }
77
78 match(str, "----------------------------");
79 match(r.readLine(), "Contents of C2 compile queue");
80 match(r.readLine(), "----------------------------");
81 str = r.readLine();
82 if (!str.equals("Empty")) {
83 while (str.charAt(0) != '-') {
84 validateMethodLine(str);
85 str = r.readLine();
86 }
87 } else {
88 str = r.readLine();
89 }
90 match(str, "----------------------------");
91 }
92
93 private static void validateMethodLine(String str) throws Exception {
94 String name = str.substring(19);
95 int sep = name.indexOf("::");
96 try {
97 Class.forName(name.substring(0, sep));
98 } catch (ClassNotFoundException e) {
99 throw new Exception("Failed parsing dcmd queue");
100 }
101 }
102
103 public static void match(String line, String str) throws Exception {
104 if (!line.equals(str)) {
105 throw new Exception("String equals: " + line + ", " + str);
106 }
107 }
108 }
|
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 * @test CompilerQueueTest
26 * @bug 8054889
27 * @library ..
28 * @build DcmdUtil CompilerQueueTest
29 * @run main CompilerQueueTest
30 * @run main/othervm -Xint CompilerQueueTest
31 * @summary Test of diagnostic command Compiler.queue
32 */
33
34 import java.io.BufferedReader;
35 import java.io.StringReader;
36
37 public class CompilerQueueTest {
38
39 /**
40 * This test calls Jcmd (diagnostic command tool) Compiler.queue and
41 * then parses the output, making sure that the output look ok.
42 *
43 *
44 * Output example:
45 *
46 * Contents of C1 compile queue
47 * ----------------------------
48 * 73 3 java.lang.AbstractStringBuilder::append (50 bytes)
49 * 74 1 java.util.TreeMap::size (5 bytes)
50 * 75 3 java.lang.StringBuilder::append (8 bytes)
51 * 83 3 java.util.TreeMap$ValueIterator::next (8 bytes)
52 * 84 1 javax.management.MBeanFeatureInfo::getName (5 bytes)
53 * ----------------------------
54 * Contents of C2 compile queue
55 * ----------------------------
56 * Empty
57 * ----------------------------
58 *
59 **/
60
61 public static void main(String arg[]) throws Exception {
62
63 // Get output from dcmd (diagnostic command)
64 String result = DcmdUtil.executeDcmd("Compiler.queue");
65 BufferedReader r = new BufferedReader(new StringReader(result));
66
67 String str = r.readLine();
68
69 while (str != null) {
70 if (str.startsWith("Contents of C")) {
71 match(r.readLine(), "----------------------------");
72 str = r.readLine();
73 if (!str.equals("Empty")) {
74 while (str.charAt(0) != '-') {
75 validateMethodLine(str);
76 str = r.readLine();
77 }
78 } else {
79 str = r.readLine();
80 }
81 match(str,"----------------------------");
82 str = r.readLine();
83 } else {
84 throw new Exception("Failed parsing dcmd queue, line: " + str);
85 }
86 }
87 }
88
89 private static void validateMethodLine(String str) throws Exception {
90 String name = str.substring(19);
91 int sep = name.indexOf("::");
92 if (sep == -1) {
93 throw new Exception("Failed dcmd queue, didn't find separator :: in: " + name);
94 }
95 try {
96 Class.forName(name.substring(0, sep));
97 } catch (ClassNotFoundException e) {
98 throw new Exception("Failed dcmd queue, Class for name: " + str);
99 }
100 }
101
102 public static void match(String line, String str) throws Exception {
103 if (!line.equals(str)) {
104 throw new Exception("String equals: " + line + ", " + str);
105 }
106 }
107 }
|