diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-08-23 08:11:23 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-08-23 08:11:23 +0000 |
commit | 4ec82f62c18894d92bafc6c6f98784650106373d (patch) | |
tree | a0cec5585dff0434608241c373b9ad30af5ae869 /test | |
parent | c877f5bfcc5301b441c9b13e8c32d83e9df04f37 (diff) | |
parent | 2a494cb534dbe3535a9bf4c61dfbc8b6c9e750be (diff) | |
download | ChibiOS-4ec82f62c18894d92bafc6c6f98784650106373d.tar.gz ChibiOS-4ec82f62c18894d92bafc6c6f98784650106373d.tar.bz2 ChibiOS-4ec82f62c18894d92bafc6c6f98784650106373d.zip |
I2C. 1 - Merge code from trunk. 2 - Fix driver problems detected by the CH_DBG_SYSTEM_STATE_CHECK
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3249 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test')
-rw-r--r-- | test/coverage/chconf.h | 72 | ||||
-rw-r--r-- | test/test.h | 16 | ||||
-rw-r--r-- | test/testbmk.c | 2 | ||||
-rw-r--r-- | test/testmbox.c | 34 | ||||
-rw-r--r-- | test/testqueues.c | 52 | ||||
-rw-r--r-- | test/testsem.c | 2 |
6 files changed, 130 insertions, 48 deletions
diff --git a/test/coverage/chconf.h b/test/coverage/chconf.h index d063fa93f..0859452de 100644 --- a/test/coverage/chconf.h +++ b/test/coverage/chconf.h @@ -33,7 +33,10 @@ #define _CHCONF_H_
/*===========================================================================*/
-/* Kernel parameters. */
+/**
+ * @name Kernel parameters and options
+ * @{
+ */
/*===========================================================================*/
/**
@@ -61,21 +64,6 @@ #endif
/**
- * @brief Nested locks.
- * @details If enabled then the use of nested @p chSysLock() / @p chSysUnlock()
- * operations is allowed.<br>
- * For performance and code size reasons the recommended setting
- * is to leave this option disabled.<br>
- * You may use this option if you need to merge ChibiOS/RT with
- * external libraries that require nested lock/unlock operations.
- *
- * @note The default is @p FALSE.
- */
-#if !defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__)
-#define CH_USE_NESTED_LOCKS TRUE
-#endif
-
-/**
* @brief Managed RAM size.
* @details Size of the RAM area to be managed by the OS. If set to zero
* then the whole available RAM is used. The core memory is made
@@ -107,8 +95,13 @@ #define CH_NO_IDLE_THREAD FALSE
#endif
+/** @} */
+
/*===========================================================================*/
-/* Performance options. */
+/**
+ * @name Performance options
+ * @{
+ */
/*===========================================================================*/
/**
@@ -123,8 +116,13 @@ #define CH_OPTIMIZE_SPEED FALSE
#endif
+/** @} */
+
/*===========================================================================*/
-/* Subsystem options. */
+/**
+ * @name Subsystem options
+ * @{
+ */
/*===========================================================================*/
/**
@@ -346,11 +344,27 @@ #define CH_USE_DYNAMIC TRUE
#endif
+/** @} */
+
/*===========================================================================*/
-/* Debug options. */
+/**
+ * @name Debug options
+ * @{
+ */
/*===========================================================================*/
/**
+ * @brief Debug option, system state check.
+ * @details If enabled the correct call protocol for system APIs is checked
+ * at runtime.
+ *
+ * @note The default is @p FALSE.
+ */
+#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
+#define CH_DBG_SYSTEM_STATE_CHECK FALSE
+#endif
+
+/**
* @brief Debug option, parameters checks.
* @details If enabled then the checks on the API functions input
* parameters are activated.
@@ -423,8 +437,13 @@ #define CH_DBG_THREADS_PROFILING TRUE
#endif
+/** @} */
+
/*===========================================================================*/
-/* Kernel hooks. */
+/**
+ * @name Kernel hooks
+ * @{
+ */
/*===========================================================================*/
/**
@@ -464,6 +483,16 @@ #endif
/**
+ * @brief Context switch hook.
+ * @details This hook is invoked just before switching between threads.
+ */
+#if !defined(THREAD_CONTEXT_SWITCH_HOOK) || defined(__DOXYGEN__)
+#define THREAD_CONTEXT_SWITCH_HOOK(ntp, otp) { \
+ /* System halt code here.*/ \
+}
+#endif
+
+/**
* @brief Idle Loop hook.
* @details This hook is continuously invoked by the idle thread loop.
*/
@@ -484,6 +513,7 @@ }
#endif
+
/**
* @brief System halt hook.
* @details This hook is invoked in case to a system halting error before
@@ -495,6 +525,8 @@ }
#endif
+/** @} */
+
/*===========================================================================*/
/* Port-specific settings (override port settings defaulted in chcore.h). */
/*===========================================================================*/
diff --git a/test/test.h b/test/test.h index 31806fddb..b1fd311e6 100644 --- a/test/test.h +++ b/test/test.h @@ -127,6 +127,22 @@ extern "C" { }
/**
+ * @brief Test assertion with lock.
+ *
+ * @param[in] point numeric assertion identifier
+ * @param[in] condition a boolean expression that must be verified to be true
+ * @param[in] msg failure message
+ */
+#define test_assert_lock(point, condition, msg) { \
+ chSysLock(); \
+ if (_test_assert(point, condition)) { \
+ chSysUnlock(); \
+ return; \
+ } \
+ chSysUnlock(); \
+}
+
+/**
* @brief Test sequence assertion.
*
* @param[in] point numeric assertion identifier
diff --git a/test/testbmk.c b/test/testbmk.c index 54da81fd8..4958ddf8b 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -465,10 +465,12 @@ static void bmk9_execute(void) { test_wait_tick();
test_start_timer(1000);
do {
+ chSysLock();
chIQPutI(&iq, 0);
chIQPutI(&iq, 1);
chIQPutI(&iq, 2);
chIQPutI(&iq, 3);
+ chSysUnlock();
(void)chIQGet(&iq);
(void)chIQGet(&iq);
(void)chIQGet(&iq);
diff --git a/test/testmbox.c b/test/testmbox.c index 8797536c6..86b9febb4 100644 --- a/test/testmbox.c +++ b/test/testmbox.c @@ -101,19 +101,23 @@ static void mbox1_execute(void) { */
msg1 = chMBPost(&mb1, 'X', 1);
test_assert(4, msg1 == RDY_TIMEOUT, "wrong wake-up message");
+ chSysLock();
msg1 = chMBPostI(&mb1, 'X');
+ chSysUnlock();
test_assert(5, msg1 == RDY_TIMEOUT, "wrong wake-up message");
msg1 = chMBPostAhead(&mb1, 'X', 1);
test_assert(6, msg1 == RDY_TIMEOUT, "wrong wake-up message");
+ chSysLock();
msg1 = chMBPostAheadI(&mb1, 'X');
+ chSysUnlock();
test_assert(7, msg1 == RDY_TIMEOUT, "wrong wake-up message");
/*
* Testing final conditions.
*/
- test_assert(8, chMBGetFreeCountI(&mb1) == 0, "still empty");
- test_assert(9, chMBGetUsedCountI(&mb1) == MB_SIZE, "not full");
- test_assert(10, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
+ test_assert_lock(8, chMBGetFreeCountI(&mb1) == 0, "still empty");
+ test_assert_lock(9, chMBGetUsedCountI(&mb1) == MB_SIZE, "not full");
+ test_assert_lock(10, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
/*
* Testing dequeuing.
@@ -140,19 +144,22 @@ static void mbox1_execute(void) { */
msg1 = chMBFetch(&mb1, &msg2, 1);
test_assert(17, msg1 == RDY_TIMEOUT, "wrong wake-up message");
+ chSysLock();
msg1 = chMBFetchI(&mb1, &msg2);
+ chSysUnlock();
test_assert(18, msg1 == RDY_TIMEOUT, "wrong wake-up message");
/*
* Testing final conditions.
*/
- test_assert(19, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
- test_assert(20, chMBGetUsedCountI(&mb1) == 0, "still full");
- test_assert(21, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
+ test_assert_lock(19, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
+ test_assert_lock(20, chMBGetUsedCountI(&mb1) == 0, "still full");
+ test_assert_lock(21, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
/*
* Testing I-Class.
*/
+ chSysLock()
msg1 = chMBPostI(&mb1, 'A');
test_assert(22, msg1 == RDY_OK, "wrong wake-up message");
msg1 = chMBPostI(&mb1, 'B');
@@ -162,16 +169,20 @@ static void mbox1_execute(void) { msg1 = chMBPostI(&mb1, 'D');
test_assert(25, msg1 == RDY_OK, "wrong wake-up message");
msg1 = chMBPostI(&mb1, 'E');
+ chSysUnlock()
test_assert(26, msg1 == RDY_OK, "wrong wake-up message");
test_assert(27, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
for (i = 0; i < MB_SIZE; i++) {
+ chSysLock();
msg1 = chMBFetchI(&mb1, &msg2);
+ chSysUnlock();
test_assert(28, msg1 == RDY_OK, "wrong wake-up message");
test_emit_token(msg2);
}
test_assert_sequence(29, "ABCDE");
test_assert(30, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
+ chSysLock();
msg1 = chMBPostAheadI(&mb1, 'E');
test_assert(31, msg1 == RDY_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'D');
@@ -181,10 +192,13 @@ static void mbox1_execute(void) { msg1 = chMBPostAheadI(&mb1, 'B');
test_assert(34, msg1 == RDY_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'A');
+ chSysUnlock();
test_assert(35, msg1 == RDY_OK, "wrong wake-up message");
test_assert(36, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
for (i = 0; i < MB_SIZE; i++) {
+ chSysLock();
msg1 = chMBFetchI(&mb1, &msg2);
+ chSysUnlock();
test_assert(37, msg1 == RDY_OK, "wrong wake-up message");
test_emit_token(msg2);
}
@@ -199,10 +213,10 @@ static void mbox1_execute(void) { /*
* Re-testing final conditions.
*/
- test_assert(40, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
- test_assert(41, chMBGetUsedCountI(&mb1) == 0, "still full");
- test_assert(42, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base");
- test_assert(43, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base");
+ test_assert_lock(40, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
+ test_assert_lock(41, chMBGetUsedCountI(&mb1) == 0, "still full");
+ test_assert_lock(42, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base");
+ test_assert_lock(43, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base");
}
ROMCONST struct testcase testmbox1 = {
diff --git a/test/testqueues.c b/test/testqueues.c index 55945761d..456598fa4 100644 --- a/test/testqueues.c +++ b/test/testqueues.c @@ -96,46 +96,54 @@ static void queues1_execute(void) { size_t n;
/* Initial empty state */
- test_assert(1, chIQIsEmptyI(&iq), "not empty");
+ test_assert_lock(1, chIQIsEmptyI(&iq), "not empty");
/* Queue filling */
+ chSysLock();
for (i = 0; i < TEST_QUEUES_SIZE; i++)
chIQPutI(&iq, 'A' + i);
- test_assert(2, chIQIsFullI(&iq), "still has space");
- test_assert(3, chIQPutI(&iq, 0) == Q_FULL, "failed to report Q_FULL");
+ chSysUnlock();
+ test_assert_lock(2, chIQIsFullI(&iq), "still has space");
+ test_assert_lock(3, chIQPutI(&iq, 0) == Q_FULL, "failed to report Q_FULL");
/* Queue emptying */
for (i = 0; i < TEST_QUEUES_SIZE; i++)
test_emit_token(chIQGet(&iq));
- test_assert(4, chIQIsEmptyI(&iq), "still full");
+ test_assert_lock(4, chIQIsEmptyI(&iq), "still full");
test_assert_sequence(5, "ABCD");
/* Queue filling again */
+ chSysLock();
for (i = 0; i < TEST_QUEUES_SIZE; i++)
chIQPutI(&iq, 'A' + i);
+ chSysUnlock();
/* Reading the whole thing */
n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE);
test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size");
- test_assert(7, chIQIsEmptyI(&iq), "still full");
+ test_assert_lock(7, chIQIsEmptyI(&iq), "still full");
/* Queue filling again */
+ chSysLock();
for (i = 0; i < TEST_QUEUES_SIZE; i++)
chIQPutI(&iq, 'A' + i);
+ chSysUnlock();
/* Partial reads */
n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE);
test_assert(8, n == TEST_QUEUES_SIZE / 2, "wrong returned size");
n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE);
test_assert(9, n == TEST_QUEUES_SIZE / 2, "wrong returned size");
- test_assert(10, chIQIsEmptyI(&iq), "still full");
+ test_assert_lock(10, chIQIsEmptyI(&iq), "still full");
/* Testing reset */
+ chSysLock();
chIQPutI(&iq, 0);
chIQResetI(&iq);
- test_assert(11, chIQGetFullI(&iq) == 0, "still full");
+ chSysUnlock();
+ test_assert_lock(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_assert_lock(12, chIQGetFullI(&iq) == 0, "not empty");
test_wait_threads();
/* Timeout */
@@ -175,38 +183,46 @@ static void queues2_execute(void) { size_t n;
/* Initial empty state */
- test_assert(1, chOQIsEmptyI(&oq), "not empty");
+ test_assert_lock(1, chOQIsEmptyI(&oq), "not empty");
/* Queue filling */
for (i = 0; i < TEST_QUEUES_SIZE; i++)
chOQPut(&oq, 'A' + i);
- test_assert(2, chOQIsFullI(&oq), "still has space");
+ test_assert_lock(2, chOQIsFullI(&oq), "still has space");
/* Queue emptying */
- for (i = 0; i < TEST_QUEUES_SIZE; i++)
- test_emit_token(chOQGetI(&oq));
- test_assert(3, chOQIsEmptyI(&oq), "still full");
+ for (i = 0; i < TEST_QUEUES_SIZE; i++) {
+ char c;
+
+ chSysLock();
+ c = chOQGetI(&oq);
+ chSysUnlock();
+ test_emit_token(c);
+ }
+ test_assert_lock(3, chOQIsEmptyI(&oq), "still full");
test_assert_sequence(4, "ABCD");
- test_assert(5, chOQGetI(&oq) == Q_EMPTY, "failed to report Q_EMPTY");
+ test_assert_lock(5, chOQGetI(&oq) == Q_EMPTY, "failed to report Q_EMPTY");
/* Writing the whole thing */
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");
+ test_assert_lock(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_assert_lock(8, chOQGetFullI(&oq) == TEST_QUEUES_SIZE, "not empty");
test_wait_threads();
/* Testing reset */
+ chSysLock();
chOQResetI(&oq);
- test_assert(9, chOQGetFullI(&oq) == 0, "still full");
+ chSysUnlock();
+ test_assert_lock(9, chOQGetFullI(&oq) == 0, "still full");
/* Partial writes */
n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE);
test_assert(10, n == TEST_QUEUES_SIZE / 2, "wrong returned size");
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");
+ test_assert_lock(12, chOQIsFullI(&oq), "not full");
/* Timeout */
test_assert(13, chOQPutTimeout(&oq, 0, 10) == Q_TIMEOUT, "wrong timeout return");
diff --git a/test/testsem.c b/test/testsem.c index 6a6a622ef..d5c9072a7 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -104,7 +104,9 @@ static void sem1_execute(void) { test_assert_sequence(1, "ABCDE");
#endif
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread1, "A");
+ chSysLock();
chSemAddCounterI(&sem1, 2);
+ chSysUnlock();
test_wait_threads();
test_assert(2, chSemGetCounterI(&sem1) == 1, "invalid counter");
}
|