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