2193
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
1447
|
3 |
"{ Package: 'stx:goodies/regression' }"
|
105
|
4 |
|
96
|
5 |
"{ NameSpace: RegressionTests }"
|
105
|
6 |
|
|
7 |
TestCase subclass:#DelayTest
|
|
8 |
instanceVariableNames:''
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
2049
|
11 |
category:'tests-Regression-Processes'
|
96
|
12 |
!
|
105
|
13 |
|
106
|
14 |
|
586
|
15 |
!DelayTest class methodsFor:'queries'!
|
|
16 |
|
|
17 |
coveredClasses
|
|
18 |
^ Array with:Delay
|
|
19 |
|
|
20 |
"Created: / 05-07-2011 / 09:51:28 / cg"
|
|
21 |
! !
|
|
22 |
|
105
|
23 |
!DelayTest methodsFor:'tests'!
|
|
24 |
|
96
|
25 |
test1
|
1789
|
26 |
|n verbose delayMultiplier|
|
650
|
27 |
|
|
28 |
verbose := false.
|
55
|
29 |
|
1789
|
30 |
"/ sorry, but the test machines are much too slow, give them more time
|
|
31 |
"/ delayMultiplier := 1.
|
2193
|
32 |
delayMultiplier := 2.
|
1789
|
33 |
|
96
|
34 |
[
|
1789
|
35 |
n := 0.
|
|
36 |
[n < 10] whileTrue:[
|
|
37 |
Delay waitForSeconds:(delayMultiplier * 0.1).
|
|
38 |
verbose ifTrue:[ Transcript showCR:n ].
|
|
39 |
n := n + 1.
|
|
40 |
]
|
105
|
41 |
] forkAt:(Processor activePriority - 1).
|
|
42 |
|
696
|
43 |
self assert:(n == nil). "because the process has lower prio and should not run"
|
105
|
44 |
|
1789
|
45 |
Delay waitForSeconds:(delayMultiplier * 0.05).
|
105
|
46 |
|
696
|
47 |
self assert:(n == 0). "because I should have interrupted the process"
|
105
|
48 |
|
1789
|
49 |
Delay waitForSeconds:(delayMultiplier * 1.5).
|
105
|
50 |
|
696
|
51 |
self assert:(n == 10). "because process should be complete now"
|
105
|
52 |
|
|
53 |
"
|
|
54 |
self basicNew test1
|
|
55 |
"
|
650
|
56 |
|
|
57 |
"Modified: / 10-01-2012 / 19:25:22 / cg"
|
2193
|
58 |
"Modified: / 28-03-2019 / 10:57:26 / Claus Gittinger"
|
105
|
59 |
!
|
|
60 |
|
|
61 |
test2
|
1789
|
62 |
|n verbose delayMultiplier|
|
|
63 |
|
|
64 |
"/ sorry, but the test machines are much too slow, give them more time
|
|
65 |
"/ delayMultiplier := 1.
|
2193
|
66 |
delayMultiplier := 2.
|
650
|
67 |
|
|
68 |
verbose := false.
|
682
|
69 |
n := 0.
|
105
|
70 |
[
|
1789
|
71 |
[n < 10] whileTrue:[
|
|
72 |
Delay waitForSeconds:(delayMultiplier * 0.1).
|
|
73 |
verbose ifTrue:[ Transcript showCR:n ].
|
|
74 |
n := n + 1.
|
|
75 |
]
|
105
|
76 |
] forkAt:(Processor activePriority + 1).
|
|
77 |
|
1790
|
78 |
self assert:(n == 0) description:'thread with delays should not have started yet, because its first action is a delay'.
|
1789
|
79 |
Delay waitForSeconds:(delayMultiplier * 1.1).
|
626
|
80 |
self assert:(n == 10) description:('thread with delays should have finished by now (n=%d)' bindWith:n).
|
105
|
81 |
|
|
82 |
"
|
|
83 |
self basicNew test2
|
|
84 |
"
|
626
|
85 |
|
650
|
86 |
"Modified: / 10-01-2012 / 19:25:35 / cg"
|
2193
|
87 |
"Modified: / 28-03-2019 / 10:57:36 / Claus Gittinger"
|
592
|
88 |
!
|
|
89 |
|
|
90 |
test3_longDelay
|
|
91 |
"in stx6.2.1, the following does not wait, due to an overflow in
|
|
92 |
the millisecond computation..."
|
|
93 |
|
|
94 |
|stillWaiting watchDogBite|
|
|
95 |
|
|
96 |
[
|
2193
|
97 |
watchDogBite := false.
|
|
98 |
stillWaiting := true.
|
|
99 |
Delay waitForSeconds:1000000.
|
|
100 |
stillWaiting := false.
|
|
101 |
] valueWithWatchDog:[ watchDogBite := true] afterMilliseconds:500.
|
592
|
102 |
|
|
103 |
self assert:stillWaiting.
|
|
104 |
self assert:watchDogBite.
|
|
105 |
|
|
106 |
"
|
|
107 |
self basicNew test3_longDelay
|
|
108 |
"
|
|
109 |
|
|
110 |
"Created: / 31-07-2011 / 18:44:53 / cg"
|
2193
|
111 |
"Modified: / 28-03-2019 / 10:57:49 / Claus Gittinger"
|
645
|
112 |
!
|
|
113 |
|
|
114 |
test4
|
2204
|
115 |
"check that we can wake up early and the watchdog does not bite"
|
645
|
116 |
|
|
117 |
|longDelay waitTime watchDogBite|
|
|
118 |
|
|
119 |
longDelay := Delay forSeconds:1000000.
|
|
120 |
[
|
2204
|
121 |
Delay waitForSeconds:0.5.
|
2193
|
122 |
longDelay resume.
|
645
|
123 |
] fork.
|
|
124 |
|
2203
|
125 |
waitTime := Time millisecondsToRun:[
|
2193
|
126 |
"never wait longer than 10 seconds"
|
|
127 |
[
|
|
128 |
longDelay wait.
|
2204
|
129 |
] valueWithWatchDog:[ watchDogBite := true] afterMilliseconds:3000.
|
645
|
130 |
].
|
|
131 |
self assert:watchDogBite ~~ true.
|
2204
|
132 |
self assert:waitTime < 600.
|
645
|
133 |
|
|
134 |
"
|
|
135 |
self basicNew test4
|
|
136 |
"
|
2193
|
137 |
|
2204
|
138 |
"Modified: / 29-03-2019 / 12:03:32 / Claus Gittinger"
|
|
139 |
!
|
|
140 |
|
|
141 |
test5
|
|
142 |
"check that a watchdog does bark"
|
|
143 |
|
|
144 |
|longDelay waitTime watchDogBite|
|
|
145 |
|
|
146 |
longDelay := Delay forSeconds:1000000.
|
|
147 |
|
|
148 |
waitTime := Time millisecondsToRun:[
|
|
149 |
"never wait longer than 10 seconds"
|
|
150 |
[
|
|
151 |
longDelay wait.
|
|
152 |
] valueWithWatchDog:[ watchDogBite := true] afterMilliseconds:500.
|
|
153 |
].
|
|
154 |
self assert:watchDogBite == true.
|
|
155 |
self assert:waitTime < 600.
|
|
156 |
|
|
157 |
"
|
|
158 |
self basicNew test5
|
|
159 |
"
|
|
160 |
|
|
161 |
"Created: / 29-03-2019 / 12:02:46 / Claus Gittinger"
|
96
|
162 |
! !
|
105
|
163 |
|
106
|
164 |
!DelayTest class methodsFor:'documentation'!
|
|
165 |
|
|
166 |
version
|
|
167 |
^ '$Header$'
|
1790
|
168 |
!
|
|
169 |
|
|
170 |
version_CVS
|
|
171 |
^ '$Header$'
|
106
|
172 |
! !
|
1789
|
173 |
|