Better lock tests.
This commit is contained in:
parent
1a5b9cd54b
commit
b0649d1fd0
@ -173,7 +173,9 @@ locktestthread(void *junk, unsigned long num)
|
|||||||
|
|
||||||
for (i=0; i<NLOCKLOOPS; i++) {
|
for (i=0; i<NLOCKLOOPS; i++) {
|
||||||
kprintf_t(".");
|
kprintf_t(".");
|
||||||
|
KASSERT(!(lock_do_i_hold(testlock)));
|
||||||
lock_acquire(testlock);
|
lock_acquire(testlock);
|
||||||
|
KASSERT(lock_do_i_hold(testlock));
|
||||||
random_yielder(4);
|
random_yielder(4);
|
||||||
|
|
||||||
testval1 = num;
|
testval1 = num;
|
||||||
@ -184,38 +186,46 @@ locktestthread(void *junk, unsigned long num)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
random_yielder(4);
|
random_yielder(4);
|
||||||
|
KASSERT(lock_do_i_hold(testlock));
|
||||||
|
|
||||||
if (testval2%3 != (testval3*testval3)%3) {
|
if (testval2%3 != (testval3*testval3)%3) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
random_yielder(4);
|
random_yielder(4);
|
||||||
|
KASSERT(lock_do_i_hold(testlock));
|
||||||
|
|
||||||
if (testval3 != testval1%3) {
|
if (testval3 != testval1%3) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
random_yielder(4);
|
random_yielder(4);
|
||||||
|
KASSERT(lock_do_i_hold(testlock));
|
||||||
|
|
||||||
if (testval1 != num) {
|
if (testval1 != num) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
random_yielder(4);
|
random_yielder(4);
|
||||||
|
KASSERT(lock_do_i_hold(testlock));
|
||||||
|
|
||||||
if (testval2 != num*num) {
|
if (testval2 != num*num) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
random_yielder(4);
|
random_yielder(4);
|
||||||
|
KASSERT(lock_do_i_hold(testlock));
|
||||||
|
|
||||||
if (testval3 != num%3) {
|
if (testval3 != num%3) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
random_yielder(4);
|
random_yielder(4);
|
||||||
|
KASSERT(lock_do_i_hold(testlock));
|
||||||
|
|
||||||
if (!(lock_do_i_hold(testlock))) {
|
if (!(lock_do_i_hold(testlock))) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
random_yielder(4);
|
random_yielder(4);
|
||||||
|
KASSERT(lock_do_i_hold(testlock));
|
||||||
|
|
||||||
lock_release(testlock);
|
lock_release(testlock);
|
||||||
|
KASSERT(!(lock_do_i_hold(testlock)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for solutions that don't track ownership properly */
|
/* Check for solutions that don't track ownership properly */
|
||||||
@ -437,7 +447,7 @@ locktest5(int nargs, char **args) {
|
|||||||
|
|
||||||
P(donesem);
|
P(donesem);
|
||||||
secprintf(SECRET, "Should panic...", "lt5");
|
secprintf(SECRET, "Should panic...", "lt5");
|
||||||
KASSERT(!(lock_do_i_hold(testlock)));
|
KASSERT(lock_do_i_hold(testlock));
|
||||||
|
|
||||||
/* Should not get here on success. */
|
/* Should not get here on success. */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user