|
1 /* |
|
2 * Copyright (c) 2002, 2018, 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 /* |
|
26 * @test |
|
27 * |
|
28 * @summary converted from VM Testbase nsk/jdb/classes/classes001. |
|
29 * VM Testbase keywords: [jpda, jdb] |
|
30 * VM Testbase readme: |
|
31 * DECSRIPTION |
|
32 * A positive test case for the 'classes' command. |
|
33 * The test checks if jdb correctly replies on 'classes' command. |
|
34 * The test passes when reply contains full names of all checked classes. |
|
35 * COMMENTS |
|
36 * |
|
37 * @library /vmTestbase |
|
38 * /test/lib |
|
39 * @run driver jdk.test.lib.FileInstaller . . |
|
40 * @build nsk.jdb.classes.classes001.classes001 |
|
41 * nsk.jdb.classes.classes001.classes001a |
|
42 * @run main/othervm PropertyResolvingWrapper nsk.jdb.classes.classes001.classes001 |
|
43 * -arch=${os.family}-${os.simpleArch} |
|
44 * -waittime=5 |
|
45 * -debugee.vmkind=java |
|
46 * -transport.address=dynamic |
|
47 * -jdb=${test.jdk}/bin/jdb |
|
48 * -java.options="${test.vm.opts} ${test.java.opts}" |
|
49 * -workdir=. |
|
50 * -debugee.vmkeys="${test.vm.opts} ${test.java.opts}" |
|
51 */ |
|
52 |
|
53 package nsk.jdb.classes.classes001; |
|
54 |
|
55 import nsk.share.*; |
|
56 import nsk.share.jdb.*; |
|
57 |
|
58 import java.io.*; |
|
59 import java.util.*; |
|
60 |
|
61 public class classes001 extends JdbTest { |
|
62 |
|
63 public static void main (String argv[]) { |
|
64 System.exit(run(argv, System.out) + JCK_STATUS_BASE); |
|
65 } |
|
66 |
|
67 public static int run(String argv[], PrintStream out) { |
|
68 debuggeeClass = DEBUGGEE_CLASS; |
|
69 firstBreak = FIRST_BREAK; |
|
70 lastBreak = LAST_BREAK; |
|
71 return new classes001().runTest(argv, out); |
|
72 } |
|
73 |
|
74 static final String PACKAGE_NAME = "nsk.jdb.classes.classes001"; |
|
75 static final String TEST_CLASS = PACKAGE_NAME + ".classes001"; |
|
76 static final String DEBUGGEE_CLASS = TEST_CLASS + "a"; |
|
77 static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main"; |
|
78 static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak"; |
|
79 static final String NOT_VALID_SAMPLE = "is not a valid"; |
|
80 |
|
81 static String[] checkedClasses = { |
|
82 DEBUGGEE_CLASS, |
|
83 DEBUGGEE_CLASS + "$Inner1", |
|
84 DEBUGGEE_CLASS + "$Inner2", |
|
85 DEBUGGEE_CLASS + "$Inner3", |
|
86 DEBUGGEE_CLASS + "$Inner4", |
|
87 DEBUGGEE_CLASS + "$Inner5", |
|
88 DEBUGGEE_CLASS + "$Inner6", |
|
89 DEBUGGEE_CLASS + "$Inner7", |
|
90 DEBUGGEE_CLASS + "$Inner8", |
|
91 DEBUGGEE_CLASS + "$InnerInt1", |
|
92 DEBUGGEE_CLASS + "$InnerInt2", |
|
93 DEBUGGEE_CLASS + "$InnerInt3", |
|
94 DEBUGGEE_CLASS + "$InnerInt4", |
|
95 DEBUGGEE_CLASS + "$InnerInt5", |
|
96 PACKAGE_NAME + ".Outer1", |
|
97 PACKAGE_NAME + ".Outer2", |
|
98 PACKAGE_NAME + ".Outer3", |
|
99 PACKAGE_NAME + ".OuterInt1", |
|
100 PACKAGE_NAME + ".OuterInt2" |
|
101 }; |
|
102 |
|
103 /* ------------------------------------- */ |
|
104 |
|
105 protected void runCases() { |
|
106 String[] reply; |
|
107 Paragrep grep; |
|
108 int count; |
|
109 Vector v; |
|
110 String found; |
|
111 |
|
112 jdb.setBreakpointInMethod(LAST_BREAK); |
|
113 reply = jdb.receiveReplyFor(JdbCommand.cont); |
|
114 |
|
115 reply = jdb.receiveReplyFor(JdbCommand.classes); |
|
116 |
|
117 for (int i = 0; i < checkedClasses.length; i++) { |
|
118 if (!checkClass(checkedClasses[i], reply)) { |
|
119 success = false; |
|
120 } |
|
121 } |
|
122 |
|
123 jdb.contToExit(1); |
|
124 } |
|
125 |
|
126 private boolean checkClass (String className, String[] reply) { |
|
127 Paragrep grep; |
|
128 String found; |
|
129 boolean result = true; |
|
130 |
|
131 grep = new Paragrep(reply); |
|
132 found = grep.findFirst(className); |
|
133 if (found.length() == 0) { |
|
134 log.complain("Failed to report class " + className); |
|
135 result = false; |
|
136 } |
|
137 return result; |
|
138 } |
|
139 } |