Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/print/print002/print002.java
40951 views
1
/*
2
* Copyright (c) 2003, 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/print/print002.
29
* VM Testbase keywords: [quick, jpda, jdb]
30
* VM Testbase readme:
31
* DECSRIPTION
32
* This is a test for the 'print <expr>' command.
33
* The test checks if jdb correctly prints values for the following
34
* expressions:
35
* - arithmetic expression of local variables,
36
* - boolean expression of local variables,
37
* - string field deeply nested in class hierarchy.
38
* The test passes when all printed values are equal to expected ones.
39
* The test consists of two program:
40
* print002.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
41
* print002a.java - the debugged application.
42
* COMMENTS
43
* The test replaces the nsk/jdb/print/print001 one.
44
* Test was fixed according to test bug:
45
* 4862693 NSK testcase nsk/jdb/print/print002 fails with operation not yet supported
46
*
47
* @library /vmTestbase
48
* /test/lib
49
* @build nsk.jdb.print.print002.print002
50
*
51
* @comment make sure print002a is compiled w/ full debug info
52
* @clean nsk.jdb.print.print002.print002a
53
* @compile -g:lines,source,vars print002a.java
54
*
55
* @run main/othervm
56
* nsk.jdb.print.print002.print002
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.print.print002;
68
69
import nsk.share.*;
70
import nsk.share.jdb.*;
71
72
import java.io.*;
73
import java.util.*;
74
75
public class print002 extends JdbTest {
76
77
public static void main (String argv[]) {
78
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
79
}
80
81
public static int run(String argv[], PrintStream out) {
82
debuggeeClass = DEBUGGEE_CLASS;
83
firstBreak = FIRST_BREAK;
84
lastBreak = LAST_BREAK;
85
return new print002().runTest(argv, out);
86
}
87
88
static final String PACKAGE_NAME = "nsk.jdb.print.print002";
89
static final String TEST_CLASS = PACKAGE_NAME + ".print002";
90
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
91
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
92
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
93
94
static final String[][] checkedExpr = {
95
{ "i + j", "8"},
96
{ "j - i", "4"},
97
{ "j * i", "12"},
98
{ "j / i", "3"},
99
// { "j % i", "0"},
100
// { "i++", "2"},
101
// { "++i", "3"},
102
// { "j--", "6"},
103
// { "--j", "5"},
104
// { "!b1 ", "false"},
105
// { "b2 && b1", "false"},
106
// { "b2 || b1", "true"},
107
{ "a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.s", "foo" }
108
};
109
110
protected void runCases() {
111
String[] reply;
112
Paragrep grep;
113
int count;
114
Vector v;
115
String found;
116
117
jdb.setBreakpointInMethod(LAST_BREAK);
118
reply = jdb.receiveReplyFor(JdbCommand.cont);
119
120
// to get out of lastBreak()
121
reply = jdb.receiveReplyFor(JdbCommand.step);
122
123
for (int i = 0; i < checkedExpr.length; i++) {
124
if (!checkValue(checkedExpr[i][0], checkedExpr[i][1])) {
125
success = false;
126
}
127
}
128
129
jdb.contToExit(1);
130
}
131
132
private boolean checkValue (String expr, String value) {
133
Paragrep grep;
134
String[] reply;
135
String found;
136
Vector v;
137
boolean result = true;
138
139
reply = jdb.receiveReplyFor(JdbCommand.print + expr);
140
grep = new Paragrep(reply);
141
found = grep.findFirst(value);
142
if (found.length() <= 0) {
143
log.complain("jdb failed to report value of expression: " + expr);
144
log.complain("\t expected : " + value + " ;\n\t reported: " + (reply.length > 0? reply[0]: ""));
145
result = false;
146
}
147
return result;
148
}
149
}
150
151