author | gadams |
Fri, 28 Sep 2018 14:31:36 -0400 | |
changeset 51956 | f1f7ff620f83 |
parent 51308 | acf02a6f369e |
permissions | -rw-r--r-- |
50220 | 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/exclude/exclude001. |
|
29 |
* VM Testbase keywords: [jpda, jdb, quarantine] |
|
51298 | 30 |
* VM Testbase comments: 8191037 |
50220 | 31 |
* VM Testbase readme: |
32 |
* DECSRIPTION |
|
33 |
* A positive test for the 'exclude' command. |
|
34 |
* The debuggee program (exclude001a.java) starts three |
|
35 |
* addional threads of MyThread class. The 'run' method of these |
|
36 |
* threads invokes java.lang.System.currentTimeMillis() and |
|
51049
70295a56c207
8206007: nsk/jdb/exclude001 test is taking a long time on some builds
gadams
parents:
50889
diff
changeset
|
37 |
* sun.util.calendar.Gregorian() methods. |
50220 | 38 |
* There are three test cases: |
39 |
* - block all exclude filter; |
|
40 |
* - modified exclude filter allowing tracing events for java.* methods, |
|
41 |
* which is set with 'exclude javax.*,sun.*,com.sun.*,jdk.*' command; |
|
51049
70295a56c207
8206007: nsk/jdb/exclude001 test is taking a long time on some builds
gadams
parents:
50889
diff
changeset
|
42 |
* - modified exclude filter allowing tracing events for sun.* methods, |
70295a56c207
8206007: nsk/jdb/exclude001 test is taking a long time on some builds
gadams
parents:
50889
diff
changeset
|
43 |
* which is set with 'exclude java.*,javax.*,com.sun.*,jdk.*' command. |
50220 | 44 |
* - non-modified, predefined exclude filter; |
45 |
* - modified exclude filter allowing tracing events for java.* methods, |
|
46 |
* which is set with 'exclude javax.*,sun.*,com.sun.*' command; |
|
47 |
* - modified exclude filter allowing tracing events for all system methods, |
|
48 |
* which is set with 'exclude none' command. |
|
49 |
* For each test case the correspondent MyThread thread is started and |
|
50 |
* suspended at a breakpoint. Then method tracing is turned on with |
|
51 |
* 'trace methods <thread id>' command with correspondent exclude filtering. |
|
52 |
* The test passes if debuggee suspends on method enter/exit of only |
|
53 |
* filtered classes, i.e. in comply with exclude filter previously set. |
|
54 |
* The test consists of two program: |
|
55 |
* exclude001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output, |
|
56 |
* exclude001a.java - the debugged application. |
|
57 |
* COMMENTS |
|
58 |
* |
|
59 |
* @library /vmTestbase |
|
60 |
* /test/lib |
|
61 |
* @run driver jdk.test.lib.FileInstaller . . |
|
62 |
* @build nsk.jdb.exclude.exclude001.exclude001 |
|
63 |
* nsk.jdb.exclude.exclude001.exclude001a |
|
51956
f1f7ff620f83
8208473: [TESTBUG] nsk/jdb/exclude/exclude001/exclude001.java is timing out on solaris-sparc again
gadams
parents:
51308
diff
changeset
|
64 |
* @run main/othervm/timeout=600 PropertyResolvingWrapper nsk.jdb.exclude.exclude001.exclude001 |
50220 | 65 |
* -arch=${os.family}-${os.simpleArch} |
51956
f1f7ff620f83
8208473: [TESTBUG] nsk/jdb/exclude/exclude001/exclude001.java is timing out on solaris-sparc again
gadams
parents:
51308
diff
changeset
|
66 |
* -waittime=10 |
50220 | 67 |
* -debugee.vmkind=java |
68 |
* -transport.address=dynamic |
|
69 |
* -jdb=${test.jdk}/bin/jdb |
|
70 |
* -java.options="${test.vm.opts} ${test.java.opts}" |
|
71 |
* -workdir=. |
|
72 |
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}" |
|
73 |
*/ |
|
74 |
||
75 |
package nsk.jdb.exclude.exclude001; |
|
76 |
||
77 |
import nsk.share.*; |
|
78 |
import nsk.share.jdb.*; |
|
79 |
||
80 |
import java.io.*; |
|
81 |
import java.util.*; |
|
82 |
||
83 |
public class exclude001 extends JdbTest { |
|
84 |
||
85 |
public static void main (String argv[]) { |
|
86 |
System.exit(run(argv, System.out) + JCK_STATUS_BASE); |
|
87 |
} |
|
88 |
||
89 |
public static int run(String argv[], PrintStream out) { |
|
90 |
debuggeeClass = DEBUGGEE_CLASS; |
|
91 |
firstBreak = FIRST_BREAK; |
|
92 |
lastBreak = LAST_BREAK; |
|
93 |
return new exclude001().runTest(argv, out); |
|
94 |
} |
|
95 |
||
96 |
static final String PACKAGE_NAME = "nsk.jdb.exclude.exclude001"; |
|
97 |
static final String TEST_CLASS = PACKAGE_NAME + ".exclude001"; |
|
98 |
static final String DEBUGGEE_CLASS = TEST_CLASS + "a"; |
|
99 |
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main"; |
|
100 |
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak"; |
|
101 |
static final String MYTHREAD = "MyThread"; |
|
102 |
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD; |
|
103 |
||
104 |
static final String JAVA_CORE_METHOD = "java.lang.System.currentTimeMillis"; |
|
51049
70295a56c207
8206007: nsk/jdb/exclude001 test is taking a long time on some builds
gadams
parents:
50889
diff
changeset
|
105 |
static final String SUN_METHOD = "sun.util.calendar.Gregorian"; |
50220 | 106 |
|
107 |
protected void runCases() { |
|
108 |
String[] reply; |
|
109 |
Paragrep grep; |
|
110 |
int count; |
|
111 |
Vector v; |
|
112 |
String found; |
|
113 |
String[] threads; |
|
114 |
||
115 |
String oldExclude = ""; |
|
116 |
boolean javaTraced = false; |
|
117 |
boolean comTraced = false; |
|
118 |
boolean nskTraced = false; |
|
119 |
||
120 |
jdb.setBreakpointInMethod(LAST_BREAK); |
|
121 |
||
122 |
// getting predefined 'exclude' value |
|
123 |
reply = jdb.receiveReplyFor(JdbCommand.exclude); |
|
124 |
if (reply.length == 0) { |
|
125 |
log.complain("Predefined excluded lists of classes is empty"); |
|
126 |
success = false; |
|
127 |
} else { |
|
128 |
||
129 |
oldExclude = reply[0]; |
|
130 |
||
131 |
for (int testCase = 0; testCase < exclude001a.numThreads; testCase++) { |
|
51956
f1f7ff620f83
8208473: [TESTBUG] nsk/jdb/exclude/exclude001/exclude001.java is timing out on solaris-sparc again
gadams
parents:
51308
diff
changeset
|
132 |
String expectedPrompt = MYTHREAD + "-" + testCase + "[1]"; |
50220 | 133 |
reply = jdb.receiveReplyFor(JdbCommand.cont); |
134 |
||
135 |
if (jdb.isAtBreakpoint(reply, LAST_BREAK)) { |
|
136 |
||
137 |
threads = jdb.getThreadIds(DEBUGGEE_THREAD); |
|
138 |
||
139 |
if (threads.length != 1) { |
|
140 |
log.complain("jdb should report 1 instance of " + DEBUGGEE_THREAD); |
|
141 |
log.complain("Found: " + threads.length); |
|
142 |
success = false; |
|
143 |
} else { |
|
144 |
||
145 |
reply = jdb.receiveReplyFor(JdbCommand.step); // to get out of lastBreak; |
|
146 |
||
147 |
switch (testCase) { |
|
148 |
case 0: // block all |
|
149 |
reply = jdb.receiveReplyFor(JdbCommand.exclude + "java.*,javax.*,sun.*,com.sun.*,jdk.*"); |
|
150 |
||
151 |
break; |
|
152 |
case 1: // allow java.* |
|
153 |
reply = jdb.receiveReplyFor(JdbCommand.exclude + "javax.*,sun.*,com.sun.*,jdk.*"); |
|
154 |
break; |
|
51049
70295a56c207
8206007: nsk/jdb/exclude001 test is taking a long time on some builds
gadams
parents:
50889
diff
changeset
|
155 |
case 2: // allow sun.* |
51956
f1f7ff620f83
8208473: [TESTBUG] nsk/jdb/exclude/exclude001/exclude001.java is timing out on solaris-sparc again
gadams
parents:
51308
diff
changeset
|
156 |
reply = jdb.receiveReplyFor(JdbCommand.exclude + "java.*,javax.*,com.sun.*,jdk.*"); |
50220 | 157 |
break; |
158 |
} |
|
159 |
||
160 |
reply = jdb.receiveReplyFor(JdbCommand.trace + "methods " + threads[0]); |
|
161 |
||
162 |
while (true) { |
|
51956
f1f7ff620f83
8208473: [TESTBUG] nsk/jdb/exclude/exclude001/exclude001.java is timing out on solaris-sparc again
gadams
parents:
51308
diff
changeset
|
163 |
reply = jdb.receiveReplyForWithMessageWait(JdbCommand.cont, expectedPrompt); |
50220 | 164 |
|
165 |
grep = new Paragrep(reply); |
|
166 |
count = grep.find(JAVA_CORE_METHOD); |
|
167 |
if (count > 0) { |
|
168 |
if (testCase != 0) { |
|
169 |
javaTraced = true; |
|
170 |
} else { |
|
171 |
log.complain("Trace message for excluded method: " + JAVA_CORE_METHOD); |
|
172 |
} |
|
173 |
} |
|
174 |
||
51049
70295a56c207
8206007: nsk/jdb/exclude001 test is taking a long time on some builds
gadams
parents:
50889
diff
changeset
|
175 |
count = grep.find(SUN_METHOD); |
50220 | 176 |
if (count > 0) { |
177 |
if (testCase == 2) { |
|
178 |
comTraced = true; |
|
179 |
} else { |
|
51049
70295a56c207
8206007: nsk/jdb/exclude001 test is taking a long time on some builds
gadams
parents:
50889
diff
changeset
|
180 |
log.complain("Trace message for excluded method: " + SUN_METHOD); |
50220 | 181 |
} |
182 |
} |
|
183 |
||
184 |
count = grep.find(DEBUGGEE_THREAD + ".run"); |
|
185 |
if (count > 0) { |
|
186 |
nskTraced = true; |
|
187 |
||
188 |
reply = jdb.receiveReplyFor(JdbCommand.exclude + oldExclude); |
|
189 |
reply = jdb.receiveReplyFor(JdbCommand.untrace + "methods "+ threads[0]); |
|
190 |
break; |
|
191 |
} |
|
192 |
} |
|
193 |
} |
|
194 |
} |
|
195 |
} |
|
196 |
} |
|
197 |
||
198 |
jdb.contToExit(2); |
|
199 |
||
200 |
if (!javaTraced) { |
|
201 |
log.complain("There were no tracing events for " + JAVA_CORE_METHOD + "() method while turned off filter"); |
|
202 |
success = false; |
|
203 |
} |
|
204 |
if (!comTraced) { |
|
51049
70295a56c207
8206007: nsk/jdb/exclude001 test is taking a long time on some builds
gadams
parents:
50889
diff
changeset
|
205 |
log.complain("There were no tracing events for " + SUN_METHOD + "() method while turned off filter"); |
50220 | 206 |
success = false; |
207 |
} |
|
208 |
if (!nskTraced) { |
|
209 |
log.complain("There were no tracing events for " + DEBUGGEE_THREAD + ".run() method "); |
|
210 |
success = false; |
|
211 |
} |
|
212 |
} |
|
213 |
} |