diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-01-22 16:10:42 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-01-22 16:10:42 +0000 |
commit | 52d0114fdb2ea80c153988e3b7c36ddcfae80c14 (patch) | |
tree | 0a5af52727820779a1eaa6cba229021c9c064bb0 /test | |
parent | 84e6b0ba72ef0f931d637497a748fe40923159b2 (diff) | |
download | ChibiOS-52d0114fdb2ea80c153988e3b7c36ddcfae80c14.tar.gz ChibiOS-52d0114fdb2ea80c153988e3b7c36ddcfae80c14.tar.bz2 ChibiOS-52d0114fdb2ea80c153988e3b7c36ddcfae80c14.zip |
Coverage improvements.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2676 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test')
-rw-r--r-- | test/testqueues.c | 34 | ||||
-rw-r--r-- | test/testsem.c | 4 |
2 files changed, 31 insertions, 7 deletions
diff --git a/test/testqueues.c b/test/testqueues.c index 9d76d7ac7..dd4d00fba 100644 --- a/test/testqueues.c +++ b/test/testqueues.c @@ -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 = {
diff --git a/test/testsem.c b/test/testsem.c index 46caad56a..25d87f3f1 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -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 = {
|