Added more functionality to lock test 4 to also make sure release functions properly

This commit is contained in:
zsmoore 2017-02-16 18:15:14 -05:00
parent 694062537d
commit 434a8856c6
2 changed files with 13 additions and 6 deletions

View File

@ -593,7 +593,7 @@ static const char *testmenu[] = {
"[lt1] Lock test 1 (1) ",
"[lt2] Lock test 2 (1*) ",
"[lt3] Lock test 3 (1*) ",
"[lt4] Lock test 4 (1) ",
"[lt4] Lock test 4 (1*) ",
"[cvt1] CV test 1 (1) ",
"[cvt2] CV test 2 (1) ",
"[cvt3] CV test 3 (1*) ",

View File

@ -243,14 +243,17 @@ void
locktestthread2(void *junk, unsigned long num)
{
(void)junk;
//first thread acquire lock
if(num == 0){
lock_acquire(testlock);
}
else{
//test lock do i hold
if(lock_do_i_hold(testlock)){
goto fail;
}
//make sure release panics based on thread matching
lock_release(testlock);
}
V(donesem);
@ -370,8 +373,7 @@ locktest4(int nargs, char **args) {
(void) args;
kprintf_n("Starting lt4...\n");
test_status = TEST161_SUCCESS;
kprintf_n("(This test panics on success!)\n");
testlock = lock_create("testlock");
if(testlock == NULL) {
@ -384,6 +386,7 @@ locktest4(int nargs, char **args) {
panic("lt4: sem_create failed\n");
}
//Only 2 threads for simplification
int i, result;
for (i=0; i<2; i++) {
kprintf_t(".");
@ -398,13 +401,17 @@ locktest4(int nargs, char **args) {
P(donesem);
}
lock_destroy(testlock);
//no lock destroy in case a panic is triggered
sem_destroy(donesem);
testlock = NULL;
donesem = NULL;
secprintf(SECRET, "Should panic...", "lt4");
/* Should not get here on success. */
kprintf_t("\n");
success(test_status, SECRET, "lt4");
success(TEST161_FAIL, SECRET, "lt4");
return 0;
}