aboutsummaryrefslogtreecommitdiffstats
path: root/test/nil/source
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-03-17 10:00:40 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-03-17 10:00:40 +0000
commit4b6e936c8a66da4fc25f35914b0e9b9e66a31359 (patch)
tree87b2f368ee5635ab6e15df66d439bf79f292c4ee /test/nil/source
parent49dac4f825c0d8a29d8641688e6ee08a9137dd74 (diff)
downloadChibiOS-4b6e936c8a66da4fc25f35914b0e9b9e66a31359.tar.gz
ChibiOS-4b6e936c8a66da4fc25f35914b0e9b9e66a31359.tar.bz2
ChibiOS-4b6e936c8a66da4fc25f35914b0e9b9e66a31359.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9129 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/nil/source')
-rw-r--r--test/nil/source/test/test_root.c2
-rw-r--r--test/nil/source/test/test_root.h1
-rw-r--r--test/nil/source/test/test_sequence_002.c30
-rw-r--r--test/nil/source/test/test_sequence_003.c10
-rw-r--r--test/nil/source/test/test_sequence_004.c119
-rw-r--r--test/nil/source/test/test_sequence_004.h17
6 files changed, 179 insertions, 0 deletions
diff --git a/test/nil/source/test/test_root.c b/test/nil/source/test/test_root.c
index 23306dba6..1d42a6d44 100644
--- a/test/nil/source/test/test_root.c
+++ b/test/nil/source/test/test_root.c
@@ -24,6 +24,7 @@
* - @subpage test_sequence_001
* - @subpage test_sequence_002
* - @subpage test_sequence_003
+ * - @subpage test_sequence_004
* .
*/
@@ -50,6 +51,7 @@ const testcase_t * const *test_suite[] = {
test_sequence_001,
test_sequence_002,
test_sequence_003,
+ test_sequence_004,
NULL
};
diff --git a/test/nil/source/test/test_root.h b/test/nil/source/test/test_root.h
index aade0f83d..10daddeef 100644
--- a/test/nil/source/test/test_root.h
+++ b/test/nil/source/test/test_root.h
@@ -28,6 +28,7 @@
#include "test_sequence_001.h"
#include "test_sequence_002.h"
#include "test_sequence_003.h"
+#include "test_sequence_004.h"
/*===========================================================================*/
/* External declarations. */
diff --git a/test/nil/source/test/test_sequence_002.c b/test/nil/source/test/test_sequence_002.c
index 94c530125..bd626683b 100644
--- a/test/nil/source/test/test_sequence_002.c
+++ b/test/nil/source/test/test_sequence_002.c
@@ -46,6 +46,7 @@ static semaphore_t sem1;
* Test cases.
****************************************************************************/
+#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
/**
* @page test_002_001 Semaphore primitives, no state change
*
@@ -53,6 +54,12 @@ static semaphore_t sem1;
* Wait, Signal and Reset primitives are tested. The testing thread
* does not trigger a state change.
*
+ * <h2>Conditions</h2>
+ * This test is only executed if the following preprocessor condition
+ * evaluates to true:
+ * - CH_CFG_USE_SEMAPHORES
+ * .
+ *
* <h2>Test Steps</h2>
* - The function chSemWait() is invoked, after return the counter and
* the returned message are tested.
@@ -107,7 +114,9 @@ static const testcase_t test_002_001 = {
test_002_001_teardown,
test_002_001_execute
};
+#endif /* CH_CFG_USE_SEMAPHORES */
+#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
/**
* @page test_002_002 Semaphore primitives, with state change
*
@@ -115,6 +124,12 @@ static const testcase_t test_002_001 = {
* Wait, Signal and Reset primitives are tested. The testing thread
* triggers a state change.
*
+ * <h2>Conditions</h2>
+ * This test is only executed if the following preprocessor condition
+ * evaluates to true:
+ * - CH_CFG_USE_SEMAPHORES
+ * .
+ *
* <h2>Test Steps</h2>
* - The function chSemWait() is invoked, after return the counter and
* the returned message are tested. The semaphore is signaled by
@@ -166,13 +181,21 @@ static const testcase_t test_002_002 = {
test_002_002_teardown,
test_002_002_execute
};
+#endif /* CH_CFG_USE_SEMAPHORES */
+#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
/**
* @page test_002_003 Semaphores timeout
*
* <h2>Description</h2>
* Timeout on semaphores is tested.
*
+ * <h2>Conditions</h2>
+ * This test is only executed if the following preprocessor condition
+ * evaluates to true:
+ * - CH_CFG_USE_SEMAPHORES
+ * .
+ *
* <h2>Test Steps</h2>
* - The function chSemWaitTimeout() is invoked a first time, after
* return the system time, the counter and the returned message are
@@ -228,6 +251,7 @@ static const testcase_t test_002_003 = {
test_002_003_teardown,
test_002_003_execute
};
+#endif /* CH_CFG_USE_SEMAPHORES */
/****************************************************************************
* Exported data.
@@ -237,8 +261,14 @@ static const testcase_t test_002_003 = {
* @brief Semaphores.
*/
const testcase_t * const test_sequence_002[] = {
+#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
&test_002_001,
+#endif
+#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
&test_002_002,
+#endif
+#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
&test_002_003,
+#endif
NULL
};
diff --git a/test/nil/source/test/test_sequence_003.c b/test/nil/source/test/test_sequence_003.c
index 3d4e501d7..b58bd3b69 100644
--- a/test/nil/source/test/test_sequence_003.c
+++ b/test/nil/source/test/test_sequence_003.c
@@ -104,12 +104,19 @@ static const testcase_t test_003_001 = {
test_003_001_execute
};
+#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
/**
* @page test_003_002 Events Flags functionality
*
* <h2>Description</h2>
* Event flags functionality is tested.
*
+ * <h2>Conditions</h2>
+ * This test is only executed if the following preprocessor condition
+ * evaluates to true:
+ * - CH_CFG_USE_EVENTS
+ * .
+ *
* <h2>Test Steps</h2>
* - A set of event flags are set on the current thread then the
* function chEvtWaitAnyTimeout() is invoked, the function is
@@ -171,6 +178,7 @@ static const testcase_t test_003_002 = {
NULL,
test_003_002_execute
};
+#endif /* CH_CFG_USE_EVENTS */
/****************************************************************************
* Exported data.
@@ -181,6 +189,8 @@ static const testcase_t test_003_002 = {
*/
const testcase_t * const test_sequence_003[] = {
&test_003_001,
+#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
&test_003_002,
+#endif
NULL
};
diff --git a/test/nil/source/test/test_sequence_004.c b/test/nil/source/test/test_sequence_004.c
new file mode 100644
index 000000000..6e1f3a834
--- /dev/null
+++ b/test/nil/source/test/test_sequence_004.c
@@ -0,0 +1,119 @@
+/*
+ ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "hal.h"
+#include "ch_test.h"
+#include "test_root.h"
+
+/**
+ * @page test_sequence_004 Mailboxes
+ *
+ * File: @ref test_sequence_004.c
+ *
+ * <h2>Description</h2>
+ * This sequence tests the ChibiOS/NIL functionalities related to
+ * mailboxes.
+ *
+ * <h2>Test Cases</h2>
+ * - @subpage test_004_001
+ * .
+ */
+
+/****************************************************************************
+ * Shared code.
+ ****************************************************************************/
+
+#define ALLOWED_DELAY MS2ST(5)
+#define MB_SIZE 4
+
+static msg_t mb_buffer[MB_SIZE];
+static MAILBOX_DECL(mb1, mb_buffer, MB_SIZE);
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
+/**
+ * @page test_004_001 Mailbox non-blocking tests
+ *
+ * <h2>Description</h2>
+ * The mailbox API is tested without triggering blocking conditions.
+ *
+ * <h2>Conditions</h2>
+ * This test is only executed if the following preprocessor condition
+ * evaluates to true:
+ * - CH_CFG_USE_MAILBOXES
+ * .
+ *
+ * <h2>Test Steps</h2>
+ * - Testing the mailbox size.
+ * - Testing forward and backward queuing, checking for no errors.
+ * .
+ */
+
+static void test_004_001_setup(void) {
+ chMBObjectInit(&mb1, mb_buffer, MB_SIZE);
+}
+
+static void test_004_001_teardown(void) {
+ chMBReset(&mb1);
+}
+
+static void test_004_001_execute(void) {
+ msg_t msg1;
+
+ /* Testing the mailbox size.*/
+ test_set_step(1);
+ {
+ test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size");
+ }
+
+ /* Testing forward and backward queuing, checking for no errors.*/
+ test_set_step(2);
+ {
+ unsigned i;
+
+ for (i = 0; i < MB_SIZE - 1; i++) {
+ msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE);
+ test_assert(msg1 == MSG_OK, "wrong wake-up message");
+ }
+ msg1 = chMBPostAhead(&mb1, 'A', TIME_INFINITE);
+ test_assert(msg1 == MSG_OK, "wrong wake-up message");
+ }
+}
+
+static const testcase_t test_004_001 = {
+ "Mailbox non-blocking tests",
+ test_004_001_setup,
+ test_004_001_teardown,
+ test_004_001_execute
+};
+#endif /* CH_CFG_USE_MAILBOXES */
+
+/****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Mailboxes.
+ */
+const testcase_t * const test_sequence_004[] = {
+#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
+ &test_004_001,
+#endif
+ NULL
+};
diff --git a/test/nil/source/test/test_sequence_004.h b/test/nil/source/test/test_sequence_004.h
new file mode 100644
index 000000000..3ecaa4259
--- /dev/null
+++ b/test/nil/source/test/test_sequence_004.h
@@ -0,0 +1,17 @@
+/*
+ ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+extern const testcase_t * const test_sequence_004[];