Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanValue/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.BooleanValue.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
* BooleanValue. <BR>
37
* <BR>
38
* The test checks up that results of the method <BR>
39
* <code>com.sun.jdi.BooleanValue.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 boolean bTrue1 = true; <BR>
46
* public static boolean bFalse1 = false; <BR>
47
* <BR>
48
* which a debugger mirros as : <BR>
49
* <BR>
50
* BooleanValue bvTrue1; <BR>
51
* BooleanValue bvFalse1; <BR>
52
* <BR>
53
* the following is true: <BR>
54
* <BR>
55
* BooleanValue bvTrue.value() == true <BR>
56
* BooleanValue bvFalse.value() == false <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/BooleanValue/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.BooleanValue.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 debugee;
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
debugee = binder.bindToDebugee(debuggeeName + " -vbs"); // *** tp
122
} else {
123
debugee = binder.bindToDebugee(debuggeeName); // *** tp
124
}
125
126
IOPipe pipe = new IOPipe(debugee);
127
128
debugee.redirectStderr(out);
129
log2("value001a debugee launched");
130
debugee.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 = debugee.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 fTrue1 = execClass.fieldByName("bTrue1");
172
// Field fTrue2 = execClass.fieldByName("bTrue2");
173
Field fFalse1 = execClass.fieldByName("bFalse1");
174
// Field fFalse2 = execClass.fieldByName("bFalse2");
175
176
BooleanValue bvTrue1 = (BooleanValue) execClass.getValue(fTrue1);
177
// BooleanValue bvTrue2 = (BooleanValue) execClass.getValue(fTrue2);
178
BooleanValue bvFalse1 = (BooleanValue) execClass.getValue(fFalse1);
179
// BooleanValue bvFalse2 = (BooleanValue) execClass.getValue(fFalse2);
180
181
int i2;
182
183
for (i2 = 0; ; i2++) {
184
185
int expresult = 0;
186
187
log2("new check: #" + i2);
188
189
switch (i2) {
190
191
case 0: if (bvTrue1.value() != true)
192
expresult = 1;
193
break;
194
195
case 1: if (bvFalse1.value() != false)
196
expresult = 1;
197
break;
198
199
default: expresult = 2;
200
break ;
201
}
202
203
if (expresult == 2) {
204
log2(" test cases finished");
205
break ;
206
} else if (expresult == 1) {
207
log3("ERROR: expresult != 1; check # = " + i2);
208
testExitCode = FAILED;
209
}
210
}
211
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
212
}
213
log1(" TESTING ENDS");
214
215
//-------------------------------------------------- test summary section
216
217
//------------------------------------------------- standard end section
218
219
pipe.println("quit");
220
log2("waiting for the debugee finish ...");
221
debugee.waitFor();
222
223
int status = debugee.getStatus();
224
if (status != PASSED + PASS_BASE) {
225
log3("debugee returned UNEXPECTED exit status: " +
226
status + " != PASS_BASE");
227
testExitCode = FAILED;
228
} else {
229
log2("debugee returned expected exit status: " +
230
status + " == PASS_BASE");
231
}
232
233
if (testExitCode != PASSED) {
234
logHandler.complain("TEST FAILED");
235
}
236
return testExitCode;
237
}
238
}
239
240