16 A specialized abstract test case class for writing |
16 A specialized abstract test case class for writing |
17 VM crash tests. The test is run in separate process |
17 VM crash tests. The test is run in separate process |
18 if it eventually crashes the VM, it won't take whole test |
18 if it eventually crashes the VM, it won't take whole test |
19 suite with it. |
19 suite with it. |
20 |
20 |
|
21 Each test case *must* be annotated by one <spawn:> annotation, |
|
22 argument must be either `true` of `false`. If `true` then the |
|
23 test is run in a freshly started VM. If `false`, test is run |
|
24 in the same VM. |
|
25 |
|
26 As this is meant as a base class for regression tests that used to |
|
27 kill the VM, normally you should annotate tests with <spawn: true> |
|
28 |
21 [author:] |
29 [author:] |
22 Jan Vrany <jan.vrany@fit.cvut.cz> |
30 Jan Vrany <jan.vrany@fit.cvut.cz> |
23 |
31 |
24 [instance variables:] |
32 [instance variables:] |
25 |
33 |
48 |
56 |
49 isAbstract |
57 isAbstract |
50 ^ self == RegressionTests::VMCrashTestCase |
58 ^ self == RegressionTests::VMCrashTestCase |
51 ! ! |
59 ! ! |
52 |
60 |
|
61 !VMCrashTestCase methodsFor:'accessing'! |
|
62 |
|
63 timeout |
|
64 "Returns a default timeout (sec) for the test. |
|
65 If nil is returned, no timeout enforced. |
|
66 |
|
67 Note that the timeout is set only when running under |
|
68 report runner, interactive tools does not use it" |
|
69 |
|
70 | method | |
|
71 method := self class lookupMethodFor: testSelector. |
|
72 method annotationsAt:#timeout: do:[:annotation| |
|
73 ^annotation arguments first |
|
74 ]. |
|
75 ^60"sec - default timeout" |
|
76 |
|
77 "Created: / 08-09-2014 / 13:00:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
78 ! ! |
|
79 |
53 !VMCrashTestCase methodsFor:'running'! |
80 !VMCrashTestCase methodsFor:'running'! |
54 |
81 |
55 runCase |
82 runCase |
56 "Actually peform the testcase in a separate process" |
83 "Perform the testcase. |
57 |
84 |
58 | testcaseFile exe args script environment outputFile output pid blocker status | |
85 If testcase is annotated by <spawn: false> the test is run in the |
59 |
86 very same VM. If <spawn: true>, a new VM is started and the testcase |
60 "/ A hack to run infrastructure test... |
87 in run in that new VM" |
61 (testSelector == #test_infrastructure) ifTrue:[ |
88 |
|
89 | testcaseFile exe args script environment outputFile output pid blocker status spawn | |
|
90 |
|
91 spawn := (self class lookupMethodFor: testSelector) annotationAt: #spawn:. |
|
92 spawn isNil ifTrue:[ |
|
93 self error: 'No <spawn:> annotation'. |
|
94 ]. |
|
95 (spawn argumentAt: 1) == false ifTrue:[ |
62 ^ super runCase. |
96 ^ super runCase. |
|
97 ] ifFalse:[ |
|
98 (spawn argumentAt: 1) ~~ true ifTrue:[ |
|
99 self error: 'Argument to <spawn:> must be either `true` or `false`'. |
|
100 ] |
63 ]. |
101 ]. |
64 |
102 |
65 [ |
103 [ |
66 testcaseFile := Filename newTemporary. |
104 testcaseFile := Filename newTemporary. |
67 self class fileOutAs: testcaseFile. |
105 self class fileOutAs: testcaseFile. |
199 self assert: result passedCount = 0. |
242 self assert: result passedCount = 0. |
200 self assert: result failureCount = 0. |
243 self assert: result failureCount = 0. |
201 self assert: result errorCount = 1. |
244 self assert: result errorCount = 1. |
202 |
245 |
203 "Created: / 05-09-2014 / 18:22:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
246 "Created: / 05-09-2014 / 18:22:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
247 "Modified: / 08-09-2014 / 12:26:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
204 ! |
248 ! |
205 |
249 |
206 tst_crash |
250 tst_crash |
|
251 |
|
252 <spawn: true> |
|
253 |
207 | bytes | |
254 | bytes | |
208 |
255 |
209 bytes := ExternalBytes address: 16r10 size: 100. |
256 bytes := ExternalBytes address: 16r10 size: 100. |
210 bytes byteAt: 1 put: 10. |
257 bytes byteAt: 1 put: 10. |
211 |
258 |
212 "Created: / 05-09-2014 / 18:24:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
259 "Created: / 05-09-2014 / 18:24:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
260 "Modified: / 08-09-2014 / 12:26:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
213 ! |
261 ! |
214 |
262 |
215 tst_error |
263 tst_error |
|
264 <spawn: true> |
216 self error:'Error' |
265 self error:'Error' |
217 |
266 |
218 "Created: / 05-09-2014 / 18:20:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
267 "Created: / 05-09-2014 / 18:20:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
268 "Modified: / 08-09-2014 / 12:26:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
219 ! |
269 ! |
220 |
270 |
221 tst_fail |
271 tst_fail |
|
272 <spawn: true> |
222 self assert: false. |
273 self assert: false. |
223 |
274 |
224 "Created: / 05-09-2014 / 18:20:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
275 "Created: / 05-09-2014 / 18:20:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
225 ! |
276 "Modified: / 08-09-2014 / 12:26:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
226 |
277 ! |
227 tst_pass |
278 |
|
279 tst_pass |
|
280 <spawn: true> |
228 |
281 |
229 "Created: / 05-09-2014 / 18:20:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
282 "Created: / 05-09-2014 / 18:20:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
283 "Modified: / 08-09-2014 / 12:26:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
230 ! ! |
284 ! ! |
231 |
285 |
232 !VMCrashTestCase class methodsFor:'documentation'! |
286 !VMCrashTestCase class methodsFor:'documentation'! |
233 |
287 |
234 version |
288 version |