Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/FloatValue/value/value001.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.value;
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.value()</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 float pos_inf = Float.POSITIVE_INFINITY; <BR>
46
* public static float pos_zero = 0.0d; <BR>
47
* public static float neg_zero = -0.0d; <BR>
48
* public static float neg_inf = Float.NEGATIVE_INFINITY; <BR>
49
* public static float pos_largest = Float.MAX_VALUE; <BR>
50
* public static float pos_smallest = Float.MIN_VALUE; <BR>
51
* public static float neg_largest = -Float.MAX_VALUE; <BR>
52
* public static float neg_smallest = -Float.MIN_VALUE; <BR>
53
* public static float float_nan = Float.NaN; <BR>
54
* <BR>
55
* which a debugger mirros as : <BR>
56
* <BR>
57
* FloatValue fvpos_inf; <BR>
58
* FloatValue fvpos_zero; <BR>
59
* FloatValue fvneg_zero; <BR>
60
* FloatValue fvneg_inf; <BR>
61
* FloatValue fvpos_largest; <BR>
62
* FloatValue fvpos_smallest; <BR>
63
* FloatValue fvneg_largest; <BR>
64
* FloatValue fvneg_smallest; <BR>
65
* FloatValue fvdouble_nan; <BR>
66
* <BR>
67
* the following is true: <BR>
68
* <BR>
69
* fvneg_inf.value() == Floate.NEGATIVE_INFINITY <BR>
70
* fvneg_largest.value() == -Float.MAX_VALUE <BR>
71
* fvneg_smallest.value() == -Double.MIN_VALUE <BR>
72
* fvneg_zero.value() == -0.0d <BR>
73
* fvpos_zero.value() == 0.0d <BR>
74
* fvpos_smallest.value() == Float.MIN_VALUE <BR>
75
* fvpos_largest.value() == Float.MAX_VALUE <BR>
76
* fvpos_inf.value() == Float.POSITIVE_INFINITY <BR>
77
* fvfloat_nan.value() != fvfloat_nan.value() <BR>
78
* <BR>
79
*/
80
81
public class value001 {
82
83
//----------------------------------------------------- templete section
84
static final int PASSED = 0;
85
static final int FAILED = 2;
86
static final int PASS_BASE = 95;
87
88
//----------------------------------------------------- templete parameters
89
static final String
90
sHeader1 = "\n==> nsk/jdi/FloatValue/value/value001",
91
sHeader2 = "--> value001: ",
92
sHeader3 = "##> value001: ";
93
94
//----------------------------------------------------- main method
95
96
public static void main (String argv[]) {
97
int result = run(argv, System.out);
98
System.exit(result + PASS_BASE);
99
}
100
101
public static int run (String argv[], PrintStream out) {
102
return new value001().runThis(argv, out);
103
}
104
105
//-------------------------------------------------- log procedures
106
107
private static boolean verbMode = false;
108
109
private static Log logHandler;
110
111
private static void log1(String message) {
112
logHandler.display(sHeader1 + message);
113
}
114
private static void log2(String message) {
115
logHandler.display(sHeader2 + message);
116
}
117
private static void log3(String message) {
118
logHandler.complain(sHeader3 + message);
119
}
120
121
// ************************************************ test parameters
122
123
private String debuggeeName =
124
"nsk.jdi.FloatValue.value.value001a";
125
126
//====================================================== test program
127
128
static ArgumentHandler argsHandler;
129
static int testExitCode = PASSED;
130
131
//------------------------------------------------------ common section
132
133
private int runThis (String argv[], PrintStream out) {
134
135
Debugee debuggee;
136
137
argsHandler = new ArgumentHandler(argv);
138
logHandler = new Log(out, argsHandler);
139
Binder binder = new Binder(argsHandler, logHandler);
140
141
if (argsHandler.verbose()) {
142
debuggee = binder.bindToDebugee(debuggeeName + " -vbs"); // *** tp
143
} else {
144
debuggee = binder.bindToDebugee(debuggeeName); // *** tp
145
}
146
147
IOPipe pipe = new IOPipe(debuggee);
148
149
debuggee.redirectStderr(out);
150
log2("value001a debuggee launched");
151
debuggee.resume();
152
153
String line = pipe.readln();
154
if ((line == null) || !line.equals("ready")) {
155
log3("signal received is not 'ready' but: " + line);
156
return FAILED;
157
} else {
158
log2("'ready' recieved");
159
}
160
161
VirtualMachine vm = debuggee.VM();
162
163
//------------------------------------------------------ testing section
164
log1(" TESTING BEGINS");
165
166
for (int i = 0; ; i++) {
167
pipe.println("newcheck");
168
line = pipe.readln();
169
170
if (line.equals("checkend")) {
171
log2(" : returned string is 'checkend'");
172
break ;
173
} else if (!line.equals("checkready")) {
174
log3("ERROR: returned string is not 'checkready'");
175
testExitCode = FAILED;
176
break ;
177
}
178
179
log1("new check: #" + i);
180
181
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part
182
183
List listOfDebuggeeExecClasses = vm.classesByName(debuggeeName);
184
if (listOfDebuggeeExecClasses.size() != 1) {
185
testExitCode = FAILED;
186
log3("ERROR: listOfDebuggeeExecClasses.size() != 1");
187
break ;
188
}
189
ReferenceType execClass =
190
(ReferenceType) listOfDebuggeeExecClasses.get(0);
191
192
Field ffneg_inf = execClass.fieldByName("neg_inf");
193
Field ffneg_largest = execClass.fieldByName("neg_largest");
194
Field ffneg_smallest = execClass.fieldByName("neg_smallest");
195
Field ffneg_zero = execClass.fieldByName("neg_zero");
196
Field ffpos_zero = execClass.fieldByName("pos_zero");
197
Field ffpos_smallest = execClass.fieldByName("pos_smallest");
198
Field ffpos_largest = execClass.fieldByName("pos_largest");
199
Field ffpos_inf = execClass.fieldByName("pos_inf");
200
Field ffloat_nan = execClass.fieldByName("float_nan");
201
202
FloatValue fvneg_inf = (FloatValue) execClass.getValue(ffneg_inf);
203
FloatValue fvneg_largest = (FloatValue) execClass.getValue(ffneg_largest);
204
FloatValue fvneg_smallest = (FloatValue) execClass.getValue(ffneg_smallest);
205
FloatValue fvneg_zero = (FloatValue) execClass.getValue(ffneg_zero);
206
FloatValue fvpos_zero = (FloatValue) execClass.getValue(ffpos_zero);
207
FloatValue fvpos_smallest = (FloatValue) execClass.getValue(ffpos_smallest);
208
FloatValue fvpos_largest = (FloatValue) execClass.getValue(ffpos_largest);
209
FloatValue fvpos_inf = (FloatValue) execClass.getValue(ffpos_inf);
210
FloatValue fvfloat_nan = (FloatValue) execClass.getValue(ffloat_nan);
211
212
int i2;
213
214
for (i2 = 0; ; i2++) {
215
216
int expresult = 0;
217
218
log2("new check: #" + i2);
219
220
switch (i2) {
221
222
case 0: if (fvneg_inf.value() != Float.NEGATIVE_INFINITY)
223
expresult = 1;
224
break;
225
226
case 1: if (fvneg_largest.value() != -Float.MAX_VALUE)
227
expresult = 1;
228
break;
229
230
case 2: if (fvneg_smallest.value() != -Float.MIN_VALUE)
231
expresult = 1;
232
break;
233
234
case 3: if (fvneg_zero.value() != -0.0d)
235
expresult = 1;
236
break;
237
238
case 4: if (fvpos_zero.value() != 0.0d)
239
expresult = 1;
240
break;
241
242
case 5: if (fvpos_smallest.value() != Float.MIN_VALUE)
243
expresult = 1;
244
break;
245
246
case 6: if (fvpos_largest.value() != Float.MAX_VALUE)
247
expresult = 1;
248
break;
249
250
case 7: if (fvpos_inf.value() != Float.POSITIVE_INFINITY)
251
expresult = 1;
252
break;
253
254
case 8: if ( !(fvfloat_nan.value() != fvfloat_nan.value()) )
255
expresult = 1;
256
break;
257
258
259
default: expresult = 2;
260
break ;
261
}
262
263
if (expresult == 2) {
264
log2(" test cases finished");
265
break ;
266
} else if (expresult == 1) {
267
log3("ERROR: expresult != true; check # = " + i);
268
testExitCode = FAILED;
269
}
270
}
271
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
272
}
273
log1(" TESTING ENDS");
274
275
//-------------------------------------------------- test summary section
276
//------------------------------------------------- standard end section
277
278
pipe.println("quit");
279
log2("waiting for the debuggee to finish ...");
280
debuggee.waitFor();
281
282
int status = debuggee.getStatus();
283
if (status != PASSED + PASS_BASE) {
284
log3("debuggee returned UNEXPECTED exit status: " +
285
status + " != PASS_BASE");
286
testExitCode = FAILED;
287
} else {
288
log2("debuggee returned expected exit status: " +
289
status + " == PASS_BASE");
290
}
291
292
if (testExitCode != PASSED) {
293
logHandler.complain("TEST FAILED");
294
}
295
return testExitCode;
296
}
297
}
298
299