Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/read/read001/read001.java
40951 views
1
/*
2
* Copyright (c) 2002, 2020, 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/read/read001.
29
* VM Testbase keywords: [jpda, jdb]
30
* VM Testbase readme:
31
* DESCRIPTION
32
* A positive test for the 'read <filename>' command.
33
* The jdb stops the debugged application on enter in read001a.lastBreak()
34
* method. Then the tested command is called for the 'jdb.scenario' file.
35
* The test passes if correct replies for all commands containing in
36
* 'jdb.scenario' are found in jdb stdout stream.
37
* The test consists of two program:
38
* read001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
39
* read001a.java - the debugged application.
40
* COMMENTS
41
* Only limited number of commands is used in 'jdb.scenario' file because
42
* the jdb does not wait until end of reply for current command and
43
* immediatly executes the next command from 'jdb.scenario'.
44
* Fixed test according to test bug:
45
* 4665075 TTY: error messages for commands from scenario file of 'read' command
46
*
47
* @library /vmTestbase
48
* /test/lib
49
* @build nsk.jdb.read.read001.read001
50
*
51
* @comment make sure read001a is compiled w/ full debug info
52
* @clean nsk.jdb.read.read001.read001a
53
* @compile -g:lines,source,vars read001a.java
54
*
55
* @run main/othervm
56
* nsk.jdb.read.read001.read001
57
* -arch=${os.family}-${os.simpleArch}
58
* -waittime=5
59
* -debugee.vmkind=java
60
* -transport.address=dynamic
61
* -jdb=${test.jdk}/bin/jdb
62
* -java.options="${test.vm.opts} ${test.java.opts}"
63
* -workdir=.
64
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
65
*/
66
67
package nsk.jdb.read.read001;
68
69
import nsk.share.*;
70
import nsk.share.jdb.*;
71
import jdk.test.lib.Utils;
72
73
import java.io.*;
74
import java.util.*;
75
76
public class read001 extends JdbTest {
77
78
public static void main (String argv[]) {
79
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
80
}
81
82
public static int run(String argv[], PrintStream out) {
83
debuggeeClass = DEBUGGEE_CLASS;
84
firstBreak = FIRST_BREAK;
85
lastBreak = LAST_BREAK;
86
return new read001().runTest(argv, out);
87
}
88
89
static final String PACKAGE_NAME = "nsk.jdb.read.read001";
90
static final String TEST_CLASS = PACKAGE_NAME + ".read001";
91
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
92
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
93
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
94
95
static final String SCENARIO_FILE = "jdb.scenario";
96
static final int SCENARIO_COMMANDS_COUNT = 5;
97
98
protected void runCases() {
99
String[] reply;
100
String srcdir = Utils.TEST_SRC;
101
102
// stop in lastBreak() method
103
jdb.setBreakpointInMethod(LAST_BREAK);
104
reply = jdb.receiveReplyFor(JdbCommand.cont);
105
106
// return to testedInstanceMethod()
107
reply = jdb.receiveReplyFor(JdbCommand.step);
108
109
String command = JdbCommand.read + srcdir + File.separator + SCENARIO_FILE;
110
int count = SCENARIO_COMMANDS_COUNT + 1;
111
reply = jdb.receiveReplyFor(command, true, count);
112
113
if (!checkCommands(reply)) {
114
success = false;
115
}
116
117
jdb.contToExit(1);
118
}
119
120
private boolean checkCommands(String[] reply) {
121
Paragrep grep;
122
String found;
123
Vector v = new Vector();
124
boolean result = true;
125
int count;
126
127
grep = new Paragrep(reply);
128
129
// check 'threads'
130
log.display("Check reply for command: classes");
131
if ((count = grep.find("nsk.jdb.read.read001.read001aTestedClass")) != 1) {
132
log.complain("Wrong number of execution of command: classes");
133
log.complain(" Expected: 1; found: " + count);
134
result = false;
135
}
136
137
// check 'threads'
138
log.display("Check reply for command: threads");
139
if ((count = grep.find("TestedThreadInstance")) != 1) {
140
log.complain("Wrong number of execution of command: threads");
141
log.complain(" Expected: 1; found: " + count);
142
result = false;
143
}
144
145
// check 'methods'
146
log.display("Check reply for command: methods");
147
if ((count = grep.find("testedInstanceMethod()")) != 1) {
148
log.complain("Wrong number of execution of command: methods nsk.jdb.read.read001a");
149
log.complain(" Expected: 1; found: " + count);
150
result = false;
151
}
152
153
// check 'fields'
154
log.display("Check reply for command: fields");
155
if ((count = grep.find("testedStaticFieldBoolean")) != 1) {
156
log.complain("Wrong number of execution of command: fields nsk.jdb.read.read001.presentedInstance");
157
log.complain(" Expected: 1; found: " + count);
158
result = false;
159
}
160
161
// check 'locals'
162
log.display("Check reply for command: locals");
163
if ((count = grep.find("testedLocalVarInt")) != 1) {
164
log.complain("Wrong number of execution of command: locals");
165
log.complain(" Expected: 1; found: " + count);
166
result = false;
167
}
168
169
/*
170
// check 'eval'
171
log.display("Check reply for command: eval");
172
if ((count = grep.find("556600")) != 1) {
173
log.complain("Wrong number of execution of command: "
174
+ "eval nsk.jdb.read.read001a.staticInt+instanceInt*3");
175
log.complain(" Expected: 1; found: " + count);
176
result = false;
177
}
178
179
// check 'print'
180
log.display("Check reply for command: print");
181
if ((count = grep.find("staticString = \"static string of read001a class\"")) != 1) {
182
log.complain("Wrong number of execution of command: "
183
+ "print nsk.jdb.read.read001.read001a.staticString"
184
);
185
log.complain(" Expected: 1; found: " + count);
186
result = false;
187
}
188
189
// check 'dump'
190
log.display("Check reply for command: dump");
191
if ((count = grep.find("instance of nsk.jdb.read.read001.read001a")) != 1) {
192
log.complain("Wrong number of execution of command: "
193
+ "dump nsk.jdb.read.read001.read001a._read001a");
194
log.complain(" Expected: 1; found: " + count);
195
result = false;
196
}
197
*/
198
199
return result;
200
}
201
}
202
203