diff --git a/demos/STM32/NIL-STM32F303-DISCOVERY/Makefile b/demos/STM32/NIL-STM32F303-DISCOVERY/Makefile
index e9caa45fa..5bd9437d4 100644
--- a/demos/STM32/NIL-STM32F303-DISCOVERY/Makefile
+++ b/demos/STM32/NIL-STM32F303-DISCOVERY/Makefile
@@ -5,7 +5,7 @@
# Compiler options here.
ifeq ($(USE_OPT),)
- USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
+ USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
endif
# C specific options here (added to USE_OPT).
diff --git a/test/nil/configuration.xml b/test/nil/configuration.xml
index 1e6d3d16d..d50a37dcc 100644
--- a/test/nil/configuration.xml
+++ b/test/nil/configuration.xml
@@ -1354,6 +1354,100 @@ test_assert(!chEvtIsListeningI(&es2), "stuck listener");]]>
+
+
+ Internal Tests
+
+
+ Synchronous Messages.
+
+
+ This module implements the test sequence for the Synchronous Messages subsystem.
+
+
+ CH_CFG_USE_MESSAGES
+
+
+
+
+
+
+
+ Messages Server loop.
+
+
+ A messenger thread is spawned that sends four messages back to the tester thread.<br>
+The test expect to receive the messages in the correct sequence and to not find a fifth message waiting.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Starting the messenger thread.
+
+
+
+
+
+
+
+
+
+
+ Waiting for four messages then testing the receive order.
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/nil/nil_test.mk b/test/nil/nil_test.mk
index 70659cf7a..220765268 100644
--- a/test/nil/nil_test.mk
+++ b/test/nil/nil_test.mk
@@ -4,7 +4,8 @@ TESTSRC += ${CHIBIOS}/test/nil/source/test/nil_test_root.c \
${CHIBIOS}/test/nil/source/test/nil_test_sequence_002.c \
${CHIBIOS}/test/nil/source/test/nil_test_sequence_003.c \
${CHIBIOS}/test/nil/source/test/nil_test_sequence_004.c \
- ${CHIBIOS}/test/nil/source/test/nil_test_sequence_005.c
+ ${CHIBIOS}/test/nil/source/test/nil_test_sequence_005.c \
+ ${CHIBIOS}/test/nil/source/test/nil_test_sequence_006.c
# Required include directories
TESTINC += ${CHIBIOS}/test/nil/source/test
diff --git a/test/nil/source/test/nil_test_root.c b/test/nil/source/test/nil_test_root.c
index e960aea0c..41480de80 100644
--- a/test/nil/source/test/nil_test_root.c
+++ b/test/nil/source/test/nil_test_root.c
@@ -26,6 +26,7 @@
* - @subpage nil_test_sequence_003
* - @subpage nil_test_sequence_004
* - @subpage nil_test_sequence_005
+ * - @subpage nil_test_sequence_006
* .
*/
@@ -55,6 +56,9 @@ const testsequence_t * const nil_test_suite_array[] = {
&nil_test_sequence_004,
#if (CH_CFG_USE_EVENTS) || defined(__DOXYGEN__)
&nil_test_sequence_005,
+#endif
+#if (CH_CFG_USE_MESSAGES) || defined(__DOXYGEN__)
+ &nil_test_sequence_006,
#endif
NULL
};
diff --git a/test/nil/source/test/nil_test_root.h b/test/nil/source/test/nil_test_root.h
index 93b51b951..8f2062092 100644
--- a/test/nil/source/test/nil_test_root.h
+++ b/test/nil/source/test/nil_test_root.h
@@ -29,6 +29,7 @@
#include "nil_test_sequence_003.h"
#include "nil_test_sequence_004.h"
#include "nil_test_sequence_005.h"
+#include "nil_test_sequence_006.h"
#if !defined(__DOXYGEN__)
diff --git a/test/nil/source/test/nil_test_sequence_006.c b/test/nil/source/test/nil_test_sequence_006.c
new file mode 100644
index 000000000..f3eaa4c7a
--- /dev/null
+++ b/test/nil/source/test/nil_test_sequence_006.c
@@ -0,0 +1,141 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 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 "nil_test_root.h"
+
+/**
+ * @file nil_test_sequence_006.c
+ * @brief Test Sequence 006 code.
+ *
+ * @page nil_test_sequence_006 [6] Synchronous Messages
+ *
+ * File: @ref nil_test_sequence_006.c
+ *
+ *
Description
+ * This module implements the test sequence for the Synchronous
+ * Messages subsystem.
+ *
+ * Conditions
+ * This sequence is only executed if the following preprocessor condition
+ * evaluates to true:
+ * - CH_CFG_USE_MESSAGES
+ * .
+ *
+ * Test Cases
+ * - @subpage nil_test_006_001
+ * .
+ */
+
+#if (CH_CFG_USE_MESSAGES) || defined(__DOXYGEN__)
+
+/****************************************************************************
+ * Shared code.
+ ****************************************************************************/
+
+/*
+ * Messager thread.
+ */
+static THD_WORKING_AREA(wa_messager, 128);
+static THD_FUNCTION(messager, p) {
+
+ chMsgSend(p, 'A');
+ chMsgSend(p, 'B');
+ chMsgSend(p, 'C');
+ chMsgSend(p, 'D');
+}
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+/**
+ * @page nil_test_006_001 [6.1] Messages Server loop
+ *
+ * Description
+ * A messenger thread is spawned that sends four messages back to the
+ * tester thread.
The test expect to receive the messages in the
+ * correct sequence and to not find a fifth message waiting.
+ *
+ * Test Steps
+ * - [6.1.1] Starting the messenger thread.
+ * - [6.1.2] Waiting for four messages then testing the receive order.
+ * .
+ */
+
+static void nil_test_006_001_execute(void) {
+ thread_t *tp, *tp1;
+ msg_t msg;
+
+ /* [6.1.1] Starting the messenger thread.*/
+ test_set_step(1);
+ {
+ thread_config_t tc = {
+ chThdGetPriorityX() - 1,
+ "messager",
+ wa_messager,
+ THD_WORKING_AREA_END(wa_messager),
+ messager,
+ chThdGetSelfX()
+ };
+ tp1 = chThdCreate(&tc);
+ }
+
+ /* [6.1.2] Waiting for four messages then testing the receive
+ order.*/
+ test_set_step(2);
+ {
+ unsigned i;
+
+ for (i = 0; i < 4; i++) {
+ tp = chMsgWait();
+ msg = chMsgGet(tp);
+ chMsgRelease(tp, msg);
+ test_emit_token(msg);
+ }
+ chThdWait(tp1);
+ test_assert_sequence("ABCD", "invalid sequence");
+ }
+}
+
+static const testcase_t nil_test_006_001 = {
+ "Messages Server loop",
+ NULL,
+ NULL,
+ nil_test_006_001_execute
+};
+
+/****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Array of test cases.
+ */
+const testcase_t * const nil_test_sequence_006_array[] = {
+ &nil_test_006_001,
+ NULL
+};
+
+/**
+ * @brief Synchronous Messages.
+ */
+const testsequence_t nil_test_sequence_006 = {
+ "Synchronous Messages",
+ nil_test_sequence_006_array
+};
+
+#endif /* CH_CFG_USE_MESSAGES */
diff --git a/test/nil/source/test/nil_test_sequence_006.h b/test/nil/source/test/nil_test_sequence_006.h
new file mode 100644
index 000000000..ead3bd714
--- /dev/null
+++ b/test/nil/source/test/nil_test_sequence_006.h
@@ -0,0 +1,27 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 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 nil_test_sequence_006.h
+ * @brief Test Sequence 006 header.
+ */
+
+#ifndef NIL_TEST_SEQUENCE_006_H
+#define NIL_TEST_SEQUENCE_006_H
+
+extern const testsequence_t nil_test_sequence_006;
+
+#endif /* NIL_TEST_SEQUENCE_006_H */