Added more functionality to lock test 4 to also make sure release functions properly
This commit is contained in:
parent
694062537d
commit
434a8856c6
@ -593,7 +593,7 @@ static const char *testmenu[] = {
|
|||||||
"[lt1] Lock test 1 (1) ",
|
"[lt1] Lock test 1 (1) ",
|
||||||
"[lt2] Lock test 2 (1*) ",
|
"[lt2] Lock test 2 (1*) ",
|
||||||
"[lt3] Lock test 3 (1*) ",
|
"[lt3] Lock test 3 (1*) ",
|
||||||
"[lt4] Lock test 4 (1) ",
|
"[lt4] Lock test 4 (1*) ",
|
||||||
"[cvt1] CV test 1 (1) ",
|
"[cvt1] CV test 1 (1) ",
|
||||||
"[cvt2] CV test 2 (1) ",
|
"[cvt2] CV test 2 (1) ",
|
||||||
"[cvt3] CV test 3 (1*) ",
|
"[cvt3] CV test 3 (1*) ",
|
||||||
|
@ -243,14 +243,17 @@ void
|
|||||||
locktestthread2(void *junk, unsigned long num)
|
locktestthread2(void *junk, unsigned long num)
|
||||||
{
|
{
|
||||||
(void)junk;
|
(void)junk;
|
||||||
|
//first thread acquire lock
|
||||||
if(num == 0){
|
if(num == 0){
|
||||||
lock_acquire(testlock);
|
lock_acquire(testlock);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
//test lock do i hold
|
||||||
if(lock_do_i_hold(testlock)){
|
if(lock_do_i_hold(testlock)){
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
//make sure release panics based on thread matching
|
||||||
|
lock_release(testlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
V(donesem);
|
V(donesem);
|
||||||
@ -370,8 +373,7 @@ locktest4(int nargs, char **args) {
|
|||||||
(void) args;
|
(void) args;
|
||||||
|
|
||||||
kprintf_n("Starting lt4...\n");
|
kprintf_n("Starting lt4...\n");
|
||||||
|
kprintf_n("(This test panics on success!)\n");
|
||||||
test_status = TEST161_SUCCESS;
|
|
||||||
|
|
||||||
testlock = lock_create("testlock");
|
testlock = lock_create("testlock");
|
||||||
if(testlock == NULL) {
|
if(testlock == NULL) {
|
||||||
@ -384,6 +386,7 @@ locktest4(int nargs, char **args) {
|
|||||||
panic("lt4: sem_create failed\n");
|
panic("lt4: sem_create failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Only 2 threads for simplification
|
||||||
int i, result;
|
int i, result;
|
||||||
for (i=0; i<2; i++) {
|
for (i=0; i<2; i++) {
|
||||||
kprintf_t(".");
|
kprintf_t(".");
|
||||||
@ -398,13 +401,17 @@ locktest4(int nargs, char **args) {
|
|||||||
P(donesem);
|
P(donesem);
|
||||||
}
|
}
|
||||||
|
|
||||||
lock_destroy(testlock);
|
|
||||||
|
//no lock destroy in case a panic is triggered
|
||||||
sem_destroy(donesem);
|
sem_destroy(donesem);
|
||||||
testlock = NULL;
|
testlock = NULL;
|
||||||
donesem = NULL;
|
donesem = NULL;
|
||||||
|
|
||||||
|
secprintf(SECRET, "Should panic...", "lt4");
|
||||||
|
|
||||||
|
/* Should not get here on success. */
|
||||||
kprintf_t("\n");
|
kprintf_t("\n");
|
||||||
success(test_status, SECRET, "lt4");
|
success(TEST161_FAIL, SECRET, "lt4");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user