added new lock test to check do i hold functionality. tested on incorrect implementation, fails. tested on correct implementation, passed.
This commit is contained in:
parent
398e4eb90a
commit
b51f2a88de
@ -61,6 +61,7 @@ int semtest(int, char **);
|
||||
int locktest(int, char **);
|
||||
int locktest2(int, char **);
|
||||
int locktest3(int, char **);
|
||||
int locktest4(int, char **);
|
||||
int cvtest(int, char **);
|
||||
int cvtest2(int, char **);
|
||||
int cvtest3(int, char **);
|
||||
|
@ -593,6 +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) ",
|
||||
"[cvt1] CV test 1 (1) ",
|
||||
"[cvt2] CV test 2 (1) ",
|
||||
"[cvt3] CV test 3 (1*) ",
|
||||
@ -743,6 +744,7 @@ static struct {
|
||||
{ "lt1", locktest },
|
||||
{ "lt2", locktest2 },
|
||||
{ "lt3", locktest3 },
|
||||
{ "lt4", locktest4 },
|
||||
{ "cvt1", cvtest },
|
||||
{ "cvt2", cvtest2 },
|
||||
{ "cvt3", cvtest3 },
|
||||
|
@ -238,6 +238,29 @@ fail2:
|
||||
return;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
locktestthread2(void *junk, unsigned long num)
|
||||
{
|
||||
(void)junk;
|
||||
|
||||
if(num == 0){
|
||||
lock_acquire(testlock);
|
||||
}
|
||||
else{
|
||||
if(lock_do_i_hold(testlock)){
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
V(donesem);
|
||||
return;
|
||||
|
||||
fail:
|
||||
failif(true);
|
||||
V(donesem);
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
locktest(int nargs, char **args)
|
||||
@ -314,7 +337,7 @@ locktest2(int nargs, char **args) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
locktest3(int nargs, char **args) {
|
||||
(void)nargs;
|
||||
@ -341,6 +364,51 @@ locktest3(int nargs, char **args) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
locktest4(int nargs, char **args) {
|
||||
(void) nargs;
|
||||
(void) args;
|
||||
|
||||
kprintf_n("Starting lt4...\n");
|
||||
|
||||
test_status = TEST161_SUCCESS;
|
||||
|
||||
testlock = lock_create("testlock");
|
||||
if(testlock == NULL) {
|
||||
panic("lt4: lock_create failed\n");
|
||||
}
|
||||
|
||||
donesem = sem_create("donesem", 0);
|
||||
if (donesem == NULL) {
|
||||
lock_destroy(testlock);
|
||||
panic("lt1: sem_create failed\n");
|
||||
}
|
||||
|
||||
int i, result;
|
||||
for (i=0; i<2; i++) {
|
||||
kprintf_t(".");
|
||||
result = thread_fork("lt4", NULL, locktestthread2, NULL, i);
|
||||
if (result) {
|
||||
panic("lt1: thread_fork failed: %s\n", strerror(result));
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0; i<2; i++) {
|
||||
kprintf_t(".");
|
||||
P(donesem);
|
||||
}
|
||||
|
||||
lock_destroy(testlock);
|
||||
sem_destroy(donesem);
|
||||
testlock = NULL;
|
||||
donesem = NULL;
|
||||
|
||||
kprintf_t("\n");
|
||||
success(test_status, SECRET, "lt1");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
cvtestthread(void *junk, unsigned long num)
|
||||
|
Loading…
x
Reference in New Issue
Block a user