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