diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/ch_test.c | 289 | ||||
-rw-r--r-- | test/lib/ch_test.h | 192 | ||||
-rw-r--r-- | test/lib/templates/test_root.c | 45 | ||||
-rw-r--r-- | test/lib/templates/test_root.h | 57 | ||||
-rw-r--r-- | test/lib/templates/test_sequence_XXX.c | 97 | ||||
-rw-r--r-- | test/lib/templates/test_sequence_XXX.h | 22 | ||||
-rw-r--r-- | test/nil/test.mk | 9 | ||||
-rw-r--r-- | test/nil/test_root.c | 75 | ||||
-rw-r--r-- | test/nil/test_root.h | 64 | ||||
-rw-r--r-- | test/nil/test_sequence_001.c | 183 | ||||
-rw-r--r-- | test/nil/test_sequence_001.h | 22 | ||||
-rw-r--r-- | test/nil/test_sequence_002.c | 435 | ||||
-rw-r--r-- | test/nil/test_sequence_002.h | 22 | ||||
-rw-r--r-- | test/rt/coverage/Makefile (renamed from test/coverage/Makefile) | 14 | ||||
-rw-r--r-- | test/rt/coverage/chconf.h (renamed from test/coverage/chconf.h) | 0 | ||||
-rw-r--r-- | test/rt/coverage/halconf.h (renamed from test/coverage/halconf.h) | 7 | ||||
-rw-r--r-- | test/rt/coverage/main.c (renamed from test/coverage/main.c) | 0 | ||||
-rw-r--r-- | test/rt/coverage/readme.txt (renamed from test/coverage/readme.txt) | 0 | ||||
-rw-r--r-- | test/rt/test.c (renamed from test/test.c) | 38 | ||||
-rw-r--r-- | test/rt/test.dox (renamed from test/test.dox) | 0 | ||||
-rw-r--r-- | test/rt/test.h (renamed from test/test.h) | 24 | ||||
-rw-r--r-- | test/rt/test.mk | 16 | ||||
-rw-r--r-- | test/rt/testbmk.c (renamed from test/testbmk.c) | 151 | ||||
-rw-r--r-- | test/rt/testbmk.h (renamed from test/testbmk.h) | 0 | ||||
-rw-r--r-- | test/rt/testdyn.c (renamed from test/testdyn.c) | 71 | ||||
-rw-r--r-- | test/rt/testdyn.h (renamed from test/testdyn.h) | 0 | ||||
-rw-r--r-- | test/rt/testevt.c (renamed from test/testevt.c) | 44 | ||||
-rw-r--r-- | test/rt/testevt.h (renamed from test/testevt.h) | 0 | ||||
-rw-r--r-- | test/rt/testheap.c (renamed from test/testheap.c) | 12 | ||||
-rw-r--r-- | test/rt/testheap.h (renamed from test/testheap.h) | 0 | ||||
-rw-r--r-- | test/rt/testmbox.c (renamed from test/testmbox.c) | 58 | ||||
-rw-r--r-- | test/rt/testmbox.h (renamed from test/testmbox.h) | 0 | ||||
-rw-r--r-- | test/rt/testmsg.c (renamed from test/testmsg.c) | 14 | ||||
-rw-r--r-- | test/rt/testmsg.h (renamed from test/testmsg.h) | 0 | ||||
-rw-r--r-- | test/rt/testmtx.c (renamed from test/testmtx.c) | 143 | ||||
-rw-r--r-- | test/rt/testmtx.h (renamed from test/testmtx.h) | 0 | ||||
-rw-r--r-- | test/rt/testpools.c (renamed from test/testpools.c) | 14 | ||||
-rw-r--r-- | test/rt/testpools.h (renamed from test/testpools.h) | 0 | ||||
-rw-r--r-- | test/rt/testqueues.c (renamed from test/testqueues.c) | 18 | ||||
-rw-r--r-- | test/rt/testqueues.h (renamed from test/testqueues.h) | 0 | ||||
-rw-r--r-- | test/rt/testsem.c (renamed from test/testsem.c) | 82 | ||||
-rw-r--r-- | test/rt/testsem.h (renamed from test/testsem.h) | 0 | ||||
-rw-r--r-- | test/rt/testthd.c (renamed from test/testthd.c) | 58 | ||||
-rw-r--r-- | test/rt/testthd.h (renamed from test/testthd.h) | 0 | ||||
-rw-r--r-- | test/test.mk | 16 |
45 files changed, 1903 insertions, 389 deletions
diff --git a/test/lib/ch_test.c b/test/lib/ch_test.c new file mode 100644 index 000000000..cb1df734f --- /dev/null +++ b/test/lib/ch_test.c @@ -0,0 +1,289 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006-2013 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 ch_test.c
+ * @brief Unit Tests Engine module code.
+ *
+ * @addtogroup CH_TEST
+ * @{
+ */
+
+#include "hal.h"
+#include "ch_test.h"
+#include "test_root.h"
+
+/*===========================================================================*/
+/* Module local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/**
+ * @brief Test step being executed.
+ */
+unsigned test_step;
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+static bool test_local_fail;
+static bool test_global_fail;
+static const char *test_failure_message;
+static char test_tokens_buffer[TEST_MAX_TOKENS];
+static char *test_tokp;
+static BaseSequentialStream *test_chp;
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
+static void clear_tokens(void) {
+
+ test_tokp = test_tokens_buffer;
+}
+
+static void print_tokens(void) {
+ char *cp = test_tokens_buffer;
+
+ while (cp < test_tokp)
+ streamPut(test_chp, *cp++);
+}
+
+static void execute_test(const testcase_t *tcp) {
+
+ /* Initialization */
+ clear_tokens();
+ test_local_fail = FALSE;
+
+ if (tcp->setup != NULL)
+ tcp->setup();
+ tcp->execute();
+ if (tcp->teardown != NULL)
+ tcp->teardown();
+}
+
+static void print_line(void) {
+ unsigned i;
+
+ for (i = 0; i < 76; i++)
+ streamPut(test_chp, '-');
+ streamWrite(test_chp, (const uint8_t *)"\r\n", 2);
+}
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
+bool _test_fail(const char *msg) {
+
+ test_local_fail = TRUE;
+ test_global_fail = TRUE;
+ test_failure_message = msg;
+ return TRUE;
+}
+
+bool _test_assert(bool condition, const char *msg) {
+
+ if (!condition)
+ return _test_fail(msg);
+ return FALSE;
+}
+
+bool _test_assert_sequence(char *expected, const char *msg) {
+ char *cp = test_tokens_buffer;
+
+ while (cp < test_tokp) {
+ if (*cp++ != *expected++)
+ return _test_fail(msg);
+ }
+
+ if (*expected)
+ return _test_fail(msg);
+
+ clear_tokens();
+
+ return FALSE;
+}
+
+bool _test_assert_time_window(systime_t start,
+ systime_t end,
+ const char *msg) {
+
+ return _test_assert(osalOsIsTimeWithinX(osalOsGetSystemTimeX(), start, end),
+ msg);
+}
+
+/**
+ * @brief Prints a decimal unsigned number.
+ *
+ * @param[in] n the number to be printed
+ *
+ * @api
+ */
+void test_printn(uint32_t n) {
+ char buf[16], *p;
+
+ if (!n)
+ streamPut(test_chp, '0');
+ else {
+ p = buf;
+ while (n)
+ *p++ = (n % 10) + '0', n /= 10;
+ while (p > buf)
+ streamPut(test_chp, *--p);
+ }
+}
+
+/**
+ * @brief Prints a line without final end-of-line.
+ *
+ * @param[in] msgp the message
+ *
+ * @api
+ */
+void test_print(const char *msgp) {
+
+ while (*msgp)
+ streamPut(test_chp, *msgp++);
+}
+
+/**
+ * @brief Prints a line.
+ *
+ * @param[in] msgp the message
+ *
+ * @api
+ */
+void test_println(const char *msgp) {
+
+ test_print(msgp);
+ streamWrite(test_chp, (const uint8_t *)"\r\n", 2);
+}
+
+/**
+ * @brief Emits a token into the tokens buffer.
+ *
+ * @param[in] token the token as a char
+ *
+ * @api
+ */
+void test_emit_token(char token) {
+
+ osalSysLock();
+ if (test_tokp < &test_tokens_buffer[TEST_MAX_TOKENS])
+ *test_tokp++ = token;
+ osalSysUnlock();
+}
+
+/**
+ * @brief Emits a token into the tokens buffer from a critical zone.
+ *
+ * @param[in] token the token as a char
+ *
+ * @iclass
+ */
+void test_emit_token_i(char token) {
+
+ if (test_tokp < &test_tokens_buffer[TEST_MAX_TOKENS])
+ *test_tokp++ = token;
+}
+
+/**
+ * @brief Test execution thread function.
+ *
+ * @param[in] stream pointer to a @p BaseSequentialStream object for test
+ * output
+ * @return A failure boolean value casted to @p msg_t.
+ * @retval FALSE if no errors occurred.
+ * @retval TRUE if one or more tests failed.
+ *
+ * @api
+ */
+msg_t test_execute(BaseSequentialStream *stream) {
+ int i, j;
+
+ test_chp = stream;
+ test_println("");
+#if defined(TEST_SUITE_NAME)
+ test_println("*** " TEST_SUITE_NAME);
+#else
+ test_println("*** ChibiOS test suite");
+#endif
+ test_println("***");
+ test_print("*** Compiled: ");
+ test_println(__DATE__ " - " __TIME__);
+#ifdef PLATFORM_NAME
+ test_print("*** Platform: ");
+ test_println(PLATFORM_NAME);
+#endif
+#ifdef BOARD_NAME
+ test_print("*** Test Board: ");
+ test_println(BOARD_NAME);
+#endif
+ test_println("");
+
+ test_global_fail = FALSE;
+ i = 0;
+ while (test_suite[i]) {
+ j = 0;
+ while (test_suite[i][j]) {
+ print_line();
+ test_print("--- Test Case ");
+ test_printn(i + 1);
+ test_print(".");
+ test_printn(j + 1);
+ test_print(" (");
+ test_print(test_suite[i][j]->name);
+ test_println(")");
+#if TEST_DELAY_BETWEEN_TESTS > 0
+ osalThreadSleepMilliseconds(TEST_DELAY_BETWEEN_TESTS);
+#endif
+ execute_test(test_suite[i][j]);
+ if (test_local_fail) {
+ test_print("--- Result: FAILURE (#");
+ test_printn(test_step);
+ test_print(" [");
+ print_tokens();
+ test_print("] \"");
+ test_print(test_failure_message);
+ test_println("\")");
+ }
+ else
+ test_println("--- Result: SUCCESS");
+ j++;
+ }
+ i++;
+ }
+ print_line();
+ test_println("");
+ test_print("Final result: ");
+ if (test_global_fail)
+ test_println("FAILURE");
+ else
+ test_println("SUCCESS");
+
+ return (msg_t)test_global_fail;
+}
+
+/** @} */
diff --git a/test/lib/ch_test.h b/test/lib/ch_test.h new file mode 100644 index 000000000..2795f48dc --- /dev/null +++ b/test/lib/ch_test.h @@ -0,0 +1,192 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006-2013 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 ch_test.h
+ * @brief Unit Tests Engine Module macros and structures.
+ *
+ * @addtogroup CH_TEST
+ * @{
+ */
+
+#ifndef _CH_TEST_H_
+#define _CH_TEST_H_
+
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Maximum number of entries in the tokens buffer.
+ */
+#if !defined(TEST_MAX_TOKENS) || defined(__DOXYGEN__)
+#define TEST_MAX_TOKENS 16
+#endif
+
+/**
+ * @brief Delay inserted between test cases.
+ */
+#if !defined(TEST_DELAY_BETWEEN_TESTS) || defined(__DOXYGEN__)
+#define TEST_DELAY_BETWEEN_TESTS 200
+#endif
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
+/**
+ * @brief Structure representing a test case.
+ */
+typedef struct {
+ const char *name; /**< @brief Test case name. */
+ void (*setup)(void); /**< @brief Test case preparation function. */
+ void (*teardown)(void); /**< @brief Test case clean up function. */
+ void (*execute)(void); /**< @brief Test case execution function. */
+} testcase_t;
+
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
+
+/**
+ * @brief Sets the step identifier.
+ *
+ * @param[in] step the step number
+ */
+#define test_set_step(step) test_step = (step)
+
+/**
+ * @brief Test failure enforcement.
+ * @note This function can only be called from test_case execute context.
+ *
+ * @param[in] msg failure message as string
+ *
+ * @api
+ */
+#define test_fail(msg) { \
+ _test_fail(msg); \
+ return; \
+}
+
+/**
+ * @brief Test assertion.
+ * @note This function can only be called from test_case execute context.
+ *
+ * @param[in] condition a boolean expression that must be verified to be true
+ * @param[in] msg failure message as string
+ *
+ * @api
+ */
+#define test_assert(condition, msg) { \
+ if (_test_assert(condition, msg)) \
+ return; \
+}
+
+/**
+ * @brief Test assertion with lock.
+ * @note This function can only be called from test_case execute context.
+ *
+ * @param[in] condition a boolean expression that must be verified to be true
+ * @param[in] msg failure message as string
+ *
+ * @api
+ */
+#define test_assert_lock(condition, msg) { \
+ osalSysLock(); \
+ if (_test_assert(condition, msg)) { \
+ osalSysUnlock(); \
+ return; \
+ } \
+ osalSysUnlock(); \
+}
+
+/**
+ * @brief Test sequence assertion.
+ * @note This function can only be called from test_case execute context.
+ *
+ * @param[in] expected string to be matched with the tokens buffer
+ * @param[in] msg failure message as string
+ *
+ * @api
+ */
+#define test_assert_sequence(expected, msg) { \
+ if (_test_assert_sequence(expected, msg)) \
+ return; \
+}
+
+/**
+ * @brief Test time window assertion.
+ * @note This function can only be called from test_case execute context.
+ *
+ * @param[in] start initial time in the window (included)
+ * @param[in] end final time in the window (not included)
+ * @param[in] msg failure message as string
+ *
+ * @api
+ */
+#define test_assert_time_window(start, end, msg) { \
+ if (_test_assert_time_window(start, end, msg)) \
+ return; \
+}
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#if !defined(__DOXYGEN__)
+extern unsigned test_step;
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ bool _test_fail(const char *message);
+ bool _test_assert(bool condition, const char *msg);
+ bool _test_assert_sequence(char *expected, const char *msg);
+ bool _test_assert_time_window(systime_t start,
+ systime_t end,
+ const char *msg);
+ void test_printn(uint32_t n);
+ void test_print(const char *msgp);
+ void test_println(const char *msgp);
+ void test_emit_token(char token);
+ void test_emit_token_i(char token);
+ msg_t test_execute(BaseSequentialStream *stream);
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Late inclusions. */
+/*===========================================================================*/
+
+#include "test_root.h"
+
+#endif /* _CH_TEST_H_ */
+
+/** @} */
diff --git a/test/lib/templates/test_root.c b/test/lib/templates/test_root.c new file mode 100644 index 000000000..47e8c67e4 --- /dev/null +++ b/test/lib/templates/test_root.c @@ -0,0 +1,45 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006-2013 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.c
+ * @brief Test Suite root structures code.
+ *
+ * @addtogroup CH_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_000,
+ NULL
+};
+
+/*===========================================================================*/
+/* Shared code. */
+/*===========================================================================*/
+
+/** @} */
diff --git a/test/lib/templates/test_root.h b/test/lib/templates/test_root.h new file mode 100644 index 000000000..f32b386f8 --- /dev/null +++ b/test/lib/templates/test_root.h @@ -0,0 +1,57 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006-2013 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 CH_TEST_ROOT
+ * @{
+ */
+
+#ifndef _TEST_ROOT_H_
+#define _TEST_ROOT_H_
+
+#include "test_sequence_000.h"
+
+/*===========================================================================*/
+/* Default definitions. */
+/*===========================================================================*/
+
+/* Global test suite name, it is printed on top of the test
+ report header.*/
+#define TEST_SUITE_NAME "Test Suite"
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+extern const testcase_t * const *test_suite[];
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Shared definitions. */
+/*===========================================================================*/
+
+#endif /* _TEST_ROOT_H_ */
+
+/** @} */
diff --git a/test/lib/templates/test_sequence_XXX.c b/test/lib/templates/test_sequence_XXX.c new file mode 100644 index 000000000..af16e544e --- /dev/null +++ b/test/lib/templates/test_sequence_XXX.c @@ -0,0 +1,97 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006-2013 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_XXX Sequence brief description
+ *
+ * File: @ref test_sequence_XXX.c
+ *
+ * <h2>Description</h2>
+ * Sequence detailed description.
+ *
+ * <h2>Test Cases</h2>
+ * - @subpage test_XXX_001
+ * .
+ */
+
+/****************************************************************************
+ * Shared code.
+ ****************************************************************************/
+
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+#if TEST_XXX_000_CONDITION || defined(__DOXYGEN__)
+/**
+ * @page test_XXX_001 Brief description
+ *
+ * <h2>Description</h2>
+ * Detailed description.
+ *
+ * <h2>Conditions</h2>
+ * This test is only executed if the following preprocessor condition
+ * evaluates to true:
+ * - TEST_XXX_001_CONDITION
+ * .
+ *
+ * <h2>Test Steps</h2>
+ * - Step description.
+ * .
+ */
+
+static void test_XXX_001_setup(void) {
+
+}
+
+static void test_XXX_001_teardown(void) {
+
+}
+
+static void test_XXX_001_execute(void) {
+
+ /* Step description.*/
+ test_set_step(1);
+ {
+ }
+}
+
+static const testcase_t test_XXX_001 = {
+ "Brief description",
+ test_XXX_001_setup,
+ test_XXX_001_teardown,
+ test_XXX_001_execute
+};
+#endif /* TEST_XXX_001_CONDITION */
+
+ /****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Sequence brief description.
+ */
+const testcase_t * const test_sequence_XXX[] = {
+#if TEST_XXX_001_CONDITION || defined(__DOXYGEN__)
+ &test_XXX_001,
+#endif
+ NULL
+};
diff --git a/test/lib/templates/test_sequence_XXX.h b/test/lib/templates/test_sequence_XXX.h new file mode 100644 index 000000000..86578fdca --- /dev/null +++ b/test/lib/templates/test_sequence_XXX.h @@ -0,0 +1,22 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006-2013 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.
+*/
+
+#ifndef _TEST_SEQUENCE_XXX_H_
+#define _TEST_SEQUENCE_XXX_H_
+
+extern const testcase_t * const test_sequence_XXX[];
+
+#endif /* _TEST_SEQUENCE_XXX_H_ */
diff --git a/test/nil/test.mk b/test/nil/test.mk new file mode 100644 index 000000000..b0da9731a --- /dev/null +++ b/test/nil/test.mk @@ -0,0 +1,9 @@ +# List of all the ChibiOS/RT test files.
+TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \
+ ${CHIBIOS}/test/nil/test_root.c \
+ ${CHIBIOS}/test/nil/test_sequence_001.c \
+ ${CHIBIOS}/test/nil/test_sequence_002.c
+
+# Required include directories
+TESTINC = ${CHIBIOS}/test/lib \
+ ${CHIBIOS}/test/nil
diff --git a/test/nil/test_root.c b/test/nil/test_root.c new file mode 100644 index 000000000..a8efacba7 --- /dev/null +++ b/test/nil/test_root.c @@ -0,0 +1,75 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006-2013 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.c
+ * @brief Test Suite root structures code.
+ *
+ * @addtogroup CH_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,
+ 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) {
+ thread_t *tp = (thread_t *)arg;
+
+ /* Initializing global resources.*/
+ chSemObjectInit(&gsem1, 0);
+ chSemObjectInit(&gsem2, 0);
+
+ /* Waiting for button push and activation of the test suite.*/
+ while (true) {
+ chSysLock();
+ if (chSemGetCounterI(&gsem1) < 0)
+ chSemSignalI(&gsem1);
+ chSemResetI(&gsem2, 0);
+ chThdResumeI(>r1, MSG_OK);
+ chEvtSignalI(tp, 0x55);
+ chSchRescheduleS();
+ chSysUnlock();
+
+ chThdSleepMilliseconds(250);
+ }
+}
+
+/** @} */
diff --git a/test/nil/test_root.h b/test/nil/test_root.h new file mode 100644 index 000000000..f3ae952d6 --- /dev/null +++ b/test/nil/test_root.h @@ -0,0 +1,64 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006-2013 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 CH_TEST_ROOT
+ * @{
+ */
+
+#ifndef _TEST_ROOT_H_
+#define _TEST_ROOT_H_
+
+#include "nil.h"
+
+#include "test_sequence_001.h"
+#include "test_sequence_002.h"
+
+/*===========================================================================*/
+/* Default definitions. */
+/*===========================================================================*/
+
+/* Global test suite name, it is printed on top of the test
+ report header.*/
+#define TEST_SUITE_NAME "ChibiOS/NIL Test Suite"
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+extern const testcase_t * const *test_suite[];
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ extern semaphore_t gsem1, gsem2;
+ extern thread_reference_t gtr1;
+ extern THD_WORKING_AREA(wa_test_support, 128);
+ THD_FUNCTION(test_support, arg);
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Shared definitions. */
+/*===========================================================================*/
+
+#endif /* _TEST_ROOT_H_ */
+
+/** @} */
diff --git a/test/nil/test_sequence_001.c b/test/nil/test_sequence_001.c new file mode 100644 index 000000000..7d967ef0d --- /dev/null +++ b/test/nil/test_sequence_001.c @@ -0,0 +1,183 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006-2013 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.
+ ****************************************************************************/
+
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+#if TRUE || defined(__DOXYGEN__)
+/**
+ * @page test_001_001 System Tick Counter functionality
+ *
+ * <h2>Description</h2>
+ * The functionality of the API @p chVTGetSystemTimeX() is tested.
+ *
+ * <h2>Conditions</h2>
+ * None.
+ *
+ * <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) {
+ systime_t time;
+
+ /* A System Tick Counter increment is expected, the test simply hangs if
+ it does not happen.*/
+ test_set_step(1);
+ {
+ time = chVTGetSystemTimeX();
+ while (time == chVTGetSystemTimeX()) {
+ }
+ }
+}
+
+static const testcase_t test_001_001 = {
+ "System Tick Counter functionality",
+ NULL,
+ NULL,
+ test_001_001_execute
+};
+#endif /* TRUE */
+
+#if TRUE || defined(__DOXYGEN__)
+/**
+ * @page test_001_002 Thread Sleep functionality
+ *
+ * <h2>Description</h2>
+ * The functionality of the API @p chThdSleep() and derivatives is tested.
+ *
+ * <h2>Conditions</h2>
+ * None.
+ *
+ * <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.
+ * .
+ */
+
+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(100);
+ test_assert_time_window(time + US2ST(100),
+ time + US2ST(100) + 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");
+ }
+
+ 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
+};
+#endif /* TRUE */
+
+ /****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Sequence brief description.
+ */
+const testcase_t * const test_sequence_001[] = {
+#if TRUE || defined(__DOXYGEN__)
+ &test_001_001,
+#endif
+#if TRUE || defined(__DOXYGEN__)
+ &test_001_002,
+#endif
+ NULL
+};
diff --git a/test/nil/test_sequence_001.h b/test/nil/test_sequence_001.h new file mode 100644 index 000000000..47ae8315b --- /dev/null +++ b/test/nil/test_sequence_001.h @@ -0,0 +1,22 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006-2013 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.
+*/
+
+#ifndef _TEST_SEQUENCE_001_H_
+#define _TEST_SEQUENCE_001_H_
+
+extern const testcase_t * const test_sequence_001[];
+
+#endif /* _TEST_SEQUENCE_001_H_ */
diff --git a/test/nil/test_sequence_002.c b/test/nil/test_sequence_002.c new file mode 100644 index 000000000..a687e7f0f --- /dev/null +++ b/test/nil/test_sequence_002.c @@ -0,0 +1,435 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006-2013 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 Synchronization primitives
+ *
+ * File: @ref test_sequence_002.c
+ *
+ * <h2>Description</h2>
+ * This sequence tests the ChibiOS/NIL functionalities related to
+ * threads synchronization.
+ *
+ * <h2>Test Cases</h2>
+ * - @subpage test_002_001
+ * - @subpage test_002_002
+ * .
+ */
+
+/****************************************************************************
+ * Shared code.
+ ****************************************************************************/
+
+static semaphore_t sem1;
+static thread_reference_t tr1;
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+#if TRUE || defined(__DOXYGEN__)
+/**
+ * @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>Conditions</h2>
+ * None.
+ *
+ * <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
+};
+#endif /* TRUE */
+
+#if TRUE || defined(__DOXYGEN__)
+/**
+ * @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>Conditions</h2>
+ * None.
+ *
+ * <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(&sem1, 0);
+}
+
+static void test_002_002_teardown(void) {
+
+ chSemReset(&sem1, 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
+};
+#endif /* TRUE */
+
+#if TRUE || defined(__DOXYGEN__)
+/**
+ * @page test_002_003 Semaphores timeout
+ *
+ * <h2>Description</h2>
+ * Timeout on semaphores is tested.
+ *
+ * <h2>Conditions</h2>
+ * None.
+ *
+ * <h2>Test Steps</h2>
+ * - The function chSemWaitTimeout() is invoked, 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, 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, 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
+};
+#endif /* TRUE */
+
+#if TRUE || defined(__DOXYGEN__)
+/**
+ * @page test_002_004 Suspend and Resume functionality
+ *
+ * <h2>Description</h2>
+ * The functionality of chThdSuspendTimeoutS() and chThdResumeI() is
+ * tested.
+ *
+ * <h2>Conditions</h2>
+ * None.
+ *
+ * <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_002_004_setup(void) {
+
+ tr1 = NULL;
+}
+
+static void test_002_004_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);
+ {
+ msg = chThdSuspendTimeoutS(>r1, TIME_INFINITE);
+ 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);
+ {
+ time = chVTGetSystemTimeX();
+ msg = chThdSuspendTimeoutS(&tr1, MS2ST(1000));
+ 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_002_004 = {
+ "suspend and resume functionality",
+ test_002_004_setup,
+ NULL,
+ test_002_004_execute
+};
+#endif /* TRUE */
+
+#if TRUE || defined(__DOXYGEN__)
+/**
+ * @page test_002_005 Events functionality
+ *
+ * <h2>Description</h2>
+ * Event flags functionality is tested.
+ *
+ * <h2>Conditions</h2>
+ * None.
+ *
+ * <h2>Test Steps</h2>
+ * - A set of event flags are set on the current thread then the
+ * function chVTGetSystemTimeX() 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
+ * chVTGetSystemTimeX() is invoked, after return the events
+ * mask is tested. The thread is signaled by another thread.
+ * -
+ * . The function chVTGetSystemTimeX() is invoked, no event can
+ * wakeup the thread, the function must return because timeout.
+ */
+
+static void test_002_005_setup(void) {
+
+ chSemObjectInit(&sem1, 0);
+}
+
+static void test_002_005_execute(void) {
+ systime_t time;
+ eventmask_t events;
+
+ /* A set of event flags are set on the current thread then the
+ function chVTGetSystemTimeX() 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();
+ chEvtSignalI(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
+ chVTGetSystemTimeX() 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 chVTGetSystemTimeX() is invoked, no event can
+ wakeup the thread, the function must return because timeout.*/
+ test_set_step(3);
+ {
+ chSysLock();
+ time = chVTGetSystemTimeX();
+ events = chEvtWaitAnyTimeoutS(0, MS2ST(1000));
+ chSysUnlock();
+ 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_002_005 = {
+ "events functionality",
+ test_002_005_setup,
+ NULL,
+ test_002_005_execute
+};
+#endif /* TRUE */
+
+ /****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Sequence brief description.
+ */
+const testcase_t * const test_sequence_002[] = {
+#if TRUE || defined(__DOXYGEN__)
+ &test_002_001,
+#endif
+#if TRUE || defined(__DOXYGEN__)
+ &test_002_002,
+#endif
+#if TRUE || defined(__DOXYGEN__)
+ &test_002_003,
+#endif
+#if TRUE || defined(__DOXYGEN__)
+ &test_002_004,
+#endif
+#if TRUE || defined(__DOXYGEN__)
+ &test_002_005,
+#endif
+ NULL
+};
diff --git a/test/nil/test_sequence_002.h b/test/nil/test_sequence_002.h new file mode 100644 index 000000000..e72d037e3 --- /dev/null +++ b/test/nil/test_sequence_002.h @@ -0,0 +1,22 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006-2013 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.
+*/
+
+#ifndef _TEST_SEQUENCE_002_H_
+#define _TEST_SEQUENCE_002_H_
+
+extern const testcase_t * const test_sequence_002[];
+
+#endif /* _TEST_SEQUENCE_002_H_ */
diff --git a/test/coverage/Makefile b/test/rt/coverage/Makefile index d19014202..8a1b3064d 100644 --- a/test/coverage/Makefile +++ b/test/rt/coverage/Makefile @@ -36,7 +36,7 @@ DLIBDIR = # List all default libraries here
DLIBS = -lws2_32
-# Must be a directory in ${CHIBIOS}/os/hal/platforms
+# Must be a directory in $(CHIBIOS)/os/hal/platforms
HOST_TYPE = Win32
#
@@ -62,11 +62,11 @@ UADEFS = # Imported source files
CHIBIOS = ../..
include $(CHIBIOS)/boards/simulator/board.mk
-include ${CHIBIOS}/os/hal/hal.mk
-include ${CHIBIOS}/os/hal/platforms/$(HOST_TYPE)/platform.mk
-include ${CHIBIOS}/os/ports/GCC/SIMIA32/port.mk
-include ${CHIBIOS}/os/kernel/kernel.mk
-include ${CHIBIOS}/test/test.mk
+include $(CHIBIOS)/os/hal/hal.mk
+include $(CHIBIOS)/os/hal/platforms/$(HOST_TYPE)/platform.mk
+include $(CHIBIOS)/os/ports/GCC/SIMIA32/port.mk
+include $(CHIBIOS)/os/kernel/kernel.mk
+include $(CHIBIOS)/test/rt/test.mk
# List C source files here
SRC = ${PORTSRC} \
@@ -75,7 +75,7 @@ SRC = ${PORTSRC} \ ${HALSRC} \
${PLATFORMSRC} \
$(BOARDSRC) \
- ${CHIBIOS}/os/hal/platforms/$(HOST_TYPE)/console.c \
+ $(CHIBIOS)/os/hal/platforms/$(HOST_TYPE)/console.c \
main.c
# List ASM source files here
diff --git a/test/coverage/chconf.h b/test/rt/coverage/chconf.h index 8b0f88662..8b0f88662 100644 --- a/test/coverage/chconf.h +++ b/test/rt/coverage/chconf.h diff --git a/test/coverage/halconf.h b/test/rt/coverage/halconf.h index 516a705a2..14a2e7f6b 100644 --- a/test/coverage/halconf.h +++ b/test/rt/coverage/halconf.h @@ -80,6 +80,13 @@ #endif
/**
+ * @brief Enables the I2S subsystem.
+ */
+#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
+#define HAL_USE_I2S FALSE
+#endif
+
+/**
* @brief Enables the ICU subsystem.
*/
#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
diff --git a/test/coverage/main.c b/test/rt/coverage/main.c index c4f257f0d..c4f257f0d 100644 --- a/test/coverage/main.c +++ b/test/rt/coverage/main.c diff --git a/test/coverage/readme.txt b/test/rt/coverage/readme.txt index fc3595112..fc3595112 100644 --- a/test/coverage/readme.txt +++ b/test/rt/coverage/readme.txt diff --git a/test/test.c b/test/rt/test.c index 1de688a28..0750a0d80 100644 --- a/test/test.c +++ b/test/rt/test.c @@ -56,7 +56,7 @@ static ROMCONST struct testcase * ROMCONST *patterns[] = { NULL
};
-static bool_t local_fail, global_fail;
+static bool local_fail, global_fail;
static unsigned failpoint;
static char tokens_buffer[MAX_TOKENS];
static char *tokp;
@@ -70,7 +70,7 @@ union test_buffers test; /*
* Pointers to the spawned threads.
*/
-Thread *threads[MAX_THREADS];
+thread_t *threads[MAX_THREADS];
/*
* Pointers to the working areas.
@@ -154,7 +154,7 @@ void test_emit_token(char token) { /*
* Assertions.
*/
-bool_t _test_fail(unsigned point) {
+bool _test_fail(unsigned point) {
local_fail = TRUE;
global_fail = TRUE;
@@ -162,14 +162,14 @@ bool_t _test_fail(unsigned point) { return TRUE;
}
-bool_t _test_assert(unsigned point, bool_t condition) {
+bool _test_assert(unsigned point, bool condition) {
if (!condition)
return _test_fail(point);
return FALSE;
}
-bool_t _test_assert_sequence(unsigned point, char *expected) {
+bool _test_assert_sequence(unsigned point, char *expected) {
char *cp = tokens_buffer;
while (cp < tokp) {
if (*cp++ != *expected++)
@@ -181,9 +181,9 @@ bool_t _test_assert_sequence(unsigned point, char *expected) { return FALSE;
}
-bool_t _test_assert_time_window(unsigned point, systime_t start, systime_t end) {
+bool _test_assert_time_window(unsigned point, systime_t start, systime_t end) {
- return _test_assert(point, chTimeIsWithin(start, end));
+ return _test_assert(point, chVTIsSystemTimeWithin(start, end));
}
/*
@@ -224,10 +224,10 @@ void test_wait_threads(void) { void test_cpu_pulse(unsigned duration) {
systime_t start, end, now;
- start = chThdSelf()->p_time;
+ start = chThdGetTicksX(chThdGetSelfX());
end = start + MS2ST(duration);
do {
- now = chThdSelf()->p_time;
+ now = chThdGetTicksX(chThdGetSelfX());
#if defined(SIMULATOR)
ChkIntSources();
#endif
@@ -245,7 +245,7 @@ void test_cpu_pulse(unsigned duration) { systime_t test_wait_tick(void) {
chThdSleep(1);
- return chTimeNow();
+ return chVTGetSystemTime();
}
/*
@@ -255,9 +255,9 @@ systime_t test_wait_tick(void) { /**
* @brief Set to @p TRUE when the test timer reaches its deadline.
*/
-bool_t test_timer_done;
+bool test_timer_done;
-static VirtualTimer vt;
+static virtual_timer_t vt;
static void tmr(void *p) {
(void)p;
@@ -322,19 +322,19 @@ msg_t TestThread(void *p) { test_println(CH_KERNEL_VERSION);
test_print("*** Compiled: ");
test_println(__DATE__ " - " __TIME__);
-#ifdef CH_COMPILER_NAME
+#ifdef PORT_COMPILER_NAME
test_print("*** Compiler: ");
- test_println(CH_COMPILER_NAME);
+ test_println(PORT_COMPILER_NAME);
#endif
test_print("*** Architecture: ");
- test_println(CH_ARCHITECTURE_NAME);
-#ifdef CH_CORE_VARIANT_NAME
+ test_println(PORT_ARCHITECTURE_NAME);
+#ifdef PORT_CORE_VARIANT_NAME
test_print("*** Core Variant: ");
- test_println(CH_CORE_VARIANT_NAME);
+ test_println(PORT_CORE_VARIANT_NAME);
#endif
-#ifdef CH_PORT_INFO
+#ifdef PORT_INFO
test_print("*** Port Info: ");
- test_println(CH_PORT_INFO);
+ test_println(PORT_INFO);
#endif
#ifdef PLATFORM_NAME
test_print("*** Platform: ");
diff --git a/test/test.dox b/test/rt/test.dox index 87c68320b..87c68320b 100644 --- a/test/test.dox +++ b/test/rt/test.dox diff --git a/test/test.h b/test/rt/test.h index fbdfa27f0..1b40a48e0 100644 --- a/test/test.h +++ b/test/rt/test.h @@ -51,7 +51,7 @@ #else
#define THREADS_STACK_SIZE 128
#endif
-#define WA_SIZE THD_WA_SIZE(THREADS_STACK_SIZE)
+#define WA_SIZE THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE)
/**
* @brief Structure representing a test case.
@@ -66,11 +66,11 @@ struct testcase { #ifndef __DOXYGEN__
union test_buffers {
struct {
- WORKING_AREA(T0, THREADS_STACK_SIZE);
- WORKING_AREA(T1, THREADS_STACK_SIZE);
- WORKING_AREA(T2, THREADS_STACK_SIZE);
- WORKING_AREA(T3, THREADS_STACK_SIZE);
- WORKING_AREA(T4, THREADS_STACK_SIZE);
+ THD_WORKING_AREA(T0, THREADS_STACK_SIZE);
+ THD_WORKING_AREA(T1, THREADS_STACK_SIZE);
+ THD_WORKING_AREA(T2, THREADS_STACK_SIZE);
+ THD_WORKING_AREA(T3, THREADS_STACK_SIZE);
+ THD_WORKING_AREA(T4, THREADS_STACK_SIZE);
} wa;
uint8_t buffer[WA_SIZE * 5];
};
@@ -84,10 +84,10 @@ extern "C" { void test_print(const char *msgp);
void test_println(const char *msgp);
void test_emit_token(char token);
- bool_t _test_fail(unsigned point);
- bool_t _test_assert(unsigned point, bool_t condition);
- bool_t _test_assert_sequence(unsigned point, char *expected);
- bool_t _test_assert_time_window(unsigned point, systime_t start, systime_t end);
+ bool _test_fail(unsigned point);
+ bool _test_assert(unsigned point, bool condition);
+ bool _test_assert_sequence(unsigned point, char *expected);
+ bool _test_assert_time_window(unsigned point, systime_t start, systime_t end);
void test_terminate_threads(void);
void test_wait_threads(void);
systime_t test_wait_tick(void);
@@ -162,10 +162,10 @@ extern "C" { }
#if !defined(__DOXYGEN__)
-extern Thread *threads[MAX_THREADS];
+extern thread_t *threads[MAX_THREADS];
extern union test_buffers test;
extern void * ROMCONST wa[];
-extern bool_t test_timer_done;
+extern bool test_timer_done;
#endif
#endif /* _TEST_H_ */
diff --git a/test/rt/test.mk b/test/rt/test.mk new file mode 100644 index 000000000..d2dcf355d --- /dev/null +++ b/test/rt/test.mk @@ -0,0 +1,16 @@ +# List of all the ChibiOS/RT test files.
+TESTSRC = ${CHIBIOS}/test/rt/test.c \
+ ${CHIBIOS}/test/rt/testthd.c \
+ ${CHIBIOS}/test/rt/testsem.c \
+ ${CHIBIOS}/test/rt/testmtx.c \
+ ${CHIBIOS}/test/rt/testmsg.c \
+ ${CHIBIOS}/test/rt/testmbox.c \
+ ${CHIBIOS}/test/rt/testevt.c \
+ ${CHIBIOS}/test/rt/testheap.c \
+ ${CHIBIOS}/test/rt/testpools.c \
+ ${CHIBIOS}/test/rt/testdyn.c \
+ ${CHIBIOS}/test/rt/testqueues.c \
+ ${CHIBIOS}/test/rt/testbmk.c
+
+# Required include directories
+TESTINC = ${CHIBIOS}/test/rt
diff --git a/test/testbmk.c b/test/rt/testbmk.c index a3bd767ee..4f648fa14 100644 --- a/test/testbmk.c +++ b/test/rt/testbmk.c @@ -56,13 +56,13 @@ * @brief Kernel Benchmarks header file
*/
-static Semaphore sem1;
-#if CH_USE_MUTEXES || defined(__DOXYGEN__)
-static Mutex mtx1;
+static semaphore_t sem1;
+#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
+static mutex_t mtx1;
#endif
static msg_t thread1(void *p) {
- Thread *tp;
+ thread_t *tp;
msg_t msg;
(void)p;
@@ -77,7 +77,7 @@ static msg_t thread1(void *p) { #ifdef __GNUC__
__attribute__((noinline))
#endif
-static unsigned int msg_loop_test(Thread *tp) {
+static unsigned int msg_loop_test(thread_t *tp) {
uint32_t n = 0;
test_wait_tick();
@@ -105,7 +105,7 @@ static unsigned int msg_loop_test(Thread *tp) { static void bmk1_execute(void) {
uint32_t n;
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread1, NULL);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread1, NULL);
n = msg_loop_test(threads[0]);
test_wait_threads();
test_print("--- Score : ");
@@ -134,7 +134,7 @@ ROMCONST struct testcase testbmk1 = { static void bmk2_execute(void) {
uint32_t n;
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL);
n = msg_loop_test(threads[0]);
test_wait_threads();
test_print("--- Score : ");
@@ -169,11 +169,11 @@ static msg_t thread2(void *p) { static void bmk3_execute(void) {
uint32_t n;
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL);
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-2, thread2, NULL);
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread2, NULL);
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-4, thread2, NULL);
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-5, thread2, NULL);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL);
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-2, thread2, NULL);
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread2, NULL);
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-4, thread2, NULL);
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-5, thread2, NULL);
n = msg_loop_test(threads[0]);
test_wait_threads();
test_print("--- Score : ");
@@ -202,32 +202,33 @@ ROMCONST struct testcase testbmk3 = { msg_t thread4(void *p) {
msg_t msg;
- Thread *self = chThdSelf();
+ thread_t *self = chThdGetSelfX();
(void)p;
chSysLock();
do {
- chSchGoSleepS(THD_STATE_SUSPENDED);
+ chSchGoSleepS(CH_STATE_SUSPENDED);
msg = self->p_u.rdymsg;
- } while (msg == RDY_OK);
+ } while (msg == MSG_OK);
chSysUnlock();
return 0;
}
static void bmk4_execute(void) {
- Thread *tp;
+ thread_t *tp;
uint32_t n;
- tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread4, NULL);
+ tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1,
+ thread4, NULL);
n = 0;
test_wait_tick();
test_start_timer(1000);
do {
chSysLock();
- chSchWakeupS(tp, RDY_OK);
- chSchWakeupS(tp, RDY_OK);
- chSchWakeupS(tp, RDY_OK);
- chSchWakeupS(tp, RDY_OK);
+ chSchWakeupS(tp, MSG_OK);
+ chSchWakeupS(tp, MSG_OK);
+ chSchWakeupS(tp, MSG_OK);
+ chSchWakeupS(tp, MSG_OK);
chSysUnlock();
n += 4;
#if defined(SIMULATOR)
@@ -235,7 +236,7 @@ static void bmk4_execute(void) { #endif
} while (!test_timer_done);
chSysLock();
- chSchWakeupS(tp, RDY_TIMEOUT);
+ chSchWakeupS(tp, MSG_TIMEOUT);
chSysUnlock();
test_wait_threads();
@@ -266,7 +267,7 @@ static void bmk5_execute(void) { uint32_t n = 0;
void *wap = wa[0];
- tprio_t prio = chThdGetPriority() - 1;
+ tprio_t prio = chThdGetPriorityX() - 1;
test_wait_tick();
test_start_timer(1000);
do {
@@ -305,7 +306,7 @@ static void bmk6_execute(void) { uint32_t n = 0;
void *wap = wa[0];
- tprio_t prio = chThdGetPriority() + 1;
+ tprio_t prio = chThdGetPriorityX() + 1;
test_wait_tick();
test_start_timer(1000);
do {
@@ -341,24 +342,24 @@ ROMCONST struct testcase testbmk6 = { static msg_t thread3(void *p) {
(void)p;
- while (!chThdShouldTerminate())
+ while (!chThdShouldTerminateX())
chSemWait(&sem1);
return 0;
}
static void bmk7_setup(void) {
- chSemInit(&sem1, 0);
+ chSemObjectInit(&sem1, 0);
}
static void bmk7_execute(void) {
uint32_t n;
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread3, NULL);
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()+4, thread3, NULL);
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()+3, thread3, NULL);
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()+2, thread3, NULL);
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()+1, thread3, NULL);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread3, NULL);
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()+4, thread3, NULL);
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()+3, thread3, NULL);
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()+2, thread3, NULL);
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()+1, thread3, NULL);
n = 0;
test_wait_tick();
@@ -409,7 +410,7 @@ static msg_t thread8(void *p) { #if defined(SIMULATOR)
ChkIntSources();
#endif
- } while(!chThdShouldTerminate());
+ } while(!chThdShouldTerminateX());
return 0;
}
@@ -419,11 +420,11 @@ static void bmk8_execute(void) { n = 0;
test_wait_tick();
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
chThdSleepSeconds(1);
test_terminate_threads();
@@ -441,7 +442,7 @@ ROMCONST struct testcase testbmk8 = { bmk8_execute
};
-#if CH_USE_QUEUES || defined(__DOXYGEN__)
+#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__)
/**
* @page test_benchmarks_009 I/O Queues throughput
*
@@ -455,9 +456,9 @@ ROMCONST struct testcase testbmk8 = { static void bmk9_execute(void) {
uint32_t n;
static uint8_t ib[16];
- static InputQueue iq;
+ static input_queue_t iq;
- chIQInit(&iq, ib, sizeof(ib), NULL, NULL);
+ chIQObjectInit(&iq, ib, sizeof(ib), NULL, NULL);
n = 0;
test_wait_tick();
test_start_timer(1000);
@@ -488,7 +489,7 @@ ROMCONST struct testcase testbmk9 = { NULL,
bmk9_execute
};
-#endif /* CH_USE_QUEUES */
+#endif /* CH_CFG_USE_QUEUES */
/**
* @page test_benchmarks_010 Virtual Timers set/reset performance
@@ -502,17 +503,17 @@ ROMCONST struct testcase testbmk9 = { static void tmo(void *param) {(void)param;}
static void bmk10_execute(void) {
- static VirtualTimer vt1, vt2;
+ static virtual_timer_t vt1, vt2;
uint32_t n = 0;
test_wait_tick();
test_start_timer(1000);
do {
chSysLock();
- chVTSetI(&vt1, 1, tmo, NULL);
- chVTSetI(&vt2, 10000, tmo, NULL);
- chVTResetI(&vt1);
- chVTResetI(&vt2);
+ chVTDoSetI(&vt1, 1, tmo, NULL);
+ chVTDoSetI(&vt2, 10000, tmo, NULL);
+ chVTDoResetI(&vt1);
+ chVTDoResetI(&vt2);
chSysUnlock();
n++;
#if defined(SIMULATOR)
@@ -531,7 +532,6 @@ ROMCONST struct testcase testbmk10 = { bmk10_execute
};
-#if CH_USE_SEMAPHORES || defined(__DOXYGEN__)
/**
* @page test_benchmarks_011 Semaphores wait/signal performance
*
@@ -544,7 +544,7 @@ ROMCONST struct testcase testbmk10 = { static void bmk11_setup(void) {
- chSemInit(&sem1, 1);
+ chSemObjectInit(&sem1, 1);
}
static void bmk11_execute(void) {
@@ -577,9 +577,8 @@ ROMCONST struct testcase testbmk11 = { NULL,
bmk11_execute
};
-#endif /* CH_USE_SEMAPHORES */
-#if CH_USE_MUTEXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
/**
* @page test_benchmarks_012 Mutexes lock/unlock performance
*
@@ -592,7 +591,7 @@ ROMCONST struct testcase testbmk11 = { static void bmk12_setup(void) {
- chMtxInit(&mtx1);
+ chMtxObjectInit(&mtx1);
}
static void bmk12_execute(void) {
@@ -602,13 +601,13 @@ static void bmk12_execute(void) { test_start_timer(1000);
do {
chMtxLock(&mtx1);
- chMtxUnlock();
+ chMtxUnlock(&mtx1);
chMtxLock(&mtx1);
- chMtxUnlock();
+ chMtxUnlock(&mtx1);
chMtxLock(&mtx1);
- chMtxUnlock();
+ chMtxUnlock(&mtx1);
chMtxLock(&mtx1);
- chMtxUnlock();
+ chMtxUnlock(&mtx1);
n++;
#if defined(SIMULATOR)
ChkIntSources();
@@ -637,49 +636,47 @@ ROMCONST struct testcase testbmk12 = { static void bmk13_execute(void) {
test_print("--- System: ");
- test_printn(sizeof(ReadyList) + sizeof(VTList) +
+ test_printn(sizeof(ready_list_t) + sizeof(virtual_timers_list_t) +
PORT_IDLE_THREAD_STACK_SIZE +
- (sizeof(Thread) + sizeof(struct intctx) +
- sizeof(struct extctx) +
+ (sizeof(thread_t) + sizeof(struct port_intctx) +
+ sizeof(struct port_extctx) +
PORT_INT_REQUIRED_STACK) * 2);
test_println(" bytes");
test_print("--- Thread: ");
- test_printn(sizeof(Thread));
+ test_printn(sizeof(thread_t));
test_println(" bytes");
test_print("--- Timer : ");
- test_printn(sizeof(VirtualTimer));
+ test_printn(sizeof(virtual_timer_t));
test_println(" bytes");
-#if CH_USE_SEMAPHORES || defined(__DOXYGEN__)
test_print("--- Semaph: ");
- test_printn(sizeof(Semaphore));
+ test_printn(sizeof(semaphore_t));
test_println(" bytes");
-#endif
-#if CH_USE_EVENTS || defined(__DOXYGEN__)
+#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
test_print("--- EventS: ");
- test_printn(sizeof(EventSource));
+ test_printn(sizeof(event_source_t));
test_println(" bytes");
test_print("--- EventL: ");
- test_printn(sizeof(EventListener));
+ test_printn(sizeof(event_listener_t));
test_println(" bytes");
#endif
-#if CH_USE_MUTEXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
test_print("--- Mutex : ");
- test_printn(sizeof(Mutex));
+ test_printn(sizeof(mutex_t));
test_println(" bytes");
#endif
-#if CH_USE_CONDVARS || defined(__DOXYGEN__)
+#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__)
test_print("--- CondV.: ");
- test_printn(sizeof(CondVar));
+ test_printn(sizeof(condition_variable_t));
test_println(" bytes");
#endif
-#if CH_USE_QUEUES || defined(__DOXYGEN__)
+#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__)
test_print("--- Queue : ");
- test_printn(sizeof(GenericQueue));
+ test_printn(sizeof(io_queue_t));
test_println(" bytes");
#endif
-#if CH_USE_MAILBOXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
test_print("--- MailB.: ");
- test_printn(sizeof(Mailbox));
+ test_printn(sizeof(mailbox_t));
test_println(" bytes");
#endif
}
@@ -704,14 +701,12 @@ ROMCONST struct testcase * ROMCONST patternbmk[] = { &testbmk6,
&testbmk7,
&testbmk8,
-#if CH_USE_QUEUES || defined(__DOXYGEN__)
+#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__)
&testbmk9,
#endif
&testbmk10,
-#if CH_USE_SEMAPHORES || defined(__DOXYGEN__)
&testbmk11,
-#endif
-#if CH_USE_MUTEXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
&testbmk12,
#endif
&testbmk13,
diff --git a/test/testbmk.h b/test/rt/testbmk.h index 8d7514f74..8d7514f74 100644 --- a/test/testbmk.h +++ b/test/rt/testbmk.h diff --git a/test/testdyn.c b/test/rt/testdyn.c index 8e54c81a1..bf9f127a0 100644 --- a/test/testdyn.c +++ b/test/rt/testdyn.c @@ -31,9 +31,9 @@ *
* <h2>Preconditions</h2>
* The module requires the following kernel options:
- * - @p CH_USE_DYNAMIC
- * - @p CH_USE_HEAP
- * - @p CH_USE_MEMPOOLS
+ * - @p CH_CFG_USE_DYNAMIC
+ * - @p CH_CFG_USE_HEAP
+ * - @p CH_CFG_USE_MEMPOOLS
* .
* In case some of the required options are not enabled then some or all tests
* may be skipped.
@@ -49,12 +49,12 @@ * @brief Dynamic thread APIs test header file
*/
-#if CH_USE_DYNAMIC || defined(__DOXYGEN__)
-#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
-static MemoryHeap heap1;
+#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__)
+#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
+static memory_heap_t heap1;
#endif
-#if CH_USE_MEMPOOLS || defined(__DOXYGEN__)
-static MemoryPool mp1;
+#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__)
+static memory_pool_t mp1;
#endif
/**
@@ -74,27 +74,30 @@ static msg_t thread(void *p) { return 0;
}
-#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
+#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
static void dyn1_setup(void) {
- chHeapInit(&heap1, test.buffer, sizeof(union test_buffers));
+ chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers));
}
static void dyn1_execute(void) {
size_t n, sz;
void *p1;
- tprio_t prio = chThdGetPriority();
+ tprio_t prio = chThdGetPriorityX();
(void)chHeapStatus(&heap1, &sz);
/* Starting threads from the heap. */
- threads[0] = chThdCreateFromHeap(&heap1, THD_WA_SIZE(THREADS_STACK_SIZE),
+ threads[0] = chThdCreateFromHeap(&heap1,
+ THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE),
prio-1, thread, "A");
- threads[1] = chThdCreateFromHeap(&heap1, THD_WA_SIZE(THREADS_STACK_SIZE),
+ threads[1] = chThdCreateFromHeap(&heap1,
+ THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE),
prio-2, thread, "B");
/* Allocating the whole heap in order to make the thread creation fail.*/
(void)chHeapStatus(&heap1, &n);
p1 = chHeapAlloc(&heap1, n);
- threads[2] = chThdCreateFromHeap(&heap1, THD_WA_SIZE(THREADS_STACK_SIZE),
+ threads[2] = chThdCreateFromHeap(&heap1,
+ THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE),
prio-3, thread, "C");
chHeapFree(p1);
@@ -120,9 +123,9 @@ ROMCONST struct testcase testdyn1 = { NULL,
dyn1_execute
};
-#endif /* (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) */
+#endif /* (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) */
-#if CH_USE_MEMPOOLS || defined(__DOXYGEN__)
+#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__)
/**
* @page test_dynamic_002 Threads creation from Memory Pool
*
@@ -135,12 +138,12 @@ ROMCONST struct testcase testdyn1 = { static void dyn2_setup(void) {
- chPoolInit(&mp1, THD_WA_SIZE(THREADS_STACK_SIZE), NULL);
+ chPoolObjectInit(&mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL);
}
static void dyn2_execute(void) {
int i;
- tprio_t prio = chThdGetPriority();
+ tprio_t prio = chThdGetPriorityX();
/* Adding the WAs to the pool. */
for (i = 0; i < 4; i++)
@@ -176,9 +179,9 @@ ROMCONST struct testcase testdyn2 = { NULL,
dyn2_execute
};
-#endif /* CH_USE_MEMPOOLS */
+#endif /* CH_CFG_USE_MEMPOOLS */
-#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP && CH_USE_REGISTRY) || \
+#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP && CH_CFG_USE_REGISTRY) || \
defined(__DOXYGEN__)
/**
* @page test_dynamic_003 Registry and References test
@@ -188,9 +191,9 @@ ROMCONST struct testcase testdyn2 = { * coverage.
*/
-static bool_t regfind(Thread *tp) {
- Thread *ftp;
- bool_t found = FALSE;
+static bool regfind(thread_t *tp) {
+ thread_t *ftp;
+ bool found = false;
ftp = chRegFirstThread();
do {
@@ -202,12 +205,12 @@ static bool_t regfind(Thread *tp) { static void dyn3_setup(void) {
- chHeapInit(&heap1, test.buffer, sizeof(union test_buffers));
+ chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers));
}
static void dyn3_execute(void) {
- Thread *tp;
- tprio_t prio = chThdGetPriority();
+ thread_t *tp;
+ tprio_t prio = chThdGetPriorityX();
/* Testing references increase/decrease and final detach.*/
tp = chThdCreateFromHeap(&heap1, WA_SIZE, prio-1, thread, "A");
@@ -224,11 +227,11 @@ static void dyn3_execute(void) { /* Detach and let the thread execute and terminate.*/
chThdRelease(tp);
test_assert(6, tp->p_refs == 0, "detach failure");
- test_assert(7, tp->p_state == THD_STATE_READY, "invalid state");
+ test_assert(7, tp->p_state == CH_STATE_READY, "invalid state");
test_assert(8, regfind(tp), "thread disappeared");
test_assert(9, regfind(tp), "thread disappeared");
chThdSleepMilliseconds(50); /* The thread just terminates. */
- test_assert(10, tp->p_state == THD_STATE_FINAL, "invalid state");
+ test_assert(10, tp->p_state == CH_STATE_FINAL, "invalid state");
/* Clearing the zombie by scanning the registry.*/
test_assert(11, regfind(tp), "thread disappeared");
@@ -241,21 +244,21 @@ ROMCONST struct testcase testdyn3 = { NULL,
dyn3_execute
};
-#endif /* CH_USE_HEAP && CH_USE_REGISTRY */
-#endif /* CH_USE_DYNAMIC */
+#endif /* CH_CFG_USE_HEAP && CH_CFG_USE_REGISTRY */
+#endif /* CH_CFG_USE_DYNAMIC */
/**
* @brief Test sequence for dynamic APIs.
*/
ROMCONST struct testcase * ROMCONST patterndyn[] = {
-#if CH_USE_DYNAMIC || defined(__DOXYGEN__)
-#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
+#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__)
+#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
&testdyn1,
#endif
-#if CH_USE_MEMPOOLS || defined(__DOXYGEN__)
+#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__)
&testdyn2,
#endif
-#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP && CH_USE_REGISTRY) || \
+#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP && CH_CFG_USE_REGISTRY) || \
defined(__DOXYGEN__)
&testdyn3,
#endif
diff --git a/test/testdyn.h b/test/rt/testdyn.h index 6b25dbb30..6b25dbb30 100644 --- a/test/testdyn.h +++ b/test/rt/testdyn.h diff --git a/test/testevt.c b/test/rt/testevt.c index 0a014374e..49507f067 100644 --- a/test/testevt.c +++ b/test/rt/testevt.c @@ -30,8 +30,8 @@ *
* <h2>Preconditions</h2>
* The module requires the following kernel options:
- * - @p CH_USE_EVENTS
- * - @p CH_USE_EVENTS_TIMEOUT
+ * - @p CH_CFG_USE_EVENTS
+ * - @p CH_CFG_USE_EVENTS_TIMEOUT
* .
* In case some of the required options are not enabled then some or all tests
* may be skipped.
@@ -47,7 +47,7 @@ * @brief Events test header file
*/
-#if CH_USE_EVENTS || defined(__DOXYGEN__)
+#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
#define ALLOWED_DELAY MS2ST(5)
@@ -83,12 +83,12 @@ static void h3(eventid_t id) {(void)id;test_emit_token('C');} static ROMCONST evhandler_t evhndl[] = {h1, h2, h3};
static void evt1_execute(void) {
- EventListener el1, el2;
+ event_listener_t el1, el2;
/*
* Testing chEvtRegisterMask() and chEvtUnregister().
*/
- chEvtInit(&es1);
+ chEvtObjectInit(&es1);
chEvtRegisterMask(&es1, &el1, 1);
chEvtRegisterMask(&es1, &el2, 2);
test_assert(1, chEvtIsListeningI(&es1), "no listener");
@@ -133,7 +133,7 @@ static void evt2_setup(void) { static msg_t thread1(void *p) {
chThdSleepMilliseconds(50);
- chEvtSignal((Thread *)p, 1);
+ chEvtSignal((thread_t *)p, 1);
return 0;
}
@@ -148,7 +148,7 @@ static msg_t thread2(void *p) { static void evt2_execute(void) {
eventmask_t m;
- EventListener el1, el2;
+ event_listener_t el1, el2;
systime_t target_time;
/*
@@ -166,9 +166,9 @@ static void evt2_execute(void) { * Test on chEvtWaitOne() with wait.
*/
test_wait_tick();
- target_time = chTimeNow() + MS2ST(50);
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1,
- thread1, chThdSelf());
+ target_time = chVTGetSystemTime() + MS2ST(50);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1,
+ thread1, chThdGetSelfX());
m = chEvtWaitOne(ALL_EVENTS);
test_assert_time_window(4, target_time, target_time + ALLOWED_DELAY);
test_assert(5, m == 1, "single event error");
@@ -189,9 +189,9 @@ static void evt2_execute(void) { * Test on chEvtWaitAny() with wait.
*/
test_wait_tick();
- target_time = chTimeNow() + MS2ST(50);
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1,
- thread1, chThdSelf());
+ target_time = chVTGetSystemTime() + MS2ST(50);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1,
+ thread1, chThdGetSelfX());
m = chEvtWaitAny(ALL_EVENTS);
test_assert_time_window(9, target_time, target_time + ALLOWED_DELAY);
test_assert(10, m == 1, "single event error");
@@ -202,13 +202,13 @@ static void evt2_execute(void) { /*
* Test on chEvtWaitAll().
*/
- chEvtInit(&es1);
- chEvtInit(&es2);
+ chEvtObjectInit(&es1);
+ chEvtObjectInit(&es2);
chEvtRegisterMask(&es1, &el1, 1);
chEvtRegisterMask(&es2, &el2, 4);
test_wait_tick();
- target_time = chTimeNow() + MS2ST(50);
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1,
+ target_time = chVTGetSystemTime() + MS2ST(50);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1,
thread2, "A");
m = chEvtWaitAll(5);
test_assert_time_window(12, target_time, target_time + ALLOWED_DELAY);
@@ -228,7 +228,7 @@ ROMCONST struct testcase testevt2 = { evt2_execute
};
-#if CH_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__)
+#if CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__)
/**
* @page test_events_003 Events timeout
*
@@ -275,20 +275,20 @@ ROMCONST struct testcase testevt3 = { NULL,
evt3_execute
};
-#endif /* CH_USE_EVENTS_TIMEOUT */
+#endif /* CH_CFG_USE_EVENTS_TIMEOUT */
/**
* @brief Test sequence for events.
*/
ROMCONST struct testcase * ROMCONST patternevt[] = {
-#if CH_USE_EVENTS || defined(__DOXYGEN__)
+#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
&testevt1,
&testevt2,
-#if CH_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__)
+#if CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__)
&testevt3,
#endif
#endif
NULL
};
-#endif /* CH_USE_EVENTS */
+#endif /* CH_CFG_USE_EVENTS */
diff --git a/test/testevt.h b/test/rt/testevt.h index 7d189c17f..7d189c17f 100644 --- a/test/testevt.h +++ b/test/rt/testevt.h diff --git a/test/testheap.c b/test/rt/testheap.c index 9baa95d82..d257a4362 100644 --- a/test/testheap.c +++ b/test/rt/testheap.c @@ -30,7 +30,7 @@ *
* <h2>Preconditions</h2>
* The module requires the following kernel options:
- * - @p CH_USE_HEAP
+ * - @p CH_CFG_USE_HEAP
* .
* In case some of the required options are not enabled then some or all tests
* may be skipped.
@@ -44,11 +44,11 @@ * @brief Heap header file
*/
-#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
+#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
#define SIZE 16
-static MemoryHeap test_heap;
+static memory_heap_t test_heap;
/**
* @page test_heap_001 Allocation and fragmentation test
@@ -63,7 +63,7 @@ static MemoryHeap test_heap; static void heap1_setup(void) {
- chHeapInit(&test_heap, test.buffer, sizeof(union test_buffers));
+ chHeapObjectInit(&test_heap, test.buffer, sizeof(union test_buffers));
}
static void heap1_execute(void) {
@@ -146,13 +146,13 @@ ROMCONST struct testcase testheap1 = { heap1_execute
};
-#endif /* CH_USE_HEAP.*/
+#endif /* CH_CFG_USE_HEAP.*/
/**
* @brief Test sequence for heap.
*/
ROMCONST struct testcase * ROMCONST patternheap[] = {
-#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
+#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
&testheap1,
#endif
NULL
diff --git a/test/testheap.h b/test/rt/testheap.h index 24d577445..24d577445 100644 --- a/test/testheap.h +++ b/test/rt/testheap.h diff --git a/test/testmbox.c b/test/rt/testmbox.c index 35a22b88c..a9f57e961 100644 --- a/test/testmbox.c +++ b/test/rt/testmbox.c @@ -33,7 +33,7 @@ *
* <h2>Preconditions</h2>
* The module requires the following kernel options:
- * - @p CH_USE_MAILBOXES
+ * - @p CH_CFG_USE_MAILBOXES
* .
* In case some of the required options are not enabled then some or all tests
* may be skipped.
@@ -47,7 +47,7 @@ * @brief Mailboxes header file
*/
-#if CH_USE_MAILBOXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
#define ALLOWED_DELAY MS2ST(5)
#define MB_SIZE 5
@@ -70,7 +70,7 @@ static MAILBOX_DECL(mb1, test.wa.T0, MB_SIZE); static void mbox1_setup(void) {
- chMBInit(&mb1, (msg_t *)test.wa.T0, MB_SIZE);
+ chMBObjectInit(&mb1, (msg_t *)test.wa.T0, MB_SIZE);
}
static void mbox1_execute(void) {
@@ -80,33 +80,33 @@ static void mbox1_execute(void) { /*
* Testing initial space.
*/
- test_assert(1, chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size");
+ test_assert_lock(1, chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size");
/*
* Testing enqueuing and backward circularity.
*/
for (i = 0; i < MB_SIZE - 1; i++) {
msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE);
- test_assert(2, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(2, msg1 == MSG_OK, "wrong wake-up message");
}
msg1 = chMBPostAhead(&mb1, 'A', TIME_INFINITE);
- test_assert(3, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(3, msg1 == MSG_OK, "wrong wake-up message");
/*
* Testing post timeout.
*/
msg1 = chMBPost(&mb1, 'X', 1);
- test_assert(4, msg1 == RDY_TIMEOUT, "wrong wake-up message");
+ test_assert(4, msg1 == MSG_TIMEOUT, "wrong wake-up message");
chSysLock();
msg1 = chMBPostI(&mb1, 'X');
chSysUnlock();
- test_assert(5, msg1 == RDY_TIMEOUT, "wrong wake-up message");
+ test_assert(5, msg1 == MSG_TIMEOUT, "wrong wake-up message");
msg1 = chMBPostAhead(&mb1, 'X', 1);
- test_assert(6, msg1 == RDY_TIMEOUT, "wrong wake-up message");
+ test_assert(6, msg1 == MSG_TIMEOUT, "wrong wake-up message");
chSysLock();
msg1 = chMBPostAheadI(&mb1, 'X');
chSysUnlock();
- test_assert(7, msg1 == RDY_TIMEOUT, "wrong wake-up message");
+ test_assert(7, msg1 == MSG_TIMEOUT, "wrong wake-up message");
/*
* Testing final conditions.
@@ -120,7 +120,7 @@ static void mbox1_execute(void) { */
for (i = 0; i < MB_SIZE; i++) {
msg1 = chMBFetch(&mb1, &msg2, TIME_INFINITE);
- test_assert(11, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(11, msg1 == MSG_OK, "wrong wake-up message");
test_emit_token(msg2);
}
test_assert_sequence(12, "ABCDE");
@@ -129,9 +129,9 @@ static void mbox1_execute(void) { * Testing buffer circularity.
*/
msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE);
- test_assert(13, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(13, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBFetch(&mb1, &msg2, TIME_INFINITE);
- test_assert(14, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(14, msg1 == MSG_OK, "wrong wake-up message");
test_assert(15, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base");
test_assert(16, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base");
@@ -139,11 +139,11 @@ static void mbox1_execute(void) { * Testing fetch timeout.
*/
msg1 = chMBFetch(&mb1, &msg2, 1);
- test_assert(17, msg1 == RDY_TIMEOUT, "wrong wake-up message");
+ test_assert(17, msg1 == MSG_TIMEOUT, "wrong wake-up message");
chSysLock();
msg1 = chMBFetchI(&mb1, &msg2);
chSysUnlock();
- test_assert(18, msg1 == RDY_TIMEOUT, "wrong wake-up message");
+ test_assert(18, msg1 == MSG_TIMEOUT, "wrong wake-up message");
/*
* Testing final conditions.
@@ -157,22 +157,22 @@ static void mbox1_execute(void) { */
chSysLock();
msg1 = chMBPostI(&mb1, 'A');
- test_assert(22, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(22, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostI(&mb1, 'B');
- test_assert(23, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(23, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostI(&mb1, 'C');
- test_assert(24, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(24, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostI(&mb1, 'D');
- test_assert(25, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(25, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostI(&mb1, 'E');
chSysUnlock();
- test_assert(26, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(26, msg1 == MSG_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_assert(28, msg1 == MSG_OK, "wrong wake-up message");
test_emit_token(msg2);
}
test_assert_sequence(29, "ABCDE");
@@ -182,22 +182,22 @@ static void mbox1_execute(void) { chSysLock();
msg1 = chMBPostAheadI(&mb1, 'E');
- test_assert(33, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(33, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'D');
- test_assert(34, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(34, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'C');
- test_assert(35, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(35, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'B');
- test_assert(36, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(36, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'A');
chSysUnlock();
- test_assert(37, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(37, msg1 == MSG_OK, "wrong wake-up message");
test_assert(38, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
for (i = 0; i < MB_SIZE; i++) {
chSysLock();
msg1 = chMBFetchI(&mb1, &msg2);
chSysUnlock();
- test_assert(39, msg1 == RDY_OK, "wrong wake-up message");
+ test_assert(39, msg1 == MSG_OK, "wrong wake-up message");
test_emit_token(msg2);
}
test_assert_sequence(40, "ABCDE");
@@ -226,13 +226,13 @@ ROMCONST struct testcase testmbox1 = { mbox1_execute
};
-#endif /* CH_USE_MAILBOXES */
+#endif /* CH_CFG_USE_MAILBOXES */
/**
* @brief Test sequence for mailboxes.
*/
ROMCONST struct testcase * ROMCONST patternmbox[] = {
-#if CH_USE_MAILBOXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
&testmbox1,
#endif
NULL
diff --git a/test/testmbox.h b/test/rt/testmbox.h index 5b61ec888..5b61ec888 100644 --- a/test/testmbox.h +++ b/test/rt/testmbox.h diff --git a/test/testmsg.c b/test/rt/testmsg.c index 3ffaa6bf7..b3b2aedcd 100644 --- a/test/testmsg.c +++ b/test/rt/testmsg.c @@ -31,7 +31,7 @@ *
* <h2>Preconditions</h2>
* The module requires the following kernel options:
- * - @p CH_USE_MESSAGES
+ * - @p CH_CFG_USE_MESSAGES
* .
* In case some of the required options are not enabled then some or all tests
* may be skipped.
@@ -45,7 +45,7 @@ * @brief Messages header file
*/
-#if CH_USE_MESSAGES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__)
/**
* @page test_msg_001 Messages Server loop
@@ -65,14 +65,14 @@ static msg_t thread(void *p) { }
static void msg1_execute(void) {
- Thread *tp;
+ thread_t *tp;
msg_t msg;
/*
* Testing the whole messages loop.
*/
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() + 1,
- thread, chThdSelf());
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() + 1,
+ thread, chThdGetSelfX());
tp = chMsgWait();
msg = chMsgGet(tp);
chMsgRelease(tp, msg);
@@ -95,13 +95,13 @@ ROMCONST struct testcase testmsg1 = { msg1_execute
};
-#endif /* CH_USE_MESSAGES */
+#endif /* CH_CFG_USE_MESSAGES */
/**
* @brief Test sequence for messages.
*/
ROMCONST struct testcase * ROMCONST patternmsg[] = {
-#if CH_USE_MESSAGES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__)
&testmsg1,
#endif
NULL
diff --git a/test/testmsg.h b/test/rt/testmsg.h index 47f072d14..47f072d14 100644 --- a/test/testmsg.h +++ b/test/rt/testmsg.h diff --git a/test/testmtx.c b/test/rt/testmtx.c index 83c6278b1..ccf7b9497 100644 --- a/test/testmtx.c +++ b/test/rt/testmtx.c @@ -33,8 +33,8 @@ *
* <h2>Preconditions</h2>
* The module requires the following kernel options:
- * - @p CH_USE_MUTEXES
- * - @p CH_USE_CONDVARS
+ * - @p CH_CFG_USE_MUTEXES
+ * - @p CH_CFG_USE_CONDVARS
* - @p CH_DBG_THREADS_PROFILING
* .
* In case some of the required options are not enabled then some or all tests
@@ -56,7 +56,7 @@ * @brief Mutexes and CondVars test header file
*/
-#if CH_USE_MUTEXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
#define ALLOWED_DELAY 5
@@ -67,7 +67,7 @@ */
static MUTEX_DECL(m1);
static MUTEX_DECL(m2);
-#if CH_USE_CONDVARS || defined(__DOXYGEN__)
+#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__)
static CONDVAR_DECL(c1);
#endif
@@ -83,29 +83,29 @@ static CONDVAR_DECL(c1); static void mtx1_setup(void) {
- chMtxInit(&m1);
+ chMtxObjectInit(&m1);
}
static msg_t thread1(void *p) {
chMtxLock(&m1);
test_emit_token(*(char *)p);
- chMtxUnlock();
+ chMtxUnlock(&m1);
return 0;
}
static void mtx1_execute(void) {
- tprio_t prio = chThdGetPriority(); /* Because priority inheritance.*/
+ tprio_t prio = chThdGetPriorityX(); /* Because priority inheritance.*/
chMtxLock(&m1);
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread1, "E");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread1, "D");
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread1, "C");
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread1, "B");
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A");
- chMtxUnlock();
+ chMtxUnlock(&m1);
test_wait_threads();
- test_assert(1, prio == chThdGetPriority(), "wrong priority level");
+ test_assert(1, prio == chThdGetPriorityX(), "wrong priority level");
test_assert_sequence(2, "ABCDE");
}
@@ -150,7 +150,7 @@ ROMCONST struct testcase testmtx1 = { static void mtx2_setup(void) {
- chMtxInit(&m1);
+ chMtxObjectInit(&m1);
}
/* Low priority thread */
@@ -191,10 +191,10 @@ static void mtx2_execute(void) { systime_t time;
test_wait_tick();
- time = chTimeNow();
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread2H, 0);
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-2, thread2M, 0);
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread2L, 0);
+ time = chVTGetSystemTime();
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread2H, 0);
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-2, thread2M, 0);
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread2L, 0);
test_wait_threads();
test_assert_sequence(1, "ABC");
test_assert_time_window(2, time + MS2ST(100), time + MS2ST(100) + ALLOWED_DELAY);
@@ -240,8 +240,8 @@ ROMCONST struct testcase testmtx2 = { static void mtx3_setup(void) {
- chMtxInit(&m1); /* Mutex B.*/
- chMtxInit(&m2); /* Mutex A.*/
+ chMtxObjectInit(&m1); /* Mutex B.*/
+ chMtxObjectInit(&m2); /* Mutex A.*/
}
/* Lowest priority thread */
@@ -309,12 +309,12 @@ static void mtx3_execute(void) { systime_t time;
test_wait_tick();
- time = chTimeNow();
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread3LL, 0);
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread3L, 0);
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread3M, 0);
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread3H, 0);
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread3HH, 0);
+ time = chVTGetSystemTime();
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread3LL, 0);
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread3L, 0);
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread3M, 0);
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread3H, 0);
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread3HH, 0);
test_wait_threads();
test_assert_sequence(1, "ABCDE");
test_assert_time_window(2, time + MS2ST(110), time + MS2ST(110) + ALLOWED_DELAY);
@@ -340,8 +340,8 @@ ROMCONST struct testcase testmtx3 = { static void mtx4_setup(void) {
- chMtxInit(&m1);
- chMtxInit(&m2);
+ chMtxObjectInit(&m1);
+ chMtxObjectInit(&m2);
}
static msg_t thread4a(void *p) {
@@ -349,7 +349,7 @@ static msg_t thread4a(void *p) { (void)p;
chThdSleepMilliseconds(50);
chMtxLock(&m2);
- chMtxUnlock();
+ chMtxUnlock(&m2);
return 0;
}
@@ -358,54 +358,54 @@ static msg_t thread4b(void *p) { (void)p;
chThdSleepMilliseconds(150);
chMtxLock(&m1);
- chMtxUnlock();
+ chMtxUnlock(&m1);
return 0;
}
static void mtx4_execute(void) {
tprio_t p, p1, p2;
- p = chThdGetPriority();
+ p = chThdGetPriorityX();
p1 = p + 1;
p2 = p + 2;
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread4a, "B");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread4b, "A");
chMtxLock(&m2);
- test_assert(1, chThdGetPriority() == p, "wrong priority level");
+ test_assert(1, chThdGetPriorityX() == p, "wrong priority level");
chThdSleepMilliseconds(100);
- test_assert(2, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(2, chThdGetPriorityX() == p1, "wrong priority level");
chMtxLock(&m1);
- test_assert(3, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(3, chThdGetPriorityX() == p1, "wrong priority level");
chThdSleepMilliseconds(100);
- test_assert(4, chThdGetPriority() == p2, "wrong priority level");
- chMtxUnlock();
- test_assert(5, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(4, chThdGetPriorityX() == p2, "wrong priority level");
+ chMtxUnlock(&m1);
+ test_assert(5, chThdGetPriorityX() == p1, "wrong priority level");
chThdSleepMilliseconds(100);
- test_assert(6, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(6, chThdGetPriorityX() == p1, "wrong priority level");
chMtxUnlockAll();
- test_assert(7, chThdGetPriority() == p, "wrong priority level");
+ test_assert(7, chThdGetPriorityX() == p, "wrong priority level");
test_wait_threads();
/* Test repeated in order to cover chMtxUnlockS().*/
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread4a, "D");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread4b, "C");
chMtxLock(&m2);
- test_assert(8, chThdGetPriority() == p, "wrong priority level");
+ test_assert(8, chThdGetPriorityX() == p, "wrong priority level");
chThdSleepMilliseconds(100);
- test_assert(9, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(9, chThdGetPriorityX() == p1, "wrong priority level");
chMtxLock(&m1);
- test_assert(10, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(10, chThdGetPriorityX() == p1, "wrong priority level");
chThdSleepMilliseconds(100);
- test_assert(11, chThdGetPriority() == p2, "wrong priority level");
+ test_assert(11, chThdGetPriorityX() == p2, "wrong priority level");
chSysLock();
- chMtxUnlockS();
+ chMtxUnlockS(&m1);
chSchRescheduleS();
chSysUnlock();
- test_assert(12, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(12, chThdGetPriorityX() == p1, "wrong priority level");
chThdSleepMilliseconds(100);
- test_assert(13, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(13, chThdGetPriorityX() == p1, "wrong priority level");
chMtxUnlockAll();
- test_assert(14, chThdGetPriority() == p, "wrong priority level");
+ test_assert(14, chThdGetPriorityX() == p, "wrong priority level");
test_wait_threads();
}
@@ -428,14 +428,14 @@ ROMCONST struct testcase testmtx4 = { static void mtx5_setup(void) {
- chMtxInit(&m1);
+ chMtxObjectInit(&m1);
}
static void mtx5_execute(void) {
- bool_t b;
- tprio_t prio;
- prio = chThdGetPriority();
+#if !CH_CFG_USE_MUTEXES_RECURSIVE
+ bool b;
+ tprio_t prio = chThdGetPriorityX();
b = chMtxTryLock(&m1);
test_assert(1, b, "already locked");
@@ -444,16 +444,17 @@ static void mtx5_execute(void) { test_assert(2, !b, "not locked");
chSysLock();
- chMtxUnlockS();
+ chMtxUnlockS(&m1);
chSysUnlock();
- test_assert(3, isempty(&m1.m_queue), "queue not empty");
+ test_assert(3, queue_isempty(&m1.m_queue), "queue not empty");
test_assert(4, m1.m_owner == NULL, "still owned");
- test_assert(5, chThdGetPriority() == prio, "wrong priority level");
+ test_assert(5, chThdGetPriorityX() == prio, "wrong priority level");
+#endif /* !CH_CFG_USE_MUTEXES_RECURSIVE */
chMtxLock(&m1);
chMtxUnlockAll();
- test_assert(6, isempty(&m1.m_queue), "queue not empty");
+ test_assert(6, queue_isempty(&m1.m_queue), "queue not empty");
test_assert(7, m1.m_owner == NULL, "still owned");
}
@@ -464,7 +465,7 @@ ROMCONST struct testcase testmtx5 = { mtx5_execute
};
-#if CH_USE_CONDVARS || defined(__DOXYGEN__)
+#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__)
/**
* @page test_mtx_006 Condition Variable signal test
*
@@ -478,8 +479,8 @@ ROMCONST struct testcase testmtx5 = { static void mtx6_setup(void) {
- chCondInit(&c1);
- chMtxInit(&m1);
+ chCondObjectInit(&c1);
+ chMtxObjectInit(&m1);
}
static msg_t thread10(void *p) {
@@ -487,13 +488,13 @@ static msg_t thread10(void *p) { chMtxLock(&m1);
chCondWait(&c1);
test_emit_token(*(char *)p);
- chMtxUnlock();
+ chMtxUnlock(&m1);
return 0;
}
static void mtx6_execute(void) {
- tprio_t prio = chThdGetPriority();
+ tprio_t prio = chThdGetPriorityX();
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread10, "E");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "D");
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread10, "C");
@@ -530,13 +531,13 @@ ROMCONST struct testcase testmtx6 = { static void mtx7_setup(void) {
- chCondInit(&c1);
- chMtxInit(&m1);
+ chCondObjectInit(&c1);
+ chMtxObjectInit(&m1);
}
static void mtx7_execute(void) {
- tprio_t prio = chThdGetPriority();
+ tprio_t prio = chThdGetPriorityX();
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread10, "E");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "D");
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread10, "C");
@@ -565,23 +566,23 @@ ROMCONST struct testcase testmtx7 = { static void mtx8_setup(void) {
- chCondInit(&c1);
- chMtxInit(&m1);
- chMtxInit(&m2);
+ chCondObjectInit(&c1);
+ chMtxObjectInit(&m1);
+ chMtxObjectInit(&m2);
}
static msg_t thread11(void *p) {
chMtxLock(&m2);
chMtxLock(&m1);
-#if CH_USE_CONDVARS_TIMEOUT || defined(__DOXYGEN__)
+#if CH_CFG_USE_CONDVARS_TIMEOUT || defined(__DOXYGEN__)
chCondWaitTimeout(&c1, TIME_INFINITE);
#else
chCondWait(&c1);
#endif
test_emit_token(*(char *)p);
- chMtxUnlock();
- chMtxUnlock();
+ chMtxUnlock(&m1);
+ chMtxUnlock(&m2);
return 0;
}
@@ -589,13 +590,13 @@ static msg_t thread12(void *p) { chMtxLock(&m2);
test_emit_token(*(char *)p);
- chMtxUnlock();
+ chMtxUnlock(&m2);
return 0;
}
static void mtx8_execute(void) {
- tprio_t prio = chThdGetPriority();
+ tprio_t prio = chThdGetPriorityX();
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread11, "A");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "C");
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread12, "B");
@@ -611,14 +612,14 @@ ROMCONST struct testcase testmtx8 = { NULL,
mtx8_execute
};
-#endif /* CH_USE_CONDVARS */
-#endif /* CH_USE_MUTEXES */
+#endif /* CH_CFG_USE_CONDVARS */
+#endif /* CH_CFG_USE_MUTEXES */
/**
* @brief Test sequence for mutexes.
*/
ROMCONST struct testcase * ROMCONST patternmtx[] = {
-#if CH_USE_MUTEXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
&testmtx1,
#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__)
&testmtx2,
@@ -626,7 +627,7 @@ ROMCONST struct testcase * ROMCONST patternmtx[] = { #endif
&testmtx4,
&testmtx5,
-#if CH_USE_CONDVARS || defined(__DOXYGEN__)
+#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__)
&testmtx6,
&testmtx7,
&testmtx8,
diff --git a/test/testmtx.h b/test/rt/testmtx.h index 653c4ad24..653c4ad24 100644 --- a/test/testmtx.h +++ b/test/rt/testmtx.h diff --git a/test/testpools.c b/test/rt/testpools.c index 6515b256f..3037846ea 100644 --- a/test/testpools.c +++ b/test/rt/testpools.c @@ -30,7 +30,7 @@ *
* <h2>Preconditions</h2>
* The module requires the following kernel options:
- * - @p CH_USE_MEMPOOLS
+ * - @p CH_CFG_USE_MEMPOOLS
* .
* In case some of the required options are not enabled then some or all tests
* may be skipped.
@@ -44,9 +44,9 @@ * @brief Memory Pools test header file
*/
-#if CH_USE_MEMPOOLS || defined(__DOXYGEN__)
+#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__)
-static MEMORYPOOL_DECL(mp1, THD_WA_SIZE(THREADS_STACK_SIZE), NULL);
+static MEMORYPOOL_DECL(mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL);
/**
* @page test_pools_001 Allocation and enqueuing test
@@ -65,7 +65,7 @@ static void *null_provider(size_t size) { static void pools1_setup(void) {
- chPoolInit(&mp1, THD_WA_SIZE(THREADS_STACK_SIZE), NULL);
+ chPoolObjectInit(&mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL);
}
static void pools1_execute(void) {
@@ -93,7 +93,7 @@ static void pools1_execute(void) { test_assert(4, chPoolAlloc(&mp1) == NULL, "list not empty");
/* Covering the case where a provider is unable to return more memory.*/
- chPoolInit(&mp1, 16, null_provider);
+ chPoolObjectInit(&mp1, 16, null_provider);
test_assert(5, chPoolAlloc(&mp1) == NULL, "provider returned memory");
}
@@ -104,13 +104,13 @@ ROMCONST struct testcase testpools1 = { pools1_execute
};
-#endif /* CH_USE_MEMPOOLS */
+#endif /* CH_CFG_USE_MEMPOOLS */
/*
* @brief Test sequence for pools.
*/
ROMCONST struct testcase * ROMCONST patternpools[] = {
-#if CH_USE_MEMPOOLS || defined(__DOXYGEN__)
+#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__)
&testpools1,
#endif
NULL
diff --git a/test/testpools.h b/test/rt/testpools.h index 3fe4ed0f6..3fe4ed0f6 100644 --- a/test/testpools.h +++ b/test/rt/testpools.h diff --git a/test/testqueues.c b/test/rt/testqueues.c index 7f682ef8e..0d1bcc872 100644 --- a/test/testqueues.c +++ b/test/rt/testqueues.c @@ -35,7 +35,7 @@ *
* <h2>Preconditions</h2>
* The module requires the following kernel options:
- * - @p CH_USE_QUEUES (and dependent options)
+ * - @p CH_CFG_USE_QUEUES (and dependent options)
* .
* In case some of the required options are not enabled then some or all tests
* may be skipped.
@@ -50,11 +50,11 @@ * @brief I/O Queues test header file
*/
-#if CH_USE_QUEUES || defined(__DOXYGEN__)
+#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__)
#define TEST_QUEUES_SIZE 4
-static void notify(GenericQueue *qp) {
+static void notify(io_queue_t *qp) {
(void)qp;
}
@@ -77,7 +77,7 @@ static OUTPUTQUEUE_DECL(oq, test.wa.T1, TEST_QUEUES_SIZE, notify, NULL); static void queues1_setup(void) {
- chIQInit(&iq, wa[0], TEST_QUEUES_SIZE, notify, NULL);
+ chIQObjectInit(&iq, wa[0], TEST_QUEUES_SIZE, notify, NULL);
}
static msg_t thread1(void *p) {
@@ -138,7 +138,7 @@ static void queues1_execute(void) { chIQResetI(&iq);
chSysUnlock();
test_assert_lock(11, chIQGetFullI(&iq) == 0, "still full");
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL);
test_assert_lock(12, chIQGetFullI(&iq) == 0, "not empty");
test_wait_threads();
@@ -164,7 +164,7 @@ ROMCONST struct testcase testqueues1 = { static void queues2_setup(void) {
- chOQInit(&oq, wa[0], TEST_QUEUES_SIZE, notify, NULL);
+ chOQObjectInit(&oq, wa[0], TEST_QUEUES_SIZE, notify, NULL);
}
static msg_t thread2(void *p) {
@@ -203,7 +203,7 @@ 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_lock(7, chOQIsFullI(&oq), "not full");
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread2, NULL);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread2, NULL);
test_assert_lock(8, chOQGetFullI(&oq) == TEST_QUEUES_SIZE, "not empty");
test_wait_threads();
@@ -230,13 +230,13 @@ ROMCONST struct testcase testqueues2 = { NULL,
queues2_execute
};
-#endif /* CH_USE_QUEUES */
+#endif /* CH_CFG_USE_QUEUES */
/**
* @brief Test sequence for queues.
*/
ROMCONST struct testcase * ROMCONST patternqueues[] = {
-#if CH_USE_QUEUES || defined(__DOXYGEN__)
+#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__)
&testqueues1,
&testqueues2,
#endif
diff --git a/test/testqueues.h b/test/rt/testqueues.h index fdfbc4359..fdfbc4359 100644 --- a/test/testqueues.h +++ b/test/rt/testqueues.h diff --git a/test/testsem.c b/test/rt/testsem.c index c97a3d35d..cb7f13bc2 100644 --- a/test/testsem.c +++ b/test/rt/testsem.c @@ -30,7 +30,7 @@ *
* <h2>Preconditions</h2>
* The module requires the following kernel options:
- * - @p CH_USE_SEMAPHORES
+ * - @p CH_CFG_USE_SEMAPHORES
* .
* In case some of the required options are not enabled then some or all tests
* may be skipped.
@@ -47,7 +47,7 @@ * @brief Semaphores test header file
*/
-#if CH_USE_SEMAPHORES || defined(__DOXYGEN__)
+#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
#define ALLOWED_DELAY MS2ST(5)
@@ -65,13 +65,13 @@ static SEMAPHORE_DECL(sem1, 0); * Five threads with randomized priorities are enqueued to a semaphore then
* awakened one at time.<br>
* The test expects that the threads reach their goal in FIFO order or
- * priority order depending on the CH_USE_SEMAPHORES_PRIORITY configuration
+ * priority order depending on the CH_CFG_USE_SEMAPHORES_PRIORITY configuration
* setting.
*/
static void sem1_setup(void) {
- chSemInit(&sem1, 0);
+ chSemObjectInit(&sem1, 0);
}
static msg_t thread1(void *p) {
@@ -83,29 +83,29 @@ static msg_t thread1(void *p) { static void sem1_execute(void) {
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread1, "A");
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()+1, thread1, "B");
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()+3, thread1, "C");
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()+4, thread1, "D");
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()+2, thread1, "E");
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread1, "A");
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()+1, thread1, "B");
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()+3, thread1, "C");
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()+4, thread1, "D");
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()+2, thread1, "E");
chSemSignal(&sem1);
chSemSignal(&sem1);
chSemSignal(&sem1);
chSemSignal(&sem1);
chSemSignal(&sem1);
test_wait_threads();
-#if CH_USE_SEMAPHORES_PRIORITY
+#if CH_CFG_USE_SEMAPHORES_PRIORITY
test_assert_sequence(1, "ADCEB");
#else
test_assert_sequence(1, "ABCDE");
#endif
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread1, "A");
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread1, "A");
chSysLock();
chSemAddCounterI(&sem1, 2);
chSchRescheduleS();
chSysUnlock();
test_wait_threads();
- test_assert(2, chSemGetCounterI(&sem1) == 1, "invalid counter");
+ test_assert_lock(2, chSemGetCounterI(&sem1) == 1, "invalid counter");
}
ROMCONST struct testcase testsem1 = {
@@ -128,7 +128,7 @@ ROMCONST struct testcase testsem1 = { static void sem2_setup(void) {
- chSemInit(&sem1, 0);
+ chSemObjectInit(&sem1, 0);
}
static msg_t thread2(void *p) {
@@ -151,31 +151,31 @@ static void sem2_execute(void) { * Testing special case TIME_IMMEDIATE.
*/
msg = chSemWaitTimeout(&sem1, TIME_IMMEDIATE);
- test_assert(1, msg == RDY_TIMEOUT, "wrong wake-up message");
- test_assert(2, isempty(&sem1.s_queue), "queue not empty");
+ test_assert(1, msg == MSG_TIMEOUT, "wrong wake-up message");
+ test_assert(2, queue_isempty(&sem1.s_queue), "queue not empty");
test_assert(3, sem1.s_cnt == 0, "counter not zero");
/*
* Testing not timeout condition.
*/
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1,
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1,
thread2, 0);
msg = chSemWaitTimeout(&sem1, MS2ST(500));
test_wait_threads();
- test_assert(4, msg == RDY_OK, "wrong wake-up message");
- test_assert(5, isempty(&sem1.s_queue), "queue not empty");
+ test_assert(4, msg == MSG_OK, "wrong wake-up message");
+ test_assert(5, queue_isempty(&sem1.s_queue), "queue not empty");
test_assert(6, sem1.s_cnt == 0, "counter not zero");
/*
* Testing timeout condition.
*/
test_wait_tick();
- target_time = chTimeNow() + MS2ST(5 * 500);
+ target_time = chVTGetSystemTime() + MS2ST(5 * 500);
for (i = 0; i < 5; i++) {
test_emit_token('A' + i);
msg = chSemWaitTimeout(&sem1, MS2ST(500));
- test_assert(7, msg == RDY_TIMEOUT, "wrong wake-up message");
- test_assert(8, isempty(&sem1.s_queue), "queue not empty");
+ test_assert(7, msg == MSG_TIMEOUT, "wrong wake-up message");
+ test_assert(8, queue_isempty(&sem1.s_queue), "queue not empty");
test_assert(9, sem1.s_cnt == 0, "counter not zero");
}
test_assert_sequence(10, "ABCDE");
@@ -189,7 +189,6 @@ ROMCONST struct testcase testsem2 = { sem2_execute
};
-#if CH_USE_SEMSW || defined(__DOXYGEN__)
/**
* @page test_sem_003 Atomic signal-wait test
*
@@ -204,7 +203,7 @@ ROMCONST struct testcase testsem2 = { static void sem3_setup(void) {
- chSemInit(&sem1, 0);
+ chSemObjectInit(&sem1, 0);
}
static msg_t thread3(void *p) {
@@ -217,13 +216,13 @@ static msg_t thread3(void *p) { static void sem3_execute(void) {
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread3, 0);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread3, 0);
chSemSignalWait(&sem1, &sem1);
- test_assert(1, isempty(&sem1.s_queue), "queue not empty");
+ test_assert(1, queue_isempty(&sem1.s_queue), "queue not empty");
test_assert(2, sem1.s_cnt == 0, "counter not zero");
chSemSignalWait(&sem1, &sem1);
- test_assert(3, isempty(&sem1.s_queue), "queue not empty");
+ test_assert(3, queue_isempty(&sem1.s_queue), "queue not empty");
test_assert(4, sem1.s_cnt == 0, "counter not zero");
}
@@ -233,7 +232,6 @@ ROMCONST struct testcase testsem3 = { NULL,
sem3_execute
};
-#endif /* CH_USE_SEMSW */
/**
* @page test_sem_004 Binary Wait and Signal
@@ -245,38 +243,38 @@ ROMCONST struct testcase testsem3 = { */
static msg_t thread4(void *p) {
- chBSemSignal((BinarySemaphore *)p);
+ chBSemSignal((binary_semaphore_t *)p);
return 0;
}
static void sem4_execute(void) {
- BinarySemaphore bsem;
+ binary_semaphore_t bsem;
/* Creates a taken binary semaphore.*/
- chBSemInit(&bsem, TRUE);
+ chBSemObjectInit(&bsem, TRUE);
chBSemReset(&bsem, TRUE);
- test_assert(1, chBSemGetStateI(&bsem) == TRUE, "not taken");
+ test_assert_lock(1, chBSemGetStateI(&bsem) == TRUE, "not taken");
/* Starts a signaler thread at a lower priority.*/
threads[0] = chThdCreateStatic(wa[0], WA_SIZE,
- chThdGetPriority()-1, thread4, &bsem);
+ chThdGetPriorityX()-1, thread4, &bsem);
/* Waits to be signaled.*/
chBSemWait(&bsem);
/* The binary semaphore is expected to be taken.*/
- test_assert(2, chBSemGetStateI(&bsem) == TRUE, "not taken");
-
+ test_assert_lock(2, chBSemGetStateI(&bsem) == TRUE, "not taken");
+
/* Releasing it, check both the binary semaphore state and the underlying
counter semaphore state..*/
chBSemSignal(&bsem);
- test_assert(3, chBSemGetStateI(&bsem) == FALSE, "still taken");
- test_assert(4, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter");
-
+ test_assert_lock(3, chBSemGetStateI(&bsem) == FALSE, "still taken");
+ test_assert_lock(4, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter");
+
/* Checking signaling overflow, the counter must not go beyond 1.*/
chBSemSignal(&bsem);
- test_assert(3, chBSemGetStateI(&bsem) == FALSE, "taken");
- test_assert(5, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter");
+ test_assert_lock(3, chBSemGetStateI(&bsem) == FALSE, "taken");
+ test_assert_lock(5, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter");
}
ROMCONST struct testcase testsem4 = {
@@ -285,18 +283,16 @@ ROMCONST struct testcase testsem4 = { NULL,
sem4_execute
};
-#endif /* CH_USE_SEMAPHORES */
+#endif /* CH_CFG_USE_SEMAPHORES */
/**
* @brief Test sequence for semaphores.
*/
ROMCONST struct testcase * ROMCONST patternsem[] = {
-#if CH_USE_SEMAPHORES || defined(__DOXYGEN__)
+#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
&testsem1,
&testsem2,
-#if CH_USE_SEMSW || defined(__DOXYGEN__)
&testsem3,
-#endif
&testsem4,
#endif
NULL
diff --git a/test/testsem.h b/test/rt/testsem.h index 94a8bfca8..94a8bfca8 100644 --- a/test/testsem.h +++ b/test/rt/testsem.h diff --git a/test/testthd.c b/test/rt/testthd.c index 35b413acf..522e54b9b 100644 --- a/test/testthd.c +++ b/test/rt/testthd.c @@ -65,11 +65,11 @@ static msg_t thread(void *p) { static void thd1_execute(void) {
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E");
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread, "D");
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C");
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B");
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A");
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E");
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D");
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C");
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B");
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A");
test_wait_threads();
test_assert_sequence(1, "ABCDE");
}
@@ -93,15 +93,15 @@ ROMCONST struct testcase testthd1 = { static void thd2_execute(void) {
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread, "D");
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E");
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A");
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B");
- /* Done this way for coverage of chThdCreateI() and chThdResume().*/
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D");
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E");
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A");
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B");
+ /* Done this way for coverage of chThdCreateI() and chThdStart().*/
chSysLock();
- threads[2] = chThdCreateI(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C");
+ threads[2] = chThdCreateI(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C");
chSysUnlock();
- chThdResume(threads[2]);
+ chThdStart(threads[2]);
test_wait_threads();
test_assert_sequence(1, "ABCDE");
}
@@ -119,54 +119,54 @@ ROMCONST struct testcase testthd2 = { * <h2>Description</h2>
* A series of priority changes are performed on the current thread in order
* to verify that the priority change happens as expected.<br>
- * If the @p CH_USE_MUTEXES option is enabled then the priority changes are
+ * If the @p CH_CFG_USE_MUTEXES option is enabled then the priority changes are
* also tested under priority inheritance boosted priority state.
*/
static void thd3_execute(void) {
tprio_t prio, p1;
- prio = chThdGetPriority();
+ prio = chThdGetPriorityX();
p1 = chThdSetPriority(prio + 1);
test_assert(1, p1 == prio,
"unexpected returned priority level");
- test_assert(2, chThdGetPriority() == prio + 1,
+ test_assert(2, chThdGetPriorityX() == prio + 1,
"unexpected priority level");
p1 = chThdSetPriority(p1);
test_assert(3, p1 == prio + 1,
"unexpected returned priority level");
- test_assert(4, chThdGetPriority() == prio,
+ test_assert(4, chThdGetPriorityX() == prio,
"unexpected priority level");
-#if CH_USE_MUTEXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
/* Simulates a priority boost situation (p_prio > p_realprio).*/
chSysLock();
- chThdSelf()->p_prio += 2;
+ chThdGetSelfX()->p_prio += 2;
chSysUnlock();
- test_assert(5, chThdGetPriority() == prio + 2,
+ test_assert(5, chThdGetPriorityX() == prio + 2,
"unexpected priority level");
/* Tries to raise but below the boost level. */
p1 = chThdSetPriority(prio + 1);
test_assert(6, p1 == prio,
"unexpected returned priority level");
- test_assert(7, chThdSelf()->p_prio == prio + 2,
+ test_assert(7, chThdGetSelfX()->p_prio == prio + 2,
"unexpected priority level");
- test_assert(8, chThdSelf()->p_realprio == prio + 1,
+ test_assert(8, chThdGetSelfX()->p_realprio == prio + 1,
"unexpected returned real priority level");
/* Tries to raise above the boost level. */
p1 = chThdSetPriority(prio + 3);
test_assert(9, p1 == prio + 1,
"unexpected returned priority level");
- test_assert(10, chThdSelf()->p_prio == prio + 3,
+ test_assert(10, chThdGetSelfX()->p_prio == prio + 3,
"unexpected priority level");
- test_assert(11, chThdSelf()->p_realprio == prio + 3,
+ test_assert(11, chThdGetSelfX()->p_realprio == prio + 3,
"unexpected real priority level");
chSysLock();
- chThdSelf()->p_prio = prio;
- chThdSelf()->p_realprio = prio;
+ chThdGetSelfX()->p_prio = prio;
+ chThdGetSelfX()->p_realprio = prio;
chSysUnlock();
#endif
}
@@ -192,22 +192,22 @@ static void thd4_execute(void) { test_wait_tick();
/* Timeouts in microseconds.*/
- time = chTimeNow();
+ time = chVTGetSystemTime();
chThdSleepMicroseconds(100000);
test_assert_time_window(1, time + US2ST(100000), time + US2ST(100000) + 1);
/* Timeouts in milliseconds.*/
- time = chTimeNow();
+ time = chVTGetSystemTime();
chThdSleepMilliseconds(100);
test_assert_time_window(2, time + MS2ST(100), time + MS2ST(100) + 1);
/* Timeouts in seconds.*/
- time = chTimeNow();
+ time = chVTGetSystemTime();
chThdSleepSeconds(1);
test_assert_time_window(3, time + S2ST(1), time + S2ST(1) + 1);
/* Absolute timelines.*/
- time = chTimeNow() + MS2ST(100);
+ time = chVTGetSystemTime() + MS2ST(100);
chThdSleepUntil(time);
test_assert_time_window(4, time, time + 1);
}
diff --git a/test/testthd.h b/test/rt/testthd.h index f1e3a9475..f1e3a9475 100644 --- a/test/testthd.h +++ b/test/rt/testthd.h diff --git a/test/test.mk b/test/test.mk deleted file mode 100644 index 3f740288c..000000000 --- a/test/test.mk +++ /dev/null @@ -1,16 +0,0 @@ -# List of all the ChibiOS/RT test files.
-TESTSRC = ${CHIBIOS}/test/test.c \
- ${CHIBIOS}/test/testthd.c \
- ${CHIBIOS}/test/testsem.c \
- ${CHIBIOS}/test/testmtx.c \
- ${CHIBIOS}/test/testmsg.c \
- ${CHIBIOS}/test/testmbox.c \
- ${CHIBIOS}/test/testevt.c \
- ${CHIBIOS}/test/testheap.c \
- ${CHIBIOS}/test/testpools.c \
- ${CHIBIOS}/test/testdyn.c \
- ${CHIBIOS}/test/testqueues.c \
- ${CHIBIOS}/test/testbmk.c
-
-# Required include directories
-TESTINC = ${CHIBIOS}/test
|