author | mikejwre |
Thu, 25 Mar 2010 15:05:15 -0700 (2010-03-25) | |
changeset 5074 | 9c9bfe8f3a47 |
parent 1081 | 1382b6e4980b |
child 10607 | 1ba66093449c |
permissions | -rw-r--r-- |
2 | 1 |
/** |
2 |
* @test |
|
3 |
* @bug 4390869 |
|
4 |
* @bug 4460328 |
|
5 |
* @summary Test Stepping in the new SourceDebugExtension facility |
|
6 |
* |
|
7 |
* @author Robert Field |
|
8 |
* |
|
9 |
* @library .. |
|
10 |
* @run build TestScaffold VMConnection TargetListener TargetAdapter InstallSDE |
|
11 |
* @run compile MangleStepTest.java |
|
12 |
* @run compile -g onion/pickle/Mangle.java |
|
1081
1382b6e4980b
6737900: TEST: Some JDI regression tests timeout on slow machines
jjh
parents:
2
diff
changeset
|
13 |
* @run main MangleStepTest unset |
1382b6e4980b
6737900: TEST: Some JDI regression tests timeout on slow machines
jjh
parents:
2
diff
changeset
|
14 |
* @run main MangleStepTest Java |
1382b6e4980b
6737900: TEST: Some JDI regression tests timeout on slow machines
jjh
parents:
2
diff
changeset
|
15 |
* @run main MangleStepTest XYZ |
1382b6e4980b
6737900: TEST: Some JDI regression tests timeout on slow machines
jjh
parents:
2
diff
changeset
|
16 |
* @run main MangleStepTest Rats |
1382b6e4980b
6737900: TEST: Some JDI regression tests timeout on slow machines
jjh
parents:
2
diff
changeset
|
17 |
* @run main MangleStepTest bogus |
2 | 18 |
*/ |
19 |
import com.sun.jdi.*; |
|
20 |
import com.sun.jdi.event.*; |
|
21 |
import com.sun.jdi.request.*; |
|
22 |
||
23 |
import java.util.*; |
|
24 |
import java.io.File; |
|
25 |
||
26 |
public class MangleStepTest extends TestScaffold { |
|
27 |
static final String op = "onion" + File.separator + "pickle" + File.separator; |
|
28 |
ReferenceType targetClass; |
|
29 |
final String stratum; |
|
30 |
static boolean aTestFailed = false; |
|
31 |
||
32 |
MangleStepTest (String stratum) { |
|
33 |
super(new String[0]); |
|
34 |
this.stratum = stratum; |
|
35 |
} |
|
36 |
||
37 |
public static void main(String[] args) throws Exception { |
|
38 |
testSetUp(); |
|
1081
1382b6e4980b
6737900: TEST: Some JDI regression tests timeout on slow machines
jjh
parents:
2
diff
changeset
|
39 |
new MangleStepTest(args[0]).startTests(); |
2 | 40 |
if (aTestFailed) { |
41 |
throw new Exception("MangleStepTest: failed"); |
|
42 |
} |
|
43 |
||
44 |
} |
|
45 |
||
46 |
/********** test set-up **********/ |
|
47 |
||
48 |
static void testSetUp() throws Exception { |
|
49 |
InstallSDE.install(new File(System.getProperty("test.classes", "."), |
|
50 |
op + "Mangle.class"), |
|
51 |
new File(System.getProperty("test.src", "."), |
|
52 |
"Mangle.sde")); |
|
53 |
} |
|
54 |
||
55 |
/********** test assist **********/ |
|
56 |
||
57 |
void lineMatch(Location loc, int javaLine, int defaultLine) { |
|
58 |
if (loc.lineNumber() != defaultLine) { |
|
59 |
failure("FAIL: at " + loc.lineNumber() + |
|
60 |
", expected " + defaultLine); |
|
61 |
} else { |
|
62 |
println("at: " + loc.lineNumber()); |
|
63 |
} |
|
64 |
if (loc.lineNumber("Java") != javaLine) { |
|
65 |
failure("FAIL: at Java line " + loc.lineNumber("Java") + |
|
66 |
", expected " + javaLine); |
|
67 |
} |
|
68 |
} |
|
69 |
||
70 |
/********** test core **********/ |
|
71 |
||
72 |
protected void runTests() throws Exception { |
|
73 |
/* |
|
74 |
* Get to the top of main() |
|
75 |
*/ |
|
76 |
int[] lines; |
|
77 |
int[] jLines; |
|
78 |
String targetName = "onion.pickle.Mangle"; |
|
79 |
startUp(targetName); |
|
80 |
if (!stratum.equals("unset")) { |
|
81 |
vm().setDefaultStratum(stratum); |
|
82 |
} |
|
83 |
BreakpointEvent bpe = resumeTo(targetName, "main", |
|
84 |
"([Ljava/lang/String;)V"); |
|
85 |
waitForInput(); |
|
86 |
||
87 |
ThreadReference thread = bpe.thread(); |
|
88 |
||
89 |
if (stratum.equals("Java")) { |
|
90 |
lines = new int[] {4, 5, 6, 7, 8, 9}; |
|
91 |
jLines = new int[] {4, 5, 6, 7, 8, 9}; |
|
92 |
} else if (stratum.equals("Rats")) { |
|
93 |
lines = new int[] {1000, 1111, 1112}; |
|
94 |
jLines = new int[] {4, 5, 7}; |
|
95 |
} else { /* XYZ (the class default) */ |
|
96 |
lines = new int[] {200, 210, 217, 218}; |
|
97 |
jLines = new int[] {4, 7, 8, 9}; |
|
98 |
} |
|
99 |
||
100 |
println("Testing stratum: " + stratum); |
|
101 |
||
102 |
lineMatch(bpe.location(), jLines[0], lines[0]); |
|
103 |
||
104 |
for (int i = 1; i < lines.length; ++i) { |
|
105 |
StepEvent se = stepOverLine(thread); |
|
106 |
lineMatch(se.location(), jLines[i], lines[i]); |
|
107 |
} |
|
108 |
||
109 |
/* |
|
110 |
* resume the target to completion |
|
111 |
*/ |
|
112 |
listenUntilVMDisconnect(); |
|
113 |
||
114 |
/* |
|
115 |
* deal with results of test |
|
116 |
* if anything has called failure("foo") testFailed will be true |
|
117 |
*/ |
|
118 |
if (!testFailed) { |
|
119 |
println("MangleStepTest (" + stratum + "): passed"); |
|
120 |
} else { |
|
121 |
println("MangleStepTest (" + stratum + "): failed"); |
|
122 |
aTestFailed = true; |
|
123 |
} |
|
124 |
} |
|
125 |
} |