Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanValue/equals/equals001.java
41161 views
1
/*
2
* Copyright (c) 2000, 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
package nsk.jdi.BooleanValue.equals;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdi.*;
29
30
import com.sun.jdi.*;
31
import java.util.*;
32
import java.io.*;
33
34
/**
35
* The test for the implementation of an object of the type <BR>
36
* BooleanValue. <BR>
37
* <BR>
38
* The test checks up that results of the method <BR>
39
* <code>com.sun.jdi.BooleanValue.equals()</code> <BR>
40
* complies with its spec. <BR>
41
* The cases for testing are as follows : <BR>
42
* <BR>
43
* when a gebuggee executes the following : <BR>
44
* public static boolean bTrue1 = true; <BR>
45
* public static boolean bTrue2 = true; <BR>
46
* public static boolean bFalse1 = false; <BR>
47
* public static boolean bFalse2 = false; <BR>
48
* <BR>
49
* which a debugger mirros as : <BR>
50
* <BR>
51
* BooleanValue bvTrue1; <BR>
52
* BooleanValue bvTrue2; <BR>
53
* BooleanValue bvFalse1; <BR>
54
* BooleanValue bvFalse2; <BR>
55
* <BR>
56
* the following is true: <BR>
57
* <BR>
58
* bvTrue1.equals(bvTrue2) <BR>
59
* !bvTrue1.equals(bvFalse1) <BR>
60
* bvFalse1.equals(bvFalse2) <BR>
61
* !bvFalse1.equals(bvTrue1) <BR>
62
* <BR>
63
* !bvTrue1.equals(IntegerValue i0) <BR>
64
* !bvFalse1.equals(IntegerValue i1) <BR>
65
* <BR>
66
*/
67
68
public class equals001 {
69
70
//----------------------------------------------------- templete section
71
static final int PASSED = 0;
72
static final int FAILED = 2;
73
static final int PASS_BASE = 95;
74
75
//----------------------------------------------------- templete parameters
76
static final String
77
sHeader1 = "\n==> nsk/jdi/BooleanValue/equals/equals001",
78
sHeader2 = "--> equals001: ",
79
sHeader3 = "##> equals001: ";
80
81
//----------------------------------------------------- main method
82
83
public static void main (String argv[]) {
84
int result = run(argv, System.out);
85
System.exit(result + PASS_BASE);
86
}
87
88
public static int run (String argv[], PrintStream out) {
89
return new equals001().runThis(argv, out);
90
}
91
92
//-------------------------------------------------- log procedures
93
94
private static boolean verbMode = false;
95
96
private static Log logHandler;
97
98
private static void log1(String message) {
99
logHandler.display(sHeader1 + message);
100
}
101
private static void log2(String message) {
102
logHandler.display(sHeader2 + message);
103
}
104
private static void log3(String message) {
105
logHandler.complain(sHeader3 + message);
106
}
107
108
// ************************************************ test parameters
109
110
private String debuggeeName =
111
"nsk.jdi.BooleanValue.equals.equals001a";
112
113
//====================================================== test program
114
115
static ArgumentHandler argsHandler;
116
static int testExitCode = PASSED;
117
118
//------------------------------------------------------ common section
119
120
private int runThis (String argv[], PrintStream out) {
121
122
Debugee debugee;
123
124
argsHandler = new ArgumentHandler(argv);
125
logHandler = new Log(out, argsHandler);
126
Binder binder = new Binder(argsHandler, logHandler);
127
128
if (argsHandler.verbose()) {
129
debugee = binder.bindToDebugee(debuggeeName + " -vbs"); // *** tp
130
} else {
131
debugee = binder.bindToDebugee(debuggeeName); // *** tp
132
}
133
134
IOPipe pipe = new IOPipe(debugee);
135
136
debugee.redirectStderr(out);
137
log2("equals001a debugee launched");
138
debugee.resume();
139
140
String line = pipe.readln();
141
if ((line == null) || !line.equals("ready")) {
142
log3("signal received is not 'ready' but: " + line);
143
return FAILED;
144
} else {
145
log2("'ready' recieved");
146
}
147
148
VirtualMachine vm = debugee.VM();
149
150
//------------------------------------------------------ testing section
151
log1(" TESTING BEGINS");
152
153
for (int i = 0; ; i++) {
154
pipe.println("newcheck");
155
line = pipe.readln();
156
157
if (line.equals("checkend")) {
158
log2(" : returned string is 'checkend'");
159
break ;
160
} else if (!line.equals("checkready")) {
161
log3("ERROR: returned string is not 'checkready'");
162
testExitCode = FAILED;
163
break ;
164
}
165
166
log1("new check: #" + i);
167
168
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part
169
170
List listOfDebuggeeExecClasses = vm.classesByName(debuggeeName);
171
if (listOfDebuggeeExecClasses.size() != 1) {
172
testExitCode = FAILED;
173
log3("ERROR: listOfDebuggeeExecClasses.size() != 1");
174
break ;
175
}
176
ReferenceType execClass =
177
(ReferenceType) listOfDebuggeeExecClasses.get(0);
178
179
Field fTrue1 = execClass.fieldByName("bTrue1");
180
Field fTrue2 = execClass.fieldByName("bTrue2");
181
Field fFalse1 = execClass.fieldByName("bFalse1");
182
Field fFalse2 = execClass.fieldByName("bFalse2");
183
184
BooleanValue bvTrue1 = (BooleanValue) execClass.getValue(fTrue1);
185
BooleanValue bvTrue2 = (BooleanValue) execClass.getValue(fTrue2);
186
BooleanValue bvFalse1 = (BooleanValue) execClass.getValue(fFalse1);
187
BooleanValue bvFalse2 = (BooleanValue) execClass.getValue(fFalse2);
188
189
int i2;
190
191
for (i2 = 0; ; i2++) {
192
193
int expresult = 0;
194
195
log2("new check: #" + i2);
196
197
switch (i2) {
198
199
case 0: if (!bvTrue1.equals(bvTrue2))
200
expresult = 1;
201
break;
202
203
case 1: if (bvTrue1.equals(bvFalse1))
204
expresult = 1;
205
break;
206
207
case 2: if (!bvFalse1.equals(bvFalse2))
208
expresult = 1;
209
break;
210
211
case 3: if (bvFalse1.equals(bvTrue1))
212
expresult = 1;
213
break;
214
215
case 4: IntegerValue i0 = vm.mirrorOf(0);
216
if (bvTrue1.equals(i0))
217
expresult = 1;
218
break;
219
220
case 5: IntegerValue i1 = vm.mirrorOf(1);
221
if (bvFalse1.equals(i1))
222
expresult = 1;
223
break;
224
225
226
default: expresult = 2;
227
break ;
228
}
229
230
if (expresult == 2) {
231
log2(" test cases finished");
232
break ;
233
} else if (expresult == 1) {
234
log3("ERROR: expresult != 1; check # = " + i2);
235
testExitCode = FAILED;
236
}
237
}
238
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
239
}
240
log1(" TESTING ENDS");
241
242
//-------------------------------------------------- test summary section
243
244
//------------------------------------------------- standard end section
245
246
pipe.println("quit");
247
log2("waiting for the debugee finish ...");
248
debugee.waitFor();
249
250
int status = debugee.getStatus();
251
if (status != PASSED + PASS_BASE) {
252
log3("debugee returned UNEXPECTED exit status: " +
253
status + " != PASS_BASE");
254
testExitCode = FAILED;
255
} else {
256
log2("debugee returned expected exit status: " +
257
status + " == PASS_BASE");
258
}
259
260
if (testExitCode != PASSED) {
261
logHandler.complain("TEST FAILED");
262
}
263
return testExitCode;
264
}
265
}
266
267