New CV test.
This commit is contained in:
parent
08fd92507d
commit
00eb1b44fb
@ -65,6 +65,7 @@ int cvtest(int, char **);
|
||||
int cvtest2(int, char **);
|
||||
int cvtest3(int, char **);
|
||||
int cvtest4(int, char **);
|
||||
int cvtest5(int, char **);
|
||||
int rwtest(int, char **);
|
||||
int rwtest2(int, char **);
|
||||
int rwtest3(int, char **);
|
||||
|
@ -495,6 +495,7 @@ static const char *testmenu[] = {
|
||||
"[cvt2] CV test 2 (1) ",
|
||||
"[cvt3] CV test 3 (1*) ",
|
||||
"[cvt4] CV test 4 (1*) ",
|
||||
"[cvt5] CV test 5 (1) ",
|
||||
"[rwt1] RW lock test (1?) ",
|
||||
"[rwt2] RW lock test 2 (1?) ",
|
||||
"[rwt3] RW lock test 3 (1?) ",
|
||||
@ -641,6 +642,7 @@ static struct {
|
||||
{ "cvt2", cvtest2 },
|
||||
{ "cvt3", cvtest3 },
|
||||
{ "cvt4", cvtest4 },
|
||||
{ "cvt5", cvtest5 },
|
||||
{ "rwt1", rwtest },
|
||||
{ "rwt2", rwtest2 },
|
||||
{ "rwt3", rwtest3 },
|
||||
|
@ -56,7 +56,9 @@ static volatile unsigned long testval3;
|
||||
static volatile int32_t testval4;
|
||||
|
||||
static struct semaphore *testsem = NULL;
|
||||
static struct semaphore *testsem2 = NULL;
|
||||
static struct lock *testlock = NULL;
|
||||
static struct lock *testlock2 = NULL;
|
||||
static struct cv *testcv = NULL;
|
||||
static struct semaphore *donesem = NULL;
|
||||
|
||||
@ -292,19 +294,13 @@ locktest2(int nargs, char **args) {
|
||||
(void)nargs;
|
||||
(void)args;
|
||||
|
||||
int i;
|
||||
|
||||
kprintf_n("Starting lt2...\n");
|
||||
kprintf_n("(This test panics on success!)\n");
|
||||
for (i=0; i<CREATELOOPS; i++) {
|
||||
|
||||
testlock = lock_create("testlock");
|
||||
if (testlock == NULL) {
|
||||
panic("lt2: lock_create failed\n");
|
||||
}
|
||||
if (i != CREATELOOPS - 1) {
|
||||
lock_destroy(testlock);
|
||||
}
|
||||
}
|
||||
|
||||
ksecprintf(SECRET, "Should panic...", "lt2");
|
||||
lock_release(testlock);
|
||||
@ -324,19 +320,13 @@ locktest3(int nargs, char **args) {
|
||||
(void)nargs;
|
||||
(void)args;
|
||||
|
||||
int i;
|
||||
|
||||
kprintf_n("Starting lt3...\n");
|
||||
kprintf_n("(This test panics on success!)\n");
|
||||
for (i=0; i<CREATELOOPS; i++) {
|
||||
|
||||
testlock = lock_create("testlock");
|
||||
if (testlock == NULL) {
|
||||
panic("lt3: lock_create failed\n");
|
||||
}
|
||||
if (i != CREATELOOPS - 1) {
|
||||
lock_destroy(testlock);
|
||||
}
|
||||
}
|
||||
|
||||
ksecprintf(SECRET, "Should panic...", "lt3");
|
||||
lock_acquire(testlock);
|
||||
@ -419,7 +409,7 @@ cvtest(int nargs, char **args)
|
||||
kprintf_t(".");
|
||||
testlock = lock_create("testlock");
|
||||
if (testlock == NULL) {
|
||||
panic("lockt1: lock_create failed\n");
|
||||
panic("cvt1: lock_create failed\n");
|
||||
}
|
||||
testcv = cv_create("testcv");
|
||||
if (testcv == NULL) {
|
||||
@ -607,23 +597,16 @@ cvtest3(int nargs, char **args) {
|
||||
(void)nargs;
|
||||
(void)args;
|
||||
|
||||
int i;
|
||||
|
||||
kprintf_n("Starting cvt3...\n");
|
||||
kprintf_n("(This test panics on success!)\n");
|
||||
for (i=0; i<CREATELOOPS; i++) {
|
||||
|
||||
testlock = lock_create("testlock");
|
||||
if (testlock == NULL) {
|
||||
panic("lockt1: lock_create failed\n");
|
||||
panic("cvt3: lock_create failed\n");
|
||||
}
|
||||
testcv = cv_create("testcv");
|
||||
if (testcv == NULL) {
|
||||
panic("cvt1: cv_create failed\n");
|
||||
}
|
||||
if (i != CREATELOOPS - 1) {
|
||||
lock_destroy(testlock);
|
||||
cv_destroy(testcv);
|
||||
}
|
||||
panic("cvt3: cv_create failed\n");
|
||||
}
|
||||
|
||||
ksecprintf(SECRET, "Should panic...", "cvt3");
|
||||
@ -646,23 +629,16 @@ cvtest4(int nargs, char **args) {
|
||||
(void)nargs;
|
||||
(void)args;
|
||||
|
||||
int i;
|
||||
|
||||
kprintf_n("Starting cvt4...\n");
|
||||
kprintf_n("(This test panics on success!)\n");
|
||||
for (i=0; i<CREATELOOPS; i++) {
|
||||
|
||||
testlock = lock_create("testlock");
|
||||
if (testlock == NULL) {
|
||||
panic("lockt1: lock_create failed\n");
|
||||
panic("cvt4: lock_create failed\n");
|
||||
}
|
||||
testcv = cv_create("testcv");
|
||||
if (testcv == NULL) {
|
||||
panic("cvt1: cv_create failed\n");
|
||||
}
|
||||
if (i != CREATELOOPS - 1) {
|
||||
lock_destroy(testlock);
|
||||
cv_destroy(testcv);
|
||||
}
|
||||
panic("cvt4: cv_create failed\n");
|
||||
}
|
||||
|
||||
ksecprintf(SECRET, "Should panic...", "cvt4");
|
||||
@ -679,3 +655,118 @@ cvtest4(int nargs, char **args) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
sleeperthread(void *junk1, unsigned long junk2) {
|
||||
(void)junk1;
|
||||
(void)junk2;
|
||||
|
||||
random_yielder(4);
|
||||
lock_acquire(testlock);
|
||||
random_yielder(4);
|
||||
failif((testval1 != 0));
|
||||
testval1 = 1;
|
||||
cv_signal(testcv, testlock);
|
||||
|
||||
random_yielder(4);
|
||||
cv_wait(testcv, testlock);
|
||||
failif((testval1 != 3));
|
||||
testval1 = 4;
|
||||
random_yielder(4);
|
||||
lock_release(testlock);
|
||||
random_yielder(4);
|
||||
|
||||
V(exitsem);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
wakerthread(void *junk1, unsigned long junk2) {
|
||||
(void)junk1;
|
||||
(void)junk2;
|
||||
|
||||
random_yielder(4);
|
||||
lock_acquire(testlock2);
|
||||
failif((testval1 != 2));
|
||||
testval1 = 3;
|
||||
|
||||
random_yielder(4);
|
||||
cv_signal(testcv, testlock2);
|
||||
random_yielder(4);
|
||||
lock_release(testlock2);
|
||||
random_yielder(4);
|
||||
|
||||
V(exitsem);
|
||||
}
|
||||
|
||||
int
|
||||
cvtest5(int nargs, char **args) {
|
||||
(void)nargs;
|
||||
(void)args;
|
||||
|
||||
int result;
|
||||
|
||||
kprintf_n("Starting cvt5...\n");
|
||||
|
||||
testlock = lock_create("testlock");
|
||||
if (testlock == NULL) {
|
||||
panic("cvt5: lock_create failed\n");
|
||||
}
|
||||
testlock2 = lock_create("testlock2");
|
||||
if (testlock == NULL) {
|
||||
panic("cvt5: lock_create failed\n");
|
||||
}
|
||||
testcv = cv_create("testcv");
|
||||
if (testcv == NULL) {
|
||||
panic("cvt5: cv_create failed\n");
|
||||
}
|
||||
exitsem = sem_create("exitsem", 0);
|
||||
if (exitsem == NULL) {
|
||||
panic("cvt5: sem_create failed\n");
|
||||
}
|
||||
spinlock_init(&status_lock);
|
||||
test_status = SUCCESS;
|
||||
testval1 = 0;
|
||||
|
||||
lock_acquire(testlock);
|
||||
lock_acquire(testlock2);
|
||||
|
||||
result = thread_fork("cvt5", NULL, sleeperthread, NULL, 0);
|
||||
if (result) {
|
||||
panic("cvt5: thread_fork failed\n");
|
||||
}
|
||||
result = thread_fork("cvt5", NULL, wakerthread, NULL, 0);
|
||||
if (result) {
|
||||
panic("cvt5: thread_fork failed\n");
|
||||
}
|
||||
|
||||
random_yielder(4);
|
||||
cv_wait(testcv, testlock);
|
||||
failif((testval1 != 1));
|
||||
testval1 = 2;
|
||||
random_yielder(4);
|
||||
lock_release(testlock);
|
||||
random_yielder(4);
|
||||
lock_release(testlock2);
|
||||
|
||||
P(exitsem);
|
||||
P(exitsem);
|
||||
failif((testval1 != 4));
|
||||
|
||||
sem_destroy(exitsem);
|
||||
cv_destroy(testcv);
|
||||
lock_destroy(testlock2);
|
||||
lock_destroy(testlock);
|
||||
|
||||
success(test_status, SECRET, "cvt5");
|
||||
|
||||
exitsem = NULL;
|
||||
testcv = NULL;
|
||||
testlock2 = NULL;
|
||||
testlock = NULL;
|
||||
testsem2 = NULL;
|
||||
testsem = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -164,8 +164,8 @@ clean:
|
||||
rm -f *.o *.a tags $(KERNEL)
|
||||
rm -rf includelinks
|
||||
@ABSTOP=$$(readlink -f $(TOP))
|
||||
unlink $(OSTREE)/.src
|
||||
unlink $(TOP)/.root
|
||||
rm -f $(OSTREE)/.src
|
||||
rm -f $(TOP)/.root
|
||||
|
||||
distclean cleandir: clean
|
||||
rm -f .depend
|
||||
|
Loading…
x
Reference in New Issue
Block a user