Skip to content

Commit b0649d1

Browse files
author
Geoffrey Challen
committed
Better lock tests.
1 parent 1a5b9cd commit b0649d1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

kern/test/synchtest.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ locktestthread(void *junk, unsigned long num)
173173

174174
for (i=0; i<NLOCKLOOPS; i++) {
175175
kprintf_t(".");
176+
KASSERT(!(lock_do_i_hold(testlock)));
176177
lock_acquire(testlock);
178+
KASSERT(lock_do_i_hold(testlock));
177179
random_yielder(4);
178180

179181
testval1 = num;
@@ -184,38 +186,46 @@ locktestthread(void *junk, unsigned long num)
184186
goto fail;
185187
}
186188
random_yielder(4);
189+
KASSERT(lock_do_i_hold(testlock));
187190

188191
if (testval2%3 != (testval3*testval3)%3) {
189192
goto fail;
190193
}
191194
random_yielder(4);
195+
KASSERT(lock_do_i_hold(testlock));
192196

193197
if (testval3 != testval1%3) {
194198
goto fail;
195199
}
196200
random_yielder(4);
201+
KASSERT(lock_do_i_hold(testlock));
197202

198203
if (testval1 != num) {
199204
goto fail;
200205
}
201206
random_yielder(4);
207+
KASSERT(lock_do_i_hold(testlock));
202208

203209
if (testval2 != num*num) {
204210
goto fail;
205211
}
206212
random_yielder(4);
213+
KASSERT(lock_do_i_hold(testlock));
207214

208215
if (testval3 != num%3) {
209216
goto fail;
210217
}
211218
random_yielder(4);
219+
KASSERT(lock_do_i_hold(testlock));
212220

213221
if (!(lock_do_i_hold(testlock))) {
214222
goto fail;
215223
}
216224
random_yielder(4);
225+
KASSERT(lock_do_i_hold(testlock));
217226

218227
lock_release(testlock);
228+
KASSERT(!(lock_do_i_hold(testlock)));
219229
}
220230

221231
/* Check for solutions that don't track ownership properly */
@@ -437,7 +447,7 @@ locktest5(int nargs, char **args) {
437447

438448
P(donesem);
439449
secprintf(SECRET, "Should panic...", "lt5");
440-
KASSERT(!(lock_do_i_hold(testlock)));
450+
KASSERT(lock_do_i_hold(testlock));
441451

442452
/* Should not get here on success. */
443453

0 commit comments

Comments
 (0)