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