Coverage improvements.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2676 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2011-01-22 16:10:42 +00:00
parent 84e6b0ba72
commit 52d0114fdb
3 changed files with 33 additions and 9 deletions

View File

@ -33,7 +33,7 @@ Lines executed:100.00% of 18
../../os/kernel/src/chregistry.c:creating `chregistry.c.gcov'
File `../../os/kernel/src/chsem.c'
Lines executed:91.01% of 89
Lines executed:100.00% of 89
../../os/kernel/src/chsem.c:creating `chsem.c.gcov'
File `../../os/kernel/src/chmtx.c'
@ -57,7 +57,7 @@ Lines executed:100.00% of 65
../../os/kernel/src/chmboxes.c:creating `chmboxes.c.gcov'
File `../../os/kernel/src/chqueues.c'
Lines executed:90.16% of 122
Lines executed:100.00% of 122
../../os/kernel/src/chqueues.c:creating `chqueues.c.gcov'
File `../../os/kernel/src/chmemcore.c'

View File

@ -83,6 +83,13 @@ static void queues1_setup(void) {
chIQInit(&iq, wa[0], TEST_QUEUES_SIZE, notify);
}
static msg_t thread1(void *p) {
(void)p;
chIQGetTimeout(&iq, MS2ST(200));
return 0;
}
static void queues1_execute(void) {
unsigned i;
size_t n;
@ -125,10 +132,13 @@ static void queues1_execute(void) {
/* Testing reset */
chIQPutI(&iq, 0);
chIQResetI(&iq);
test_assert(11, chIQIsEmptyI(&iq), "still full");
test_assert(11, chIQGetFullI(&iq) == 0, "still full");
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL);
test_assert(12, chIQGetFullI(&iq) == 0, "not empty");
test_wait_threads();
/* Timeout */
test_assert(12, chIQGetTimeout(&iq, 10) == Q_TIMEOUT, "wrong timeout return");
test_assert(13, chIQGetTimeout(&iq, 10) == Q_TIMEOUT, "wrong timeout return");
}
ROMCONST struct testcase testqueues1 = {
@ -152,6 +162,13 @@ static void queues2_setup(void) {
chOQInit(&oq, wa[0], TEST_QUEUES_SIZE, notify);
}
static msg_t thread2(void *p) {
(void)p;
chOQPutTimeout(&oq, 0, MS2ST(200));
return 0;
}
static void queues2_execute(void) {
unsigned i;
size_t n;
@ -175,20 +192,23 @@ static void queues2_execute(void) {
n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE);
test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size");
test_assert(7, chOQIsFullI(&oq), "not full");
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread2, NULL);
test_assert(8, chOQGetFullI(&oq) == TEST_QUEUES_SIZE, "not empty");
test_wait_threads();
/* Testing reset */
chOQResetI(&oq);
test_assert(8, chOQIsEmptyI(&oq), "still full");
test_assert(9, chOQGetFullI(&oq) == 0, "still full");
/* Partial writes */
n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE);
test_assert(9, n == TEST_QUEUES_SIZE / 2, "wrong returned size");
n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE);
test_assert(10, n == TEST_QUEUES_SIZE / 2, "wrong returned size");
test_assert(11, chOQIsFullI(&oq), "not full");
n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE);
test_assert(11, n == TEST_QUEUES_SIZE / 2, "wrong returned size");
test_assert(12, chOQIsFullI(&oq), "not full");
/* Timeout */
test_assert(12, chOQPutTimeout(&oq, 0, 10) == Q_TIMEOUT, "wrong timeout return");
test_assert(13, chOQPutTimeout(&oq, 0, 10) == Q_TIMEOUT, "wrong timeout return");
}
ROMCONST struct testcase testqueues2 = {

View File

@ -102,6 +102,10 @@ static void sem1_execute(void) {
#else
test_assert_sequence(1, "ABCDE");
#endif
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread1, "A");
chSemSetCounterI(&sem1, 2);
test_wait_threads();
test_assert(2, chSemGetCounterI(&sem1) == 2, "invalid counter");
}
ROMCONST struct testcase testsem1 = {