author | Jan Vrany <jan.vrany@labware.com> |
Thu, 25 Aug 2022 11:29:18 +0100 | |
branch | jv |
changeset 2607 | ddf2eb8b3f1d |
parent 1974 | f2eaf05205d6 |
permissions | -rwxr-xr-x |
1974 | 1 |
" |
2 |
COPYRIGHT (c) Claus Gittinger / eXept Software AG |
|
3 |
COPYRIGHT (c) 2017 Jan Vrany |
|
4 |
All Rights Reserved |
|
5 |
||
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
1447 | 13 |
"{ Package: 'stx:goodies/regression' }" |
105 | 14 |
|
96 | 15 |
"{ NameSpace: RegressionTests }" |
105 | 16 |
|
17 |
TestCase subclass:#DelayTest |
|
18 |
instanceVariableNames:'' |
|
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
181 | 21 |
category:'tests-Regression' |
96 | 22 |
! |
105 | 23 |
|
1974 | 24 |
!DelayTest class methodsFor:'documentation'! |
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) Claus Gittinger / eXept Software AG |
|
29 |
COPYRIGHT (c) 2017 Jan Vrany |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! ! |
|
106 | 40 |
|
586 | 41 |
!DelayTest class methodsFor:'others'! |
42 |
||
43 |
version_CVS |
|
44 |
^ '$Header$' |
|
45 |
! ! |
|
46 |
||
47 |
!DelayTest class methodsFor:'queries'! |
|
48 |
||
49 |
coveredClasses |
|
50 |
^ Array with:Delay |
|
51 |
||
52 |
"Created: / 05-07-2011 / 09:51:28 / cg" |
|
53 |
! ! |
|
54 |
||
105 | 55 |
!DelayTest methodsFor:'tests'! |
56 |
||
96 | 57 |
test1 |
650 | 58 |
|n verbose| |
59 |
||
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
60 |
self skipIf: (OperatingSystem getEnvironment:'JOB_NAME') notNil description: 'This test depends on real time timing and thus unreliable under CI setups'. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
61 |
|
650 | 62 |
verbose := false. |
55 | 63 |
|
96 | 64 |
[ |
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
65 |
n := 0. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
66 |
[n < 10] whileTrue:[ |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
67 |
Delay waitForSeconds:0.1. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
68 |
verbose ifTrue:[ Transcript showCR:n ]. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
69 |
n := n + 1. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
70 |
] |
105 | 71 |
] forkAt:(Processor activePriority - 1). |
72 |
||
696 | 73 |
self assert:(n == nil). "because the process has lower prio and should not run" |
105 | 74 |
|
696 | 75 |
Delay waitForSeconds:0.05. |
105 | 76 |
|
696 | 77 |
self assert:(n == 0). "because I should have interrupted the process" |
105 | 78 |
|
106 | 79 |
Delay waitForSeconds:1.5. |
105 | 80 |
|
696 | 81 |
self assert:(n == 10). "because process should be complete now" |
105 | 82 |
|
83 |
" |
|
84 |
self basicNew test1 |
|
85 |
" |
|
650 | 86 |
|
87 |
"Modified: / 10-01-2012 / 19:25:22 / cg" |
|
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
88 |
"Modified: / 26-07-2017 / 11:49:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
105 | 89 |
! |
90 |
||
91 |
test2 |
|
650 | 92 |
|n verbose| |
93 |
||
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
94 |
self skipIf: (OperatingSystem getEnvironment:'JOB_NAME') notNil description: 'This test depends on real time timing and thus unreliable under CI setups'. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
95 |
|
650 | 96 |
verbose := false. |
682 | 97 |
n := 0. |
105 | 98 |
[ |
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
99 |
[n < 10] whileTrue:[ |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
100 |
Delay waitForSeconds:0.1. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
101 |
verbose ifTrue:[ Transcript showCR:n ]. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
102 |
n := n + 1. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
103 |
] |
105 | 104 |
] forkAt:(Processor activePriority + 1). |
105 |
||
626 | 106 |
self assert:(n == 0) description:'thread with delays should not have started yet'. |
106 | 107 |
Delay waitForSeconds:1.1. |
626 | 108 |
self assert:(n == 10) description:('thread with delays should have finished by now (n=%d)' bindWith:n). |
105 | 109 |
|
110 |
" |
|
111 |
self basicNew test2 |
|
112 |
" |
|
626 | 113 |
|
650 | 114 |
"Modified: / 10-01-2012 / 19:25:35 / cg" |
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
115 |
"Modified: / 26-07-2017 / 11:48:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
592 | 116 |
! |
117 |
||
118 |
test3_longDelay |
|
119 |
"in stx6.2.1, the following does not wait, due to an overflow in |
|
120 |
the millisecond computation..." |
|
121 |
||
122 |
|stillWaiting watchDogBite| |
|
123 |
||
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
124 |
self skipIf: (OperatingSystem getEnvironment:'JOB_NAME') notNil description: 'This test depends on real time timing and thus unreliable under CI setups'. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
125 |
|
592 | 126 |
[ |
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
127 |
watchDogBite := false. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
128 |
stillWaiting := true. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
129 |
Delay waitForSeconds:1000000. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
130 |
stillWaiting := false. |
592 | 131 |
] valueWithWatchDog:[ watchDogBite := true] afterMilliseconds:1000. |
132 |
||
133 |
self assert:stillWaiting. |
|
134 |
self assert:watchDogBite. |
|
135 |
||
136 |
" |
|
137 |
self basicNew test3_longDelay |
|
138 |
" |
|
139 |
||
140 |
"Created: / 31-07-2011 / 18:44:53 / cg" |
|
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
141 |
"Modified: / 26-07-2017 / 11:49:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
645 | 142 |
! |
143 |
||
144 |
test4 |
|
145 |
"check that we can wake up early" |
|
146 |
||
147 |
|longDelay waitTime watchDogBite| |
|
148 |
||
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
149 |
self skipIf: (OperatingSystem getEnvironment:'JOB_NAME') notNil description: 'This test depends on real time timing and thus unreliable under CI setups'. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
150 |
|
645 | 151 |
longDelay := Delay forSeconds:1000000. |
152 |
[ |
|
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
153 |
Delay waitForSeconds:2. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
154 |
longDelay resume. |
645 | 155 |
] fork. |
156 |
||
157 |
waitTime := Time secondsToRun:[ |
|
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
158 |
"never wait longer than 10 seconds" |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
159 |
[ |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
160 |
longDelay wait. |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
161 |
] valueWithWatchDog:[ watchDogBite := true] afterMilliseconds:10000. |
645 | 162 |
]. |
163 |
self assert:watchDogBite ~~ true. |
|
164 |
self assert:waitTime < 10. |
|
165 |
||
166 |
" |
|
167 |
self basicNew test4 |
|
168 |
" |
|
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
169 |
|
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
170 |
"Modified: / 26-07-2017 / 11:49:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
96 | 171 |
! ! |
105 | 172 |
|
106 | 173 |
!DelayTest class methodsFor:'documentation'! |
174 |
||
175 |
version |
|
176 |
^ '$Header$' |
|
1642
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
177 |
! |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
178 |
|
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
179 |
version_HG |
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
180 |
|
281f5999cc6c
Skip tests `DelayTests` when running under CI server
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1567
diff
changeset
|
181 |
^ '$Changeset: <not expanded> $' |
106 | 182 |
! ! |
1567
e17701a073f9
Added abstract VMSpawningTestCase
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
183 |