aboutsummaryrefslogtreecommitdiffstats
path: root/test/nil/source
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-03-16 14:48:13 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-03-16 14:48:13 +0000
commit13375b4faaeb666b0684161d90426a62efaf0829 (patch)
tree8fd7f83948a667487395e0f96f5b5a1b087f5504 /test/nil/source
parent94bbc4d19ca17984db3262089ba7365fbf62c6de (diff)
downloadChibiOS-13375b4faaeb666b0684161d90426a62efaf0829.tar.gz
ChibiOS-13375b4faaeb666b0684161d90426a62efaf0829.tar.bz2
ChibiOS-13375b4faaeb666b0684161d90426a62efaf0829.zip
Updated the NIL test suite by generating the code using the new system.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9127 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/nil/source')
-rw-r--r--test/nil/source/test/test_root.c94
-rw-r--r--test/nil/source/test/test_root.h59
-rw-r--r--test/nil/source/test/test_sequence_001.c175
-rw-r--r--test/nil/source/test/test_sequence_001.h17
-rw-r--r--test/nil/source/test/test_sequence_002.c244
-rw-r--r--test/nil/source/test/test_sequence_002.h17
-rw-r--r--test/nil/source/test/test_sequence_003.c186
-rw-r--r--test/nil/source/test/test_sequence_003.h17
8 files changed, 809 insertions, 0 deletions
diff --git a/test/nil/source/test/test_root.c b/test/nil/source/test/test_root.c
new file mode 100644
index 000000000..23306dba6
--- /dev/null
+++ b/test/nil/source/test/test_root.c
@@ -0,0 +1,94 @@
+/*
+ ChibiOS - Copyright (C) 2006..2016 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.
+*/
+
+/**
+ * @mainpage Test Suite Specification
+ * Test suite for ChibiOS/NIL. The purpose of this suite is to perform
+ * unit tests on the NIL modules and to converge to 100% code coverage
+ * through successive improvements.
+ *
+ * <h2>Test Sequences</h2>
+ * - @subpage test_sequence_001
+ * - @subpage test_sequence_002
+ * - @subpage test_sequence_003
+ * .
+ */
+
+/**
+ * @file test_root.c
+ * @brief Test Suite root structures code.
+ *
+ * @addtogroup SPC5_TEST_ROOT
+ * @{
+ */
+
+#include "hal.h"
+#include "ch_test.h"
+#include "test_root.h"
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/**
+ * @brief Array of all the test sequences.
+ */
+const testcase_t * const *test_suite[] = {
+ test_sequence_001,
+ test_sequence_002,
+ test_sequence_003,
+ NULL
+};
+
+/*===========================================================================*/
+/* Shared code. */
+/*===========================================================================*/
+
+semaphore_t gsem1, gsem2;
+thread_reference_t gtr1;
+
+/*
+ * Support thread.
+ */
+THD_WORKING_AREA(wa_test_support, 128);
+THD_FUNCTION(test_support, arg) {
+#if CH_CFG_USE_EVENTS == TRUE
+ thread_t *tp = (thread_t *)arg;
+#else
+ (void)arg;
+#endif
+
+ /* Initializing global resources.*/
+ chSemObjectInit(&gsem1, 0);
+ chSemObjectInit(&gsem2, 0);
+
+ while (true) {
+ chSysLock();
+ if (chSemGetCounterI(&gsem1) < 0)
+ chSemSignalI(&gsem1);
+ chSemResetI(&gsem2, 0);
+ chThdResumeI(&gtr1, MSG_OK);
+#if CH_CFG_USE_EVENTS == TRUE
+ chEvtSignalI(tp, 0x55);
+#endif
+ chSchRescheduleS();
+ chSysUnlock();
+
+ chThdSleepMilliseconds(250);
+ }
+}
+
+/** @} */
diff --git a/test/nil/source/test/test_root.h b/test/nil/source/test/test_root.h
new file mode 100644
index 000000000..aade0f83d
--- /dev/null
+++ b/test/nil/source/test/test_root.h
@@ -0,0 +1,59 @@
+/*
+ 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.
+*/
+
+/**
+ * @file test_root.h
+ * @brief Test Suite root structures header.
+ *
+ * @addtogroup SPC5_TEST_ROOT
+ * @{
+ */
+
+#ifndef _SPC5_TEST_ROOT_H_
+#define _SPC5_TEST_ROOT_H_
+
+#include "test_sequence_001.h"
+#include "test_sequence_002.h"
+#include "test_sequence_003.h"
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+extern const testcase_t * const *test_suite[];
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Shared definitions. */
+/*===========================================================================*/
+
+#define TEST_SUITE_NAME "ChibiOS/NIL Test Suite"
+
+extern semaphore_t gsem1, gsem2;
+extern thread_reference_t gtr1;
+extern THD_WORKING_AREA(wa_test_support, 128);
+
+THD_FUNCTION(test_support, arg);
+
+#endif /* _SPC5_TEST_ROOT_H_ */
+
+/** @} */
diff --git a/test/nil/source/test/test_sequence_001.c b/test/nil/source/test/test_sequence_001.c
new file mode 100644
index 000000000..4be1c4785
--- /dev/null
+++ b/test/nil/source/test/test_sequence_001.c
@@ -0,0 +1,175 @@
+/*
+ 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_001 Threads Functionality
+ *
+ * File: @ref test_sequence_001.c
+ *
+ * <h2>Description</h2>
+ * This sequence tests the ChibiOS/NIL functionalities related to
+ * threading.
+ *
+ * <h2>Test Cases</h2>
+ * - @subpage test_001_001
+ * - @subpage test_001_002
+ * .
+ */
+
+/****************************************************************************
+ * Shared code.
+ ****************************************************************************/
+
+#include "ch.h"
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+/**
+ * @page test_001_001 System Tick Counter functionality
+ *
+ * <h2>Description</h2>
+ * The functionality of the API @p chVTGetSystemTimeX() is tested.
+ *
+ * <h2>Test Steps</h2>
+ * - A System Tick Counter increment is expected, the test simply hangs
+ * if it does not happen.
+ * .
+ */
+
+static void test_001_001_execute(void) {
+
+ /* A System Tick Counter increment is expected, the test simply hangs
+ if it does not happen.*/
+ test_set_step(1);
+ {
+ systime_t time = chVTGetSystemTimeX();
+ while (time == chVTGetSystemTimeX()) {
+ }
+ }
+}
+
+static const testcase_t test_001_001 = {
+ "System Tick Counter functionality",
+ NULL,
+ NULL,
+ test_001_001_execute
+};
+
+/**
+ * @page test_001_002 Thread Sleep functionality
+ *
+ * <h2>Description</h2>
+ * The functionality of @p chThdSleep() and derivatives is tested.
+ *
+ * <h2>Test Steps</h2>
+ * - The current system time is read then a sleep is performed for 100
+ * system ticks and on exit the system time is verified again.
+ * - The current system time is read then a sleep is performed for
+ * 100000 microseconds and on exit the system time is verified again.
+ * - The current system time is read then a sleep is performed for 100
+ * milliseconds and on exit the system time is verified again.
+ * - The current system time is read then a sleep is performed for 1
+ * second and on exit the system time is verified again.
+ * - Function chThdSleepUntil() is tested with a timeline of "now" +
+ * 100 ticks.
+ * .
+ */
+
+static void test_001_002_execute(void) {
+ systime_t time;
+
+ /* The current system time is read then a sleep is performed for 100
+ system ticks and on exit the system time is verified again.*/
+ test_set_step(1);
+ {
+ time = chVTGetSystemTimeX();
+ chThdSleep(100);
+ test_assert_time_window(time + 100,
+ time + 100 + 1,
+ "out of time window");
+ }
+
+ /* The current system time is read then a sleep is performed for
+ 100000 microseconds and on exit the system time is verified
+ again.*/
+ test_set_step(2);
+ {
+ time = chVTGetSystemTimeX();
+ chThdSleepMicroseconds(100000);
+ test_assert_time_window(time + US2ST(100000),
+ time + US2ST(100000) + 1,
+ "out of time window");
+ }
+
+ /* The current system time is read then a sleep is performed for 100
+ milliseconds and on exit the system time is verified again.*/
+ test_set_step(3);
+ {
+ time = chVTGetSystemTimeX();
+ chThdSleepMilliseconds(100);
+ test_assert_time_window(time + MS2ST(100),
+ time + MS2ST(100) + 1,
+ "out of time window");
+ }
+
+ /* The current system time is read then a sleep is performed for 1
+ second and on exit the system time is verified again.*/
+ test_set_step(4);
+ {
+ time = chVTGetSystemTimeX();
+ chThdSleepSeconds(1);
+ test_assert_time_window(time + S2ST(1),
+ time + S2ST(1) + 1,
+ "out of time window");
+ }
+
+ /* Function chThdSleepUntil() is tested with a timeline of "now" +
+ 100 ticks.*/
+ test_set_step(5);
+ {
+ time = chVTGetSystemTimeX();
+ chThdSleepUntil(time + 100);
+ test_assert_time_window(time + 100,
+ time + 100 + 1,
+ "out of time window");
+ }
+}
+
+static const testcase_t test_001_002 = {
+ "Thread Sleep functionality",
+ NULL,
+ NULL,
+ test_001_002_execute
+};
+
+/****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Threads Functionality.
+ */
+const testcase_t * const test_sequence_001[] = {
+ &test_001_001,
+ &test_001_002,
+ NULL
+};
diff --git a/test/nil/source/test/test_sequence_001.h b/test/nil/source/test/test_sequence_001.h
new file mode 100644
index 000000000..83ef96518
--- /dev/null
+++ b/test/nil/source/test/test_sequence_001.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_001[];
diff --git a/test/nil/source/test/test_sequence_002.c b/test/nil/source/test/test_sequence_002.c
new file mode 100644
index 000000000..94c530125
--- /dev/null
+++ b/test/nil/source/test/test_sequence_002.c
@@ -0,0 +1,244 @@
+/*
+ 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_002 Semaphores
+ *
+ * File: @ref test_sequence_002.c
+ *
+ * <h2>Description</h2>
+ * This sequence tests the ChibiOS/NIL functionalities related to
+ * counter semaphores.
+ *
+ * <h2>Test Cases</h2>
+ * - @subpage test_002_001
+ * - @subpage test_002_002
+ * - @subpage test_002_003
+ * .
+ */
+
+/****************************************************************************
+ * Shared code.
+ ****************************************************************************/
+
+#include "ch.h"
+
+static semaphore_t sem1;
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+/**
+ * @page test_002_001 Semaphore primitives, no state change
+ *
+ * <h2>Description</h2>
+ * Wait, Signal and Reset primitives are tested. The testing thread
+ * does not trigger a state change.
+ *
+ * <h2>Test Steps</h2>
+ * - The function chSemWait() is invoked, after return the counter and
+ * the returned message are tested.
+ * - The function chSemSignal() is invoked, after return the counter is
+ * tested.
+ * - The function chSemReset() is invoked, after return the counter is
+ * tested.
+ * .
+ */
+
+static void test_002_001_setup(void) {
+ chSemObjectInit(&sem1, 1);
+}
+
+static void test_002_001_teardown(void) {
+ chSemReset(&sem1, 0);
+}
+
+static void test_002_001_execute(void) {
+
+ /* The function chSemWait() is invoked, after return the counter and
+ the returned message are tested.*/
+ test_set_step(1);
+ {
+ msg_t msg;
+
+ msg = chSemWait(&sem1);
+ test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
+ test_assert(MSG_OK == msg, "wrong returned message");
+ }
+
+ /* The function chSemSignal() is invoked, after return the counter is
+ tested.*/
+ test_set_step(2);
+ {
+ chSemSignal(&sem1);
+ test_assert_lock(chSemGetCounterI(&sem1) == 1, "wrong counter value");
+ }
+
+ /* The function chSemReset() is invoked, after return the counter is
+ tested.*/
+ test_set_step(3);
+ {
+ chSemReset(&sem1, 2);
+ test_assert_lock(chSemGetCounterI(&sem1) == 2, "wrong counter value");
+ }
+}
+
+static const testcase_t test_002_001 = {
+ "Semaphore primitives, no state change",
+ test_002_001_setup,
+ test_002_001_teardown,
+ test_002_001_execute
+};
+
+/**
+ * @page test_002_002 Semaphore primitives, with state change
+ *
+ * <h2>Description</h2>
+ * Wait, Signal and Reset primitives are tested. The testing thread
+ * triggers a state change.
+ *
+ * <h2>Test Steps</h2>
+ * - The function chSemWait() is invoked, after return the counter and
+ * the returned message are tested. The semaphore is signaled by
+ * another thread.
+ * - The function chSemWait() is invoked, after return the counter and
+ * the returned message are tested. The semaphore is reset by another
+ * thread.
+ * .
+ */
+
+static void test_002_002_setup(void) {
+ chSemObjectInit(&gsem1, 0);
+}
+
+static void test_002_002_teardown(void) {
+ chSemReset(&gsem1, 0);
+}
+
+static void test_002_002_execute(void) {
+
+ /* The function chSemWait() is invoked, after return the counter and
+ the returned message are tested. The semaphore is signaled by
+ another thread.*/
+ test_set_step(1);
+ {
+ msg_t msg;
+
+ msg = chSemWait(&gsem1);
+ test_assert_lock(chSemGetCounterI(&gsem1) == 0, "wrong counter value");
+ test_assert(MSG_OK == msg, "wrong returned message");
+ }
+
+ /* The function chSemWait() is invoked, after return the counter and
+ the returned message are tested. The semaphore is reset by another
+ thread.*/
+ test_set_step(2);
+ {
+ msg_t msg;
+
+ msg = chSemWait(&gsem2);
+ test_assert_lock(chSemGetCounterI(&gsem2) == 0,"wrong counter value");
+ test_assert(MSG_RESET == msg, "wrong returned message");
+ }
+}
+
+static const testcase_t test_002_002 = {
+ "Semaphore primitives, with state change",
+ test_002_002_setup,
+ test_002_002_teardown,
+ test_002_002_execute
+};
+
+/**
+ * @page test_002_003 Semaphores timeout
+ *
+ * <h2>Description</h2>
+ * Timeout on semaphores is tested.
+ *
+ * <h2>Test Steps</h2>
+ * - The function chSemWaitTimeout() is invoked a first time, after
+ * return the system time, the counter and the returned message are
+ * tested.
+ * - The function chSemWaitTimeout() is invoked again, after return the
+ * system time, the counter and the returned message are tested.
+ * .
+ */
+
+static void test_002_003_setup(void) {
+ chSemObjectInit(&sem1, 0);
+}
+
+static void test_002_003_teardown(void) {
+ chSemReset(&sem1, 0);
+}
+
+static void test_002_003_execute(void) {
+ systime_t time;
+ msg_t msg;
+
+ /* The function chSemWaitTimeout() is invoked a first time, after
+ return the system time, the counter and the returned message are
+ tested.*/
+ test_set_step(1);
+ {
+ time = chVTGetSystemTimeX();
+ msg = chSemWaitTimeout(&sem1, MS2ST(1000));
+ test_assert_time_window(time + MS2ST(1000),
+ time + MS2ST(1000) + 1,
+ "out of time window");
+ test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
+ test_assert(MSG_TIMEOUT == msg, "wrong timeout message");
+ }
+
+ /* The function chSemWaitTimeout() is invoked again, after return the
+ system time, the counter and the returned message are tested.*/
+ test_set_step(2);
+ {
+ time = chVTGetSystemTimeX();
+ msg = chSemWaitTimeout(&sem1, MS2ST(1000));
+ test_assert_time_window(time + MS2ST(1000),
+ time + MS2ST(1000) + 1,
+ "out of time window");
+ test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
+ test_assert(MSG_TIMEOUT == msg, "wrong timeout message");
+ }
+}
+
+static const testcase_t test_002_003 = {
+ "Semaphores timeout",
+ test_002_003_setup,
+ test_002_003_teardown,
+ test_002_003_execute
+};
+
+/****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Semaphores.
+ */
+const testcase_t * const test_sequence_002[] = {
+ &test_002_001,
+ &test_002_002,
+ &test_002_003,
+ NULL
+};
diff --git a/test/nil/source/test/test_sequence_002.h b/test/nil/source/test/test_sequence_002.h
new file mode 100644
index 000000000..bd7b6c764
--- /dev/null
+++ b/test/nil/source/test/test_sequence_002.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_002[];
diff --git a/test/nil/source/test/test_sequence_003.c b/test/nil/source/test/test_sequence_003.c
new file mode 100644
index 000000000..3d4e501d7
--- /dev/null
+++ b/test/nil/source/test/test_sequence_003.c
@@ -0,0 +1,186 @@
+/*
+ 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_003 Suspend/Resume and Event Flags
+ *
+ * File: @ref test_sequence_003.c
+ *
+ * <h2>Description</h2>
+ * This sequence tests the ChibiOS/NIL functionalities related to
+ * threads suspend/resume and event flags.
+ *
+ * <h2>Test Cases</h2>
+ * - @subpage test_003_001
+ * - @subpage test_003_002
+ * .
+ */
+
+/****************************************************************************
+ * Shared code.
+ ****************************************************************************/
+
+static thread_reference_t tr1;
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+/**
+ * @page test_003_001 Suspend and Resume functionality
+ *
+ * <h2>Description</h2>
+ * The functionality of chThdSuspendTimeoutS() and chThdResumeI() is
+ * tested.
+ *
+ * <h2>Test Steps</h2>
+ * - The function chThdSuspendTimeoutS() is invoked, the thread is
+ * remotely resumed with message @p MSG_OK. On return the message and
+ * the state of the reference are tested.
+ * - The function chThdSuspendTimeoutS() is invoked, the thread is not
+ * resumed so a timeout must occur. On return the message and the
+ * state of the reference are tested.
+ * .
+ */
+
+static void test_003_001_setup(void) {
+ tr1 = NULL;
+}
+
+static void test_003_001_execute(void) {
+ systime_t time;
+ msg_t msg;
+
+ /* The function chThdSuspendTimeoutS() is invoked, the thread is
+ remotely resumed with message @p MSG_OK. On return the message and
+ the state of the reference are tested.*/
+ test_set_step(1);
+ {
+ chSysLock();
+ msg = chThdSuspendTimeoutS(&gtr1, TIME_INFINITE);
+ chSysUnlock();
+ test_assert(NULL == gtr1, "not NULL");
+ test_assert(MSG_OK == msg,"wrong returned message");
+ }
+
+ /* The function chThdSuspendTimeoutS() is invoked, the thread is not
+ resumed so a timeout must occur. On return the message and the
+ state of the reference are tested.*/
+ test_set_step(2);
+ {
+ chSysLock();
+ time = chVTGetSystemTimeX();
+ msg = chThdSuspendTimeoutS(&tr1, MS2ST(1000));
+ chSysUnlock();
+ test_assert_time_window(time + MS2ST(1000),
+ time + MS2ST(1000) + 1,
+ "out of time window");
+ test_assert(NULL == tr1, "not NULL");
+ test_assert(MSG_TIMEOUT == msg, "wrong returned message");
+ }
+}
+
+static const testcase_t test_003_001 = {
+ "Suspend and Resume functionality",
+ test_003_001_setup,
+ NULL,
+ test_003_001_execute
+};
+
+/**
+ * @page test_003_002 Events Flags functionality
+ *
+ * <h2>Description</h2>
+ * Event flags functionality is tested.
+ *
+ * <h2>Test Steps</h2>
+ * - A set of event flags are set on the current thread then the
+ * function chEvtWaitAnyTimeout() is invoked, the function is
+ * supposed to return immediately because the event flags are already
+ * pending, after return the events mask is tested.
+ * - The pending event flags mask is cleared then the function
+ * chEvtWaitAnyTimeout() is invoked, after return the events mask is
+ * tested. The thread is signaled by another thread.
+ * - The function chEvtWaitAnyTimeout() is invoked, no event can wakeup
+ * the thread, the function must return because timeout.
+ * .
+ */
+
+static void test_003_002_execute(void) {
+ systime_t time;
+ eventmask_t events;
+
+ /* A set of event flags are set on the current thread then the
+ function chEvtWaitAnyTimeout() is invoked, the function is
+ supposed to return immediately because the event flags are already
+ pending, after return the events mask is tested.*/
+ test_set_step(1);
+ {
+ time = chVTGetSystemTimeX();
+ chEvtSignal(chThdGetSelfX(), 0x55);
+ events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
+ test_assert((eventmask_t)0 != events, "timed out");
+ test_assert((eventmask_t)0x55 == events, "wrong events mask");
+ }
+
+ /* The pending event flags mask is cleared then the function
+ chEvtWaitAnyTimeout() is invoked, after return the events mask is
+ tested. The thread is signaled by another thread.*/
+ test_set_step(2);
+ {
+ time = chVTGetSystemTimeX();
+ chThdGetSelfX()->epmask = 0;
+ events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
+ test_assert((eventmask_t)0 != events, "timed out");
+ test_assert((eventmask_t)0x55 == events, "wrong events mask");
+ }
+
+ /* The function chEvtWaitAnyTimeout() is invoked, no event can wakeup
+ the thread, the function must return because timeout.*/
+ test_set_step(3);
+ {
+ time = chVTGetSystemTimeX();
+ events = chEvtWaitAnyTimeout(0, MS2ST(1000));
+ test_assert_time_window(time + MS2ST(1000),
+ time + MS2ST(1000) + 1,
+ "out of time window");
+ test_assert((eventmask_t)0 == events, "wrong events mask");
+ }
+}
+
+static const testcase_t test_003_002 = {
+ "Events Flags functionality",
+ NULL,
+ NULL,
+ test_003_002_execute
+};
+
+/****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Suspend/Resume and Event Flags.
+ */
+const testcase_t * const test_sequence_003[] = {
+ &test_003_001,
+ &test_003_002,
+ NULL
+};
diff --git a/test/nil/source/test/test_sequence_003.h b/test/nil/source/test/test_sequence_003.h
new file mode 100644
index 000000000..587acc5de
--- /dev/null
+++ b/test/nil/source/test/test_sequence_003.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_003[];