From 7772ea4579a45bcf63ebd5e68be66ba1a9c72dfa Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Fri, 11 Nov 2016 15:02:17 -0500 Subject: chibios! --- ChibiOS_16.1.5/test/rt/test.c | 390 ++++ ChibiOS_16.1.5/test/rt/test.dox | 55 + ChibiOS_16.1.5/test/rt/test.h | 175 ++ ChibiOS_16.1.5/test/rt/test.mk | 17 + ChibiOS_16.1.5/test/rt/testbmk.c | 723 +++++++ ChibiOS_16.1.5/test/rt/testbmk.h | 22 + ChibiOS_16.1.5/test/rt/testbuild/Makefile | 146 ++ ChibiOS_16.1.5/test/rt/testbuild/chconf.h | 567 +++++ ChibiOS_16.1.5/test/rt/testbuild/go.sh | 123 ++ ChibiOS_16.1.5/test/rt/testbuild/halconf.h | 381 ++++ ChibiOS_16.1.5/test/rt/testbuild/main.c | 49 + .../test/rt/testbuild/pclint/au-misra3.lnt | 2173 ++++++++++++++++++++ ChibiOS_16.1.5/test/rt/testbuild/pclint/co-gcc.h | 129 ++ ChibiOS_16.1.5/test/rt/testbuild/pclint/co-gcc.lnt | 209 ++ .../test/rt/testbuild/pclint/gcc-include-path.lnt | 6 + .../test/rt/testbuild/pclint/lint_cmac.h | 330 +++ .../test/rt/testbuild/pclint/lint_cppmac.h | 336 +++ .../test/rt/testbuild/pclint/size-options.lnt | 1 + .../test/rt/testbuild/pclint/waivers.lnt | 122 ++ ChibiOS_16.1.5/test/rt/testbuild/readme.txt | 28 + ChibiOS_16.1.5/test/rt/testdyn.c | 264 +++ ChibiOS_16.1.5/test/rt/testdyn.h | 22 + ChibiOS_16.1.5/test/rt/testevt.c | 295 +++ ChibiOS_16.1.5/test/rt/testevt.h | 22 + ChibiOS_16.1.5/test/rt/testheap.c | 159 ++ ChibiOS_16.1.5/test/rt/testheap.h | 22 + ChibiOS_16.1.5/test/rt/testmbox.c | 239 +++ ChibiOS_16.1.5/test/rt/testmbox.h | 22 + ChibiOS_16.1.5/test/rt/testmsg.c | 107 + ChibiOS_16.1.5/test/rt/testmsg.h | 22 + ChibiOS_16.1.5/test/rt/testmtx.c | 623 ++++++ ChibiOS_16.1.5/test/rt/testmtx.h | 22 + ChibiOS_16.1.5/test/rt/testpools.c | 117 ++ ChibiOS_16.1.5/test/rt/testpools.h | 22 + ChibiOS_16.1.5/test/rt/testqueues.c | 242 +++ ChibiOS_16.1.5/test/rt/testqueues.h | 22 + ChibiOS_16.1.5/test/rt/testsem.c | 295 +++ ChibiOS_16.1.5/test/rt/testsem.h | 22 + ChibiOS_16.1.5/test/rt/testsys.c | 177 ++ ChibiOS_16.1.5/test/rt/testsys.h | 22 + ChibiOS_16.1.5/test/rt/testthd.c | 238 +++ ChibiOS_16.1.5/test/rt/testthd.h | 22 + 42 files changed, 8980 insertions(+) create mode 100644 ChibiOS_16.1.5/test/rt/test.c create mode 100644 ChibiOS_16.1.5/test/rt/test.dox create mode 100644 ChibiOS_16.1.5/test/rt/test.h create mode 100644 ChibiOS_16.1.5/test/rt/test.mk create mode 100644 ChibiOS_16.1.5/test/rt/testbmk.c create mode 100644 ChibiOS_16.1.5/test/rt/testbmk.h create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/Makefile create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/chconf.h create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/go.sh create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/halconf.h create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/main.c create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/pclint/au-misra3.lnt create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/pclint/co-gcc.h create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/pclint/co-gcc.lnt create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/pclint/gcc-include-path.lnt create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/pclint/lint_cmac.h create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/pclint/lint_cppmac.h create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/pclint/size-options.lnt create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/pclint/waivers.lnt create mode 100644 ChibiOS_16.1.5/test/rt/testbuild/readme.txt create mode 100644 ChibiOS_16.1.5/test/rt/testdyn.c create mode 100644 ChibiOS_16.1.5/test/rt/testdyn.h create mode 100644 ChibiOS_16.1.5/test/rt/testevt.c create mode 100644 ChibiOS_16.1.5/test/rt/testevt.h create mode 100644 ChibiOS_16.1.5/test/rt/testheap.c create mode 100644 ChibiOS_16.1.5/test/rt/testheap.h create mode 100644 ChibiOS_16.1.5/test/rt/testmbox.c create mode 100644 ChibiOS_16.1.5/test/rt/testmbox.h create mode 100644 ChibiOS_16.1.5/test/rt/testmsg.c create mode 100644 ChibiOS_16.1.5/test/rt/testmsg.h create mode 100644 ChibiOS_16.1.5/test/rt/testmtx.c create mode 100644 ChibiOS_16.1.5/test/rt/testmtx.h create mode 100644 ChibiOS_16.1.5/test/rt/testpools.c create mode 100644 ChibiOS_16.1.5/test/rt/testpools.h create mode 100644 ChibiOS_16.1.5/test/rt/testqueues.c create mode 100644 ChibiOS_16.1.5/test/rt/testqueues.h create mode 100644 ChibiOS_16.1.5/test/rt/testsem.c create mode 100644 ChibiOS_16.1.5/test/rt/testsem.h create mode 100644 ChibiOS_16.1.5/test/rt/testsys.c create mode 100644 ChibiOS_16.1.5/test/rt/testsys.h create mode 100644 ChibiOS_16.1.5/test/rt/testthd.c create mode 100644 ChibiOS_16.1.5/test/rt/testthd.h (limited to 'ChibiOS_16.1.5/test/rt') diff --git a/ChibiOS_16.1.5/test/rt/test.c b/ChibiOS_16.1.5/test/rt/test.c new file mode 100644 index 0000000..f4a08ee --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/test.c @@ -0,0 +1,390 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file test.c + * @brief Tests support code. + * + * @addtogroup test + * @{ + */ + +#include "ch.h" +#include "hal.h" + +#include "test.h" +#include "testsys.h" +#include "testthd.h" +#include "testsem.h" +#include "testmtx.h" +#include "testmsg.h" +#include "testmbox.h" +#include "testevt.h" +#include "testheap.h" +#include "testpools.h" +#include "testdyn.h" +#include "testqueues.h" +#include "testbmk.h" + +/* + * Array of all the test patterns. + */ +static ROMCONST struct testcase * ROMCONST *patterns[] = { + patternsys, + patternthd, + patternsem, + patternmtx, + patternmsg, + patternmbox, + patternevt, + patternheap, + patternpools, + patterndyn, + patternqueues, + patternbmk, + NULL +}; + +bool test_global_fail; +static bool local_fail; +static unsigned failpoint; +static char tokens_buffer[MAX_TOKENS]; +static char *tokp; + +/* + * Static working areas, the following areas can be used for threads or + * used as temporary buffers. + */ +union test_buffers test; + +/* + * Pointers to the spawned threads. + */ +thread_t *threads[MAX_THREADS]; + +/* + * Pointers to the working areas. + */ +void * ROMCONST wa[5] = {test.wa.T0, test.wa.T1, test.wa.T2, + test.wa.T3, test.wa.T4}; + +/* + * Console output. + */ +static BaseSequentialStream *chp; + +/** + * @brief Prints a decimal unsigned number. + * + * @param[in] n the number to be printed + */ +void test_printn(uint32_t n) { + char buf[16], *p; + + if (!n) + chSequentialStreamPut(chp, '0'); + else { + p = buf; + while (n) + *p++ = (n % 10) + '0', n /= 10; + while (p > buf) + chSequentialStreamPut(chp, *--p); + } +} + +/** + * @brief Prints a line without final end-of-line. + * + * @param[in] msgp the message + */ +void test_print(const char *msgp) { + + while (*msgp) + chSequentialStreamPut(chp, *msgp++); +} + +/** + * @brief Prints a line. + * + * @param[in] msgp the message + */ +void test_println(const char *msgp) { + + test_print(msgp); + chSequentialStreamWrite(chp, (const uint8_t *)"\r\n", 2); +} + +/* + * Tokens. + */ +static void clear_tokens(void) { + + tokp = tokens_buffer; +} + +static void print_tokens(void) { + char *cp = tokens_buffer; + + while (cp < tokp) + chSequentialStreamPut(chp, *cp++); +} + +/** + * @brief Emits a token into the tokens buffer. + * + * @param[in] token the token as a char + */ +void test_emit_token(char token) { + + chSysLock(); + *tokp++ = token; + chSysUnlock(); +} + +/* + * Assertions. + */ +bool _test_fail(unsigned point) { + + test_global_fail = TRUE; + local_fail = TRUE; + failpoint = point; + return TRUE; +} + +bool _test_assert(unsigned point, bool condition) { + + if (!condition) + return _test_fail(point); + return FALSE; +} + +bool _test_assert_sequence(unsigned point, char *expected) { + char *cp = tokens_buffer; + while (cp < tokp) { + if (*cp++ != *expected++) + return _test_fail(point); + } + if (*expected) + return _test_fail(point); + clear_tokens(); + return FALSE; +} + +bool _test_assert_time_window(unsigned point, systime_t start, systime_t end) { + + return _test_assert(point, chVTIsSystemTimeWithin(start, end)); +} + +/* + * Threads utils. + */ + +/** + * @brief Sets a termination request in all the test-spawned threads. + */ +void test_terminate_threads(void) { + int i; + + for (i = 0; i < MAX_THREADS; i++) + if (threads[i]) + chThdTerminate(threads[i]); +} + +/** + * @brief Waits for the completion of all the test-spawned threads. + */ +void test_wait_threads(void) { + int i; + + for (i = 0; i < MAX_THREADS; i++) + if (threads[i] != NULL) { + chThdWait(threads[i]); + threads[i] = NULL; + } +} + +#if CH_DBG_THREADS_PROFILING +/** + * @brief CPU pulse. + * @note The current implementation is not totally reliable. + * + * @param[in] duration CPU pulse duration in milliseconds + */ +void test_cpu_pulse(unsigned duration) { + systime_t start, end, now; + + start = chThdGetTicksX(chThdGetSelfX()); + end = start + MS2ST(duration); + do { + now = chThdGetTicksX(chThdGetSelfX()); +#if defined(SIMULATOR) + _sim_check_for_interrupts(); +#endif + } + while (end > start ? (now >= start) && (now < end) : + (now >= start) || (now < end)); +} +#endif + +/** + * @brief Delays execution until next system time tick. + * + * @return The system time. + */ +systime_t test_wait_tick(void) { + + chThdSleep(1); + return chVTGetSystemTime(); +} + +/* + * Timer utils. + */ + +/** + * @brief Set to @p TRUE when the test timer reaches its deadline. + */ +bool test_timer_done; + +static virtual_timer_t vt; +static void tmr(void *p) { + (void)p; + + test_timer_done = TRUE; +} + +/** + * @brief Starts the test timer. + * + * @param[in] ms time in milliseconds + */ +void test_start_timer(unsigned ms) { + + systime_t duration = MS2ST(ms); + test_timer_done = FALSE; + chVTSet(&vt, duration, tmr, NULL); +} + +/* + * Test suite execution. + */ +static void execute_test(const struct testcase *tcp) { + int i; + + /* Initialization */ + clear_tokens(); + local_fail = FALSE; + for (i = 0; i < MAX_THREADS; i++) + threads[i] = NULL; + + if (tcp->setup != NULL) + tcp->setup(); + tcp->execute(); + if (tcp->teardown != NULL) + tcp->teardown(); + + test_wait_threads(); +} + +static void print_line(void) { + unsigned i; + + for (i = 0; i < 76; i++) + chSequentialStreamPut(chp, '-'); + chSequentialStreamWrite(chp, (const uint8_t *)"\r\n", 2); +} + +/** + * @brief Test execution thread function. + * + * @param[in] p pointer to a @p BaseChannel object for test output + */ +void TestThread(void *p) { + int i, j; + + chp = p; + test_println(""); + test_println("*** ChibiOS/RT test suite"); + test_println("***"); + test_print("*** Kernel: "); + test_println(CH_KERNEL_VERSION); + test_print("*** Compiled: "); + test_println(__DATE__ " - " __TIME__); +#ifdef PORT_COMPILER_NAME + test_print("*** Compiler: "); + test_println(PORT_COMPILER_NAME); +#endif + test_print("*** Architecture: "); + test_println(PORT_ARCHITECTURE_NAME); +#ifdef PORT_CORE_VARIANT_NAME + test_print("*** Core Variant: "); + test_println(PORT_CORE_VARIANT_NAME); +#endif +#ifdef PORT_INFO + test_print("*** Port Info: "); + test_println(PORT_INFO); +#endif +#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 (patterns[i]) { + j = 0; + while (patterns[i][j]) { + print_line(); + test_print("--- Test Case "); + test_printn(i + 1); + test_print("."); + test_printn(j + 1); + test_print(" ("); + test_print(patterns[i][j]->name); + test_println(")"); +#if DELAY_BETWEEN_TESTS > 0 + chThdSleepMilliseconds(DELAY_BETWEEN_TESTS); +#endif + execute_test(patterns[i][j]); + if (local_fail) { + test_print("--- Result: FAILURE (#"); + test_printn(failpoint); + test_print(" ["); + print_tokens(); + 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"); +} + +/** @} */ diff --git a/ChibiOS_16.1.5/test/rt/test.dox b/ChibiOS_16.1.5/test/rt/test.dox new file mode 100644 index 0000000..29de03e --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/test.dox @@ -0,0 +1,55 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @defgroup test Test Runtime + * @details Runtime code for the test suite execution, this code is not part + * of the OS and should not be included in user applications. + */ + +/** + * @page testsuite Testing Strategy + *

Description

+ * Most of the ChibiOS/RT demos link a set of software modules (test suite) in + * order to verify the proper working of the kernel, the port and the demo + * itself. + * + *

Kernel Test Suite

+ * The kernel test suite is divided in modules or test sequences. Each Test + * Module performs a series of tests on a specified kernel subsystem or + * subsystems and can report a failure/success status and/or a performance + * index as the test suite output.
+ * The test suite is usually activated in the demo applications by pressing a + * button on the target board, see the readme file into the various demos + * directories. The test suite output is usually sent through a serial port + * and can be examined by using a terminal emulator program. + * + *

Kernel Test Modules

+ * + * - @subpage test_threads + * - @subpage test_dynamic + * - @subpage test_msg + * - @subpage test_sem + * - @subpage test_mtx + * - @subpage test_events + * - @subpage test_mbox + * - @subpage test_queues + * - @subpage test_heap + * - @subpage test_pools + * - @subpage test_sys + * - @subpage test_benchmarks + * . + */ diff --git a/ChibiOS_16.1.5/test/rt/test.h b/ChibiOS_16.1.5/test/rt/test.h new file mode 100644 index 0000000..da080db --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/test.h @@ -0,0 +1,175 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file test.h + * @brief Tests support header. + * + * @addtogroup test + * @{ + */ + +#ifndef _TEST_H_ +#define _TEST_H_ + +/** + * @brief Delay inserted between test cases. + */ +#if !defined(DELAY_BETWEEN_TESTS) || defined(__DOXYGEN__) +#define DELAY_BETWEEN_TESTS 200 +#endif + +/** + * @brief If @p TRUE then benchmarks are not included. + */ +#if !defined(TEST_NO_BENCHMARKS) || defined(__DOXYGEN__) +#define TEST_NO_BENCHMARKS FALSE +#endif + +#define MAX_THREADS 5 +#define MAX_TOKENS 16 + +#if defined(CH_ARCHITECTURE_AVR) || defined(CH_ARCHITECTURE_MSP430) +#define THREADS_STACK_SIZE 48 +#elif defined(CH_ARCHITECTURE_STM8) +#define THREADS_STACK_SIZE 64 +#elif defined(CH_ARCHITECTURE_SIMIA32) +#define THREADS_STACK_SIZE 512 +#else +#define THREADS_STACK_SIZE 128 +#endif +#define WA_SIZE THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE) + +/** + * @brief Structure representing a test case. + */ +struct testcase { + 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. */ +}; + +#ifndef __DOXYGEN__ +union test_buffers { + struct { + 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]; +}; +#endif + +extern bool test_global_fail; + +#ifdef __cplusplus +extern "C" { +#endif + void TestThread(void *p); + void test_printn(uint32_t n); + void test_print(const char *msgp); + void test_println(const char *msgp); + void test_emit_token(char token); + 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); + void test_start_timer(unsigned ms); +#if CH_DBG_THREADS_PROFILING + void test_cpu_pulse(unsigned duration); +#endif +#if defined(WIN32) + void ChkIntSources(void); +#endif +#ifdef __cplusplus +} +#endif + +/** + * @brief Test failure enforcement. + */ +#define test_fail(point) { \ + _test_fail(point); \ + return; \ +} + +/** + * @brief Test assertion. + * + * @param[in] point numeric assertion identifier + * @param[in] condition a boolean expression that must be verified to be true + * @param[in] msg failure message + */ +#define test_assert(point, condition, msg) { \ + if (_test_assert(point, condition)) \ + return; \ +} + +/** + * @brief Test assertion with lock. + * + * @param[in] point numeric assertion identifier + * @param[in] condition a boolean expression that must be verified to be true + * @param[in] msg failure message + */ +#define test_assert_lock(point, condition, msg) { \ + chSysLock(); \ + if (_test_assert(point, condition)) { \ + chSysUnlock(); \ + return; \ + } \ + chSysUnlock(); \ +} + +/** + * @brief Test sequence assertion. + * + * @param[in] point numeric assertion identifier + * @param[in] expected string to be matched with the tokens buffer + */ +#define test_assert_sequence(point, expected) { \ + if (_test_assert_sequence(point, expected)) \ + return; \ +} + +/** + * @brief Test time window assertion. + * + * @param[in] point numeric assertion identifier + * @param[in] start initial time in the window (included) + * @param[in] end final time in the window (not included) + */ +#define test_assert_time_window(point, start, end) { \ + if (_test_assert_time_window(point, start, end)) \ + return; \ +} + +#if !defined(__DOXYGEN__) +extern thread_t *threads[MAX_THREADS]; +extern union test_buffers test; +extern void * ROMCONST wa[]; +extern bool test_timer_done; +#endif + +#endif /* _TEST_H_ */ + +/** @} */ diff --git a/ChibiOS_16.1.5/test/rt/test.mk b/ChibiOS_16.1.5/test/rt/test.mk new file mode 100644 index 0000000..03de3c8 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/test.mk @@ -0,0 +1,17 @@ +# 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/testsys.c \ + ${CHIBIOS}/test/rt/testbmk.c + +# Required include directories +TESTINC = ${CHIBIOS}/test/rt diff --git a/ChibiOS_16.1.5/test/rt/testbmk.c b/ChibiOS_16.1.5/test/rt/testbmk.c new file mode 100644 index 0000000..b4f4af7 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbmk.c @@ -0,0 +1,723 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_benchmarks Kernel Benchmarks + * + * File: @ref testbmk.c + * + *

Description

+ * This module implements a series of system benchmarks. The benchmarks are + * useful as a stress test and as a reference when comparing ChibiOS/RT + * with similar systems. + * + *

Objective

+ * Objective of the test module is to provide a performance index for the + * most critical system subsystems. The performance numbers allow to + * discover performance regressions between successive ChibiOS/RT releases. + * + *

Preconditions

+ * None. + * + *

Test Cases

+ * - @subpage test_benchmarks_001 + * - @subpage test_benchmarks_002 + * - @subpage test_benchmarks_003 + * - @subpage test_benchmarks_004 + * - @subpage test_benchmarks_005 + * - @subpage test_benchmarks_006 + * - @subpage test_benchmarks_007 + * - @subpage test_benchmarks_008 + * - @subpage test_benchmarks_009 + * - @subpage test_benchmarks_010 + * - @subpage test_benchmarks_011 + * - @subpage test_benchmarks_012 + * - @subpage test_benchmarks_013 + * . + * @file testbmk.c Kernel Benchmarks + * @brief Kernel Benchmarks source file + * @file testbmk.h + * @brief Kernel Benchmarks header file + */ + +#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) +static semaphore_t sem1; +#endif +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) +static mutex_t mtx1; +#endif + +static THD_FUNCTION(thread1, p) { + + chThdExit((msg_t)p); +} + +#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__) +static THD_FUNCTION(thread2, p) { + thread_t *tp; + msg_t msg; + + (void)p; + do { + tp = chMsgWait(); + msg = chMsgGet(tp); + chMsgRelease(tp, msg); + } while (msg); +} + +#ifdef __GNUC__ +__attribute__((noinline)) +#endif +static unsigned int msg_loop_test(thread_t *tp) { + + uint32_t n = 0; + test_wait_tick(); + test_start_timer(1000); + do { + (void)chMsgSend(tp, 1); + n++; +#if defined(SIMULATOR) + _sim_check_for_interrupts(); +#endif + } while (!test_timer_done); + (void)chMsgSend(tp, 0); + return n; +} + +/** + * @page test_benchmarks_001 Messages performance #1 + * + *

Description

+ * A message server thread is created with a lower priority than the client + * thread, the messages throughput per second is measured and the result + * printed in the output log. + */ + +static void bmk1_execute(void) { + uint32_t n; + + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread2, NULL); + n = msg_loop_test(threads[0]); + test_wait_threads(); + test_print("--- Score : "); + test_printn(n); + test_print(" msgs/S, "); + test_printn(n << 1); + test_println(" ctxswc/S"); +} + +ROMCONST struct testcase testbmk1 = { + "Benchmark, messages #1", + NULL, + NULL, + bmk1_execute +}; + +/** + * @page test_benchmarks_002 Messages performance #2 + * + *

Description

+ * A message server thread is created with an higher priority than the client + * thread, the messages throughput per second is measured and the result + * printed in the output log. + */ + +static void bmk2_execute(void) { + uint32_t n; + + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread2, NULL); + n = msg_loop_test(threads[0]); + test_wait_threads(); + test_print("--- Score : "); + test_printn(n); + test_print(" msgs/S, "); + test_printn(n << 1); + test_println(" ctxswc/S"); +} + +ROMCONST struct testcase testbmk2 = { + "Benchmark, messages #2", + NULL, + NULL, + bmk2_execute +}; + +/** + * @page test_benchmarks_003 Messages performance #3 + * + *

Description

+ * A message server thread is created with an higher priority than the client + * thread, four lower priority threads crowd the ready list, the messages + * throughput per second is measured while the ready list and the result + * printed in the output log. + */ + +static void bmk3_execute(void) { + uint32_t n; + + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread2, NULL); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-2, thread1, NULL); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread1, NULL); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-4, thread1, NULL); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-5, thread1, NULL); + n = msg_loop_test(threads[0]); + test_wait_threads(); + test_print("--- Score : "); + test_printn(n); + test_print(" msgs/S, "); + test_printn(n << 1); + test_println(" ctxswc/S"); +} + +ROMCONST struct testcase testbmk3 = { + "Benchmark, messages #3", + NULL, + NULL, + bmk3_execute +}; +#endif /* if CH_CFG_USE_MESSAGES */ + +/** + * @page test_benchmarks_004 Context Switch performance + * + *

Description

+ * A thread is created that just performs a @p chSchGoSleepS() into a loop, + * the thread is awakened as fast is possible by the tester thread.
+ * The Context Switch performance is calculated by measuring the number of + * iterations after a second of continuous operations. + */ + +static THD_FUNCTION(thread4, p) { + msg_t msg; + thread_t *self = chThdGetSelfX(); + + (void)p; + chSysLock(); + do { + chSchGoSleepS(CH_STATE_SUSPENDED); + msg = self->p_u.rdymsg; + } while (msg == MSG_OK); + chSysUnlock(); +} + +static void bmk4_execute(void) { + thread_t *tp; + uint32_t n; + + 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, MSG_OK); + chSchWakeupS(tp, MSG_OK); + chSchWakeupS(tp, MSG_OK); + chSchWakeupS(tp, MSG_OK); + chSysUnlock(); + n += 4; +#if defined(SIMULATOR) + _sim_check_for_interrupts(); +#endif + } while (!test_timer_done); + chSysLock(); + chSchWakeupS(tp, MSG_TIMEOUT); + chSysUnlock(); + + test_wait_threads(); + test_print("--- Score : "); + test_printn(n * 2); + test_println(" ctxswc/S"); +} + +ROMCONST struct testcase testbmk4 = { + "Benchmark, context switch", + NULL, + NULL, + bmk4_execute +}; + +/** + * @page test_benchmarks_005 Threads performance, full cycle + * + *

Description

+ * Threads are continuously created and terminated into a loop. A full + * @p chThdCreateStatic() / @p chThdExit() / @p chThdWait() cycle is performed + * in each iteration.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static void bmk5_execute(void) { + + uint32_t n = 0; + void *wap = wa[0]; + tprio_t prio = chThdGetPriorityX() - 1; + test_wait_tick(); + test_start_timer(1000); + do { + chThdWait(chThdCreateStatic(wap, WA_SIZE, prio, thread1, NULL)); + n++; +#if defined(SIMULATOR) + _sim_check_for_interrupts(); +#endif + } while (!test_timer_done); + test_print("--- Score : "); + test_printn(n); + test_println(" threads/S"); +} + +ROMCONST struct testcase testbmk5 = { + "Benchmark, threads, full cycle", + NULL, + NULL, + bmk5_execute +}; + +/** + * @page test_benchmarks_006 Threads performance, create/exit only + * + *

Description

+ * Threads are continuously created and terminated into a loop. A partial + * @p chThdCreateStatic() / @p chThdExit() cycle is performed in each + * iteration, the @p chThdWait() is not necessary because the thread is + * created at an higher priority so there is no need to wait for it to + * terminate.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static void bmk6_execute(void) { + + uint32_t n = 0; + void *wap = wa[0]; + tprio_t prio = chThdGetPriorityX() + 1; + test_wait_tick(); + test_start_timer(1000); + do { + chThdCreateStatic(wap, WA_SIZE, prio, thread1, NULL); + n++; +#if defined(SIMULATOR) + _sim_check_for_interrupts(); +#endif + } while (!test_timer_done); + test_print("--- Score : "); + test_printn(n); + test_println(" threads/S"); +} + +ROMCONST struct testcase testbmk6 = { + "Benchmark, threads, create only", + NULL, + NULL, + bmk6_execute +}; + +#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) +/** + * @page test_benchmarks_007 Mass reschedule performance + * + *

Description

+ * Five threads are created and atomically rescheduled by resetting the + * semaphore where they are waiting on. The operation is performed into a + * continuous loop.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static THD_FUNCTION(thread3, p) { + + (void)p; + while (!chThdShouldTerminateX()) + chSemWait(&sem1); +} + +static void bmk7_setup(void) { + + chSemObjectInit(&sem1, 0); +} + +static void bmk7_execute(void) { + uint32_t n; + + 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(); + test_start_timer(1000); + do { + chSemReset(&sem1, 0); + n++; +#if defined(SIMULATOR) + _sim_check_for_interrupts(); +#endif + } while (!test_timer_done); + test_terminate_threads(); + chSemReset(&sem1, 0); + test_wait_threads(); + + test_print("--- Score : "); + test_printn(n); + test_print(" reschedules/S, "); + test_printn(n * 6); + test_println(" ctxswc/S"); +} + +ROMCONST struct testcase testbmk7 = { + "Benchmark, mass reschedule, 5 threads", + bmk7_setup, + NULL, + bmk7_execute +}; +#endif + +/** + * @page test_benchmarks_008 I/O Round-Robin voluntary reschedule. + * + *

Description

+ * Five threads are created at equal priority, each thread just increases a + * variable and yields.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static THD_FUNCTION(thread8, p) { + + do { + chThdYield(); + chThdYield(); + chThdYield(); + chThdYield(); + (*(uint32_t *)p) += 4; +#if defined(SIMULATOR) + _sim_check_for_interrupts(); +#endif + } while(!chThdShouldTerminateX()); +} + +static void bmk8_execute(void) { + uint32_t n; + + n = 0; + test_wait_tick(); + + 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(); + test_wait_threads(); + + test_print("--- Score : "); + test_printn(n); + test_println(" ctxswc/S"); +} + +ROMCONST struct testcase testbmk8 = { + "Benchmark, round robin context switching", + NULL, + NULL, + bmk8_execute +}; + +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) +/** + * @page test_benchmarks_009 I/O Queues throughput + * + *

Description

+ * Four bytes are written and then read from an @p InputQueue into a continuous + * loop.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static void bmk9_execute(void) { + uint32_t n; + static uint8_t ib[16]; + static input_queue_t iq; + + chIQObjectInit(&iq, ib, sizeof(ib), NULL, NULL); + n = 0; + test_wait_tick(); + test_start_timer(1000); + do { + chSysLock(); + chIQPutI(&iq, 0); + chIQPutI(&iq, 1); + chIQPutI(&iq, 2); + chIQPutI(&iq, 3); + chSysUnlock(); + (void)chIQGet(&iq); + (void)chIQGet(&iq); + (void)chIQGet(&iq); + (void)chIQGet(&iq); + n++; +#if defined(SIMULATOR) + _sim_check_for_interrupts(); +#endif + } while (!test_timer_done); + test_print("--- Score : "); + test_printn(n * 4); + test_println(" bytes/S"); +} + +ROMCONST struct testcase testbmk9 = { + "Benchmark, I/O Queues throughput", + NULL, + NULL, + bmk9_execute +}; +#endif /* CH_CFG_USE_QUEUES */ + +/** + * @page test_benchmarks_010 Virtual Timers set/reset performance + * + *

Description

+ * A virtual timer is set and immediately reset into a continuous loop.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static void tmo(void *param) {(void)param;} + +static void bmk10_execute(void) { + static virtual_timer_t vt1, vt2; + uint32_t n = 0; + + test_wait_tick(); + test_start_timer(1000); + do { + chSysLock(); + chVTDoSetI(&vt1, 1, tmo, NULL); + chVTDoSetI(&vt2, 10000, tmo, NULL); + chVTDoResetI(&vt1); + chVTDoResetI(&vt2); + chSysUnlock(); + n++; +#if defined(SIMULATOR) + _sim_check_for_interrupts(); +#endif + } while (!test_timer_done); + test_print("--- Score : "); + test_printn(n * 2); + test_println(" timers/S"); +} + +ROMCONST struct testcase testbmk10 = { + "Benchmark, virtual timers set/reset", + NULL, + NULL, + bmk10_execute +}; + +#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) +/** + * @page test_benchmarks_011 Semaphores wait/signal performance + * + *

Description

+ * A counting semaphore is taken/released into a continuous loop, no Context + * Switch happens because the counter is always non negative.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static void bmk11_setup(void) { + + chSemObjectInit(&sem1, 1); +} + +static void bmk11_execute(void) { + uint32_t n = 0; + + test_wait_tick(); + test_start_timer(1000); + do { + chSemWait(&sem1); + chSemSignal(&sem1); + chSemWait(&sem1); + chSemSignal(&sem1); + chSemWait(&sem1); + chSemSignal(&sem1); + chSemWait(&sem1); + chSemSignal(&sem1); + n++; +#if defined(SIMULATOR) + _sim_check_for_interrupts(); +#endif + } while (!test_timer_done); + test_print("--- Score : "); + test_printn(n * 4); + test_println(" wait+signal/S"); +} + +ROMCONST struct testcase testbmk11 = { + "Benchmark, semaphores wait/signal", + bmk11_setup, + NULL, + bmk11_execute +}; +#endif + +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) +/** + * @page test_benchmarks_012 Mutexes lock/unlock performance + * + *

Description

+ * A mutex is locked/unlocked into a continuous loop, no Context Switch happens + * because there are no other threads asking for the mutex.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static void bmk12_setup(void) { + + chMtxObjectInit(&mtx1); +} + +static void bmk12_execute(void) { + uint32_t n = 0; + + test_wait_tick(); + test_start_timer(1000); + do { + chMtxLock(&mtx1); + chMtxUnlock(&mtx1); + chMtxLock(&mtx1); + chMtxUnlock(&mtx1); + chMtxLock(&mtx1); + chMtxUnlock(&mtx1); + chMtxLock(&mtx1); + chMtxUnlock(&mtx1); + n++; +#if defined(SIMULATOR) + _sim_check_for_interrupts(); +#endif + } while (!test_timer_done); + test_print("--- Score : "); + test_printn(n * 4); + test_println(" lock+unlock/S"); +} + +ROMCONST struct testcase testbmk12 = { + "Benchmark, mutexes lock/unlock", + bmk12_setup, + NULL, + bmk12_execute +}; +#endif + +/** + * @page test_benchmarks_013 RAM Footprint + * + *

Description

+ * The memory size of the various kernel objects is printed. + */ + +static void bmk13_execute(void) { + + test_print("--- System: "); + test_printn(sizeof(ch_system_t)); + test_println(" bytes"); + test_print("--- Thread: "); + test_printn(sizeof(thread_t)); + test_println(" bytes"); + test_print("--- Timer : "); + test_printn(sizeof(virtual_timer_t)); + test_println(" bytes"); +#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) + test_print("--- Semaph: "); + test_printn(sizeof(semaphore_t)); + test_println(" bytes"); +#endif +#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) + test_print("--- EventS: "); + test_printn(sizeof(event_source_t)); + test_println(" bytes"); + test_print("--- EventL: "); + test_printn(sizeof(event_listener_t)); + test_println(" bytes"); +#endif +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) + test_print("--- Mutex : "); + test_printn(sizeof(mutex_t)); + test_println(" bytes"); +#endif +#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) + test_print("--- CondV.: "); + test_printn(sizeof(condition_variable_t)); + test_println(" bytes"); +#endif +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) + test_print("--- Queue : "); + test_printn(sizeof(io_queue_t)); + test_println(" bytes"); +#endif +#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__) + test_print("--- MailB.: "); + test_printn(sizeof(mailbox_t)); + test_println(" bytes"); +#endif +} + +ROMCONST struct testcase testbmk13 = { + "Benchmark, RAM footprint", + NULL, + NULL, + bmk13_execute +}; + +/** + * @brief Test sequence for benchmarks. + */ +ROMCONST struct testcase * ROMCONST patternbmk[] = { +#if !TEST_NO_BENCHMARKS +#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__) + &testbmk1, + &testbmk2, + &testbmk3, +#endif + &testbmk4, + &testbmk5, + &testbmk6, +#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) + &testbmk7, +#endif + &testbmk8, +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) + &testbmk9, +#endif + &testbmk10, +#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) + &testbmk11, +#endif +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) + &testbmk12, +#endif + &testbmk13, +#endif + NULL +}; diff --git a/ChibiOS_16.1.5/test/rt/testbmk.h b/ChibiOS_16.1.5/test/rt/testbmk.h new file mode 100644 index 0000000..6325fbe --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbmk.h @@ -0,0 +1,22 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTBMK_H_ +#define _TESTBMK_H_ + +extern ROMCONST struct testcase * ROMCONST patternbmk[]; + +#endif /* _TESTBMK_H_ */ diff --git a/ChibiOS_16.1.5/test/rt/testbuild/Makefile b/ChibiOS_16.1.5/test/rt/testbuild/Makefile new file mode 100644 index 0000000..8886603 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/Makefile @@ -0,0 +1,146 @@ +# This makefile expects the following variables to be externally +# defined: +# XOPT - Compiler extra options +# XDEFS - Extra definitions + +############################################################################################## +# Start of default section +# + +TRGT = mingw32- +CC = $(TRGT)gcc +AS = $(TRGT)gcc -x assembler-with-cpp +AR = $(TRGT)ar +COV = gcov + +# List all default C defines here, like -D_DEBUG=1 +DDEFS = -DSIMULATOR + +# List all default ASM defines here, like -D_DEBUG=1 +DADEFS = + +# List all default directories to look for include files here +DINCDIR = + +# List the default directory to look for the libraries here +DLIBDIR = + +# List all default libraries here +DLIBS = -lws2_32 + +# +# End of default section +############################################################################################## + +############################################################################################## +# Start of user section +# + +# Define project name here +PROJECT = ch + +# Define linker script file here +LDSCRIPT= + +# List all user C define here, like -D_DEBUG=1 +UDEFS = + +# Define ASM defines here +UADEFS = + +# Imported source files +CHIBIOS = ../../.. +include $(CHIBIOS)/os/hal/boards/simulator/board.mk +include $(CHIBIOS)/os/hal/hal.mk +include $(CHIBIOS)/os/hal/ports/simulator/win32/platform.mk +include $(CHIBIOS)/os/hal/osal/rt/osal.mk +include $(CHIBIOS)/os/rt/ports/SIMIA32/compilers/GCC/port.mk +include $(CHIBIOS)/os/rt/rt.mk +include $(CHIBIOS)/test/rt/test.mk + +# List C source files here +SRC = $(PORTSRC) \ + $(KERNSRC) \ + $(TESTSRC) \ + $(HALSRC) \ + $(OSALSRC) \ + $(PLATFORMSRC) \ + $(BOARDSRC) \ + main.c + +# List ASM source files here +ASRC = + +# List all user directories here +UINCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ + $(HALINC) $(OSALINC) $(PLATFORMINC) $(BOARDINC) \ + $(CHIBIOS)/os/various + +# List the user directory to look for the libraries here +ULIBDIR = + +# List all user libraries here +ULIBS = + +# Define optimisation level here +OPT = $(XOPT) + +# +# End of user defines +############################################################################################## + + +INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR)) +LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) +DEFS = $(DDEFS) $(UDEFS) $(XDEFS) +ADEFS = $(DADEFS) $(UADEFS) +OBJS = $(ASRC:.s=.o) $(SRC:.c=.o) +LIBS = $(DLIBS) $(ULIBS) + +LDFLAGS = -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch -lgcov $(LIBDIR) +ASFLAGS = -Wa,-amhls=$(<:.s=.lst) $(ADEFS) +CPFLAGS = $(OPT) -Wall -Wextra -Wundef -Wstrict-prototypes -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(DEFS) + +# Generate dependency information +CPFLAGS += -MD -MP -MF .dep/$(@F).d + +# +# makefile rules +# + +all: $(OBJS) $(PROJECT).exe + +%.o : %.c + $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@ + +%.o : %.s + $(AS) -c $(ASFLAGS) $< -o $@ + +%.exe: $(OBJS) + $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ + +.PHONY: gcov +gcov: + $(COV) -u -f -b -o $(CHIBIOS)/os/rt/src $(KERNSRC) + +clean: + -rm -f $(OBJS) + -rm -f $(PROJECT).exe + -rm -f $(PROJECT).map + -rm -f $(SRC:.c=.c.bak) + -rm -f $(SRC:.c=.lst) + -rm -f $(SRC:.c=.gcno) + -rm -f $(SRC:.c=.gcda) + -rm -f $(ASRC:.s=.s.bak) + -rm -f $(ASRC:.s=.lst) + -rm -fR .dep + +misra: + @lint-nt -v -w3 $(DEFS) pclint/co-gcc.lnt pclint/au-misra3.lnt pclint/waivers.lnt $(INCDIR) $(KERNSRC) + +# +# Include the dependency files, should be the last of the makefile +# +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + +# *** EOF *** diff --git a/ChibiOS_16.1.5/test/rt/testbuild/chconf.h b/ChibiOS_16.1.5/test/rt/testbuild/chconf.h new file mode 100644 index 0000000..5b21d70 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/chconf.h @@ -0,0 +1,567 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file templates/chconf.h + * @brief Configuration file template. + * @details A copy of this file must be placed in each project directory, it + * contains the application specific kernel settings. + * + * @addtogroup config + * @details Kernel related settings and hooks. + * @{ + */ + +#ifndef _CHCONF_H_ +#define _CHCONF_H_ + +/*===========================================================================*/ +/** + * @name System timers settings + * @{ + */ +/*===========================================================================*/ + +/** + * @brief System time counter resolution. + * @note Allowed values are 16 or 32 bits. + */ +#if !defined(CH_CFG_ST_RESOLUTION) || defined(__DOXIGEN__) +#define CH_CFG_ST_RESOLUTION 32 +#endif + +/** + * @brief System tick frequency. + * @details Frequency of the system timer that drives the system ticks. This + * setting also defines the system tick time unit. + */ +#if !defined(CH_CFG_ST_FREQUENCY) || defined(__DOXIGEN__) +#define CH_CFG_ST_FREQUENCY 1000 +#endif + +/** + * @brief Time delta constant for the tick-less mode. + * @note If this value is zero then the system uses the classic + * periodic tick. This value represents the minimum number + * of ticks that is safe to specify in a timeout directive. + * The value one is not valid, timeouts are rounded up to + * this value. + */ +#if !defined(CH_CFG_ST_TIMEDELTA) || defined(__DOXIGEN__) +#define CH_CFG_ST_TIMEDELTA 0 +#endif + +/** @} */ + +/*===========================================================================*/ +/** + * @name Kernel parameters and options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Round robin interval. + * @details This constant is the number of system ticks allowed for the + * threads before preemption occurs. Setting this value to zero + * disables the preemption for threads with equal priority and the + * round robin becomes cooperative. Note that higher priority + * threads can still preempt, the kernel is always preemptive. + * @note Disabling the round robin preemption makes the kernel more compact + * and generally faster. + * @note The round robin preemption is not supported in tickless mode and + * must be set to zero in that case. + */ +#if !defined(CH_CFG_TIME_QUANTUM) || defined(__DOXIGEN__) +#define CH_CFG_TIME_QUANTUM 20 +#endif + +/** + * @brief Managed RAM size. + * @details Size of the RAM area to be managed by the OS. If set to zero + * then the whole available RAM is used. The core memory is made + * available to the heap allocator and/or can be used directly through + * the simplified core memory allocator. + * + * @note In order to let the OS manage the whole RAM the linker script must + * provide the @p __heap_base__ and @p __heap_end__ symbols. + * @note Requires @p CH_CFG_USE_MEMCORE. + */ +#if !defined(CH_CFG_MEMCORE_SIZE) || defined(__DOXIGEN__) +#define CH_CFG_MEMCORE_SIZE 0x20000 +#endif + +/** + * @brief Idle thread automatic spawn suppression. + * @details When this option is activated the function @p chSysInit() + * does not spawn the idle thread. The application @p main() + * function becomes the idle thread and must implement an + * infinite loop. + */ +#if !defined(CH_CFG_NO_IDLE_THREAD) || defined(__DOXIGEN__) +#define CH_CFG_NO_IDLE_THREAD FALSE +#endif + +/** @} */ + +/*===========================================================================*/ +/** + * @name Performance options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief OS optimization. + * @details If enabled then time efficient rather than space efficient code + * is used when two possible implementations exist. + * + * @note This is not related to the compiler optimization options. + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_OPTIMIZE_SPEED) || defined(__DOXIGEN__) +#define CH_CFG_OPTIMIZE_SPEED TRUE +#endif + +/** @} */ + +/*===========================================================================*/ +/** + * @name Subsystem options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Time Measurement APIs. + * @details If enabled then the time measurement APIs are included in + * the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_TM) || defined(__DOXIGEN__) +#define CH_CFG_USE_TM TRUE +#endif + +/** + * @brief Threads registry APIs. + * @details If enabled then the registry APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_REGISTRY) || defined(__DOXIGEN__) +#define CH_CFG_USE_REGISTRY TRUE +#endif + +/** + * @brief Threads synchronization APIs. + * @details If enabled then the @p chThdWait() function is included in + * the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_WAITEXIT) || defined(__DOXIGEN__) +#define CH_CFG_USE_WAITEXIT TRUE +#endif + +/** + * @brief Semaphores APIs. + * @details If enabled then the Semaphores APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_SEMAPHORES) || defined(__DOXIGEN__) +#define CH_CFG_USE_SEMAPHORES TRUE +#endif + +/** + * @brief Semaphores queuing mode. + * @details If enabled then the threads are enqueued on semaphores by + * priority rather than in FIFO order. + * + * @note The default is @p FALSE. Enable this if you have special + * requirements. + * @note Requires @p CH_CFG_USE_SEMAPHORES. + */ +#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY) || defined(__DOXIGEN__) +#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE +#endif + +/** + * @brief Mutexes APIs. + * @details If enabled then the mutexes APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_MUTEXES) || defined(__DOXIGEN__) +#define CH_CFG_USE_MUTEXES TRUE +#endif + +/** + * @brief Enables recursive behavior on mutexes. + * @note Recursive mutexes are heavier and have an increased + * memory footprint. + * + * @note The default is @p FALSE. + * @note Requires @p CH_CFG_USE_MUTEXES. + */ +#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE) || defined(__DOXIGEN__) +#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE +#endif + +/** + * @brief Conditional Variables APIs. + * @details If enabled then the conditional variables APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_MUTEXES. + */ +#if !defined(CH_CFG_USE_CONDVARS) || defined(__DOXIGEN__) +#define CH_CFG_USE_CONDVARS TRUE +#endif + +/** + * @brief Conditional Variables APIs with timeout. + * @details If enabled then the conditional variables APIs with timeout + * specification are included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_CONDVARS. + */ +#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT) || defined(__DOXIGEN__) +#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE +#endif + +/** + * @brief Events Flags APIs. + * @details If enabled then the event flags APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_EVENTS) || defined(__DOXIGEN__) +#define CH_CFG_USE_EVENTS TRUE +#endif + +/** + * @brief Events Flags APIs with timeout. + * @details If enabled then the events APIs with timeout specification + * are included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_EVENTS. + */ +#if !defined(CH_CFG_USE_EVENTS_TIMEOUT) || defined(__DOXIGEN__) +#define CH_CFG_USE_EVENTS_TIMEOUT TRUE +#endif + +/** + * @brief Synchronous Messages APIs. + * @details If enabled then the synchronous messages APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_MESSAGES) || defined(__DOXIGEN__) +#define CH_CFG_USE_MESSAGES TRUE +#endif + +/** + * @brief Synchronous Messages queuing mode. + * @details If enabled then messages are served by priority rather than in + * FIFO order. + * + * @note The default is @p FALSE. Enable this if you have special + * requirements. + * @note Requires @p CH_CFG_USE_MESSAGES. + */ +#if !defined(CH_CFG_USE_MESSAGES_PRIORITY) || defined(__DOXIGEN__) +#define CH_CFG_USE_MESSAGES_PRIORITY FALSE +#endif + +/** + * @brief Mailboxes APIs. + * @details If enabled then the asynchronous messages (mailboxes) APIs are + * included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_SEMAPHORES. + */ +#if !defined(CH_CFG_USE_MAILBOXES) || defined(__DOXIGEN__) +#define CH_CFG_USE_MAILBOXES TRUE +#endif + +/** + * @brief I/O Queues APIs. + * @details If enabled then the I/O queues APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_QUEUES) || defined(__DOXIGEN__) +#define CH_CFG_USE_QUEUES TRUE +#endif + +/** + * @brief Core Memory Manager APIs. + * @details If enabled then the core memory manager APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_MEMCORE) || defined(__DOXIGEN__) +#define CH_CFG_USE_MEMCORE TRUE +#endif + +/** + * @brief Heap Allocator APIs. + * @details If enabled then the memory heap allocator APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or + * @p CH_CFG_USE_SEMAPHORES. + * @note Mutexes are recommended. + */ +#if !defined(CH_CFG_USE_HEAP) || defined(__DOXIGEN__) +#define CH_CFG_USE_HEAP TRUE +#endif + +/** + * @brief Memory Pools Allocator APIs. + * @details If enabled then the memory pools allocator APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_MEMPOOLS) || defined(__DOXIGEN__) +#define CH_CFG_USE_MEMPOOLS TRUE +#endif + +/** + * @brief Dynamic Threads APIs. + * @details If enabled then the dynamic threads creation APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_WAITEXIT. + * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS. + */ +#if !defined(CH_CFG_USE_DYNAMIC) || defined(__DOXIGEN__) +#define CH_CFG_USE_DYNAMIC TRUE +#endif + +/** @} */ + +/*===========================================================================*/ +/** + * @name Debug options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Debug option, kernel statistics. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_STATISTICS) || defined(__DOXIGEN__) +#define CH_DBG_STATISTICS FALSE +#endif + +/** + * @brief Debug option, system state check. + * @details If enabled the correct call protocol for system APIs is checked + * at runtime. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXIGEN__) +#define CH_DBG_SYSTEM_STATE_CHECK FALSE +#endif + +/** + * @brief Debug option, parameters checks. + * @details If enabled then the checks on the API functions input + * parameters are activated. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXIGEN__) +#define CH_DBG_ENABLE_CHECKS FALSE +#endif + +/** + * @brief Debug option, consistency checks. + * @details If enabled then all the assertions in the kernel code are + * activated. This includes consistency checks inside the kernel, + * runtime anomalies and port-defined checks. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXIGEN__) +#define CH_DBG_ENABLE_ASSERTS FALSE +#endif + +/** + * @brief Debug option, trace buffer. + * @details If enabled then the context switch circular trace buffer is + * activated. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXIGEN__) +#define CH_DBG_ENABLE_TRACE FALSE +#endif + +/** + * @brief Debug option, stack checks. + * @details If enabled then a runtime stack check is performed. + * + * @note The default is @p FALSE. + * @note The stack check is performed in a architecture/port dependent way. + * It may not be implemented or some ports. + * @note The default failure mode is to halt the system with the global + * @p panic_msg variable set to @p NULL. + */ +#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXIGEN__) +#define CH_DBG_ENABLE_STACK_CHECK FALSE +#endif + +/** + * @brief Debug option, stacks initialization. + * @details If enabled then the threads working area is filled with a byte + * value when a thread is created. This can be useful for the + * runtime measurement of the used stack. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXIGEN__) +#define CH_DBG_FILL_THREADS FALSE +#endif + +/** + * @brief Debug option, threads profiling. + * @details If enabled then a field is added to the @p thread_t structure that + * counts the system ticks occurred while executing the thread. + * + * @note The default is @p FALSE. + * @note This debug option is not currently compatible with the + * tickless mode. + */ +#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXIGEN__) +#define CH_DBG_THREADS_PROFILING TRUE +#endif + +/** @} */ + +/*===========================================================================*/ +/** + * @name Kernel hooks + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Threads descriptor structure extension. + * @details User fields added to the end of the @p thread_t structure. + */ +#define CH_CFG_THREAD_EXTRA_FIELDS \ + /* Add threads custom fields here.*/ + +/** + * @brief Threads initialization hook. + * @details User initialization code added to the @p chThdInit() API. + * + * @note It is invoked from within @p chThdInit() and implicitly from all + * the threads creation APIs. + */ +#define CH_CFG_THREAD_INIT_HOOK(tp) { \ + /* Add threads initialization code here.*/ \ +} + +/** + * @brief Threads finalization hook. + * @details User finalization code added to the @p chThdExit() API. + * + * @note It is inserted into lock zone. + * @note It is also invoked when the threads simply return in order to + * terminate. + */ +#define CH_CFG_THREAD_EXIT_HOOK(tp) { \ + /* Add threads finalization code here.*/ \ +} + +/** + * @brief Context switch hook. + * @details This hook is invoked just before switching between threads. + */ +#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \ + /* Context switch code here.*/ \ +} + +/** + * @brief Idle thread enter hook. + * @note This hook is invoked within a critical zone, no OS functions + * should be invoked from here. + * @note This macro can be used to activate a power saving mode. + */ +#define CH_CFG_IDLE_ENTER_HOOK() { \ +} + +/** + * @brief Idle thread leave hook. + * @note This hook is invoked within a critical zone, no OS functions + * should be invoked from here. + * @note This macro can be used to deactivate a power saving mode. + */ +#define CH_CFG_IDLE_LEAVE_HOOK() { \ +} + +/** + * @brief Idle Loop hook. + * @details This hook is continuously invoked by the idle thread loop. + */ +#define CH_CFG_IDLE_LOOP_HOOK() { \ + /* Idle loop code here.*/ \ +} + +/** + * @brief System tick event hook. + * @details This hook is invoked in the system tick handler immediately + * after processing the virtual timers queue. + */ +#define CH_CFG_SYSTEM_TICK_HOOK() { \ + /* System tick event code here.*/ \ +} + +/** + * @brief System halt hook. + * @details This hook is invoked in case to a system halting error before + * the system is halted. + */ +#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \ + /* System halt code here.*/ \ +} + +/** @} */ + +/*===========================================================================*/ +/* Port-specific settings (override port settings defaulted in chcore.h). */ +/*===========================================================================*/ + +#endif /* _CHCONF_H_ */ + +/** @} */ diff --git a/ChibiOS_16.1.5/test/rt/testbuild/go.sh b/ChibiOS_16.1.5/test/rt/testbuild/go.sh new file mode 100644 index 0000000..ac73b78 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/go.sh @@ -0,0 +1,123 @@ +#!/bin/bash +export XOPT XDEFS + +XOPT="-ggdb -O0 -fomit-frame-pointer -DDELAY_BETWEEN_TESTS=0 -fprofile-arcs -ftest-coverage" +XDEFS="" + +function clean() { + echo -n " * Cleaning..." + make clean > /dev/null + echo "OK" +} + +function compile() { + echo -n " * Building..." + if ! make > buildlog.txt + then + echo "failed" + clean + exit + fi + mv -f buildlog.txt ./reports/${1}_build.txt + echo "OK" +} + +function execute_test() { + echo -n " * Testing..." + if ! ./ch > testlog.txt + then + echo "failed" + clean + exit + fi + mv -f testlog.txt ./reports/${1}_test.txt + echo "OK" +} + +function coverage() { + echo -n " * Coverage..." + mkdir reports/${1}_gcov 2> /dev/null + echo "Configuration $2" > gcovlog.txt + echo "----------------------------------------------------------------" >> reports/gcovlog.txt + if ! make gcov >> gcovlog.txt 2> /dev/null + then + echo "failed" + clean + exit + fi + mv -f gcovlog.txt ./reports/${1}_gcov.txt + mv -f *.gcov ./reports/${1}_gcov + echo "OK" +} + +function misra() { + echo -n " * Analysing..." + if ! make misra > misralog.txt 2> misraerrlog.txt + then + echo "failed" + clean + exit + fi + echo "OK" +} + +function test() { + if [ -z "$2" ] + then + msg=$1": Default Settings" + XDEFS= + else + msg=$1": "$2 + XDEFS=$2 + fi + echo $msg + compile $1 + execute_test $1 + coverage $1 "$msg" + misra + clean +} + +function partial() { + compile + execute_test + misra + clean +} + +mkdir reports 2> /dev/null + +test cfg1 "" +test cfg2 "-DCH_CFG_OPTIMIZE_SPEED=FALSE" +test cfg3 "-DCH_CFG_TIME_QUANTUM=0" +test cfg4 "-DCH_CFG_USE_REGISTRY=FALSE" +test cfg5 "-DCH_CFG_USE_TM=FALSE" +test cfg6 "-DCH_CFG_USE_SEMAPHORES=FALSE -DCH_CFG_USE_MAILBOXES=FALSE" +test cfg7 "-DCH_CFG_USE_SEMAPHORES_PRIORITY=TRUE" +test cfg8 "-DCH_CFG_USE_MUTEXES=FALSE -DCH_CFG_USE_CONDVARS=FALSE" +test cfg9 "-DCH_CFG_USE_MUTEXES_RECURSIVE=TRUE" +test cfg10 "-DCH_CFG_USE_CONDVARS=FALSE" +test cfg11 "-DCH_CFG_USE_CONDVARS_TIMEOUT=FALSE" +test cfg12 "-DCH_CFG_USE_EVENTS=FALSE" +test cfg13 "-DCH_CFG_USE_EVENTS_TIMEOUT=FALSE" +test cfg14 "-DCH_CFG_USE_MESSAGES=FALSE" +test cfg15 "-DCH_CFG_USE_MESSAGES_PRIORITY=TRUE" +test cfg16 "-DCH_CFG_USE_MAILBOXES=FALSE" +test cfg17 "-DCH_CFG_USE_MEMCORE=FALSE -DCH_CFG_USE_MEMPOOLS=FALSE -DCH_CFG_USE_HEAP=FALSE -DCH_CFG_USE_DYNAMIC=FALSE" +test cfg18 "-DCH_CFG_USE_MEMPOOLS=FALSE -DCH_CFG_USE_HEAP=FALSE -DCH_CFG_USE_DYNAMIC=FALSE" +test cfg19 "-DCH_CFG_USE_MEMPOOLS=FALSE" +test cfg20 "-DCH_CFG_USE_HEAP=FALSE" +test cfg21 "-DCH_CFG_USE_DYNAMIC=FALSE" +test cfg22 "-DCH_DBG_STATISTICS=TRUE" +test cfg23 "-DCH_DBG_SYSTEM_STATE_CHECK=TRUE" +test cfg24 "-DCH_DBG_ENABLE_CHECKS=TRUE" +test cfg25 "-DCH_DBG_ENABLE_ASSERTS=TRUE" +test cfg26 "-DCH_DBG_ENABLE_TRACE=TRUE" +#test cfg27 "-DCH_DBG_ENABLE_STACK_CHECK=TRUE" +test cfg28 "-DCH_DBG_FILL_THREADS=TRUE" +test cfg29 "-DCH_DBG_THREADS_PROFILING=FALSE" +test cfg30 "-DCH_DBG_SYSTEM_STATE_CHECK=TRUE -DCH_DBG_ENABLE_CHECKS=TRUE -DCH_DBG_ENABLE_ASSERTS=TRUE -DCH_DBG_ENABLE_TRACE=TRUE -DCH_DBG_FILL_THREADS=TRUE" + +rm *log.txt 2> /dev/null +echo +echo "Done" diff --git a/ChibiOS_16.1.5/test/rt/testbuild/halconf.h b/ChibiOS_16.1.5/test/rt/testbuild/halconf.h new file mode 100644 index 0000000..28f1842 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/halconf.h @@ -0,0 +1,381 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file templates/halconf.h + * @brief HAL configuration header. + * @details HAL configuration file, this file allows to enable or disable the + * various device drivers from your application. You may also use + * this file in order to override the device drivers default settings. + * + * @addtogroup HAL_CONF + * @{ + */ + +#ifndef _HALCONF_H_ +#define _HALCONF_H_ + +/*#include "mcuconf.h"*/ + +/** + * @brief Enables the PAL subsystem. + */ +#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) +#define HAL_USE_PAL FALSE +#endif + +/** + * @brief Enables the ADC subsystem. + */ +#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) +#define HAL_USE_ADC FALSE +#endif + +/** + * @brief Enables the CAN subsystem. + */ +#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) +#define HAL_USE_CAN FALSE +#endif + +/** + * @brief Enables the DAC subsystem. + */ +#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) +#define HAL_USE_DAC FALSE +#endif + +/** + * @brief Enables the EXT subsystem. + */ +#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__) +#define HAL_USE_EXT FALSE +#endif + +/** + * @brief Enables the GPT subsystem. + */ +#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) +#define HAL_USE_GPT FALSE +#endif + +/** + * @brief Enables the I2C subsystem. + */ +#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) +#define HAL_USE_I2C FALSE +#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__) +#define HAL_USE_ICU FALSE +#endif + +/** + * @brief Enables the MAC subsystem. + */ +#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) +#define HAL_USE_MAC FALSE +#endif + +/** + * @brief Enables the MMC_SPI subsystem. + */ +#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) +#define HAL_USE_MMC_SPI FALSE +#endif + +/** + * @brief Enables the PWM subsystem. + */ +#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) +#define HAL_USE_PWM FALSE +#endif + +/** + * @brief Enables the RTC subsystem. + */ +#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) +#define HAL_USE_RTC FALSE +#endif + +/** + * @brief Enables the SDC subsystem. + */ +#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) +#define HAL_USE_SDC FALSE +#endif + +/** + * @brief Enables the SERIAL subsystem. + */ +#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL FALSE +#endif + +/** + * @brief Enables the SERIAL over USB subsystem. + */ +#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL_USB FALSE +#endif + +/** + * @brief Enables the SPI subsystem. + */ +#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) +#define HAL_USE_SPI FALSE +#endif + +/** + * @brief Enables the UART subsystem. + */ +#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) +#define HAL_USE_UART FALSE +#endif + +/** + * @brief Enables the USB subsystem. + */ +#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) +#define HAL_USE_USB FALSE +#endif + +/** + * @brief Enables the WDG subsystem. + */ +#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) +#define HAL_USE_WDG FALSE +#endif + +/*===========================================================================*/ +/* ADC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) +#define ADC_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define ADC_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* CAN driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Sleep mode related APIs inclusion switch. + */ +#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) +#define CAN_USE_SLEEP_MODE TRUE +#endif + +/*===========================================================================*/ +/* I2C driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables the mutual exclusion APIs on the I2C bus. + */ +#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define I2C_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* MAC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables an event sources for incoming packets. + */ +#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) +#define MAC_USE_ZERO_COPY FALSE +#endif + +/** + * @brief Enables an event sources for incoming packets. + */ +#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) +#define MAC_USE_EVENTS TRUE +#endif + +/*===========================================================================*/ +/* MMC_SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + * This option is recommended also if the SPI driver does not + * use a DMA channel and heavily loads the CPU. + */ +#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) +#define MMC_NICE_WAITING TRUE +#endif + +/*===========================================================================*/ +/* SDC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Number of initialization attempts before rejecting the card. + * @note Attempts are performed at 10mS intervals. + */ +#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) +#define SDC_INIT_RETRY 100 +#endif + +/** + * @brief Include support for MMC cards. + * @note MMC support is not yet implemented so this option must be kept + * at @p FALSE. + */ +#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) +#define SDC_MMC_SUPPORT FALSE +#endif + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + */ +#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) +#define SDC_NICE_WAITING TRUE +#endif + +/*===========================================================================*/ +/* SERIAL driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Default bit rate. + * @details Configuration parameter, this is the baud rate selected for the + * default configuration. + */ +#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) +#define SERIAL_DEFAULT_BITRATE 38400 +#endif + +/** + * @brief Serial buffers size. + * @details Configuration parameter, you can change the depth of the queue + * buffers depending on the requirements of your application. + * @note The default is 16 bytes for both the transmission and receive + * buffers. + */ +#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_BUFFERS_SIZE 16 +#endif + +/*===========================================================================*/ +/* SERIAL_USB driver related setting. */ +/*===========================================================================*/ + +/** + * @brief Serial over USB buffers size. + * @details Configuration parameter, the buffer size must be a multiple of + * the USB data endpoint maximum packet size. + * @note The default is 256 bytes for both the transmission and receive + * buffers. + */ +#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_USB_BUFFERS_SIZE 256 +#endif + +/** + * @brief Serial over USB number of buffers. + * @note The default is 2 buffers. + */ +#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__) +#define SERIAL_USB_BUFFERS_NUMBER 2 +#endif + +/*===========================================================================*/ +/* SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) +#define SPI_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define SPI_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* UART driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__) +#define UART_USE_WAIT FALSE +#endif + +/** + * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define UART_USE_MUTUAL_EXCLUSION FALSE +#endif + +/*===========================================================================*/ +/* USB driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) +#define USB_USE_WAIT FALSE +#endif + +#endif /* _HALCONF_H_ */ + +/** @} */ diff --git a/ChibiOS_16.1.5/test/rt/testbuild/main.c b/ChibiOS_16.1.5/test/rt/testbuild/main.c new file mode 100644 index 0000000..5eccafa --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/main.c @@ -0,0 +1,49 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include + +#include "ch.h" +#include "hal.h" +#include "test.h" +#include "console.h" + +/* + * Simulator main. + */ +int main(int argc, char *argv[]) { + + (void)argc; + (void)argv; + + /* + * System initializations. + * - HAL initialization, this also initializes the configured device drivers + * and performs the board-specific initializations. + * - Kernel initialization, the main() function becomes a thread and the + * RTOS is active. + */ + halInit(); + conInit(); + chSysInit(); + + TestThread(&CD1); + if (test_global_fail) + exit(1); + else + exit(0); +} diff --git a/ChibiOS_16.1.5/test/rt/testbuild/pclint/au-misra3.lnt b/ChibiOS_16.1.5/test/rt/testbuild/pclint/au-misra3.lnt new file mode 100644 index 0000000..c20ded9 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/pclint/au-misra3.lnt @@ -0,0 +1,2173 @@ +/* Date Stamp */ -d"_lint_au_misra3_lnt=au-misra3.lnt modified 12-Jun-2014" +/* To document usage use: -message( "Using " _lint_au_misra3_lnt ) */ + +// --------------------------------------------------------------------- +// This file is provided by Gimpel Software (www.gimpel.com) for use with +// its products PC-lint and FlexeLint. +// +// Redistribution and use of this file, with or without modification, is +// permitted provided that any such redistribution retains this notice. +// --------------------------------------------------------------------- + +// au-misra3.lnt -- Author options - MISRA C 2012 + +/* + This options file can be used to explicitly activate those + checks advocated by the Motor Industry Software Reliability + Association. + + You can use this file directly when linting your programs as in: + + lin au-misra3 files + + Gimpel Software relies on the document, "MISRA-C:2012 + Guidelines for the use of the C language in critical systems", + copyright 2012 by MIRA Limited, as the primary source for this + file. Gimpel Software makes no warranty as to the completeness + or applicability of this options file and reserves the right to + amend or alter the official contents of such at any time. + + "MISRA" is a registered trademark of MIRA Limited, held on + behalf of the MISRA Consortium. + + */ + -misra(3) // Activate MISRA Essential Type model + +/**** Dir 1.1 (Req) ************/ + + /* not statically checkable */ + +/**** Dir 2.1 (Req) ************/ + + -A(C99) /* strict ISO C99 */ + /* Note: if you code to the C90 standard instead, you may + want to comment out the above option and uncomment the + following option. You will also want to do likewise for + other uses of the '-A(C99)' option throughout this file. */ + // -A(C90) /* strict ANSI */ + +e950 /* flag non-standard word or construct */ + +elib(950) + -append(950,[MISRA 2012 Directive 2.1, required]) + +/**** Dir 3.1 (Req) ************/ + + /* not statically checkable */ + +/**** Dir 4.1 (Req) ************/ + + /* not statically checkable */ + +/**** Dir 4.2 (Adv) ************/ + + /* not statically checkable */ + +/**** Dir 4.3 (Req) ************/ + + +e586 /* to activate the deprecation message */ + +elib(586) + -deprecate(keyword,asm,[MISRA 2012 4.3, required]) + +/**** Dir 4.4 (Adv) ************/ + + /* This requirement (that there be no commented-out code) is, in + principle, not statically checkable. The reason given for the + requirement is that comments do not nest. Thus a commented + out section of code that happens to use slash-star commenting + could inadvertently introduce unwanted code. Rule 3.1, however, + addresses the nested comment issue and hence the major concern + that this requirement seeks to address is indeed checkable. + */ + -fnc /* flag nested comments */ + +e602 /* comment within comment */ + +elib(602) + -append(602,[MISRA 2012 Directive 4.4, advisory]) + +/**** Dir 4.5 (Adv) ************/ + + // While Lint can enforce this directive with the following four + // options, doing so can increase the run time of Lint depending + // upon the number of identifiers in your program. If you want + // this checking, uncomment each of the following four options. + // + // +fta + // +e9046 /* typographical ambiguity */ + // +elib(9046) + // -append(9046,[MISRA 2012 Directive 4.5, advisory]) + +/**** Dir 4.6 (Adv) ************/ + + +e970 /* flag modifiers used outside of typedefs */ + +elib(970) + -append(970,[MISRA 2012 Directive 4.6, advisory]) + // For the duration, we are presuming MISRA does not want + // diagnostics for the bool type. + -esym(970,bool) + -esym(970,char) + +/**** Dir 4.7 (Req) ************/ + + +e534 /* ignoring return value of function */ + +elib(534) + -append(534,[MISRA 2012 Directive 4.7, required]) + +/**** Dir 4.8 (Adv) ************/ + + +e9045 /* non-hidden definition of type */ + +elib(9045) + -append(9045,[MISRA 2012 Directive 4.8, advisory]) + +/**** Dir 4.9 (Adv) ************/ + + +e9026 /* function-like macro defined */ + +elib(9026) + -append(9026,[MISRA 2012 Directive 4.9, advisory]) + +/**** Dir 4.10 (Req) ************/ + + +e451 /* Header repeatedly included without guard */ + +elib(451) + -append(451,[MISRA 2012 Directive 4.10, required]) + +/**** Dir 4.11 (Req) ************/ + + /* The arguments to over 100 calls to standard library functions + are monitored; users can specify additional constraints for + other functions. + */ + +/**** Dir 4.12 (Req) ************/ + + +e586 /* Symbol is deprecated */ + +elib(586) + -deprecate(function,calloc,[MISRA 2012 Directive 4.12, required]) + -deprecate(function,malloc,[MISRA 2012 Directive 4.12, required]) + -deprecate(function,realloc,[MISRA 2012 Directive 4.12, required]) + -deprecate(function,free,[MISRA 2012 Directive 4.12, required]) + +/**** Dir 4.13 (Adv) ************/ + + /* supported by uncommenting the next six options and use of the + -function_pair() option */ + // +e480 + // +elib(480) + // -append(480,[MISRA 2012 Directive 4.13, advisory]) + // +e481 + // +elib(481) + // -append(481,[MISRA 2012 Directive 4.13, advisory]) + +/**** Rule 1.1 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + -A(C99) /* strict ISO C99 */ + /* Note: if you code to the C90 standard instead, you may + want to comment out the above option and uncomment the + following option. You will also want to do likewise for + other uses of the '-A(C99)' option throughout this file. */ + // -A(C90) /* strict ANSI */ + +e950 /* flag non-standard word or construct */ + +elib(950) + -append(950,[MISRA 2012 Rule 1.1, required]) + +/**** Rule 1.2 (Adv) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + -A(C99) /* strict ISO C99 */ + /* Note: if you code to the C90 standard instead, you may + want to comment out the above option and uncomment the + following option. You will also want to do likewise for + other uses of the '-A(C99)' option throughout this file. */ + // -A(C90) /* strict ANSI */ + +e950 /* flag non-ANSI word or construct */ + +elib(950) + -append(950,[MISRA 2012 Rule 1.2, advisory]) + +/**** Rule 1.3 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + + /* Avoid the use of undefined or unspecified behavior as described + in ISO C, Appendix A.6.1 and Appendix A.6.2 */ + + /* Source file not ending in a new-line character, ending in + new-line character immediately preceded by a backslash + character, or ending in a partial preprocessing token or + comment (ISO C, Appendix A.6.2, point 1). + */ + +e406 /* unclosed comment */ + +elib(406) + -append(406,[MISRA 2012 Rule 1.3, required]) + + /* Non-standard character usage (ISO C, Appendix A.6.2, point 2). + */ + +e27 /* illegal character */ + +elib(27) + -append(27,[MISRA 2012 Rule 1.3, required]) + + /* Unclosed quotes (ISO C, Appendix A.6.2, point 4). + */ + +e2 /* unclosed quote */ + +elib(2) + -append(2,[MISRA 2012 Rule 1.3, required]) + + /* Repeated label within a function (ISO C, Appendix A.6.2, point + 5). + */ + +e31 /* symbol redefinition */ + +elib(31) + -append(31,[MISRA 2012 Rule 1.3, required]) + + /* Non-visible identifier used (ISO C, Appendix A.6.2, point 6). + */ + +e40 /* undeclared identifier */ + +elib(40) + -append(40,[MISRA 2012 Rule 1.3, required]) + + /* Identifiers for the same entity differ beyond the minimal + significant characters (ISO C, Appendix A.6.2, point 7). + See Rules 5.1, 5.2, 5.4, and 5.5. + */ + + /* The same identifier has both internal and external linkage in + the same translation unit (ISO C, Appendix A.6.2, point 8). + */ + +e401 /* symbol not previously declared static */ + +elib(401) + -append(401,[MISRA 2012 Rule 1.3, required]) + + /* Multiple definitions for the same externally linked identifier + (ISO C, Appendix A.6.2, point 9). + */ + +e31 /* symbol redefinition */ + +elib(31) + + /* Using automatic storage data via a pointer after the data's + lifetime (ISO C, Appendix A.6.2, point 10). + */ + +e604 /* returning address of auto variable */ + +elib(604) + -append(604,[MISRA 2012 Rule 1.3, required]) + +e934 /* taking address of near auto variable */ + +elib(934) + -append(934,[MISRA 2012 Rule 1.3, required]) + + /* Incompatible redeclarations (ISO C, Appendix A.6.2, point 11). + See Rule 8.3 + */ + + /* Non-standard escape sequence (ISO C, Appendix A.6.2, point 12). + */ + +e606 /* non-ANSI escape sequence */ + +elib(606) + -append(606,[MISRA 2012 Rule 1.3, required]) + + /* Non-standard character in header name (ISO C, Appendix A.6.2, + point 15). + See Rule 20.2 + */ + +e9020 /* header name with non-standard character */ + +elib(9020) + -append(9020,[MISRA 2012 Rule 1.3, required]) + + /* No complete type available (ISO C, Appendix A.6.2, point 16). + */ + +e86 /* structure has no data elements */ + +elib(86) + -append(86,[MISRA 2012 Rule 1.3, required]) + + /* Using or converting a void expression (ISO C, Appendix A.6.2, + point 17). + */ + +e64 /* type mismatch */ + +elib(64) + -append(64,[MISRA 2012 Rule 1.3, required]) + +e67 /* cannot cast between types */ + +elib(67) + -append(67,[MISRA 2012 Rule 1.3, required]) + +e144 /* non-existent return value */ + +elib(144) + -append(144,[MISRA 2012 Rule 1.3, required]) + + /* Modifying an object more than once or modifying and accessing + between two sequence points (ISO C, Appendix A.6.2, point 18). + See Rule 13.2 + */ + +e564 /* variable depends on order of evaluation */ + +elib(564) + -append(564,[MISRA 2012 Rule 1.3, required]) + + /* Invalid arithmetic operations or unrepresentable results + (ISO C, Appendix A.6.2, point 19). + */ + +e54 /* division by 0 */ + +elib(54) + -append(54,[MISRA 2012 Rule 1.3, required]) + +e414 /* possible division by 0 */ + +elib(414) + -append(414,[MISRA 2012 Rule 1.3, required]) + +e795 /* conceivable division by 0 */ + +elib(795) + -append(795,[MISRA 2012 Rule 1.3, required]) + /* Also, see Rule 12.4 */ + + /* Passing a void argument to a function (ISO C, Appendix A.6.2, + point 20). + */ + +e64 /* type mismatch */ + +elib(64) + + /* Incompatible function redeclaration (ISO C, Appendix A.6.2, + point 22). + See Rule 8.3 + */ + + /* An invalid array reference, null pointer reference, or + reference to an object declared with automatic storage duration in + a terminated block occurs (ISO C, Appendix A.6.2, point 24). + */ + +e64 /* type mismatch */ + +elib(64) + +e413 /* likely use of null pointer */ + +elib(413) + -append(413,[MISRA 2012 Rule 1.3, required]) + +e415 /* out-of-bounds pointer */ + +elib(415) + -append(415,[MISRA 2012 Rule 1.3, required]) + +e416 /* out-of-bounds pointer */ + +elib(416) + -append(416,[MISRA 2012 Rule 1.3, required]) + +e428 /* negative subscript */ + +elib(428) + -append(428,[MISRA 2012 Rule 1.3, required]) + /* Also, see Rule 17.6 */ + + /* A pointer to a function is converted to a pointer to an object + or a pointer to an object is converted to a pointer to a function + (ISO C, Appendix A.6.2, point 26). + */ + +e64 /* type mismatch */ + +elib(64) + +e740 /* unusual pointer cast */ + +elib(740) + -append(740,[MISRA 2012 Rule 1.3, required]) + /* Also, see Rule 11.1 and 11.2 */ + + /* A pointer is converted to other than an integral or pointer + type (ISO C, Appendix A.6.2, point 27). + */ + +e64 /* type mismatch */ + +elib(64) + +e71 /* cannot cast */ + +elib(71) + + /* An expression is shifted by a negative number or by an amount + greater than or equal to the width in bits of the expression being + shifted (ISO C, Appendix A.6.2, point 30). + */ + +e504 /* unusual shift */ + +elib(504) + -append(504,[MISRA 2012 Rule 1.3, required]) + + /* An identifier for an object is declared with no linkage and the + type of the object is incomplete after its declarator, or after its + init-declarator if it has an initializer (ISO C, Appendix + A.6.2, point 33). + */ + +e86 /* structure has no data elements */ + +elib(86) + + /* Declaring a function at block scope with a storage-class + specifier other than extern (ISO C, Appendix A.6.2, point 34). + */ + +e629 /* static class for function */ + +elib(629) + -append(629,[MISRA 2012 Rule 1.3, required]) + + /* A bit-field is declared with a type other than int, signed int, + or unsigned int (ISO C, Appendix A.6.2, point 35). + See Rule 6.1. + */ + + /* Attempting to modify an object with const-qualified type by + means of an lvalue with non-const-qualified type (ISO C, + Appendix A.6.2, point 36). + */ + +e158 /* assignment increases capability */ + +elib(158) + -append(158,[MISRA 2012 Rule 1.3, required]) + + /* Attempting to refer to an object with volatile-qualified type + by means of an lvalue with non-volatile-qualified type (ISO C, + Appendix A.6.2, point 37). + */ + +e158 /* assignment increases capability */ + +elib(158) + + /* Using the value of uninitialized automatic object (ISO C, + Appendix A.6.2, point 38). + See Rule 9.1 + */ + + /* An object with aggregate or union type with static storage + duration has a non-brace-enclosed initializer, or an object + with aggregate or union type with automatic storage duration + has either a single expression initializer with a type other + than that of the object or a non-brace-enclosed initializer + (ISO C, Appendix A.6.2, point 39). + Also, see Rule 9.2 + */ + +e64 /* type mismatch */ + +elib(64) + + /* The value of a function is used, but no value was returned + (ISO C, Appendix A.6.2, point 40). + See Rule 17.4. + */ + + /* A function that accepts a variable number of arguments is + defined without a parameter type list that ends with the + ellipsis notation (ISO C, Appendix A.6.2, point 41). + */ + + /* An identifier for an object with internal linkage and an + incomplete type is declared with a tentative definition (ISO C, + Appendix A.6.2, point 42). + */ + +e86 /* structure has no data elements */ + +elib(86) + + /* Non-standard #include preprocessing directive (ISO C, Appendix + A.6.2, point 44). + See Rule 20.3. + */ + + /* Non-standard #line directive (ISO C, Appendix A.6.2, point 49). + */ + +"estring(10,a numeric constant)" /* expecting a numeric constant */ + + /* #defining or #undefing any of: defined, __LINE__, __FILE__, + __DATE__, __TIME__, or __STDC__ (ISO C, Appendix A.6.2, point 50). + */ + +e136 /* illegal macro name */ + +elib(136) + -append(136,[MISRA 2012 Rule 1.3, required]) + + /* Format-argument mismatch in an fprintf or fscanf type of + function (ISO C, Appendix A.6.2, point 75). + */ + +e558 /* too few arguments */ + +elib(558) + -append(558,[MISRA 2012 Rule 1.3, required]) + +e719 /* too many arguments */ + +elib(719) + -append(719,[MISRA 2012 Rule 1.3, required]) + + /* A %% conversion specification for the fprintf or fscanf + function contains characters between the pair of % characters + (ISO C, Appendix A.6.2, point 77). + */ + +e557 /* unrecognized format */ + +elib(557) + -append(557,[MISRA 2012 Rule 1.3, required]) + + /* An aggregate or union, or a pointer to an aggregate or union is + an argument to the fprintf function, except for the conversion + specifiers %s (for an array of character type) or %p (for a pointer + to void) (ISO C, Appendix A.6.2, point 81). + */ + +e437 /* passing struct to ellipsis */ + +elib(437) + -append(437,[MISRA 2012 Rule 1.3, required]) + + /* Referring to deallocated space (ISO C, Appendix A.6.2, point + 87). + */ + +e449 /* previously deallocated pointer */ + +elib(449) + -append(449,[MISRA 2012 Rule 1.3, required]) + + /* Misuse of free or realloc (ISO C, Appendix A.6.2, point 88). + */ + +esym(424,free) /* inappropriate deallocation */ + -append(424,[MISRA 2012 Rule 1.3, required]) + + /* An array written to by a copying or concatenation function is + too small (ISO C, Appendix A.6.2, point 91). + */ + +e419 /* data overrun */ + +elib(419) + -append(419,[MISRA 2012 Rule 1.3, required]) + + /* Order of evaluation (ISO C, Appendix A.6.1, point 7). + */ + +e564 /* variable depends on order of evaluation */ + +elib(564) + -append(564,[MISRA 2012 Rule 1.3, required]) + + /* Side effects order (ISO C, Appendix A.6.1, point 8). + */ + +e931 /* both sides of an expression have side-effects */ + +elib(931) + -append(931,[MISRA 2012 Rule 1.3, required]) + + /* Function argument evaluation (ISO C, Appendix A.6.1, point 9). + */ + +e564 /* variable depends on order of evaluation */ + +elib(564) + + /* The order in which # and ## operations are evaluated during + macro substitution (ISO C, Appendix A.6.1, point 12). + */ + +e9023 /* multiple '#/##' operators in macro definition */ + +elib(9023) + -append(9023,[MISRA 2012 Rule 1.3, required]) + + /* Whether setjmp is a macro or an external identifier (ISO C, + Appendix A.6.1, point 14). + See Rule 21.2. + */ + +/**** Rule 2.1 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e506 /* constant value boolean */ + +elib(506) + -append(506,[MISRA 2012 Rule 2.1, required]) + +e527 /* unreachable */ + +elib(527) + -append(527,[MISRA 2012 Rule 2.1, required]) + +e681 /* loop not entered */ + +elib(681) + -append(681,[MISRA 2012 Rule 2.1, required]) + +e827 /* loop not reachable */ + +elib(827) + -append(827,[MISRA 2012 Rule 2.1, required]) + +/**** Rule 2.2 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e438 /* value not used */ + +elib(438) + -append(438,[MISRA 2012 Rule 2.2, required]) + +e505 /* redundant argument to comma */ + +elib(505) + -append(505,[MISRA 2012 Rule 2.2, required]) + +e520 /* highest operator has no side effects */ + +elib(520) + -append(520,[MISRA 2012 Rule 2.2, required]) + +e521 /* highest operator has no side effects */ + +elib(521) + -append(521,[MISRA 2012 Rule 2.2, required]) + +e522 /* highest operator has no side effects */ + +elib(522) + -append(522,[MISRA 2012 Rule 2.2, required]) + +/**** Rule 2.3 (Adv) ************/ + + +e751 /* local typedef not referenced */ + +elib(751) + -append(751,[MISRA 2012 Rule 2.3, advisory]) + +e756 /* global not referenced */ + +elib(756) + -append(756,[MISRA 2012 Rule 2.3, advisory]) + +/**** Rule 2.4 (Adv) ************/ + + +e753 /* local tag not referenced */ + +elib(753) + -append(753,[MISRA 2012 Rule 2.4, advisory]) + +e9058 + +elibsym(9058) + -append(9058,[MISRA 2012 Rule 2.4, advisory]) + +/**** Rule 2.5 (Adv) ************/ + + +e750 /* local macro not referenced */ + +elib(750) + -append(750,[MISRA 2012 Rule 2.5, advisory]) + +e755 /* global macro not referenced */ + +elib(755) + -append(755,[MISRA 2012 Rule 2.5, advisory]) + +/**** Rule 2.6 (Adv) ************/ + + +e563 /* label not referenced */ + +elib(563) + -append(563,[MISRA 2012 Rule 2.6, advisory]) + +/**** Rule 2.7 (Adv) ************/ + + +e715 /* not referenced */ + +elib(715) + -append(715,[MISRA 2012 Rule 2.7, advisory]) + +/**** Rule 3.1 (Req) ************/ + + -fnc /* flag nested comments */ + +e602 /* comment within comment */ + +elib(602) + -append(602,[MISRA 2012 Rule 3.1, required]) + +e9059 + +elib(9059) + -append(9059,[MISRA 2012 Rule 3.1, required]) + +e9066 + +elib(9066) + -append(9066,[MISRA 2012 Rule 3.1, required]) + +/**** Rule 3.2 (Req) ************/ + + +e427 /* C++ comment ends in \\ */ + +elib(427) + -append(427,[MISRA 2012 Rule 3.2, required]) + +/**** Rule 4.1 (Req) ************/ + + +e9039 /* prohibited escape sequence */ + +elib(9039) + -append(9039,[MISRA 2012 Rule 4.1, required]) + +/**** Rule 4.2 (Adv) ************/ + + -ftg /* inhibit use of trigraphs */ + +e584 /* activate trigraph detected message */ + +elib(584) + -append(584,[MISRA 2012 Rule 4.2, advisory]) + +e739 /* activate trigraph in string message */ + +elib(739) + -append(739,[MISRA 2012 Rule 4.2, advisory]) + +e9060 /* trigraph in comment */ + +elib(9060) + -append(9060,[MISRA 2012 Rule 4.2, advisory]) + +/**** Rule 5.1 (Req) ************/ + + -idlen(31) /* flag names identical in the first 31 characters */ + +e621 /* Identifier clash - length set by -idlen */ + +elib(621) + -append(621,[MISRA 2012 Rule 5.1, required]) + +/**** Rule 5.2 (Req) ************/ + + -idlen(31) /* flag names identical in the first 31 characters */ + +e621 /* Identifier clash - length set by -idlen */ + +elib(621) + -append(621,[MISRA 2012 Rule 5.2, required]) + +/**** Rule 5.3 (Req) ************/ + + +e578 /* enable reports of name hiding */ + +elib(578) + -append(578,[MISRA 2012 Rule 5.3, required]) + +/**** Rule 5.4 (Req) ************/ + + -idlen(31) /* flag names identical in the first 31 characters */ + +e621 /* Identifier clash - length set by -idlen */ + +elib(621) + -append(621,[MISRA 2012 Rule 5.4, required]) + +/**** Rule 5.5 (Req) ************/ + + +e123 /* macro defined with arguments */ + +elib(123) + -append(123,[MISRA 2012 Rule 5.5, required]) + -idlen(31) /* flag names identical in the first 31 characters */ + +e621 /* Identifier clash - length set by -idlen */ + +elib(621) + -append(621,[MISRA 2012 Rule 5.5, required]) + +e9061 /* non-distinct identifier */ + +elib(9061) + -append(9061,[MISRA 2012 Rule 5.5, required]) + +/**** Rule 5.6 (Req) ************/ + + +e578 /* enable reports of name hiding */ + +elib(578) + -append(578,[MISRA 2012 Rule 5.6, required]) + +e623 /* redefining the storage class of symbol */ + +elib(623) + -append(623,[MISRA 2012 Rule 5.6, required]) + +estring(9062,typedef) /* non-unique typedef */ + +elib(9062) + -append(9062(typedef),[MISRA 2012 Rule 5.6, required]) + +/**** Rule 5.7 (Req) ************/ + + +e407 /* Inconsistent use of tag */ + +elib(407) + -append(407,[MISRA 2012 Rule 5.7, required]) + +e578 /* Declaration of Symbol hides Symbol */ + +elib(578) + -append(578,[MISRA 2012 Rule 5.7, required]) + +e14 /* Symbol previously defined */ + +elib(14) + -append(14,[MISRA 2012 Rule 5.7, required]) + +e15 /* Symbol redeclared */ + +elib(15) + -append(15,[MISRA 2012 Rule 5.7, required]) + +e631 /* Tag defined differently */ + +elib(631) + -append(631,[MISRA 2012 Rule 5.7, required]) + +e9062 /* non-unique tag */ + +elib(9062) + -append(9062(tag),[MISRA 2012 Rule 5.7, required]) + +/**** Rule 5.8 (Req) ************/ + + +e401 /* Symbol not previously declared static */ + +elib(401) + -append(401,[MISRA 2012 Rule 5.8, required]) + +e578 /* Declaration of Symbol hides Symbol */ + +elib(578) + -append(578,[MISRA 2012 Rule 5.8, required]) + +e580 /* enable reports of name hiding */ + +elib(580) + -append(580,[MISRA 2012 Rule 5.8, required]) + +/**** Rule 5.9 (Adv) ************/ + + +e578 /* enable reports of name hiding */ + +elib(578) + -append(578,[MISRA 2012 Rule 5.9, advisory]) + +e580 /* enable reports of name hiding */ + +elib(580) + -append(580,[MISRA 2012 Rule 5.9, advisory]) + +/**** Rule 6.1 (Req) ************/ + + +e46 /* field type should be int */ + +elib(46) + -append(46,[MISRA 2012 Rule 6.1, required]) + +e806 /* small bit field is signed rather than unsigned */ + +elib(806) + -append(806,[MISRA 2012 Rule 6.1, required]) + +/**** Rule 6.2 (Req) ************/ + + +e9088 /* named signed single-bit bit-field */ + +elib(9088) + -append(9088,[MISRA 2012 Rule 6.2, required]) + +/**** Rule 7.1 (Req) ************/ + + +e9001 /* Octal constant used */ + +elib(9001) + -append(9001,[MISRA 2012 Rule 7.1, required]) + +/**** Rule 7.2 (Req) ************/ + + +e9048 /* unsigned literal without 'U' suffix */ + +elib(9048) + -append(9048,[MISRA 2012 Rule 7.2, required]) + +/**** Rule 7.3 (Req) ************/ + + +e620 /* suspicious constant */ + +elib(620) + -append(620,[MISRA 2012 Rule 7.3, required]) + +e9057 /* "l" after "u" in literal suffix */ + +elib(9057) + -append(9057,[MISRA 2012 Rule 7.3, required]) + +/**** Rule 7.4 (Req) ************/ + + +fsc + +e489 /* attempting to modify a string literal */ + +elib(489) + -append(489,[MISRA 2012 Rule 7.4, required]) + +e1776 /* string literal not const safe */ + +elib(1776) + -append(1776,[MISRA 2012 Rule 7.4, required]) + +e1778 /* assignment of string literal not const safe */ + +elib(1778) + -append(1778,[MISRA 2012 Rule 7.4, required]) + +/**** Rule 8.1 (Req) ************/ + + +e601 /* no explicit type */ + +elib(601) + -append(601,[MISRA 2012 Rule 8.1, required]) + +e745 /* function has no explicit type */ + +elib(745) + -append(745,[MISRA 2012 Rule 8.1, required]) + +e808 /* no explicit type */ + +elib(808) + -append(808,[MISRA 2012 Rule 8.1, required]) + +e832 /* parameter has no explicit type */ + +elib(832) + -append(832,[MISRA 2012 Rule 8.1, required]) + +e939 /* return type defaults to int */ + +elib(939) + -append(939,[MISRA 2012 Rule 8.1, required]) + +/**** Rule 8.2 (Req) ************/ + + +e937 /* old-style function declaration */ + +elib(937) + -append(937,[MISRA 2012 Rule 8.2, required]) + +e745 /* function has no explicit type */ + +elib(745) + -append(745,[MISRA 2012 Rule 8.2, required]) + +e939 /* return type defaults to int */ + +elib(939) + -append(939,[MISRA 2012 Rule 8.2, required]) + -fvr /* varying return mode not allowed */ + -strong() /* enable strong typing for + declarations */ + +e18 /* symbol redeclared */ + +elib(18) + -append(18,[MISRA 2012 Rule 8.2, required]) + + +e936 /* old-style function definition */ + +elib(936) + -append(936,[MISRA 2012 Rule 8.2, required]) + + +e955 /* param name missing from prototype */ + +elib(955) + -append(955,[MISRA 2012 Rule 8.2, required]) + +/**** Rule 8.3 (Req) ************/ + + -fvr /* varying return mode not allowed */ + -strong() /* enable strong typing for declarations */ + +e18 /* symbol redeclared */ + +elib(18) + -append(18,[MISRA 2012 Rule 8.3, required]) + +e516 /* argument type conflict */ + +elib(516) + -append(516,[MISRA 2012 Rule 8.3, required]) + +e532 /* return mode of symbol inconsistent */ + +elib(532) + -append(532,[MISRA 2012 Rule 8.3, required]) + +e9072 /* parameter list differs */ + +elib(9072) + -append(9072,[MISRA 2012 Rule 8.3, required]) + +/**** Rule 8.4 (Req) ************/ + + +e15 /* symbol redeclared */ + +elib(15) + -append(15,[MISRA 2012 Rule 8.4, required]) + +e64 /* flag type mismatch */ + +elib(64) + -append(64,[MISRA 2012 Rule 8.4, required]) + +e516 /* argument type mismatch */ + +elib(516) + -append(516,[MISRA 2012 Rule 8.4, required]) + +e9075 /* extern defined without prior declaration */ + +elib(9075) + -append(9075,[MISRA 2012 Rule 8.4, required]) + +/**** Rule 8.5 (Req) ************/ + + +e9004 /* object/function previously declared */ + +elib(9004) + -append(9004,[MISRA 2012 Rule 8.5, required]) + +/**** Rule 8.6 (Req) ************/ + + --fmd /* diallow multiple definitions */ + +e14 /* Symbol previously defined */ + +elib(14) + -append(14,[MISRA 2012 Rule 8.6, required]) + +/**** Rule 8.7 (Adv) ************/ + + +e765 /* could be made static */ + +elib(765) + -append(765,[MISRA 2012 Rule 8.7, advisory]) + +/**** Rule 8.8 (Req) ************/ + + +e839 /* storage class assumed static */ + +elib(839) + -append(839,[MISRA 2012 Rule 8.8, required]) + +/**** Rule 8.9 (Adv) ************/ + + +e9003 /* could define variable at block scope */ + +elib(9003) + -append(9003,[MISRA 2012 Rule 8.9, advisory]) + +/**** Rule 8.10 (Req) ************/ + + +e695 /* inline function without storage-class specifier */ + +elib(695) + -append(695,[MISRA 2012 Rule 8.10, required]) + +estring(9056,extern) /* inline function defined with extern */ + -append(9056,[MISRA 2012 Rule 8.10, required]) + +/**** Rule 8.11 (Adv) ************/ + + +e9067 /* array has no dimension or initializer */ + +elib(9067) + -append(9067,[MISRA 2012 Rule 8.11, advisory]) + +/**** Rule 8.12 (Req) ************/ + + +e488 /* duplicate enumerator values */ + +elib(488) + -append(488,[MISRA 2012 Rule 8.12, required]) + +/**** Rule 8.13 (Adv) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e818 /* pointer could be declared pointing to const */ + +elib(818) + -append(818,[MISRA 2012 Rule 8.13, advisory]) + +e844 /* pointer could be declared pointing to const */ + +elib(844) + -append(844,[MISRA 2012 Rule 8.13, advisory]) + +e954 /* pointer could be declared pointing to const */ + +elib(954) + -append(954,[MISRA 2012 Rule 8.13, advisory]) + +/**** Rule 8.14 (Req) ************/ + + +e586 /* Symbol is deprecated */ + +elib(586) + -deprecate(keyword,restrict,[MISRA 2012 Rule 8.14, required]) + +/**** Rule 9.1 (Mand) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e644 /* Symbol may not have been initialized */ + +elib(644) + -append(644,[MISRA 2012 Rule 9.1, mandatory]) + +e771 /* Symbol conceivably not initialized */ + +elib(771) + -append(771,[MISRA 2012 Rule 9.1, mandatory]) + +e530 /* Symbol not initialized */ + +elib(530) + -append(530,[MISRA 2012 Rule 9.1, mandatory]) + -specific(+e644 +e771 +e530,) + +/**** Rule 9.2 (Req) ************/ + + +e9069 /* omitted braces within an initializer */ + +elib(9069) + -append(9069,[MISRA 2012 Rule 9.2, required]) + +/**** Rule 9.3 (Req) ************/ + + +e9068 /* too few initializers */ + +elib(9068) + -append(9068,[MISRA 2012 Rule 9.3, required]) + +/**** Rule 9.4 (Req) ************/ + + +e485 /* duplicate initialization */ + +elib(485) + -append(485,[MISRA 2012 Rule 9.4, required]) + +/**** Rule 9.5 (Req) ************/ + + +e9054 /* designated initializer and dimensionless array */ + +elib(9054) + -append(9054,[MISRA 2012 Rule 9.5, required]) + +/**** Rule 10.1 (Req) ************/ + + +e48 /* bad type */ + +elib(48) + -append(48,[MISRA 2012 Rule 10.1, required]) + +e9027 /* unpermitted operand */ + +elib(9027) + -append(9027,[MISRA 2012 Rule 10.1, required]) + +/**** Rule 10.2 (Req) ************/ + + +e9028 /* unpermitted arithmetic */ + +elib(9028) + -append(9028,[MISRA 2012 Rule 10.2, required]) + +/**** Rule 10.3 (Req) ************/ + + +e9034 /* expression assigned to narrower or different essential type */ + +elib(9034) + // Note: the following -d options for true and false don't apply + // to C90 and should be commented out if not using C99 + +"dtrue=/*lint -save -e921 */(_Bool) 1/*lint -restore */" // exception + +"dfalse=/*lint -save -e921 */(_Bool) 0/*lint -restore */" // exception + -append(9034,[MISRA 2012 Rule 10.3, required]) + +/**** Rule 10.4 (Req) ************/ + + +e9029 /* mismatched essential type */ + +elib(9029) + -append(9029,[MISRA 2012 Rule 10.4, required]) + +/**** Rule 10.5 (Adv) ************/ + + +e9030 /* impermissible cast */ + +elib(9030) + -append(9030,[MISRA 2012 Rule 10.5, advisory]) + +/**** Rule 10.6 (Req) ************/ + + +e9031 /* composite expression assigned to wider essential type */ + +elib(9031) + -append(9031,[MISRA 2012 Rule 10.6, required]) + +/**** Rule 10.7 (Req) ************/ + + +e9032 /* composite expression with smaller essential type than other operand*/ + +elib(9032) + -append(9032,[MISRA 2012 Rule 10.7, required]) + +/**** Rule 10.8 (Req) ************/ + + +e9033 /* impermissible cast of composite expression */ + +elib(9033) + -append(9033,[MISRA 2012 Rule 10.8, required]) + +/**** Rule 11.1 (Req) ************/ + + +e9074 /* conversion between a pointer to function and another type */ + +elib(9074) + --emacro((9074),NULL) /* explicit exception */ + -append(9074,[MISRA 2012 Rule 11.1, required]) + +/**** Rule 11.2 (Req) ************/ + + +e9076 /* conversion between a pointer to incomplete type and another type */ + +elib(9076) + --emacro((9076),NULL) /* explicit exception */ + -append(9076,[MISRA 2012 Rule 11.2, required]) + +/**** Rule 11.3 (Req) ************/ + + +e9087 /* cast from pointer to pointer */ + +elib(9087) + -append(9087,[MISRA 2012 Rule 11.3, required]) + +/**** Rule 11.4 (Adv) ************/ + + +e9078 /* cast pointer/integer */ + +elib(9078) + -append(9078,[MISRA 2012 Rule 11.4, advisory]) + +/**** Rule 11.5 (Adv) ************/ + + +e9079 /* cast from pointer to pointer */ + +elib(9079) + -append(9079,[MISRA 2012 Rule 11.5, advisory]) + +/**** Rule 11.6 (Req) ************/ + + +e923 /* cast pointer/non-pointer */ + +elib(923) + -append(923,[MISRA 2012 Rule 11.6, required]) + +/**** Rule 11.7 (Req) ************/ + + +e68 /* cast pointer/float */ + +elib(68) + -append(68,[MISRA 2012 Rule 11.7, required]) + +e70 /* cast pointer/float */ + +elib(70) + -append(70,[MISRA 2012 Rule 11.7, required]) + +/**** Rule 11.8 (Req) ************/ + + +e9005 /* attempt to cast away const/volatile from pointer or reference */ + +elib(9005) + -append(9005,[MISRA 2012 Rule 11.8, required]) + +/**** Rule 11.9 (Req) ************/ + + +e910 /* conversion from 0 to pointer */ + +elib(910) + --emacro((910),NULL) /* explicit exception */ + -append(910,[MISRA 2012 Rule 11.9, required]) + +e9080 /* integer null pointer constant */ + +elib(9080) + -append(9080,[MISRA 2012 Rule 11.9, required]) + +/**** Rule 12.1 (Adv) ************/ + + +e9050 /* dependence placed on precedence */ + +elib(9050) + -append(9050,[MISRA 2012 Rule 12.1, advisory]) + +/**** Rule 12.2 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e598 /* excessive left shift */ + +elib(598) + -append(598,[MISRA 2012 Rule 12.2, required]) + +e9053 /* shift value exceeds size of LHS */ + +elib(9053) + -append(9053,[MISRA 2012 Rule 12.2, required]) + +/**** Rule 12.3 (Adv) ************/ + + +e9008 /* comma operator used */ + +elib(9008) + -append(9008,[MISRA 2012 Rule 12.3, advisory]) + +/**** Rule 12.4 (Adv) ************/ + + +elib(648) /* Overflow in computing constant */ + +estring(648,unsigned addition) + +estring(648,unsigned multiplication) + +estring(648,unsigned sub.) + +estring(648,unsigned shift left) + +estring(648,unsigned shift right) + -append(648,[MISRA 2012 Rule 12.4, advisory]) + +/**** Rule 13.1 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e446 /* side effect in initializer */ + +elib(446) + -append(446,[MISRA 2012 Rule 13.1, required]) + +/**** Rule 13.2 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e564 /* variable depends on order of evaluation */ + +elib(564) + -append(564,[MISRA 2012 Rule 13.2, required]) + +e864 /* variable possibly depends on order of evaluation */ + +elib(864) + -append(864,[MISRA 2012 Rule 13.2, required]) + +e931 /* both sides have side effects */ + +elib(931) + -append(931,[MISRA 2012 Rule 13.2, required]) + +/**** Rule 13.3 (Adv) ************/ + + +e9049 /* increment/decrement combined with other operations */ + +elib(9049) + -append(9049,[MISRA 2012 Rule 13.3, advisory]) + +/**** Rule 13.4 (Adv) ************/ + + +e720 /* Boolean test of assignment */ + +elib(720) + -append(720,[MISRA 2012 Rule 13.4, advisory]) + +e820 /* Boolean test of parenthesized assignment */ + +elib(820) + -append(820,[MISRA 2012 Rule 13.4, advisory]) + +e9084 /* assignment used inside larger + expression */ + +elib(9084) + -append(9084,[MISRA 2012 Rule 13.4, advisory]) + +/**** Rule 13.5 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e9007 /* side effects on right hand side of logical operator */ + +elib(9007) + -append(9007,[MISRA 2012 Rule 13.5, required]) + +/**** Rule 13.6 (Mand) ************/ + + +e9006 /* sizeof used with expression with side effect */ + +elib(9006) + -append(9006,[MISRA 2012 Rule 13.6, mandatory]) + +e9089 /* potential side-effect in argument to sizeof */ + +elib(9089) + -append(9089,[MISRA 2012 Rule 13.6, mandatory]) + +/**** Rule 14.1 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e9009 /* floating point variable used as loop counter */ + +elib(9009) + -append(9009,[MISRA 2012 Rule 14.1, required]) + +/**** Rule 14.2 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e850 /* index variable modified in body of for loop */ + +elib(850) + -append(850,[MISRA 2012 Rule 14.2, required]) + +/**** Rule 14.3 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e685 /* relational always evaluates to true/false */ + +elib(685) + -append(685,[MISRA 2012 Rule 14.3, required]) + +e774 /* boolean always evaluates to true/false */ + +elib(774) + -append(774,[MISRA 2012 Rule 14.3, required]) + +e650 /* constant out of range for operator */ + +elib(650) + -append(650,[MISRA 2012 Rule 14.3, required]) + +/**** Rule 14.4 (Req) ************/ + + +e9036 /* condition should have essentially Boolean type */ + +elib(9036) + -append(9036,[MISRA 2012 Rule 14.4, required]) + +/**** Rule 15.1 (Adv) ************/ + + +e801 /* use of 'goto' is deprecated */ + +elib(801) + -append(801,[MISRA 2012 Rule 15.1, advisory]) + +/**** Rule 15.2 (Req) ************/ + + +e9064 /* goto references earlier label */ + +elib(9064) + -append(9064,[MISRA 2012 Rule 15.2, required]) + +/**** Rule 15.3 (Req) ************/ + + +e9041 /* goto not nested in the same block as label */ + +elib(9041) + -append(9041,[MISRA 2012 Rule 15.3, required]) + +/**** Rule 15.4 (Adv) ************/ + + +e9011 /* more than one 'break' terminates loop */ + +elib(9011) + -append(9011,[MISRA 2012 Rule 15.4, advisory]) + +/**** Rule 15.5 (Adv) ************/ + + +e904 /* return before function end */ + +elib(904) + -append(904,[MISRA 2012 Rule 15.5, advisory]) + +/**** Rule 15.6 (Req) ************/ + + +e9012 /* sub-statement should be a compound statement */ + +elib(9012) + -append(9012,[MISRA 2012 Rule 15.6, required]) + +/**** Rule 15.7 (Req) ************/ + + +e9013 /* no 'else' at end of 'if ... else if' chain */ + +elib(9013) + -append(9013,[MISRA 2012 Rule 15.7, required]) + +e9063 /* no comment or action in else-branch */ + +elib(9063) + -append(9063,[MISRA 2012 Rule 15.7, required]) + +/**** Rule 16.1 (Req) ************/ + + +e616 /* control flows into case/default */ + +elib(616) + -append(616,[MISRA 2012 Rule 16.1, required]) + +e744 /* switch statement has no default */ + +elib(744) + -append(744,[MISRA 2012 Rule 16.1, required]) + +e764 /* switch does not have a case */ + +elib(764) + -append(764,[MISRA 2012 Rule 16.1, required]) + +e825 /* control flows into case/default without -fallthrough comment */ + +elib(825) + -append(825,[MISRA 2012 Rule 16.1, required]) + +e9014 /* default missing from switch */ + +elib(9014) + -append(9014,[MISRA 2012 Rule 16.1, required]) + +e9042 /* departure from MISRA switch syntax */ + +elib(9042) + -append(9042,[MISRA 2012 Rule 16.1, required]) + +e9077 /* missing unconditional break */ + +elib(9077) + -append(9077,[MISRA 2012 Rule 16.1, required]) + +e9081 /* too few independent cases for switch */ + +elib(9081) + -append(9081,[MISRA 2012 Rule 16.1, required]) + +e9082 /* switch statement should either begin or end with default label */ + +elib(9082) + -append(9082,[MISRA 2012 Rule 16.1, required]) + +e9085 /* statement or comment should appear in default case */ + +elib(9085) + -append(9085,[MISRA 2012 Rule 16.1, required]) + +/**** Rule 16.2 (Req) ************/ + + +e44 /* Need a switch */ + +elib(44) + -append(44,[MISRA 2012 Rule 16.2, required]) + +e9055 /* enclosing statement is not a switch */ + +elib(9055) + -append(9055,[MISRA 2012 Rule 16.2, required]) + +/**** Rule 16.3 (Req) ************/ + + +e616 /* control flows into case/default */ + +elib(616) + -append(616,[MISRA 2012 Rule 16.3, required]) + +e825 /* control flows into case/default without -fallthrough comment */ + +elib(825) + -append(825,[MISRA 2012 Rule 16.3, required]) + +e9077 /* missing unconditional break */ + +elib(9077) + -append(9077,[MISRA 2012 Rule 16.3, required]) + +e9090 /* missing unconditional break */ + +elib(9090) + -append(9090,[MISRA 2012 Rule 16.3, required]) + +/**** Rule 16.4 (Req) ************/ + + +e744 /* switch statement has no default */ + +elib(744) + -append(744,[MISRA 2012 Rule 16.4, required]) + +e9014 /* switch statement has no default */ + +elib(9014) + -append(9014,[MISRA 2012 Rule 16.4, required]) + +e9085 /* default case has no statement nor comment */ + +elib(9085) + -append(9085,[MISRA 2012 Rule 16.4, required]) + +/**** Rule 16.5 (Req) ************/ + + +e9082 /* default should be first or last */ + +elib(9082) + -append(9082,[MISRA 2012 Rule 16.5, required]) + +/**** Rule 16.6 (Req) ************/ + + +e764 /* switch does not have a case */ + +elib(764) + -append(764,[MISRA 2012 Rule 16.6, required]) + +e9081 /* too few cases */ + +elib(9081) + -append(9081,[MISRA 2012 Rule 16.6, required]) + +/**** Rule 16.7 (Req) ************/ + + +e483 /* boolean value in switch expression */ + +elib(483) + -append(483,[MISRA 2012 Rule 16.7, required]) + +/**** Rule 17.1 (Req) ************/ + + +e829 /* warn on header usage */ + +elib(829) + +headerwarn(stdarg.h) + -append(829(stdarg.h),[MISRA 2012 Rule 17.1, required]) + -deprecate(macro,va_arg,[MISRA 2012 Rule 17.1, required]) + -deprecate(macro,va_start,[MISRA 2012 Rule 17.1, required]) + -deprecate(macro,va_end,[MISRA 2012 Rule 17.1, required]) + -deprecate(macro,va_copy,[MISRA 2012 Rule 17.1, required]) + +/**** Rule 17.2 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e9070 + -append(9070,[MISRA 2012 Rule 17.2, required]) + +/**** Rule 17.3 (Mand) ************/ + + +e718 /* symbol undeclared, assumed to return int */ + +elib(718) + -append(718,[MISRA 2012 Rule 17.3, mandatory]) + +/**** Rule 17.4 (Mand) ************/ + + +e533 /* function should return a value */ + +elib(533) + -append(533,[MISRA 2012 Rule 17.4, mandatory]) + +/**** Rule 17.5 (Adv) ************/ + + /* MISRA has declared this rule to be "undecidable". */ + +/**** Rule 17.6 (Mand) ************/ + + +e9043 /* static between brackets of array declaration */ + +elib(9043) + -append(9043,[MISRA 2012 Rule 17.6, mandatory]) + +/**** Rule 17.7 (Req) ************/ + + +e534 /* ignoring return value of function */ + +elib(534) + -append(534,[MISRA 2012 Rule 17.7, required]) + +/**** Rule 17.8 (Adv) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e9044 /* function parameter modified */ + +elib(9044) + -append(9044,[MISRA 2012 Rule 17.8, advisory]) + +/**** Rule 18.1 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e415 /* out-of-bounds pointer */ + +elib(415) + -append(415,[MISRA 2012 Rule 18.1, required]) + +e416 /* out-of-bounds pointer */ + +elib(416) + -append(416,[MISRA 2012 Rule 18.1, required]) + +e428 /* out-of-bounds pointer */ + +elib(428) + -append(428,[MISRA 2012 Rule 18.1, required]) + +e661 /* out-of-bounds pointer */ + +elib(661) + -append(661,[MISRA 2012 Rule 18.1, required]) + +e662 /* out-of-bounds pointer */ + +elib(662) + -append(662,[MISRA 2012 Rule 18.1, required]) + +e676 /* out-of-bounds pointer */ + +elib(676) + -append(676,[MISRA 2012 Rule 18.1, required]) + +e796 /* out-of-bounds pointer */ + +elib(796) + -append(796,[MISRA 2012 Rule 18.1, required]) + +e797 /* out-of-bounds pointer */ + +elib(797) + -append(797,[MISRA 2012 Rule 18.1, required]) + +e817 /* out-of-bounds pointer */ + +elib(817) + -append(817,[MISRA 2012 Rule 18.1, required]) + +/**** Rule 18.2 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e946 /* relational or subtract operator applied to pointers */ + +elib(946) + -append(946,[MISRA 2012 Rule 18.2, required]) + +e947 /* relational or subtract operator applied to pointers */ + +elib(947) + -append(947,[MISRA 2012 Rule 18.2, required]) + +/**** Rule 18.3 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e946 /* relational or subtract operator applied to pointers */ + +elib(946) + -append(946,[MISRA 2012 Rule 18.3, required]) + +e947 /* relational or subtract operator applied to pointers */ + +elib(947) + -append(947,[MISRA 2012 Rule 18.3, required]) + +/**** Rule 18.4 (Adv) ************/ + + +e9016 /* pointer arithmetic other than array indexing used */ + +elib(9016) + -append(9016,[MISRA 2012 Rule 18.4, advisory]) + +/**** Rule 18.5 (Adv) ************/ + + +e9025 /* more than two pointer indirection levels used */ + +elib(9025) + -append(9025,[MISRA 2012 Rule 18.5, advisory]) + +/**** Rule 18.6 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e733 /* assigning address of auto to outer scope symbol */ + +elib(733) + -append(733,[MISRA 2012 Rule 18.6, required]) + +e789 /* assigning address of auto to static */ + +elib(789) + -append(789,[MISRA 2012 Rule 18.6, required]) + +e604 /* returning address of auto variable */ + +elib(604) + -append(604,[MISRA 2012 Rule 18.6, required]) + +/**** Rule 18.7 (Req) ************/ + + +e9038 /* flexible array member declared */ + +elib(9038) + -append(9038,[MISRA 2012 Rule 18.7, required]) + +/**** Rule 18.8 (Req) ************/ + + +e9035 /* variable length array declared */ + +elib(9035) + -append(9035,[MISRA 2012 Rule 18.8, required]) + +/**** Rule 19.1 (Mand) ************/ + + /* MISRA has declared this rule to be "undecidable". */ + +/**** Rule 19.2 (Adv) ************/ + + +e9018 /* union type/object declared */ + +elib(9018) + -append(9018,[MISRA 2012 Rule 19.2, advisory]) + +/**** Rule 20.1 (Adv) ************/ + + +e9019 /* declaration before #include */ + +elib(9019) + -append(9019,[MISRA 2012 Rule 20.1, advisory]) + +/**** Rule 20.2 (Req) ************/ + + +e9020 /* header file name with non-standard character */ + +elib(9020) + -append(9020,[MISRA 2012 Rule 20.2, required]) + /* Note: If your system requires the '\' be used as a directory + separator, uncomment the following option. + */ + // -estring(9020,\) + +/**** Rule 20.3 (Req) ************/ + + +e12 /* Need < or " after #include */ + +elib(12) + -append(12,[MISRA 2012 Rule 20.3, required]) + +e9086 /* multiple arguments after #include */ + +elib(9086) + -append(9086,[MISRA 2012 Rule 20.3, required]) + +/**** Rule 20.4 (Req) ************/ + + +e9051 /* macro with same name as a keyword */ + +elib(9051) + -append(9051,[MISRA 2012 Rule 20.4, required]) + +/**** Rule 20.5 (Adv) ************/ + + +e9021 /* use of '#undef' is discouraged */ + +elib(9021) + -append(9021,[MISRA 2012 Rule 20.5, advisory]) + +/**** Rule 20.6 (Req) ************/ + + +e436 /* preprocessor directive in invocation of macro */ + +elib(436) + -append(436,[MISRA 2012 Rule 20.6, required]) + +/**** Rule 20.7 (Req) ************/ + + +e665 /* expression passed to unparenthesized macro */ + +elib(665) + -append(665,[MISRA 2012 Rule 20.7, required]) + +/**** Rule 20.8 (Req) ************/ + + +e9037 /* conditional of #if/#elif does not evaluate to 0 or 1 */ + +elib(9037) + -append(9037,[MISRA 2012 Rule 20.8, required]) + +/**** Rule 20.9 (Req) ************/ + + +e553 /* Undefined preprocessor variable, assumed 0 */ + +elib(553) + -append(553,[MISRA 2012 Rule 20.9, required]) + +/**** Rule 20.10 (Adv) ************/ + + +e9024 /* '#/##' operators used */ + +elib(9024) + -append(9024,[MISRA 2012 Rule 20.10, advisory]) + +/**** Rule 20.11 (Req) ************/ + + +e484 /* stringize operator followed by macro parameter followed by pasting operator */ + +elib(484) + -append(484,[MISRA 2012 Rule 20.11, required]) + +/**** Rule 20.12 (Req) ************/ + + +e9015 /* macro argument is used both with and without '#/##' and is subject to further replacement */ + +elib(9015) + -append(9015,[MISRA 2012 Rule 20.12, required]) + +/**** Rule 20.13 (Req) ************/ + + +e544 /* endif or else not followed by EOL */ + +elib(544) + -append(544,[MISRA 2012 Rule 20.13, required]) + +e16 /* # directive not followed by recognizable word */ + +elib(16) + -append(16,[MISRA 2012 Rule 20.13, required]) + /* other parts of this rule such as a syntax check of the disabled + portions of the code do not seem to be statically checkable + */ + +/**** Rule 20.14 (Req) ************/ + + +e405 /* #if/#ifdef/#ifndef not closed off */ + +elib(405) + -append(405,[MISRA 2012 Rule 20.14, required]) + +/**** Rule 21.1 (Req) ************/ + + +e136 /* Illegal macro name */ + +elib(136) + -append(136,[MISRA 2012 Rule 21.1, required]) + /* Undefining standard library macros is covered by rule 20.5. */ + /* Defining/redefining reserved/standard identifiers is covered + by rules 20.4 and 21.2. + */ + +e9071 /* defined macro reserved to the compiler */ + +elib(9071) + -append(9071,[MISRA 2012 Rule 21.1, required]) + // explicit exemptions + -estring(9071,* because *) + -estring(9071,cerf) + -estring(9071,cerfc) + -estring(9071,cexp2) + -estring(9071,cexpm1) + -estring(9071,clog10) + -estring(9071,clog1p) + -estring(9071,clog2) + -estring(9071,clgamma) + -estring(9071,ctgamma) + -estring(9071,cerff) + -estring(9071,cerfcf) + -estring(9071,cexp2f) + -estring(9071,cexpm1f) + -estring(9071,clog10f) + -estring(9071,clog1pf) + -estring(9071,clog2f) + -estring(9071,clgammaf) + -estring(9071,ctgammaf) + -estring(9071,cerfl) + -estring(9071,cerfcl) + -estring(9071,cexp2l) + -estring(9071,cexpm1l) + -estring(9071,clog10l) + -estring(9071,clog1pl) + -estring(9071,clog2l) + -estring(9071,clgammal) + -estring(9071,ctgammal) + -estring(9071,E0*) + -estring(9071,E1*) + -estring(9071,E2*) + -estring(9071,E3*) + -estring(9071,E4*) + -estring(9071,E5*) + -estring(9071,E6*) + -estring(9071,E7*) + -estring(9071,E8*) + -estring(9071,E9*) + -estring(9071,NDEBUG) + -estring(9071,PRIa*) + -estring(9071,PRIb*) + -estring(9071,PRIc*) + -estring(9071,PRId*) + -estring(9071,PRIe*) + -estring(9071,PRIf*) + -estring(9071,PRIg*) + -estring(9071,PRIh*) + -estring(9071,PRIi*) + -estring(9071,PRIj*) + -estring(9071,PRIk*) + -estring(9071,PRIl*) + -estring(9071,PRIm*) + -estring(9071,PRIn*) + -estring(9071,PRIo*) + -estring(9071,PRIp*) + -estring(9071,PRIq*) + -estring(9071,PRIr*) + -estring(9071,PRIs*) + -estring(9071,PRIt*) + -estring(9071,PRIu*) + -estring(9071,PRIv*) + -estring(9071,PRIw*) + -estring(9071,PRIx*) + -estring(9071,PRIy*) + -estring(9071,PRIz*) + -estring(9071,PRIX*) + -estring(9071,SCNa*) + -estring(9071,SCNb*) + -estring(9071,SCNc*) + -estring(9071,SCNd*) + -estring(9071,SCNe*) + -estring(9071,SCNf*) + -estring(9071,SCNg*) + -estring(9071,SCNh*) + -estring(9071,SCNi*) + -estring(9071,SCNj*) + -estring(9071,SCNk*) + -estring(9071,SCNl*) + -estring(9071,SCNm*) + -estring(9071,SCNn*) + -estring(9071,SCNo*) + -estring(9071,SCNp*) + -estring(9071,SCNq*) + -estring(9071,SCNr*) + -estring(9071,SCNs*) + -estring(9071,SCNt*) + -estring(9071,SCNu*) + -estring(9071,SCNv*) + -estring(9071,SCNw*) + -estring(9071,SCNx*) + -estring(9071,SCNy*) + -estring(9071,SCNz*) + -estring(9071,SCNX*) + +e9083 /* undefined macro reserved to the compiler */ + +elib(9083) + -append(9083,[MISRA 2012 Rule 21.1, required]) + // explicit exemptions + -estring(9083,* because *) + -estring(9083,cerf) + -estring(9083,cerfc) + -estring(9083,cexp2) + -estring(9083,cexpm1) + -estring(9083,clog10) + -estring(9083,clog1p) + -estring(9083,clog2) + -estring(9083,clgamma) + -estring(9083,ctgamma) + -estring(9083,cerff) + -estring(9083,cerfcf) + -estring(9083,cexp2f) + -estring(9083,cexpm1f) + -estring(9083,clog10f) + -estring(9083,clog1pf) + -estring(9083,clog2f) + -estring(9083,clgammaf) + -estring(9083,ctgammaf) + -estring(9083,cerfl) + -estring(9083,cerfcl) + -estring(9083,cexp2l) + -estring(9083,cexpm1l) + -estring(9083,clog10l) + -estring(9083,clog1pl) + -estring(9083,clog2l) + -estring(9083,clgammal) + -estring(9083,ctgammal) + -estring(9083,E0*) + -estring(9083,E1*) + -estring(9083,E2*) + -estring(9083,E3*) + -estring(9083,E4*) + -estring(9083,E5*) + -estring(9083,E6*) + -estring(9083,E7*) + -estring(9083,E8*) + -estring(9083,E9*) + -estring(9083,NDEBUG) + -estring(9083,PRIa*) + -estring(9083,PRIb*) + -estring(9083,PRIc*) + -estring(9083,PRId*) + -estring(9083,PRIe*) + -estring(9083,PRIf*) + -estring(9083,PRIg*) + -estring(9083,PRIh*) + -estring(9083,PRIi*) + -estring(9083,PRIj*) + -estring(9083,PRIk*) + -estring(9083,PRIl*) + -estring(9083,PRIm*) + -estring(9083,PRIn*) + -estring(9083,PRIo*) + -estring(9083,PRIp*) + -estring(9083,PRIq*) + -estring(9083,PRIr*) + -estring(9083,PRIs*) + -estring(9083,PRIt*) + -estring(9083,PRIu*) + -estring(9083,PRIv*) + -estring(9083,PRIw*) + -estring(9083,PRIx*) + -estring(9083,PRIy*) + -estring(9083,PRIz*) + -estring(9083,PRIX*) + -estring(9083,SCNa*) + -estring(9083,SCNb*) + -estring(9083,SCNc*) + -estring(9083,SCNd*) + -estring(9083,SCNe*) + -estring(9083,SCNf*) + -estring(9083,SCNg*) + -estring(9083,SCNh*) + -estring(9083,SCNi*) + -estring(9083,SCNj*) + -estring(9083,SCNk*) + -estring(9083,SCNl*) + -estring(9083,SCNm*) + -estring(9083,SCNn*) + -estring(9083,SCNo*) + -estring(9083,SCNp*) + -estring(9083,SCNq*) + -estring(9083,SCNr*) + -estring(9083,SCNs*) + -estring(9083,SCNt*) + -estring(9083,SCNu*) + -estring(9083,SCNv*) + -estring(9083,SCNw*) + -estring(9083,SCNx*) + -estring(9083,SCNy*) + -estring(9083,SCNz*) + -estring(9083,SCNX*) + +/**** Rule 21.2 (Req) ************/ + + +e683 /* complain about #define standard functions */ + +elib(683) + -append(683,[MISRA 2012 Rule 21.2, required]) + /* Undefining standard library macros is covered by rule 20.5. */ + /* Defining/redefining reserved/standard identifiers is covered + by rule 20.4 and 21.2. + */ + +/**** Rule 21.3 (Req) ************/ + + +e586 /* Symbol is deprecated */ + +elib(586) + -deprecate(function,calloc,[MISRA 2012 Rule 21.3, required]) + -deprecate(macro,calloc,[MISRA 2012 Rule 21.3, required]) + -deprecate(function,malloc,[MISRA 2012 Rule 21.3, required]) + -deprecate(macro,malloc,[MISRA 2012 Rule 21.3, required]) + -deprecate(function,realloc,[MISRA 2012 Rule 21.3, required]) + -deprecate(macro,realloc,[MISRA 2012 Rule 21.3, required]) + -deprecate(function,free,[MISRA 2012 Rule 21.3, required]) + -deprecate(macro,free,[MISRA 2012 Rule 21.3, required]) + +/**** Rule 21.4 (Req) ************/ + + +e829 /* warn on header usage */ + +elib(829) + +headerwarn(setjmp.h) + -append(829(setjmp.h),[MISRA 2012 Rule 21.4, required]) + -deprecate(function,setjmp,[MISRA 2012 Rule 21.4, required]) + -deprecate(function,longjmp,[MISRA 2012 Rule 21.4, required]) + -deprecate(macro,setjmp,[MISRA 2012 Rule 21.4, required]) + -deprecate(macro,longjmp,[MISRA 2012 Rule 21.4, required]) + +/**** Rule 21.5 (Req) ************/ + + +e586 /* Symbol is deprecated */ + +elib(586) + -deprecate(function,signal,[MISRA 2012 Rule 21.5, required]) + -deprecate(function,raise,[MISRA 2012 Rule 21.5, required]) + -deprecate(macro,SIGABRT,[MISRA 2012 Rule 21.5, required]) + -deprecate(macro,SIGFPE,[MISRA 2012 Rule 21.5, required]) + -deprecate(macro,SIGILL,[MISRA 2012 Rule 21.5, required]) + -deprecate(macro,SIGINT,[MISRA 2012 Rule 21.5, required]) + -deprecate(macro,SIGSEGV,[MISRA 2012 Rule 21.5, required]) + -deprecate(macro,SIGTERM,[MISRA 2012 Rule 21.5, required]) + -deprecate(macro,SIG_DFL,[MISRA 2012 Rule 21.5, required]) + -deprecate(macro,SIG_ERR,[MISRA 2012 Rule 21.5, required]) + -deprecate(macro,SIG_IGN,[MISRA 2012 Rule 21.5, required]) + +e829 /* warn on header usage */ + +elib(829) + +headerwarn(signal.h) + -append(829(signal.h),[MISRA 2012 Rule 21.5, required]) + +/**** Rule 21.6 (Req) ************/ + + +e586 /* Symbol is deprecated */ + +elib(586) + -deprecate(function,clearerr,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fclose,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,feof,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,ferror,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fflush,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fgetc,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fgetpos,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fgets,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fgetwc,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fgetws,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fopen,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fputc,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fputs,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fputwc,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fputws,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fread,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fseek,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fsetpos,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,freopen,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,ftell,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fwide,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fwprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fwrite,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,fwscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,getc,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,getchar,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,gets,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,getwc,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,getwchar,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,perror,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,printf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,putc,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,putchar,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,puts,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,putwc,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,putwchar,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,remove,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,rename,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,rewind,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,scanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,setbuf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,setvbuf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,snprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,sprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,sscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,swprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,swscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,tmpfile,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,tmpnam,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,ungetc,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,ungetwc,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,vfprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,vfscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,vfwprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,vfwscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,vprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,vscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,vsnprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,vsprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,vsscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,vswprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,vswscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,vwprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,vwscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,wprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(function,wscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,clearerr,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fclose,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,feof,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,ferror,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fflush,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fgetc,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fgets,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fgetpos,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fgetwc,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fgetws,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fopen,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fputc,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fputs,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fputwc,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fputws,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fread,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fseek,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fsetpos,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,freopen,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,ftell,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fwide,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fwprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fwrite,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,fwscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,getc,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,getchar,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,gets,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,getwc,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,getwchar,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,perror,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,printf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,putc,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,putchar,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,puts,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,putwc,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,putwchar,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,remove,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,rename,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,rewind,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,scanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,setbuf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,setvbuf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,snprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,sprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,sscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,swprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,swscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,tmpfile,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,tmpnam,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,ungetc,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,ungetwc,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,vfprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,vfscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,vfwprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,vfwscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,vprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,vscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,vsnprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,vsprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,vsscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,vswprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,vswscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,vwprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,vwscanf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,wprintf,[MISRA 2012 Rule 21.6, required]) + -deprecate(macro,wscanf,[MISRA 2012 Rule 21.6, required]) + +/**** Rule 21.7 (Req) ************/ + + +e586 /* Symbol is deprecated */ + +elib(586) + -deprecate(function,atof,[MISRA 2012 Rule 21.7, required]) + -deprecate(function,atoi,[MISRA 2012 Rule 21.7, required]) + -deprecate(function,atol,[MISRA 2012 Rule 21.7, required]) + -deprecate(function,atoll,[MISRA 2012 Rule 21.7, required]) + -deprecate(macro,atof,[MISRA 2012 Rule 21.7, required]) + -deprecate(macro,atoi,[MISRA 2012 Rule 21.7, required]) + -deprecate(macro,atol,[MISRA 2012 Rule 21.7, required]) + -deprecate(macro,atoll,[MISRA 2012 Rule 21.7, required]) + +/**** Rule 21.8 (Req) ************/ + + +e586 /* Symbol is deprecated */ + +elib(586) + -deprecate(function,abort,[MISRA 2012 Rule 21.8, required]) + -deprecate(function,exit,[MISRA 2012 Rule 21.8, required]) + -deprecate(function,getenv,[MISRA 2012 Rule 21.8, required]) + -deprecate(function,system,[MISRA 2012 Rule 21.8, required]) + -deprecate(macro,abort,[MISRA 2012 Rule 21.8, required]) + -deprecate(macro,exit,[MISRA 2012 Rule 21.8, required]) + -deprecate(macro,getenv,[MISRA 2012 Rule 21.8, required]) + -deprecate(macro,system,[MISRA 2012 Rule 21.8, required]) + +/**** Rule 21.9 (Req) ************/ + + +e586 /* Symbol is deprecated */ + +elib(586) + -deprecate(function,bsearch,[MISRA 2012 Rule 21.9, required]) + -deprecate(function,qsort,[MISRA 2012 Rule 21.9, required]) + -deprecate(macro,bsearch,[MISRA 2012 Rule 21.9, required]) + -deprecate(macro,qsort,[MISRA 2012 Rule 21.9, required]) + +/**** Rule 21.10 (Req) ************/ + + +e586 /* Symbol is deprecated */ + +elib(586) + -deprecate(macro,wcsftime,[MISRA 2012 Rule 21.10, required]) + -deprecate(function,wcsftime,[MISRA 2012 Rule 21.10, required]) + -deprecate(macro,clock,[MISRA 2012 Rule 21.10, required]) + -deprecate(function,clock,[MISRA 2012 Rule 21.10, required]) + -deprecate(macro,difftime,[MISRA 2012 Rule 21.10, required]) + -deprecate(function,difftime,[MISRA 2012 Rule 21.10, required]) + -deprecate(macro,mktime,[MISRA 2012 Rule 21.10, required]) + -deprecate(function,mktime,[MISRA 2012 Rule 21.10, required]) + -deprecate(macro,time,[MISRA 2012 Rule 21.10, required]) + -deprecate(function,time,[MISRA 2012 Rule 21.10, required]) + -deprecate(macro,asctime,[MISRA 2012 Rule 21.10, required]) + -deprecate(function,asctime,[MISRA 2012 Rule 21.10, required]) + -deprecate(macro,ctime,[MISRA 2012 Rule 21.10, required]) + -deprecate(function,ctime,[MISRA 2012 Rule 21.10, required]) + -deprecate(macro,gmtime,[MISRA 2012 Rule 21.10, required]) + -deprecate(function,gmtime,[MISRA 2012 Rule 21.10, required]) + -deprecate(macro,localtime,[MISRA 2012 Rule 21.10, required]) + -deprecate(function,localtime,[MISRA 2012 Rule 21.10, required]) + -deprecate(macro,strftime,[MISRA 2012 Rule 21.10, required]) + -deprecate(function,strftime,[MISRA 2012 Rule 21.10, required]) + -deprecate(macro,CLOCKS_PER_SEC,[MISRA 2012 Rule 21.10, required]) + +e829 /* warn on header usage */ + +elib(829) + +headerwarn(time.h) + -append(829(time.h),[MISRA 2012 Rule 21.10, required]) + +/**** Rule 21.11 (Req) ************/ + + +e829 /* warn on header usage */ + +elib(829) + +headerwarn(tgmath.h) + -append(829(tgmath.h),[MISRA 2012 Rule 21.11, required]) + +/**** Rule 21.12 (Adv) ************/ + + +e586 /* Symbol is deprecated */ + +elib(586) + -deprecate(function,feclearexcept,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(macro,feclearexcept,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(function,fegetexceptflag,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(macro,fegetexceptflag,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(function,feraiseexcept,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(macro,feraiseexcept,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(function,fesetexceptflag,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(macro,fesetexceptflag,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(function,fetestexcept,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(macro,fetestexcept,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(macro,FE_INEXACT,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(macro,FE_DIVBYZERO,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(macro,FE_UNDERFLOW,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(macro,FE_OVERFLOW,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(macro,FE_INVALID,[MISRA 2012 Rule 21.12, advisory]) + -deprecate(macro,FE_ALL_EXCEPT,[MISRA 2012 Rule 21.12, advisory]) + +/**** Rule 22.1 (Req) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e429 /* custodial pointer neither free'd nor returned */ + +elib(429) + -append(429,[MISRA 2012 Rule 22.1, required]) + -function_pair(fopen,fclose) + +e480 /* no balancing call */ + +elib(480) + -append(480,[MISRA 2012 Rule 22.1, required]) + +e481 /* different balance call states */ + +elib(481) + -append(481,[MISRA 2012 Rule 22.1, required]) + +/**** Rule 22.2 (Mand) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e424 /* inappropriate deallocation */ + +elib(424) + -append(424,[MISRA 2012 Rule 22.2, mandatory]) + +e449 /* pointer previously deallocated */ + +elib(449) + -append(449,[MISRA 2012 Rule 22.2, mandatory]) + +/**** Rule 22.3 (Req) ************/ + + /* MISRA has declared this rule to be "undecidable". */ + +/**** Rule 22.4 (Mand) ************/ + + /* MISRA has declared this rule to be "undecidable". */ + +/**** Rule 22.5 (Mand) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + Software provides the following message to assist: + */ + +e9047 /* FILE pointer dereferenced */ + +elib(9047) + -append(9047,[MISRA 2012 Rule 22.5, mandatory]) + + +/**** Rule 22.6 (Mand) ************/ + + /* While MISRA has declared this rule to be "undecidable", Gimpel + * Software provides the following options to assist: + */ + +e449 /* previously deallocated pointer */ + +elib(449) + -append(449,[MISRA 2012 Rule 22.6, mandatory]) diff --git a/ChibiOS_16.1.5/test/rt/testbuild/pclint/co-gcc.h b/ChibiOS_16.1.5/test/rt/testbuild/pclint/co-gcc.h new file mode 100644 index 0000000..d18d71e --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/pclint/co-gcc.h @@ -0,0 +1,129 @@ +// --------------------------------------------------------------------- +// This file is provided by Gimpel Software (www.gimpel.com) for use with +// its products PC-lint and FlexeLint. +// +// Redistribution and use of this file, with or without modification, is +// permitted provided that any such redistribution retains this notice. +// --------------------------------------------------------------------- + +#ifndef CO_GCC_H_ +#define CO_GCC_H_ +/*lint -save -w1 */ + +#ifdef _lint /* Make sure no compiler comes this way */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Standard library headers typically define the assert macro so that it + expands to a complicated conditional expression that uses special + funtions that Lint does not know about by default. For linting + purposes, we can simplify things a bit by forcing assert() to expand to + a call to a special function that has the appropriate 'assert' + semantics. + */ +//lint -function( __assert, __lint_assert ) +void __lint_assert( int ); +//lint ++d"assert(e)=__lint_assert(!!(e))" +//(++d makes this definition permanently immutable for the Lint run.) +//Now that we've made our own 'assert', we need to keep people from being +//punished when the marco in 'assert.h' appears not to be used: +//lint -efile(766,*assert.h) + +typedef char *__builtin_va_list; + +/*lint -e{171} */ +__builtin_va_list __lint_init_va(...); + +void __builtin_va_end( __builtin_va_list ); + /*lint +++d"__builtin_va_start(ap,parmN)=((ap)=__lint_init_va(parmN))" +++d"__builtin_va_arg(a,b)=(*( ((b) *) ( (((a) += sizeof(b)) - sizeof(b) )))" + */ + + +/* + The headers included below must be generated; For C++, generate + with: + + g++ [usual build options] -E -dM t.cpp >lint_cppmac.h + + For C, generate with: + + gcc [usual build options] -E -dM t.c >lint_cmac.h + + ...where "t.cpp" and "t.c" are empty source files. + + It's important to use the same compiler options used when compiling + project code because they can affect the existence and precise + definitions of certain predefined macros. See gcc-readme.txt for + details and a tutorial. + */ +#if defined(__cplusplus) +# include "lint_cppmac.h" // DO NOT COMMENT THIS OUT. DO NOT SUPPRESS ERROR 322. (If you see an error here, your Lint configuration is broken; check -i options and ensure that you have generated lint_cppmac.h as documented in gcc-readme.txt. Otherwise Gimpel Software cannot support your configuration.) +#else +# include "lint_cmac.h" // DO NOT COMMENT THIS OUT. DO NOT SUPPRESS ERROR 322. (If you see an error here, your Lint configuration is broken; check -i options and ensure that you have generated lint_cmac.h as documented in gcc-readme.txt. Otherwise Gimpel Software cannot support your configuration.) +#endif + +/* If the macro set given by the generated macro files must be adjusted in + order for Lint to cope, then you can make those adjustments here. + */ + +#define LINT_CO_GCC_H_GCC_VERSION ( __GNUC__ * 10000 + \ + __GNUC_MINOR__ * 100 + \ + __GNUC_PATCHLEVEL__ ) + +/* The following is a workaround for versions of GCC with bug 25717, in + which the preprocessor does not dump a #define directive for __STDC__ + when -dM is given: + http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25717 + + We know the unconditional definition of __STDC__ was introduced no + later than version 3.0; the preprocessor bug was fixed no later than + version 4.1.0. + */ +#if ( LINT_CO_GCC_H_GCC_VERSION >= 30000 && \ + LINT_CO_GCC_H_GCC_VERSION < 40100 ) +# define __STDC__ 1 +#endif + +#if !__cplusplus && !__STRICT_ANSI__ && __STDC_VERSION__ < 199901L +/* apparently, the code is compiled with -std=gnu89 (as opposed to -std=c89), + so: */ +/*lint -rw_asgn(inline,__inline) */ +#endif + +#if LINT_CO_GCC_H_GCC_VERSION >= 40300 +# define __COUNTER__ __lint__COUNTER__ +//lint +rw( *type_traits ) // Enable type traits support +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#if _lint >= 909 // For 9.00i and later: + //// __attribute__ is GCC's __attribute__: + // + //lint -rw_asgn(__attribute__,__gcc_attribute__) + //lint -rw_asgn(__attribute, __gcc_attribute__) + // + //// Prevent "__attribute__" from being defined as a macro: + // + //lint --u"__attribute__" + //lint --u"__attribute" + // + //// Because an attribute-specifier is a form of + //// declaration-modifier, and because it can appear at the + //// beginning of a decl-specifier-seq, we must enable "Early + //// Modifiers": + // + //lint +fem +#else // for 9.00h and earlier: + //lint -d__attribute__()= + //lint -d__attribute()= +#endif + +#endif /* _lint */ +/*lint -restore */ +#endif /* CO_GCC_H_ */ diff --git a/ChibiOS_16.1.5/test/rt/testbuild/pclint/co-gcc.lnt b/ChibiOS_16.1.5/test/rt/testbuild/pclint/co-gcc.lnt new file mode 100644 index 0000000..b7e1ed2 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/pclint/co-gcc.lnt @@ -0,0 +1,209 @@ +/* Date Stamp */ -d"_lint_co_gcc_lnt=co-gcc.lnt modified 12-Jun-2014" +/* To document usage use: -message( "Using " _lint_co_gcc_lnt ) */ +// --------------------------------------------------------------------- +// This file is provided by Gimpel Software (www.gimpel.com) for use with +// its products PC-lint and FlexeLint. +// +// Redistribution and use of this file, with or without modification, is +// permitted provided that any such redistribution retains this notice. +// --------------------------------------------------------------------- +/* co-gcc.lnt: This is the seed file for configuring Lint for use with + GCC versions 2.95.3 and later. + + Like all compiler options files this file is intended to be used + as follows: + + lint co-gcc.lnt source-files-to-be-linted + + Some of the information that co-gcc.lnt requires needs to be furnished + with the help of the gcc system itself. The easiest way to generate + this information is to use the makefile co-gcc.mak (supplied with the + Lint distribution) in an invocation of GNU Make; for details, see the + commentary at the top of co-gcc.mak. +*/ + +-cgnu // Notifies FlexeLint that gcc is being used. + +// =========================== +// Preprocessor Configuration: ++fdi // GCC starts its #include search in the directory of the including + // file. + +++fln // Allow: + // # digit-sequence " [s-char-sequence] " new-line + // as a synonym for: + // # line digit-sequence " [s-char-sequence] " new-line + // GCC additionally allows flag values to follow the + // s-char-sequence, but currently Lint ignores them. + +-header(pclint/co-gcc.h) // Includes headers generated by GCC (bringing in + // predefined macros). ++libh(pclint/co-gcc.h) // Marks that header as library code. + +pclint/gcc-include-path.lnt // This .lnt file should contain --i options + // and should be generated by invoking gcc with its '-v' option. + // (GCC's implicit #include search path is presented in the output.) + // This happens automatically when 'make -f co-gcc.mak' is invoked. + +// Assertion directives (a feature of GCC's preprocessor) have been +// considered obsolete in GCC's documentation since version 3.0, so we do +// not use them here. If support for #assert is needed in the form of a +// lint option, one may use '-a#' like so: +// -a#machine(i386) // #assert's machine(i386) (SVR4 facility). + +// File extensions: +// From the GCC man page: +// +// file.cc +// file.cp +// file.cxx +// file.cpp +// file.CPP +// file.c++ +// file.C +// C++ source code that must be preprocessed. Note that in .cxx, the +// last two letters must both be literally x. Likewise, .C refers to +// a literal capital C. +// +// We emulate this with: + + +cpp(.cc) + +cpp(.cp) + +cpp(.cxx) + +cpp(.cpp) + +cpp(.c++) + // Note the exceptions: + // +cpp(.CPP) + // +cpp(.C) + // These are commented out for the default config because they seem to + // cause trouble more often than not. For starters, it is problematic + // with filesystems that are case-insensitive (which has become common + // even on some POSIX systems). + +// ============= +// Size Options: +// +fwc // wchar_t might be builtin; if so, uncomment this option. (NOTE: +// // this option needs to be set before a size option is given for +// // wchar_t; see the documentation for -sw# in the Lint manual.) + +pclint/size-options.lnt // This .lnt file should be generated (preferrably + // by a program created by invoking GCC with the compile options that + // are used in the compilation of the project to be linted). This + // happens automatically when 'make -f co-gcc.mak' is invoked. + + +// =========================================== +// +rw and -d options to cope with GNU syntax: ++ppw(ident) // Tolerate #ident ++ppw(warning) + +// GCC provides alternative spellings of certain keywords: ++rw(__inline) +-rw_asgn(__inline__,__inline) +-rw_asgn(__header_always_inline,__inline) +-rw_asgn(__header_inline,__inline) + +-rw_asgn(__signed__,signed) +-rw_asgn(__signed,signed) +-rw_asgn( __volatile__, volatile ) +-rw_asgn( __volatile, volatile ) ++rw(restrict) +-rw_asgn(__restrict,restrict) +-rw_asgn(__restrict__,restrict) +++d"__const=const" // gconv.h uses __const rather than const +++d"const=const" // ensure const expands to const. + +-rw_asgn( asm, _up_to_brackets ) +-rw_asgn( __asm, _up_to_brackets ) +-rw_asgn( __asm__, _up_to_brackets ) +// This re-definition of the various spellings of the asm keyword enables +// Lint to pass gracefully over expression-statements like: +// __asm __volatile ("fsqrt" : "=t" (__result) : "0" (__x)); +// But it may be necessary to suppress certain error messages that are +// triggered by tokens that are part of an assembly declaration or +// statement. For example: + +// -d"__asm__(p...)=/*lint -e{19}*/ __asm__(p)" + +// ...causes Lint to be quiet about the semicolon that follows an +// __asm__() declaration. Note, the -e{N} form of suppression takes +// effect only for the forward-declaration, definition or +// [possibly-compound] statement that immediately follows. Because a +// semicolon is seen as a declaration-terminator, Error 19 will be +// re-enabled immediately after the semicolon in '__asm__(...);'. +// (The elipsis after the macro parameter p allows zero or more commas to +// appear in the operand.) +// +// If you encounter other diagnostics that appear to need suppression in +// or near assembly regions, please let us know! +// +-esym(123,__asm__) + +-rw_asgn(__alignof__,__alignof) + +// "__extension__" is GCC's way of allowing the use of non-standard +// constructs in a strict Standard-conforming mode. We don't currently +// have explicit support for it, but we can use local suppressions. For +// example, we can use -e(160) so that we will not see any Errors about +// GNU statement-expressions wrapped in __extension__(). +++d"__extension__=/*lint -e(160) */" + +++d"__null=0" ++rw(_to_semi) // needed for the two macros above. ++rw(__typeof__) // activate __typeof__ keyword +-d"__typeof=__typeof__" // an alternative to using __typeof__ + +-rw(__except) // This MS reserved word is used as an identifier ++rw( __complex__, __real__, __imag__ ) // reserved words that can be ignored. +++d"__builtin_strchr=(char*)" // permits the inline definition ... +++d"__builtin_strpbrk=(char*)" // of these functions to be linted ... +++d"__builtin_strrchr=(char*)" // without drawing a complaint +++d"__builtin_strstr=(char*)" // about the use of a non-standard name +++d"__PRETTY_FUNCTION__=___function___" // lint defines ___function___ internally +++d"__FUNCTION__=___function___" // lint defines ___function___ internally +++d"__func__=___function___" // Some C++ modes suport the implicit __func__ + // identifier. +-ident($) + +// ========================================================= +// Other options supporting GNU C/C++ syntax: ++fld // enables the processing of _L_abel _D_esignators E.g.: + // union { double d; int i; } u = { d: 3.141 }; + +// ========================================================= +// Generally useful suppressions: +-wlib(1) // sets the warning level within library headers to 1 + // (no warnings, just syntax errors). Comment out if you + // are actually linting library headers. +-elib(123) // 123 is really a warning, but it's in the "Error" range. +-elib(93) // allow newlines within quoted string arguments to macros +-elib(46) // allow bit fields to have integral types other than + // '_Bool' and 'int'. +-elibsym(628) // Suppress 628 for __builtin symbols. + +-esym(528,__huge_val,__nan,__qnan,__qnanf,__snan,__snanf) + // We don't care if we don't reference some GNU functions +-esym(528,__gnu_malloc,__gnu_calloc) + +// The following functions exhibit variable return modes. +// That is, they may equally-usefully be called for a value +// as called just for their effects. Accordingly we inhibit +// Warning 534 for these functions. +// Feel free to add to or subtract from this list. + +-esym(534,close,creat,fclose,fprintf,fputc) +-esym(534,fputs,fscanf,fseek,fwrite,lseek,memcpy,memmove,memset) +-esym(534,printf,puts,scanf,sprintf,sscanf,strcat,strcpy) +-esym(534,strncat,strncpy,unlink,write) + +// For non-ANSI compilers we suppress messages 515 and 516 +// for functions known to have variable argument lists. +// For ANSI compilers, header files should take care of this. + +-esym(515,fprintf,printf,sprintf,fscanf,scanf,sscanf) +-esym(516,fprintf,printf,sprintf,fscanf,scanf,sscanf) +-esym(1702,*operator<<,*operator>>) +-esym(534,*operator<<,*operator>>) +-esym(1055,*__builtin*) +-esym(718,*__builtin*) // The compiler does not need these ... +-esym(746,*__builtin*) // declared and it knows their prototypes. diff --git a/ChibiOS_16.1.5/test/rt/testbuild/pclint/gcc-include-path.lnt b/ChibiOS_16.1.5/test/rt/testbuild/pclint/gcc-include-path.lnt new file mode 100644 index 0000000..0e8fd31 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/pclint/gcc-include-path.lnt @@ -0,0 +1,6 @@ +--i"C:/ChibiStudio/tools/GNU Tools ARM Embedded/4.9 2015q3/arm-none-eabi/include" +--i"C:/ChibiStudio/tools/GNU Tools ARM Embedded/4.9 2015q3/arm-none-eabi/include/c++/4.9.3" +--i"C:/ChibiStudio/tools/GNU Tools ARM Embedded/4.9 2015q3/arm-none-eabi/include/c++/4.9.3/arm-none-eabi" +--i"C:/ChibiStudio/tools/GNU Tools ARM Embedded/4.9 2015q3/arm-none-eabi/include/c++/4.9.3/backward" +--i"C:/ChibiStudio/tools/GNU Tools ARM Embedded/4.9 2015q3/lib/gcc/arm-none-eabi/4.9.3/include" +--i"C:/ChibiStudio/tools/GNU Tools ARM Embedded/4.9 2015q3/lib/gcc/arm-none-eabi/4.9.3/include-fixed" diff --git a/ChibiOS_16.1.5/test/rt/testbuild/pclint/lint_cmac.h b/ChibiOS_16.1.5/test/rt/testbuild/pclint/lint_cmac.h new file mode 100644 index 0000000..3d0ae4b --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/pclint/lint_cmac.h @@ -0,0 +1,330 @@ +#define __DBL_MIN_EXP__ (-1021) +#define __HQ_FBIT__ 15 +#define __UINT_LEAST16_MAX__ 65535 +#define __ATOMIC_ACQUIRE 2 +#define __SFRACT_IBIT__ 0 +#define __FLT_MIN__ 1.1754943508222875e-38F +#define __UFRACT_MAX__ 0XFFFFP-16UR +#define __UINT_LEAST8_TYPE__ unsigned char +#define __DQ_FBIT__ 63 +#define __INTMAX_C(c) c ## LL +#define __ULFRACT_FBIT__ 32 +#define __SACCUM_EPSILON__ 0x1P-7HK +#define __CHAR_BIT__ 8 +#define __USQ_IBIT__ 0 +#define __UINT8_MAX__ 255 +#define __ACCUM_FBIT__ 15 +#define __WINT_MAX__ 4294967295U +#define __USFRACT_FBIT__ 8 +#define __ORDER_LITTLE_ENDIAN__ 1234 +#define __SIZE_MAX__ 4294967295U +#define __WCHAR_MAX__ 4294967295U +#define __LACCUM_IBIT__ 32 +#define __DBL_DENORM_MIN__ ((double)4.9406564584124654e-324L) +#define __GCC_ATOMIC_CHAR_LOCK_FREE 1 +#define __FLT_EVAL_METHOD__ 0 +#define __LLACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LLK +#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1 +#define __FRACT_FBIT__ 15 +#define __UINT_FAST64_MAX__ 18446744073709551615ULL +#define __SIG_ATOMIC_TYPE__ int +#define __UACCUM_FBIT__ 16 +#define __DBL_MIN_10_EXP__ (-307) +#define __FINITE_MATH_ONLY__ 0 +#define __ARMEL__ 1 +#define __LFRACT_IBIT__ 0 +#define __GNUC_PATCHLEVEL__ 4 +#define __LFRACT_MAX__ 0X7FFFFFFFP-31LR +#define __UINT_FAST8_MAX__ 4294967295U +#define __DEC64_MAX_EXP__ 385 +#define __INT8_C(c) c +#define __UINT_LEAST64_MAX__ 18446744073709551615ULL +#define __SA_FBIT__ 15 +#define __SHRT_MAX__ 32767 +#define __LDBL_MAX__ 1.7976931348623157e+308L +#define __FRACT_MAX__ 0X7FFFP-15R +#define __UFRACT_FBIT__ 16 +#define __UFRACT_MIN__ 0.0UR +#define __UINT_LEAST8_MAX__ 255 +#define __GCC_ATOMIC_BOOL_LOCK_FREE 1 +#define __UINTMAX_TYPE__ long long unsigned int +#define __LLFRACT_EPSILON__ 0x1P-63LLR +#define __DEC32_EPSILON__ 1E-6DF +#define __CHAR_UNSIGNED__ 1 +#define __UINT32_MAX__ 4294967295UL +#define __ULFRACT_MAX__ 0XFFFFFFFFP-32ULR +#define __TA_IBIT__ 64 +#define __LDBL_MAX_EXP__ 1024 +#define __WINT_MIN__ 0U +#define __ULLFRACT_MIN__ 0.0ULLR +#define __SCHAR_MAX__ 127 +#define __WCHAR_MIN__ 0U +#define __INT64_C(c) c ## LL +#define __DBL_DIG__ 15 +#define __GCC_ATOMIC_POINTER_LOCK_FREE 1 +#define __LLACCUM_MIN__ (-0X1P31LLK-0X1P31LLK) +#define __SIZEOF_INT__ 4 +#define __SIZEOF_POINTER__ 4 +#define __USACCUM_IBIT__ 8 +#define __USER_LABEL_PREFIX__ +#define __STDC_HOSTED__ 1 +#define __LDBL_HAS_INFINITY__ 1 +#define __LFRACT_MIN__ (-0.5LR-0.5LR) +#define __HA_IBIT__ 8 +#define __TQ_IBIT__ 0 +#define __FLT_EPSILON__ 1.1920928955078125e-7F +#define __APCS_32__ 1 +#define __USFRACT_IBIT__ 0 +#define __LDBL_MIN__ 2.2250738585072014e-308L +#define __FRACT_MIN__ (-0.5R-0.5R) +#define __DEC32_MAX__ 9.999999E96DF +#define __DA_IBIT__ 32 +#define __INT32_MAX__ 2147483647L +#define __UQQ_FBIT__ 8 +#define __SIZEOF_LONG__ 4 +#define __UACCUM_MAX__ 0XFFFFFFFFP-16UK +#define __UINT16_C(c) c +#define __DECIMAL_DIG__ 17 +#define __LFRACT_EPSILON__ 0x1P-31LR +#define __ULFRACT_MIN__ 0.0ULR +#define __LDBL_HAS_QUIET_NAN__ 1 +#define __ULACCUM_IBIT__ 32 +#define __UACCUM_EPSILON__ 0x1P-16UK +#define __GNUC__ 4 +#define __ULLACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULLK +#define __HQ_IBIT__ 0 +#define __FLT_HAS_DENORM__ 1 +#define __SIZEOF_LONG_DOUBLE__ 8 +#define __BIGGEST_ALIGNMENT__ 8 +#define __DQ_IBIT__ 0 +#define __DBL_MAX__ ((double)1.7976931348623157e+308L) +#define __ULFRACT_IBIT__ 0 +#define __INT_FAST32_MAX__ 2147483647 +#define __DBL_HAS_INFINITY__ 1 +#define __ACCUM_IBIT__ 16 +#define __DEC32_MIN_EXP__ (-94) +#define __THUMB_INTERWORK__ 1 +#define __LACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LK +#define __INT_FAST16_TYPE__ int +#define __LDBL_HAS_DENORM__ 1 +#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL +#define __INT_LEAST32_MAX__ 2147483647L +#define __ARM_PCS 1 +#define __DEC32_MIN__ 1E-95DF +#define __ACCUM_MAX__ 0X7FFFFFFFP-15K +#define __DBL_MAX_EXP__ 1024 +#define __USACCUM_EPSILON__ 0x1P-8UHK +#define __DEC128_EPSILON__ 1E-33DL +#define __SFRACT_MAX__ 0X7FP-7HR +#define __FRACT_IBIT__ 0 +#define __PTRDIFF_MAX__ 2147483647 +#define __UACCUM_MIN__ 0.0UK +#define __UACCUM_IBIT__ 16 +#define __LONG_LONG_MAX__ 9223372036854775807LL +#define __SIZEOF_SIZE_T__ 4 +#define __ULACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULK +#define __SIZEOF_WINT_T__ 4 +#define __SA_IBIT__ 16 +#define __ULLACCUM_MIN__ 0.0ULLK +#define __GXX_ABI_VERSION 1002 +#define __UTA_FBIT__ 64 +#define __SOFTFP__ 1 +#define __FLT_MIN_EXP__ (-125) +#define __USFRACT_MAX__ 0XFFP-8UHR +#define __UFRACT_IBIT__ 0 +#define __INT_FAST64_TYPE__ long long int +#define __DBL_MIN__ ((double)2.2250738585072014e-308L) +#define __LACCUM_MIN__ (-0X1P31LK-0X1P31LK) +#define __ULLACCUM_FBIT__ 32 +#define __GXX_TYPEINFO_EQUALITY_INLINE 0 +#define __ULLFRACT_EPSILON__ 0x1P-64ULLR +#define __USES_INITFINI__ 1 +#define __DEC128_MIN__ 1E-6143DL +#define __REGISTER_PREFIX__ +#define __UINT16_MAX__ 65535 +#define __DBL_HAS_DENORM__ 1 +#define __ACCUM_MIN__ (-0X1P15K-0X1P15K) +#define __SQ_IBIT__ 0 +#define __UINT8_TYPE__ unsigned char +#define __UHA_FBIT__ 8 +#define __NO_INLINE__ 1 +#define __SFRACT_MIN__ (-0.5HR-0.5HR) +#define __UTQ_FBIT__ 128 +#define __FLT_MANT_DIG__ 24 +#define __VERSION__ "4.7.4 20130913 (release) [ARM/embedded-4_7-branch revision 202601]" +#define __UINT64_C(c) c ## ULL +#define __ULLFRACT_FBIT__ 64 +#define __FRACT_EPSILON__ 0x1P-15R +#define __ULACCUM_MIN__ 0.0ULK +#define __UDA_FBIT__ 32 +#define __LLACCUM_EPSILON__ 0x1P-31LLK +#define __GCC_ATOMIC_INT_LOCK_FREE 1 +#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ +#define __USFRACT_MIN__ 0.0UHR +#define __UQQ_IBIT__ 0 +#define __INT32_C(c) c ## L +#define __DEC64_EPSILON__ 1E-15DD +#define __ORDER_PDP_ENDIAN__ 3412 +#define __DEC128_MIN_EXP__ (-6142) +#define __UHQ_FBIT__ 16 +#define __LLACCUM_FBIT__ 31 +#define __INT_FAST32_TYPE__ int +#define __UINT_LEAST16_TYPE__ short unsigned int +#define __INT16_MAX__ 32767 +#define __SIZE_TYPE__ unsigned int +#define __UINT64_MAX__ 18446744073709551615ULL +#define __UDQ_FBIT__ 64 +#define __INT8_TYPE__ signed char +#define __ELF__ 1 +#define __ULFRACT_EPSILON__ 0x1P-32ULR +#define __LLFRACT_FBIT__ 63 +#define __FLT_RADIX__ 2 +#define __INT_LEAST16_TYPE__ short int +#define __LDBL_EPSILON__ 2.2204460492503131e-16L +#define __UINTMAX_C(c) c ## ULL +#define __SACCUM_MAX__ 0X7FFFP-7HK +#define __SIG_ATOMIC_MAX__ 2147483647 +#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1 +#define __VFP_FP__ 1 +#define __SIZEOF_PTRDIFF_T__ 4 +#define __LACCUM_EPSILON__ 0x1P-31LK +#define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF +#define __INT_FAST16_MAX__ 2147483647 +#define __UINT_FAST32_MAX__ 4294967295U +#define __UINT_LEAST64_TYPE__ long long unsigned int +#define __USACCUM_MAX__ 0XFFFFP-8UHK +#define __SFRACT_EPSILON__ 0x1P-7HR +#define __FLT_HAS_QUIET_NAN__ 1 +#define __FLT_MAX_10_EXP__ 38 +#define __LONG_MAX__ 2147483647L +#define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL +#define __FLT_HAS_INFINITY__ 1 +#define __USA_FBIT__ 16 +#define __UINT_FAST16_TYPE__ unsigned int +#define __DEC64_MAX__ 9.999999999999999E384DD +#define __CHAR16_TYPE__ short unsigned int +#define __PRAGMA_REDEFINE_EXTNAME 1 +#define __INT_LEAST16_MAX__ 32767 +#define __DEC64_MANT_DIG__ 16 +#define __INT64_MAX__ 9223372036854775807LL +#define __UINT_LEAST32_MAX__ 4294967295UL +#define __SACCUM_FBIT__ 7 +#define __GCC_ATOMIC_LONG_LOCK_FREE 1 +#define __INT_LEAST64_TYPE__ long long int +#define __INT16_TYPE__ short int +#define __INT_LEAST8_TYPE__ signed char +#define __SQ_FBIT__ 31 +#define __DEC32_MAX_EXP__ 97 +#define __INT_FAST8_MAX__ 2147483647 +#define __INTPTR_MAX__ 2147483647 +#define __QQ_FBIT__ 7 +#define __UTA_IBIT__ 64 +#define __LDBL_MANT_DIG__ 53 +#define __SFRACT_FBIT__ 7 +#define __SACCUM_MIN__ (-0X1P7HK-0X1P7HK) +#define __DBL_HAS_QUIET_NAN__ 1 +#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) +#define __INTPTR_TYPE__ int +#define __UINT16_TYPE__ short unsigned int +#define __WCHAR_TYPE__ unsigned int +#define __SIZEOF_FLOAT__ 4 +#define __USQ_FBIT__ 32 +#define __UINTPTR_MAX__ 4294967295U +#define __DEC64_MIN_EXP__ (-382) +#define __ULLACCUM_IBIT__ 32 +#define __INT_FAST64_MAX__ 9223372036854775807LL +#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 +#define __FLT_DIG__ 6 +#define __UINT_FAST64_TYPE__ long long unsigned int +#define __INT_MAX__ 2147483647 +#define __LACCUM_FBIT__ 31 +#define __USACCUM_MIN__ 0.0UHK +#define __UHA_IBIT__ 8 +#define __INT64_TYPE__ long long int +#define __FLT_MAX_EXP__ 128 +#define __UTQ_IBIT__ 0 +#define __DBL_MANT_DIG__ 53 +#define __INT_LEAST64_MAX__ 9223372036854775807LL +#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1 +#define __DEC64_MIN__ 1E-383DD +#define __WINT_TYPE__ unsigned int +#define __UINT_LEAST32_TYPE__ long unsigned int +#define __SIZEOF_SHORT__ 2 +#define __ULLFRACT_IBIT__ 0 +#define __LDBL_MIN_EXP__ (-1021) +#define __arm__ 1 +#define __UDA_IBIT__ 32 +#define __INT_LEAST8_MAX__ 127 +#define __LFRACT_FBIT__ 31 +#define __LDBL_MAX_10_EXP__ 308 +#define __ATOMIC_RELAXED 0 +#define __DBL_EPSILON__ ((double)2.2204460492503131e-16L) +#define __UINT8_C(c) c +#define __INT_LEAST32_TYPE__ long int +#define __SIZEOF_WCHAR_T__ 4 +#define __UINT64_TYPE__ long long unsigned int +#define __LLFRACT_MAX__ 0X7FFFFFFFFFFFFFFFP-63LLR +#define __TQ_FBIT__ 127 +#define __INT_FAST8_TYPE__ int +#define __ULLACCUM_EPSILON__ 0x1P-32ULLK +#define __UHQ_IBIT__ 0 +#define __LLACCUM_IBIT__ 32 +#define __DBL_DECIMAL_DIG__ 17 +#define __DEC_EVAL_METHOD__ 2 +#define __TA_FBIT__ 63 +#define __UDQ_IBIT__ 0 +#define __ORDER_BIG_ENDIAN__ 4321 +#define __ACCUM_EPSILON__ 0x1P-15K +#define __UINT32_C(c) c ## UL +#define __INTMAX_MAX__ 9223372036854775807LL +#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ +#define __FLT_DENORM_MIN__ 1.4012984643248171e-45F +#define __LLFRACT_IBIT__ 0 +#define __INT8_MAX__ 127 +#define __UINT_FAST32_TYPE__ unsigned int +#define __CHAR32_TYPE__ long unsigned int +#define __FLT_MAX__ 3.4028234663852886e+38F +#define __USACCUM_FBIT__ 8 +#define __INT32_TYPE__ long int +#define __SIZEOF_DOUBLE__ 8 +#define __FLT_MIN_10_EXP__ (-37) +#define __UFRACT_EPSILON__ 0x1P-16UR +#define __INTMAX_TYPE__ long long int +#define __DEC128_MAX_EXP__ 6145 +#define __ATOMIC_CONSUME 1 +#define __GNUC_MINOR__ 7 +#define __UINTMAX_MAX__ 18446744073709551615ULL +#define __DEC32_MANT_DIG__ 7 +#define __HA_FBIT__ 7 +#define __DBL_MAX_10_EXP__ 308 +#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L +#define __INT16_C(c) c +#define __STDC__ 1 +#define __ARM_ARCH_4T__ 1 +#define __PTRDIFF_TYPE__ int +#define __LLFRACT_MIN__ (-0.5LLR-0.5LLR) +#define __ATOMIC_SEQ_CST 5 +#define __DA_FBIT__ 31 +#define __UINT32_TYPE__ long unsigned int +#define __UINTPTR_TYPE__ unsigned int +#define __USA_IBIT__ 16 +#define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD +#define __ARM_EABI__ 1 +#define __DEC128_MANT_DIG__ 34 +#define __LDBL_MIN_10_EXP__ (-307) +#define __SIZEOF_LONG_LONG__ 8 +#define __ULACCUM_EPSILON__ 0x1P-32ULK +#define __SACCUM_IBIT__ 8 +#define __GCC_ATOMIC_LLONG_LOCK_FREE 1 +#define __LDBL_DIG__ 15 +#define __FLT_DECIMAL_DIG__ 9 +#define __UINT_FAST16_MAX__ 4294967295U +#define __GNUC_GNU_INLINE__ 1 +#define __GCC_ATOMIC_SHORT_LOCK_FREE 1 +#define __ULLFRACT_MAX__ 0XFFFFFFFFFFFFFFFFP-64ULLR +#define __UINT_FAST8_TYPE__ unsigned int +#define __USFRACT_EPSILON__ 0x1P-8UHR +#define __ULACCUM_FBIT__ 32 +#define __QQ_IBIT__ 0 +#define __ATOMIC_ACQ_REL 4 +#define __ATOMIC_RELEASE 3 diff --git a/ChibiOS_16.1.5/test/rt/testbuild/pclint/lint_cppmac.h b/ChibiOS_16.1.5/test/rt/testbuild/pclint/lint_cppmac.h new file mode 100644 index 0000000..5e63a1f --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/pclint/lint_cppmac.h @@ -0,0 +1,336 @@ +#define __DBL_MIN_EXP__ (-1021) +#define __HQ_FBIT__ 15 +#define __UINT_LEAST16_MAX__ 65535 +#define __ATOMIC_ACQUIRE 2 +#define __SFRACT_IBIT__ 0 +#define __FLT_MIN__ 1.1754943508222875e-38F +#define __UFRACT_MAX__ 0XFFFFP-16UR +#define __UINT_LEAST8_TYPE__ unsigned char +#define __DQ_FBIT__ 63 +#define __INTMAX_C(c) c ## LL +#define __ULFRACT_FBIT__ 32 +#define __SACCUM_EPSILON__ 0x1P-7HK +#define __CHAR_BIT__ 8 +#define __USQ_IBIT__ 0 +#define __UINT8_MAX__ 255 +#define __ACCUM_FBIT__ 15 +#define __WINT_MAX__ 4294967295U +#define __USFRACT_FBIT__ 8 +#define __ORDER_LITTLE_ENDIAN__ 1234 +#define __SIZE_MAX__ 4294967295U +#define __WCHAR_MAX__ 4294967295U +#define __LACCUM_IBIT__ 32 +#define __DBL_DENORM_MIN__ double(4.9406564584124654e-324L) +#define __GCC_ATOMIC_CHAR_LOCK_FREE 1 +#define __FLT_EVAL_METHOD__ 0 +#define __LLACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LLK +#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1 +#define __FRACT_FBIT__ 15 +#define __UINT_FAST64_MAX__ 18446744073709551615ULL +#define __SIG_ATOMIC_TYPE__ int +#define __UACCUM_FBIT__ 16 +#define __DBL_MIN_10_EXP__ (-307) +#define __FINITE_MATH_ONLY__ 0 +#define __ARMEL__ 1 +#define __LFRACT_IBIT__ 0 +#define __GNUC_PATCHLEVEL__ 4 +#define __LFRACT_MAX__ 0X7FFFFFFFP-31LR +#define __UINT_FAST8_MAX__ 4294967295U +#define __DEC64_MAX_EXP__ 385 +#define __INT8_C(c) c +#define __UINT_LEAST64_MAX__ 18446744073709551615ULL +#define __SA_FBIT__ 15 +#define __SHRT_MAX__ 32767 +#define __LDBL_MAX__ 1.7976931348623157e+308L +#define __FRACT_MAX__ 0X7FFFP-15R +#define __UFRACT_FBIT__ 16 +#define __UFRACT_MIN__ 0.0UR +#define __UINT_LEAST8_MAX__ 255 +#define __GCC_ATOMIC_BOOL_LOCK_FREE 1 +#define __UINTMAX_TYPE__ long long unsigned int +#define __LLFRACT_EPSILON__ 0x1P-63LLR +#define __DEC32_EPSILON__ 1E-6DF +#define __CHAR_UNSIGNED__ 1 +#define __UINT32_MAX__ 4294967295UL +#define __ULFRACT_MAX__ 0XFFFFFFFFP-32ULR +#define __TA_IBIT__ 64 +#define __LDBL_MAX_EXP__ 1024 +#define __WINT_MIN__ 0U +#define __ULLFRACT_MIN__ 0.0ULLR +#define __SCHAR_MAX__ 127 +#define __WCHAR_MIN__ 0U +#define __INT64_C(c) c ## LL +#define __DBL_DIG__ 15 +#define __GCC_ATOMIC_POINTER_LOCK_FREE 1 +#define __LLACCUM_MIN__ (-0X1P31LLK-0X1P31LLK) +#define __SIZEOF_INT__ 4 +#define __SIZEOF_POINTER__ 4 +#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1 +#define __USACCUM_IBIT__ 8 +#define __USER_LABEL_PREFIX__ +#define __STDC_HOSTED__ 1 +#define __LDBL_HAS_INFINITY__ 1 +#define __LFRACT_MIN__ (-0.5LR-0.5LR) +#define __HA_IBIT__ 8 +#define __TQ_IBIT__ 0 +#define __FLT_EPSILON__ 1.1920928955078125e-7F +#define __APCS_32__ 1 +#define __GXX_WEAK__ 1 +#define __USFRACT_IBIT__ 0 +#define __LDBL_MIN__ 2.2250738585072014e-308L +#define __FRACT_MIN__ (-0.5R-0.5R) +#define __DEC32_MAX__ 9.999999E96DF +#define __DA_IBIT__ 32 +#define __INT32_MAX__ 2147483647L +#define __UQQ_FBIT__ 8 +#define __SIZEOF_LONG__ 4 +#define __UACCUM_MAX__ 0XFFFFFFFFP-16UK +#define __UINT16_C(c) c +#define __DECIMAL_DIG__ 17 +#define __LFRACT_EPSILON__ 0x1P-31LR +#define __ULFRACT_MIN__ 0.0ULR +#define __LDBL_HAS_QUIET_NAN__ 1 +#define __ULACCUM_IBIT__ 32 +#define __UACCUM_EPSILON__ 0x1P-16UK +#define __GNUC__ 4 +#define __ULLACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULLK +#define __HQ_IBIT__ 0 +#define __FLT_HAS_DENORM__ 1 +#define __SIZEOF_LONG_DOUBLE__ 8 +#define __BIGGEST_ALIGNMENT__ 8 +#define __DQ_IBIT__ 0 +#define __DBL_MAX__ double(1.7976931348623157e+308L) +#define __ULFRACT_IBIT__ 0 +#define __INT_FAST32_MAX__ 2147483647 +#define __DBL_HAS_INFINITY__ 1 +#define __INT64_MAX__ 9223372036854775807LL +#define __ACCUM_IBIT__ 16 +#define __DEC32_MIN_EXP__ (-94) +#define __THUMB_INTERWORK__ 1 +#define __LACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LK +#define __INT_FAST16_TYPE__ int +#define __LDBL_HAS_DENORM__ 1 +#define __cplusplus 199711L +#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL +#define __INT_LEAST32_MAX__ 2147483647L +#define __ARM_PCS 1 +#define __DEC32_MIN__ 1E-95DF +#define __ACCUM_MAX__ 0X7FFFFFFFP-15K +#define __DEPRECATED 1 +#define __DBL_MAX_EXP__ 1024 +#define __USACCUM_EPSILON__ 0x1P-8UHK +#define __DEC128_EPSILON__ 1E-33DL +#define __SFRACT_MAX__ 0X7FP-7HR +#define __FRACT_IBIT__ 0 +#define __PTRDIFF_MAX__ 2147483647 +#define __UACCUM_MIN__ 0.0UK +#define __UACCUM_IBIT__ 16 +#define __GNUG__ 4 +#define __LONG_LONG_MAX__ 9223372036854775807LL +#define __SIZEOF_SIZE_T__ 4 +#define __ULACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULK +#define __SIZEOF_WINT_T__ 4 +#define __SA_IBIT__ 16 +#define __ULLACCUM_MIN__ 0.0ULLK +#define __GXX_ABI_VERSION 1002 +#define __UTA_FBIT__ 64 +#define __SOFTFP__ 1 +#define __FLT_MIN_EXP__ (-125) +#define __USFRACT_MAX__ 0XFFP-8UHR +#define __UFRACT_IBIT__ 0 +#define __INT_FAST64_TYPE__ long long int +#define __DBL_MIN__ double(2.2250738585072014e-308L) +#define __FLT_MIN_10_EXP__ (-37) +#define __LACCUM_MIN__ (-0X1P31LK-0X1P31LK) +#define __ULLACCUM_FBIT__ 32 +#define __GXX_TYPEINFO_EQUALITY_INLINE 0 +#define __ULLFRACT_EPSILON__ 0x1P-64ULLR +#define __USES_INITFINI__ 1 +#define __DEC128_MIN__ 1E-6143DL +#define __REGISTER_PREFIX__ +#define __UINT16_MAX__ 65535 +#define __DBL_HAS_DENORM__ 1 +#define __ACCUM_MIN__ (-0X1P15K-0X1P15K) +#define __SQ_IBIT__ 0 +#define __UINT8_TYPE__ unsigned char +#define __UHA_FBIT__ 8 +#define __NO_INLINE__ 1 +#define __SFRACT_MIN__ (-0.5HR-0.5HR) +#define __UTQ_FBIT__ 128 +#define __FLT_MANT_DIG__ 24 +#define __VERSION__ "4.7.4 20130913 (release) [ARM/embedded-4_7-branch revision 202601]" +#define __UINT64_C(c) c ## ULL +#define __ULLFRACT_FBIT__ 64 +#define __FRACT_EPSILON__ 0x1P-15R +#define __ULACCUM_MIN__ 0.0ULK +#define __UDA_FBIT__ 32 +#define __LLACCUM_EPSILON__ 0x1P-31LLK +#define __GCC_ATOMIC_INT_LOCK_FREE 1 +#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ +#define __USFRACT_MIN__ 0.0UHR +#define __ULLACCUM_IBIT__ 32 +#define __UQQ_IBIT__ 0 +#define __INT32_C(c) c ## L +#define __DEC64_EPSILON__ 1E-15DD +#define __ORDER_PDP_ENDIAN__ 3412 +#define __DEC128_MIN_EXP__ (-6142) +#define __UHQ_FBIT__ 16 +#define __LLACCUM_FBIT__ 31 +#define __INT_FAST32_TYPE__ int +#define __UINT_LEAST16_TYPE__ short unsigned int +#define __INT16_MAX__ 32767 +#define __SIZE_TYPE__ unsigned int +#define __UINT64_MAX__ 18446744073709551615ULL +#define __UDQ_FBIT__ 64 +#define __INT8_TYPE__ signed char +#define __ELF__ 1 +#define __ULFRACT_EPSILON__ 0x1P-32ULR +#define __LLFRACT_FBIT__ 63 +#define __FLT_RADIX__ 2 +#define __INT_LEAST16_TYPE__ short int +#define __LDBL_EPSILON__ 2.2204460492503131e-16L +#define __UINTMAX_C(c) c ## ULL +#define __SACCUM_MAX__ 0X7FFFP-7HK +#define __SIG_ATOMIC_MAX__ 2147483647 +#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1 +#define __VFP_FP__ 1 +#define __SIZEOF_PTRDIFF_T__ 4 +#define __LACCUM_EPSILON__ 0x1P-31LK +#define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF +#define __INT_FAST16_MAX__ 2147483647 +#define __UINT_FAST32_MAX__ 4294967295U +#define __UINT_LEAST64_TYPE__ long long unsigned int +#define __USACCUM_MAX__ 0XFFFFP-8UHK +#define __SFRACT_EPSILON__ 0x1P-7HR +#define __FLT_HAS_QUIET_NAN__ 1 +#define __FLT_MAX_10_EXP__ 38 +#define __LONG_MAX__ 2147483647L +#define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL +#define __FLT_HAS_INFINITY__ 1 +#define __USA_FBIT__ 16 +#define __UINT_FAST16_TYPE__ unsigned int +#define __DEC64_MAX__ 9.999999999999999E384DD +#define __CHAR16_TYPE__ short unsigned int +#define __PRAGMA_REDEFINE_EXTNAME 1 +#define __INT_LEAST16_MAX__ 32767 +#define __DEC64_MANT_DIG__ 16 +#define __UINT_LEAST32_MAX__ 4294967295UL +#define __SACCUM_FBIT__ 7 +#define __GCC_ATOMIC_LONG_LOCK_FREE 1 +#define __INT_LEAST64_TYPE__ long long int +#define __INT16_TYPE__ short int +#define __INT_LEAST8_TYPE__ signed char +#define __SQ_FBIT__ 31 +#define __DEC32_MAX_EXP__ 97 +#define __INT_FAST8_MAX__ 2147483647 +#define __INTPTR_MAX__ 2147483647 +#define __QQ_FBIT__ 7 +#define __UTA_IBIT__ 64 +#define __EXCEPTIONS 1 +#define __LDBL_MANT_DIG__ 53 +#define __SFRACT_FBIT__ 7 +#define __SACCUM_MIN__ (-0X1P7HK-0X1P7HK) +#define __DBL_HAS_QUIET_NAN__ 1 +#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) +#define __INTPTR_TYPE__ int +#define __UINT16_TYPE__ short unsigned int +#define __WCHAR_TYPE__ unsigned int +#define __SIZEOF_FLOAT__ 4 +#define __USQ_FBIT__ 32 +#define __UINTPTR_MAX__ 4294967295U +#define __DEC64_MIN_EXP__ (-382) +#define __INT_FAST64_MAX__ 9223372036854775807LL +#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 +#define __FLT_DIG__ 6 +#define __UINT_FAST64_TYPE__ long long unsigned int +#define __INT_MAX__ 2147483647 +#define __LACCUM_FBIT__ 31 +#define __USACCUM_MIN__ 0.0UHK +#define __UHA_IBIT__ 8 +#define __INT64_TYPE__ long long int +#define __FLT_MAX_EXP__ 128 +#define __UTQ_IBIT__ 0 +#define __DBL_MANT_DIG__ 53 +#define __INT_LEAST64_MAX__ 9223372036854775807LL +#define __DEC64_MIN__ 1E-383DD +#define __WINT_TYPE__ unsigned int +#define __UINT_LEAST32_TYPE__ long unsigned int +#define __SIZEOF_SHORT__ 2 +#define __ULLFRACT_IBIT__ 0 +#define __LDBL_MIN_EXP__ (-1021) +#define __arm__ 1 +#define __UDA_IBIT__ 32 +#define __INT_LEAST8_MAX__ 127 +#define __LFRACT_FBIT__ 31 +#define __WCHAR_UNSIGNED__ 1 +#define __LDBL_MAX_10_EXP__ 308 +#define __ATOMIC_RELAXED 0 +#define __DBL_EPSILON__ double(2.2204460492503131e-16L) +#define __UINT8_C(c) c +#define __INT_LEAST32_TYPE__ long int +#define __SIZEOF_WCHAR_T__ 4 +#define __UINT64_TYPE__ long long unsigned int +#define __LLFRACT_MAX__ 0X7FFFFFFFFFFFFFFFP-63LLR +#define __TQ_FBIT__ 127 +#define __INT_FAST8_TYPE__ int +#define __ULLACCUM_EPSILON__ 0x1P-32ULLK +#define __UHQ_IBIT__ 0 +#define __LLACCUM_IBIT__ 32 +#define __DBL_DECIMAL_DIG__ 17 +#define __DEC_EVAL_METHOD__ 2 +#define __TA_FBIT__ 63 +#define __UDQ_IBIT__ 0 +#define __ORDER_BIG_ENDIAN__ 4321 +#define __ACCUM_EPSILON__ 0x1P-15K +#define __UINT32_C(c) c ## UL +#define __INTMAX_MAX__ 9223372036854775807LL +#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ +#define __FLT_DENORM_MIN__ 1.4012984643248171e-45F +#define __LLFRACT_IBIT__ 0 +#define __INT8_MAX__ 127 +#define __UINT_FAST32_TYPE__ unsigned int +#define __CHAR32_TYPE__ long unsigned int +#define __FLT_MAX__ 3.4028234663852886e+38F +#define __USACCUM_FBIT__ 8 +#define __INT32_TYPE__ long int +#define __SIZEOF_DOUBLE__ 8 +#define __UFRACT_EPSILON__ 0x1P-16UR +#define __INTMAX_TYPE__ long long int +#define __DEC128_MAX_EXP__ 6145 +#define __ATOMIC_CONSUME 1 +#define __GNUC_MINOR__ 7 +#define __UINTMAX_MAX__ 18446744073709551615ULL +#define __DEC32_MANT_DIG__ 7 +#define __HA_FBIT__ 7 +#define __DBL_MAX_10_EXP__ 308 +#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L +#define __INT16_C(c) c +#define __STDC__ 1 +#define __ARM_ARCH_4T__ 1 +#define __PTRDIFF_TYPE__ int +#define __LLFRACT_MIN__ (-0.5LLR-0.5LLR) +#define __ATOMIC_SEQ_CST 5 +#define __DA_FBIT__ 31 +#define __UINT32_TYPE__ long unsigned int +#define __UINTPTR_TYPE__ unsigned int +#define __USA_IBIT__ 16 +#define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD +#define __ARM_EABI__ 1 +#define __DEC128_MANT_DIG__ 34 +#define __LDBL_MIN_10_EXP__ (-307) +#define __SIZEOF_LONG_LONG__ 8 +#define __ULACCUM_EPSILON__ 0x1P-32ULK +#define __SACCUM_IBIT__ 8 +#define __GCC_ATOMIC_LLONG_LOCK_FREE 1 +#define __LDBL_DIG__ 15 +#define __FLT_DECIMAL_DIG__ 9 +#define __UINT_FAST16_MAX__ 4294967295U +#define __GNUC_GNU_INLINE__ 1 +#define __GCC_ATOMIC_SHORT_LOCK_FREE 1 +#define __ULLFRACT_MAX__ 0XFFFFFFFFFFFFFFFFP-64ULLR +#define __UINT_FAST8_TYPE__ unsigned int +#define __USFRACT_EPSILON__ 0x1P-8UHR +#define __ULACCUM_FBIT__ 32 +#define __QQ_IBIT__ 0 +#define __ATOMIC_ACQ_REL 4 +#define __ATOMIC_RELEASE 3 diff --git a/ChibiOS_16.1.5/test/rt/testbuild/pclint/size-options.lnt b/ChibiOS_16.1.5/test/rt/testbuild/pclint/size-options.lnt new file mode 100644 index 0000000..8f632b6 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/pclint/size-options.lnt @@ -0,0 +1 @@ +-ss2 -si4 -sl4 -sll8 -sf4 -sd8 -sld8 -sp4 -sw2 \ No newline at end of file diff --git a/ChibiOS_16.1.5/test/rt/testbuild/pclint/waivers.lnt b/ChibiOS_16.1.5/test/rt/testbuild/pclint/waivers.lnt new file mode 100644 index 0000000..bf03658 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/pclint/waivers.lnt @@ -0,0 +1,122 @@ +/* MISRA checks are not performed in header files marked as libraries or + vendor-provided files or belonging to other subsystems.*/ +-e686 /* Silencing warning on -elib(*) */ +-elib(*) /* No checks on library files. */ ++libclass(angle,ansi) ++libh(core_cm4.h) ++libh(stm32*.h) ++libh(*_lld.h) + +/* Reinforcing type checking for some critical types even if not required by + MISRA.*/ +-strong(AJX, systime_t) +-strong(AJX, rtcnt_t) +-strong(AJX, rttime_t) +-strong(AJX, syssts_t) +-strong(AJX, msg_t) +-strong(AJX, tmode_t) +-strong(AJX, tstate_t) +-strong(AJX, trefs_t) +-strong(AJX, tslices_t) +-strong(AJX, tprio_t) +-strong(AJX, cnt_t) +-strong(AJX, ucnt_t) +-strong(AJX, eventid_t) +-strong(AJX, eventmask_t) +-strong(AJX, eventflags_t) + +/* Permitting anonymous unions.*/ ++fan + +/* Silencing common non-MISRA info generated by PCLint in -w3 mode. All of + them have been controlled. Other infos have been fixed in the code. + Remove temporarily the following -e in order to perform extra code quality + checks.*/ +-e526 -e537 -e552 +-e611 -e613 +-e714 -e716 -e717 -e749 -e750 -e754 -e757 -e758 -e759 -e766 -e768 -e769 -e773 -e778 -e793 +-e826 -e830 -e835 -e845 + +/* Removing *advisory* directives and rules that would negatively impact + code readability or not avoidable.*/ +-e970 /* Dir-4.6 */ +-e9045 /* Dir-4.8 */ +-e9026 /* Dir-4.9 */ +-e756 /* Rule-2.3 */ +-e9058 /* Rule-2.4 */ +-e755 /* Rule-2.5 */ +-e9003 /* Rule-8.9 */ +-e9067 /* Rule-8.11 */ +-e818 /* Rule 8.13 */ +-e9078 /* Rule-11.4 */ +-e9079 /* Rule-11.5 */ +-e9049 /* Rule-13.3 */ +-e9084 /* Rule-13.4 */ +-e801 /* Rule-15.1 */ +-e9011 /* Rule-15.4 */ +-e904 /* Rule-15.5 */ +-e9044 /* Rule-17.8 */ +-e9016 /* Rule-18.4 */ +-e844 -e954 /* Rule-18.13 */ +-e9018 /* Rule-19.2 */ +-e9024 /* Rule-20.10 */ + +/* Waiver Directive 2.1, Rule 1.1, Rule 1.2, assembler is allowed in some + modules.*/ +-e950 + +/* Waiver Directive 4.10, PCLint is confused by the guard used in the CMSIS + header files, the guard is present, suppressing the noise.*/ +-e451 + +/* Waiver Rule 2.2, PCLint marks as pure functions that contain just asm + code, this does not mean that those functions do nothing.*/ +-e522 + +/* Waiver Rule 3.1, the sequence "//" is mandated by standard license + headers included on top of all source files. The sequence is part of the + license URL and cannot be removed.*/ +-e9059 + +/* Waiver Rule 8.4, this rule is disabled for the main() function only because + it, of course, does not have nor requires a prior declaration.*/ +-esym(9075, main) + +/* Waiver Rule 8.7, the static analyzer has no visibility of functions called + from asm modules.*/ +-e765 + +/* Waiver Rule 11.1, casts of function pointers are required by system + design.*/ +-e9074 + +/* Waiver Rule 11.3, casts among different types are required by system + design.*/ +-e740 /* Wrongly marked as 1.3 in PCLint 9.00L.*/ +-e9087 + +/* Waiver Rule 11.6, cast from integer to pointer is very commonly used + when accessing peripherals where the numeric address of the registers + block is cast to a structure pointer.*/ +-e923 + +/* Waiver Rule 16.1, missing break into case. It is a common occurrence and + thoroughly checked.*/ +/* Waiver Rule 16.3, missing break into case. It is a common occurrence and + thoroughly checked.*/ +-e9090 +-e9077 +-e9042 +-e616 +-e825 + +/* Waiver Rule 18.2, pointers arithmetic is required by system design and + deemed safe.*/ +/* Waiver Rule 18.3, comparisons among pointers is required by system design + and deemed safe.*/ +-e946 +-e947 + +/* Waiver Rule 21.1, this is an operating system, its identifiers are + equivalent in importance to compiler symbols.*/ +-e9071 diff --git a/ChibiOS_16.1.5/test/rt/testbuild/readme.txt b/ChibiOS_16.1.5/test/rt/testbuild/readme.txt new file mode 100644 index 0000000..5e8b854 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testbuild/readme.txt @@ -0,0 +1,28 @@ +This test performs 5 distinct operations on the RT code base. Each phase +writes a log file where errors can be found if the execution stops. + +Step 1: Build + +This step makes sure that there aren't compilation errors nor warnings in all +the defined configurations. + +Step 2: Execute + +The test suite is executed in the simulator in order to make sure that all +the defined test cases succeed in all the defined configurations. +Coverage data is collected during the execution for use by step 3. + +Step 3: Coverage + +The utility gcov is ran on the generate data and the coverage information is +stored in reports under ./reports. + +Step 4: Analysis + +PC-Lint is run on the codebase in order to detect MISRA violations or other +problems under the current analyser rules set (PC-Lint 9.0L is required). + +Step 5: Clearing + +The compilation products are cleared and the system is restored to original +state except for the generated reports and logs. diff --git a/ChibiOS_16.1.5/test/rt/testdyn.c b/ChibiOS_16.1.5/test/rt/testdyn.c new file mode 100644 index 0000000..7a6cdfb --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testdyn.c @@ -0,0 +1,264 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_dynamic Dynamic APIs test + * + * File: @ref testdyn.c + * + *

Description

+ * This module implements the test sequence for the dynamic thread creation + * APIs. + * + *

Objective

+ * Objective of the test module is to cover 100% of the dynamic APIs code. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @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. + * + *

Test Cases

+ * - @subpage test_dynamic_001 + * - @subpage test_dynamic_002 + * - @subpage test_dynamic_003 + * . + * @file testdyn.c + * @brief Dynamic thread APIs test source file + * @file testdyn.h + * @brief Dynamic thread APIs test header file + */ + +#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__) +#if CH_CFG_USE_HEAP || defined(__DOXYGEN__) +static memory_heap_t heap1; +#endif +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) +static memory_pool_t mp1; +#endif + +/** + * @page test_dynamic_001 Threads creation from Memory Heap + * + *

Description

+ * Two threads are started by allocating the memory from the Memory Heap then + * the remaining heap space is arbitrarily allocated and a third tread startup + * is attempted.
+ * The test expects the first two threads to successfully start and the last + * one to fail. + */ + +static THD_FUNCTION(thread, p) { + + test_emit_token(*(char *)p); +} + +#if CH_CFG_USE_HEAP || defined(__DOXYGEN__) +static void dyn1_setup(void) { + + chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers)); +} + +static void dyn1_execute(void) { + size_t n, sz; + void *p1; + tprio_t prio = chThdGetPriorityX(); + + (void)chHeapStatus(&heap1, &sz); + /* Starting threads from the heap. */ + threads[0] = chThdCreateFromHeap(&heap1, + THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), + prio-1, thread, "A"); + 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_WORKING_AREA_SIZE(THREADS_STACK_SIZE), + prio-3, thread, "C"); + chHeapFree(p1); + + test_assert(1, (threads[0] != NULL) && + (threads[1] != NULL) && + (threads[2] == NULL) && + (threads[3] == NULL) && + (threads[4] == NULL), + "thread creation failed"); + + /* Claiming the memory from terminated threads. */ + test_wait_threads(); + test_assert_sequence(2, "AB"); + + /* Heap status checked again.*/ + test_assert(3, chHeapStatus(&heap1, &n) == 1, "heap fragmented"); + test_assert(4, n == sz, "heap size changed"); +} + +ROMCONST struct testcase testdyn1 = { + "Dynamic APIs, threads creation from heap", + dyn1_setup, + NULL, + dyn1_execute +}; +#endif /* (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) */ + +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) +/** + * @page test_dynamic_002 Threads creation from Memory Pool + * + *

Description

+ * Five thread creation are attempted from a pool containing only four + * elements.
+ * The test expects the first four threads to successfully start and the last + * one to fail. + */ + +static void dyn2_setup(void) { + + chPoolObjectInit(&mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL); +} + +static void dyn2_execute(void) { + int i; + tprio_t prio = chThdGetPriorityX(); + + /* Adding the WAs to the pool. */ + for (i = 0; i < 4; i++) + chPoolFree(&mp1, wa[i]); + + /* Starting threads from the memory pool. */ + threads[0] = chThdCreateFromMemoryPool(&mp1, prio-1, thread, "A"); + threads[1] = chThdCreateFromMemoryPool(&mp1, prio-2, thread, "B"); + threads[2] = chThdCreateFromMemoryPool(&mp1, prio-3, thread, "C"); + threads[3] = chThdCreateFromMemoryPool(&mp1, prio-4, thread, "D"); + threads[4] = chThdCreateFromMemoryPool(&mp1, prio-5, thread, "E"); + + test_assert(1, (threads[0] != NULL) && + (threads[1] != NULL) && + (threads[2] != NULL) && + (threads[3] != NULL) && + (threads[4] == NULL), + "thread creation failed"); + + /* Claiming the memory from terminated threads. */ + test_wait_threads(); + test_assert_sequence(2, "ABCD"); + + /* Now the pool must be full again. */ + for (i = 0; i < 4; i++) + test_assert(3, chPoolAlloc(&mp1) != NULL, "pool list empty"); + test_assert(4, chPoolAlloc(&mp1) == NULL, "pool list not empty"); +} + +ROMCONST struct testcase testdyn2 = { + "Dynamic APIs, threads creation from memory pool", + dyn2_setup, + NULL, + dyn2_execute +}; +#endif /* CH_CFG_USE_MEMPOOLS */ + +#if (CH_CFG_USE_HEAP && CH_CFG_USE_REGISTRY) || defined(__DOXYGEN__) +/** + * @page test_dynamic_003 Registry and References test + * + *

Description

+ * Registry and Thread References APIs are tested for functionality and + * coverage. + */ + +static bool regfind(thread_t *tp) { + thread_t *ftp; + bool found = false; + + ftp = chRegFirstThread(); + do { + found |= ftp == tp; + ftp = chRegNextThread(ftp); + } while (ftp != NULL); + return found; +} + +static void dyn3_setup(void) { + + chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers)); +} + +static void dyn3_execute(void) { + thread_t *tp; + tprio_t prio = chThdGetPriorityX(); + + /* Testing references increase/decrease and final detach.*/ + tp = chThdCreateFromHeap(&heap1, WA_SIZE, prio-1, thread, "A"); + test_assert(1, tp->p_refs == 1, "wrong initial reference counter"); + chThdAddRef(tp); + test_assert(2, tp->p_refs == 2, "references increase failure"); + chThdRelease(tp); + test_assert(3, tp->p_refs == 1, "references decrease failure"); + + /* Verify the new threads count.*/ + test_assert(4, regfind(tp), "thread missing from registry"); + test_assert(5, regfind(tp), "thread disappeared"); + + /* 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 == 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 == CH_STATE_FINAL, "invalid state"); + + /* Clearing the zombie by scanning the registry.*/ + test_assert(11, regfind(tp), "thread disappeared"); + test_assert(12, !regfind(tp), "thread still in registry"); +} + +ROMCONST struct testcase testdyn3 = { + "Dynamic APIs, registry and references", + dyn3_setup, + NULL, + dyn3_execute +}; +#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_CFG_USE_DYNAMIC || defined(__DOXYGEN__) +#if CH_CFG_USE_HEAP || defined(__DOXYGEN__) + &testdyn1, +#endif +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) + &testdyn2, +#endif +#if (CH_CFG_USE_HEAP && CH_CFG_USE_REGISTRY) || defined(__DOXYGEN__) + &testdyn3, +#endif +#endif + NULL +}; diff --git a/ChibiOS_16.1.5/test/rt/testdyn.h b/ChibiOS_16.1.5/test/rt/testdyn.h new file mode 100644 index 0000000..4e22235 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testdyn.h @@ -0,0 +1,22 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTDYN_H_ +#define _TESTDYN_H_ + +extern ROMCONST struct testcase * ROMCONST patterndyn[]; + +#endif /* _TESTDYN_H_ */ diff --git a/ChibiOS_16.1.5/test/rt/testevt.c b/ChibiOS_16.1.5/test/rt/testevt.c new file mode 100644 index 0000000..cc4a456 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testevt.c @@ -0,0 +1,295 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_events Events test + * + * File: @ref testevt.c + * + *

Description

+ * This module implements the test sequence for the @ref events subsystem. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref events subsystem. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @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. + * + *

Test Cases

+ * - @subpage test_events_001 + * - @subpage test_events_002 + * - @subpage test_events_003 + * . + * @file testevt.c + * @brief Events test source file + * @file testevt.h + * @brief Events test header file + */ + +#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) + +#define ALLOWED_DELAY MS2ST(5) + +/* + * Note, the static initializers are not really required because the + * variables are explicitly initialized in each test case. It is done in order + * to test the macros. + */ +static EVENTSOURCE_DECL(es1); +static EVENTSOURCE_DECL(es2); + +/** + * @page test_events_001 Events registration and dispatch + * + *

Description

+ * Two event listeners are registered on an event source and then unregistered + * in the same order.
+ * The test expects that the even source has listeners after the registrations + * and after the first unregistration, then, after the second unegistration, + * the test expects no more listeners.
+ * In the second part the test dispatches three event flags and verifies that + * the associated event handlers are invoked in LSb-first order. + */ + +static void evt1_setup(void) { + + chEvtGetAndClearEvents(ALL_EVENTS); +} + +static void h1(eventid_t id) {(void)id;test_emit_token('A');} +static void h2(eventid_t id) {(void)id;test_emit_token('B');} +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) { + event_listener_t el1, el2; + + /* + * Testing chEvtRegisterMask() and chEvtUnregister(). + */ + chEvtObjectInit(&es1); + chEvtRegisterMask(&es1, &el1, 1); + chEvtRegisterMask(&es1, &el2, 2); + test_assert(1, chEvtIsListeningI(&es1), "no listener"); + chEvtUnregister(&es1, &el1); + test_assert(2, chEvtIsListeningI(&es1), "no listener"); + chEvtUnregister(&es1, &el2); + test_assert(3, !chEvtIsListeningI(&es1), "stuck listener"); + + /* + * Testing chEvtDispatch(). + */ + chEvtDispatch(evhndl, 7); + test_assert_sequence(4, "ABC"); +} + +ROMCONST struct testcase testevt1 = { + "Events, registration and dispatch", + evt1_setup, + NULL, + evt1_execute +}; + +/** + * @page test_events_002 Events wait and broadcast + * + *

Description

+ * In this test the following APIs are indipently tested by starting threads + * that signal/broadcast events after fixed delays: + * - @p chEvtWaitOne() + * - @p chEvtWaitAny() + * - @p chEvtWaitAll() + * . + * After each test phase the test verifies that the events have been served at + * the expected time and that there are no stuck event flags. + */ + +static void evt2_setup(void) { + + chEvtGetAndClearEvents(ALL_EVENTS); +} + +static THD_FUNCTION(thread1, p) { + + chThdSleepMilliseconds(50); + chEvtSignal((thread_t *)p, 1); +} + +static THD_FUNCTION(thread2, p) { + + (void)p; + chEvtBroadcast(&es1); + chThdSleepMilliseconds(50); + chEvtBroadcast(&es2); +} + +static void evt2_execute(void) { + eventmask_t m; + event_listener_t el1, el2; + systime_t target_time; + + /* + * Test on chEvtWaitOne() without wait. + */ + chEvtAddEvents(7); + m = chEvtWaitOne(ALL_EVENTS); + test_assert(1, m == 1, "single event error"); + m = chEvtWaitOne(ALL_EVENTS); + test_assert(2, m == 2, "single event error"); + m = chEvtWaitOne(ALL_EVENTS); + test_assert(3, m == 4, "single event error"); + m = chEvtGetAndClearEvents(ALL_EVENTS); + test_assert(4, m == 0, "stuck event"); + + /* + * Test on chEvtWaitOne() with wait. + */ + test_wait_tick(); + target_time = chVTGetSystemTime() + MS2ST(50); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, + thread1, chThdGetSelfX()); + m = chEvtWaitOne(ALL_EVENTS); + test_assert_time_window(5, target_time, target_time + ALLOWED_DELAY); + test_assert(6, m == 1, "single event error"); + m = chEvtGetAndClearEvents(ALL_EVENTS); + test_assert(7, m == 0, "stuck event"); + test_wait_threads(); + + /* + * Test on chEvtWaitAny() without wait. + */ + chEvtAddEvents(5); + m = chEvtWaitAny(ALL_EVENTS); + test_assert(8, m == 5, "unexpected pending bit"); + m = chEvtGetAndClearEvents(ALL_EVENTS); + test_assert(9, m == 0, "stuck event"); + + /* + * Test on chEvtWaitAny() with wait. + */ + test_wait_tick(); + target_time = chVTGetSystemTime() + MS2ST(50); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, + thread1, chThdGetSelfX()); + m = chEvtWaitAny(ALL_EVENTS); + test_assert_time_window(10, target_time, target_time + ALLOWED_DELAY); + test_assert(11, m == 1, "single event error"); + m = chEvtGetAndClearEvents(ALL_EVENTS); + test_assert(12, m == 0, "stuck event"); + test_wait_threads(); + + /* + * Test on chEvtWaitAll(). + */ + chEvtObjectInit(&es1); + chEvtObjectInit(&es2); + chEvtRegisterMask(&es1, &el1, 1); + chEvtRegisterMask(&es2, &el2, 4); + test_wait_tick(); + target_time = chVTGetSystemTime() + MS2ST(50); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, + thread2, "A"); + m = chEvtWaitAll(5); + test_assert_time_window(13, target_time, target_time + ALLOWED_DELAY); + m = chEvtGetAndClearEvents(ALL_EVENTS); + test_assert(14, m == 0, "stuck event"); + test_wait_threads(); + chEvtUnregister(&es1, &el1); + chEvtUnregister(&es2, &el2); + test_assert(15, !chEvtIsListeningI(&es1), "stuck listener"); + test_assert(16, !chEvtIsListeningI(&es2), "stuck listener"); +} + +ROMCONST struct testcase testevt2 = { + "Events, wait and broadcast", + evt2_setup, + NULL, + evt2_execute +}; + +#if CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__) +/** + * @page test_events_003 Events timeout + * + *

Description

+ * In this test the following APIs are let to timeout twice: immediatly and + * after 10ms: + * In this test the following APIs are indipently tested by starting threads + * that broadcast events after fixed delays: + * - @p chEvtWaitOneTimeout() + * - @p chEvtWaitAnyTimeout() + * - @p chEvtWaitAllTimeout() + * . + * After each test phase the test verifies that there are no stuck event flags. + */ + +static void evt3_setup(void) { + + chEvtGetAndClearEvents(ALL_EVENTS); +} + +static void evt3_execute(void) { + eventmask_t m; + + /* + * Tests various timeout situations. + */ + m = chEvtWaitOneTimeout(ALL_EVENTS, TIME_IMMEDIATE); + test_assert(1, m == 0, "spurious event"); + m = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_IMMEDIATE); + test_assert(2, m == 0, "spurious event"); + m = chEvtWaitAllTimeout(ALL_EVENTS, TIME_IMMEDIATE); + test_assert(3, m == 0, "spurious event"); + m = chEvtWaitOneTimeout(ALL_EVENTS, 10); + test_assert(4, m == 0, "spurious event"); + m = chEvtWaitAnyTimeout(ALL_EVENTS, 10); + test_assert(5, m == 0, "spurious event"); + m = chEvtWaitAllTimeout(ALL_EVENTS, 10); + test_assert(6, m == 0, "spurious event"); +} + +ROMCONST struct testcase testevt3 = { + "Events, timeouts", + evt3_setup, + NULL, + evt3_execute +}; + +#endif /* CH_CFG_USE_EVENTS_TIMEOUT */ + +#endif /* CH_CFG_USE_EVENTS */ + +/** + * @brief Test sequence for events. + */ +ROMCONST struct testcase * ROMCONST patternevt[] = { +#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) + &testevt1, + &testevt2, +#if CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__) + &testevt3, +#endif +#endif + NULL +}; diff --git a/ChibiOS_16.1.5/test/rt/testevt.h b/ChibiOS_16.1.5/test/rt/testevt.h new file mode 100644 index 0000000..07368f3 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testevt.h @@ -0,0 +1,22 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTEVT_H_ +#define _TESTEVT_H_ + +extern ROMCONST struct testcase * ROMCONST patternevt[]; + +#endif /* _TESTEVT_H_ */ diff --git a/ChibiOS_16.1.5/test/rt/testheap.c b/ChibiOS_16.1.5/test/rt/testheap.c new file mode 100644 index 0000000..b1ab001 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testheap.c @@ -0,0 +1,159 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_heap Memory Heap test + * + * File: @ref testheap.c + * + *

Description

+ * This module implements the test sequence for the @ref heaps subsystem. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref heaps subsystem. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_HEAP + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_heap_001 + * . + * @file testheap.c + * @brief Heap test source file + * @file testheap.h + * @brief Heap header file + */ + +#if CH_CFG_USE_HEAP || defined(__DOXYGEN__) + +#define SIZE 16 + +static memory_heap_t test_heap; + +/** + * @page test_heap_001 Allocation and fragmentation test + * + *

Description

+ * Series of allocations/deallocations are performed in carefully designed + * sequences in order to stimulate all the possible code paths inside the + * allocator.
+ * The test expects to find the heap back to the initial status after each + * sequence. + */ + +static void heap1_setup(void) { + + chHeapObjectInit(&test_heap, test.buffer, sizeof(union test_buffers)); +} + +static void heap1_execute(void) { + void *p1, *p2, *p3; + size_t n, sz; + + /* Unrelated, for coverage only.*/ + (void)chCoreGetStatusX(); + + /* + * Test on the default heap in order to cover the core allocator at + * least one time. + */ + (void)chHeapStatus(NULL, &sz); + p1 = chHeapAlloc(NULL, SIZE); + test_assert(1, p1 != NULL, "allocation failed"); + chHeapFree(p1); + p1 = chHeapAlloc(NULL, (size_t)-256); + test_assert(2, p1 == NULL, "allocation not failed"); + + /* Initial local heap state.*/ + (void)chHeapStatus(&test_heap, &sz); + + /* Same order.*/ + p1 = chHeapAlloc(&test_heap, SIZE); + p2 = chHeapAlloc(&test_heap, SIZE); + p3 = chHeapAlloc(&test_heap, SIZE); + chHeapFree(p1); /* Does not merge.*/ + chHeapFree(p2); /* Merges backward.*/ + chHeapFree(p3); /* Merges both sides.*/ + test_assert(3, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); + + /* Reverse order.*/ + p1 = chHeapAlloc(&test_heap, SIZE); + p2 = chHeapAlloc(&test_heap, SIZE); + p3 = chHeapAlloc(&test_heap, SIZE); + chHeapFree(p3); /* Merges forward.*/ + chHeapFree(p2); /* Merges forward.*/ + chHeapFree(p1); /* Merges forward.*/ + test_assert(4, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); + + /* Small fragments handling.*/ + p1 = chHeapAlloc(&test_heap, SIZE + 1); + p2 = chHeapAlloc(&test_heap, SIZE); + chHeapFree(p1); + test_assert(5, chHeapStatus(&test_heap, &n) == 2, "invalid state"); + p1 = chHeapAlloc(&test_heap, SIZE); + /* Note, the first situation happens when the alignment size is smaller + than the header size, the second in the other cases.*/ + test_assert(6, (chHeapStatus(&test_heap, &n) == 1) || + (chHeapStatus(&test_heap, &n) == 2), "heap fragmented"); + chHeapFree(p2); + chHeapFree(p1); + test_assert(7, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); + + /* Skip fragment handling.*/ + p1 = chHeapAlloc(&test_heap, SIZE); + p2 = chHeapAlloc(&test_heap, SIZE); + chHeapFree(p1); + test_assert(8, chHeapStatus(&test_heap, &n) == 2, "invalid state"); + p1 = chHeapAlloc(&test_heap, SIZE * 2); /* Skips first fragment.*/ + chHeapFree(p1); + chHeapFree(p2); + test_assert(9, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); + + /* Allocate all handling.*/ + (void)chHeapStatus(&test_heap, &n); + p1 = chHeapAlloc(&test_heap, n); + test_assert(10, chHeapStatus(&test_heap, &n) == 0, "not empty"); + chHeapFree(p1); + + test_assert(11, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); + test_assert(12, n == sz, "size changed"); +} + +ROMCONST struct testcase testheap1 = { + "Heap, allocation and fragmentation test", + heap1_setup, + NULL, + heap1_execute +}; + +#endif /* CH_CFG_USE_HEAP.*/ + +/** + * @brief Test sequence for heap. + */ +ROMCONST struct testcase * ROMCONST patternheap[] = { +#if CH_CFG_USE_HEAP || defined(__DOXYGEN__) + &testheap1, +#endif + NULL +}; diff --git a/ChibiOS_16.1.5/test/rt/testheap.h b/ChibiOS_16.1.5/test/rt/testheap.h new file mode 100644 index 0000000..4768cb5 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testheap.h @@ -0,0 +1,22 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTHEAP_H_ +#define _TESTHEAP_H_ + +extern ROMCONST struct testcase * ROMCONST patternheap[]; + +#endif /* _TESTHEAP_H_ */ diff --git a/ChibiOS_16.1.5/test/rt/testmbox.c b/ChibiOS_16.1.5/test/rt/testmbox.c new file mode 100644 index 0000000..901038c --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testmbox.c @@ -0,0 +1,239 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_mbox Mailboxes test + * + * File: @ref testmbox.c + * + *

Description

+ * This module implements the test sequence for the @ref mailboxes subsystem. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref mailboxes + * subsystem code.
+ * Note that the @ref mailboxes subsystem depends on the @ref semaphores + * subsystem that has to met its testing objectives as well. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_MAILBOXES + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_mbox_001 + * . + * @file testmbox.c + * @brief Mailboxes test source file + * @file testmbox.h + * @brief Mailboxes header file + */ + +#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__) + +#define ALLOWED_DELAY MS2ST(5) +#define MB_SIZE 5 + +/* + * Note, the static initializers are not really required because the + * variables are explicitly initialized in each test case. It is done in order + * to test the macros. + */ +static MAILBOX_DECL(mb1, test.wa.T0, MB_SIZE); + +/** + * @page test_mbox_001 Queuing and timeouts + * + *

Description

+ * Messages are posted/fetched from a mailbox in carefully designed sequences + * in order to stimulate all the possible code paths inside the mailbox.
+ * The test expects to find a consistent mailbox status after each operation. + */ + +static void mbox1_setup(void) { + + chMBObjectInit(&mb1, (msg_t *)test.wa.T0, MB_SIZE); +} + +static void mbox1_execute(void) { + msg_t msg1, msg2; + unsigned i; + + /* + * Testing initial space. + */ + 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 == MSG_OK, "wrong wake-up message"); + } + msg1 = chMBPostAhead(&mb1, 'A', TIME_INFINITE); + test_assert(3, msg1 == MSG_OK, "wrong wake-up message"); + + /* + * Testing post timeout. + */ + msg1 = chMBPost(&mb1, 'X', 1); + test_assert(4, msg1 == MSG_TIMEOUT, "wrong wake-up message"); + chSysLock(); + msg1 = chMBPostI(&mb1, 'X'); + chSysUnlock(); + test_assert(5, msg1 == MSG_TIMEOUT, "wrong wake-up message"); + msg1 = chMBPostAhead(&mb1, 'X', 1); + test_assert(6, msg1 == MSG_TIMEOUT, "wrong wake-up message"); + chSysLock(); + msg1 = chMBPostAheadI(&mb1, 'X'); + chSysUnlock(); + test_assert(7, msg1 == MSG_TIMEOUT, "wrong wake-up message"); + + /* + * Testing final conditions. + */ + test_assert_lock(8, chMBGetFreeCountI(&mb1) == 0, "still empty"); + test_assert_lock(9, chMBGetUsedCountI(&mb1) == MB_SIZE, "not full"); + test_assert_lock(10, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); + + /* + * Testing dequeuing. + */ + for (i = 0; i < MB_SIZE; i++) { + msg1 = chMBFetch(&mb1, &msg2, TIME_INFINITE); + test_assert(11, msg1 == MSG_OK, "wrong wake-up message"); + test_emit_token(msg2); + } + test_assert_sequence(12, "ABCDE"); + + /* + * Testing buffer circularity. + */ + msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE); + test_assert(13, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBFetch(&mb1, &msg2, TIME_INFINITE); + 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"); + + /* + * Testing fetch timeout. + */ + msg1 = chMBFetch(&mb1, &msg2, 1); + test_assert(17, msg1 == MSG_TIMEOUT, "wrong wake-up message"); + chSysLock(); + msg1 = chMBFetchI(&mb1, &msg2); + chSysUnlock(); + test_assert(18, msg1 == MSG_TIMEOUT, "wrong wake-up message"); + + /* + * Testing final conditions. + */ + test_assert_lock(19, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); + test_assert_lock(20, chMBGetUsedCountI(&mb1) == 0, "still full"); + test_assert_lock(21, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); + + /* + * Testing I-Class. + */ + chSysLock(); + msg1 = chMBPostI(&mb1, 'A'); + test_assert(22, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostI(&mb1, 'B'); + test_assert(23, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostI(&mb1, 'C'); + test_assert(24, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostI(&mb1, 'D'); + test_assert(25, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostI(&mb1, 'E'); + chSysUnlock(); + 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 == MSG_OK, "wrong wake-up message"); + test_emit_token(msg2); + } + test_assert_sequence(29, "ABCDE"); + test_assert_lock(30, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); + test_assert_lock(31, chMBGetUsedCountI(&mb1) == 0, "still full"); + test_assert(32, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); + + chSysLock(); + msg1 = chMBPostAheadI(&mb1, 'E'); + test_assert(33, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostAheadI(&mb1, 'D'); + test_assert(34, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostAheadI(&mb1, 'C'); + test_assert(35, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostAheadI(&mb1, 'B'); + test_assert(36, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostAheadI(&mb1, 'A'); + chSysUnlock(); + 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 == MSG_OK, "wrong wake-up message"); + test_emit_token(msg2); + } + test_assert_sequence(40, "ABCDE"); + test_assert_lock(41, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); + test_assert_lock(42, chMBGetUsedCountI(&mb1) == 0, "still full"); + test_assert(43, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); + + /* + * Testing reset. + */ + chMBReset(&mb1); + + /* + * Re-testing final conditions. + */ + test_assert_lock(44, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); + test_assert_lock(45, chMBGetUsedCountI(&mb1) == 0, "still full"); + test_assert_lock(46, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base"); + test_assert_lock(47, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base"); +} + +ROMCONST struct testcase testmbox1 = { + "Mailboxes, queuing and timeouts", + mbox1_setup, + NULL, + mbox1_execute +}; + +#endif /* CH_CFG_USE_MAILBOXES */ + +/** + * @brief Test sequence for mailboxes. + */ +ROMCONST struct testcase * ROMCONST patternmbox[] = { +#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__) + &testmbox1, +#endif + NULL +}; diff --git a/ChibiOS_16.1.5/test/rt/testmbox.h b/ChibiOS_16.1.5/test/rt/testmbox.h new file mode 100644 index 0000000..a1c80da --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testmbox.h @@ -0,0 +1,22 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTMBOX_H_ +#define _TESTMBOX_H_ + +extern ROMCONST struct testcase * ROMCONST patternmbox[]; + +#endif /* _TESTMBOX_H_ */ diff --git a/ChibiOS_16.1.5/test/rt/testmsg.c b/ChibiOS_16.1.5/test/rt/testmsg.c new file mode 100644 index 0000000..2a98d0f --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testmsg.c @@ -0,0 +1,107 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_msg Messages test + * + * File: @ref testmsg.c + * + *

Description

+ * This module implements the test sequence for the @ref messages subsystem. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref messages + * subsystem code. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_MESSAGES + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_msg_001 + * . + * @file testmsg.c + * @brief Messages test source file + * @file testmsg.h + * @brief Messages header file + */ + +#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__) + +/** + * @page test_msg_001 Messages Server loop + * + *

Description

+ * A thread is spawned that sends four messages back to the tester thread.
+ * The test expect to receive the messages in the correct sequence and to + * not find a fifth message waiting. + */ + +static THD_FUNCTION(thread, p) { + + chMsgSend(p, 'A'); + chMsgSend(p, 'B'); + chMsgSend(p, 'C'); +} + +static void msg1_execute(void) { + thread_t *tp; + msg_t msg; + + /* + * Testing the whole messages loop. + */ + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() + 1, + thread, chThdGetSelfX()); + tp = chMsgWait(); + msg = chMsgGet(tp); + chMsgRelease(tp, msg); + test_emit_token(msg); + tp = chMsgWait(); + msg = chMsgGet(tp); + chMsgRelease(tp, msg); + test_emit_token(msg); + tp = chMsgWait(); + msg = chMsgGet(tp); + chMsgRelease(tp, msg); + test_emit_token(msg); + test_assert_sequence(1, "ABC"); +} + +ROMCONST struct testcase testmsg1 = { + "Messages, loop", + NULL, + NULL, + msg1_execute +}; + +#endif /* CH_CFG_USE_MESSAGES */ + +/** + * @brief Test sequence for messages. + */ +ROMCONST struct testcase * ROMCONST patternmsg[] = { +#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__) + &testmsg1, +#endif + NULL +}; diff --git a/ChibiOS_16.1.5/test/rt/testmsg.h b/ChibiOS_16.1.5/test/rt/testmsg.h new file mode 100644 index 0000000..f18dd23 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testmsg.h @@ -0,0 +1,22 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTMSG_H_ +#define _TESTMSG_H_ + +extern ROMCONST struct testcase * ROMCONST patternmsg[]; + +#endif /* _TESTMSG_H_ */ diff --git a/ChibiOS_16.1.5/test/rt/testmtx.c b/ChibiOS_16.1.5/test/rt/testmtx.c new file mode 100644 index 0000000..f34072a --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testmtx.c @@ -0,0 +1,623 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_mtx Mutexes test + * + * File: @ref testmtx.c + * + *

Description

+ * This module implements the test sequence for the @ref mutexes and + * @ref condvars subsystems.
+ * Tests on those subsystems are particularly critical because the system-wide + * implications of the Priority Inheritance mechanism. + * + *

Objective

+ * Objective of the test module is to cover 100% of the subsystems code. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @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 + * may be skipped. + * + *

Test Cases

+ * - @subpage test_mtx_001 + * - @subpage test_mtx_002 + * - @subpage test_mtx_003 + * - @subpage test_mtx_004 + * - @subpage test_mtx_005 + * - @subpage test_mtx_006 + * - @subpage test_mtx_007 + * - @subpage test_mtx_008 + * . + * @file testmtx.c + * @brief Mutexes and CondVars test source file + * @file testmtx.h + * @brief Mutexes and CondVars test header file + */ + +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) + +#define ALLOWED_DELAY 5 + +/* + * Note, the static initializers are not really required because the + * variables are explicitly initialized in each test case. It is done in order + * to test the macros. + */ +static MUTEX_DECL(m1); +static MUTEX_DECL(m2); +#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) +static CONDVAR_DECL(c1); +#endif + +/** + * @page test_mtx_001 Priority enqueuing test + * + *

Description

+ * Five threads, with increasing priority, are enqueued on a locked mutex then + * the mutex is unlocked.
+ * The test expects the threads to perform their operations in increasing + * priority order regardless of the initial order. + */ + +static void mtx1_setup(void) { + + chMtxObjectInit(&m1); +} + +static THD_FUNCTION(thread1, p) { + + chMtxLock(&m1); + test_emit_token(*(char *)p); + chMtxUnlock(&m1); +} + +static void mtx1_execute(void) { + + 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(&m1); + test_wait_threads(); + test_assert(1, prio == chThdGetPriorityX(), "wrong priority level"); + test_assert_sequence(2, "ABCDE"); +} + +ROMCONST struct testcase testmtx1 = { + "Mutexes, priority enqueuing test", + mtx1_setup, + NULL, + mtx1_execute +}; + +#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) +/** + * @page test_mtx_002 Priority inheritance, simple case + * + *

Description

+ * Three threads are involved in the classic priority inversion scenario, a + * medium priority thread tries to starve an high priority thread by + * blocking a low priority thread into a mutex lock zone.
+ * The test expects the threads to reach their goal in increasing priority + * order by rearranging their priorities in order to avoid the priority + * inversion trap. + * + *

Scenario

+ * This weird looking diagram should explain what happens in the test case: + * @code + * Time ----> 0 10 20 30 40 50 60 70 80 90 100 + * 0 ......AL++++++++++............2+++++++++++AU0---------------++++++G... + * 1 ..................++++++++++++------------------++++++++++++G......... + * 2 .............................AL..........++++++AUG................... + * ^ ^ + * Legend: + * 0..2 - Priority levels + * +++ - Running + * --- - Ready + * ... - Waiting or Terminated + * xL - Lock operation on mutex 'x' + * xUn - Unlock operation on mutex 'x' with priority returning to level 'n' + * G - Goal + * ^ - Priority transition (boost or return). + * @endcode + */ + +static void mtx2_setup(void) { + + chMtxObjectInit(&m1); +} + +/* Low priority thread */ +static THD_FUNCTION(thread2L, p) { + + (void)p; + chMtxLock(&m1); + test_cpu_pulse(40); + chMtxUnlock(&m1); + test_cpu_pulse(10); + test_emit_token('C'); +} + +/* Medium priority thread */ +static THD_FUNCTION(thread2M, p) { + + (void)p; + chThdSleepMilliseconds(20); + test_cpu_pulse(40); + test_emit_token('B'); +} + +/* High priority thread */ +static THD_FUNCTION(thread2H, p) { + + (void)p; + chThdSleepMilliseconds(40); + chMtxLock(&m1); + test_cpu_pulse(10); + chMtxUnlock(&m1); + test_emit_token('A'); +} + +static void mtx2_execute(void) { + systime_t time; + + test_wait_tick(); + 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); +} + +ROMCONST struct testcase testmtx2 = { + "Mutexes, priority inheritance, simple case", + mtx2_setup, + NULL, + mtx2_execute +}; + +/** + * @page test_mtx_003 Priority inheritance, complex case + * + *

Description

+ * Five threads are involved in the complex priority inversion scenario, + * please refer to the diagram below for the complete scenario.
+ * The test expects the threads to perform their operations in increasing + * priority order by rearranging their priorities in order to avoid the + * priority inversion trap. + * + *

Scenario

+ * This weird looking diagram should explain what happens in the test case: + * @code + * Time ----> 0 10 20 30 40 50 60 70 80 90 100 110 + * 0 ......BL++++------------2+++++------4+++++BU0---------------------------G..... + * 1 ............AL++++2+++++BL----------4-----++++++BU4+++AU1---------------G..... + * 2 ..................AL----------------------------------------------++++++AUG... + * 3 ..............................+++++++-----------------------++++++G........... + * 4 ....................................AL................++++++AUG............... + * ^ ^ ^ ^ ^ ^ + * Legend: + * 0..4 - Priority levels + * +++ - Running + * --- - Ready + * ... - Waiting or Terminated + * xL - Lock operation on mutex 'x' + * xUn - Unlock operation on mutex 'x' with priority returning to level 'n' + * ^ - Priority transition (boost or return). + * @endcode + */ + +static void mtx3_setup(void) { + + chMtxObjectInit(&m1); /* Mutex B.*/ + chMtxObjectInit(&m2); /* Mutex A.*/ +} + +/* Lowest priority thread */ +static THD_FUNCTION(thread3LL, p) { + + (void)p; + chMtxLock(&m1); + test_cpu_pulse(30); + chMtxUnlock(&m1); + test_emit_token('E'); +} + +/* Low priority thread */ +static THD_FUNCTION(thread3L, p) { + + (void)p; + chThdSleepMilliseconds(10); + chMtxLock(&m2); + test_cpu_pulse(20); + chMtxLock(&m1); + test_cpu_pulse(10); + chMtxUnlock(&m1); + test_cpu_pulse(10); + chMtxUnlock(&m2); + test_emit_token('D'); +} + +/* Medium priority thread */ +static THD_FUNCTION(thread3M, p) { + + (void)p; + chThdSleepMilliseconds(20); + chMtxLock(&m2); + test_cpu_pulse(10); + chMtxUnlock(&m2); + test_emit_token('C'); +} + +/* High priority thread */ +static THD_FUNCTION(thread3H, p) { + + (void)p; + chThdSleepMilliseconds(40); + test_cpu_pulse(20); + test_emit_token('B'); +} + +/* Highest priority thread */ +static THD_FUNCTION(thread3HH, p) { + + (void)p; + chThdSleepMilliseconds(50); + chMtxLock(&m2); + test_cpu_pulse(10); + chMtxUnlock(&m2); + test_emit_token('A'); +} + +static void mtx3_execute(void) { + systime_t time; + + test_wait_tick(); + 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); +} + +ROMCONST struct testcase testmtx3 = { + "Mutexes, priority inheritance, complex case", + mtx3_setup, + NULL, + mtx3_execute +}; +#endif /* CH_DBG_THREADS_PROFILING */ + +/** + * @page test_mtx_004 Priority return verification + * + *

Description

+ * Two threads are spawned that try to lock the mutexes locked by the tester + * thread with precise timing.
+ * The test expects that the priority changes caused by the priority + * inheritance algorithm happen at the right moment and with the right values. + */ + +static void mtx4_setup(void) { + + chMtxObjectInit(&m1); + chMtxObjectInit(&m2); +} + +static THD_FUNCTION(thread4a, p) { + + (void)p; + chThdSleepMilliseconds(50); + chMtxLock(&m2); + chMtxUnlock(&m2); +} + +static THD_FUNCTION(thread4b, p) { + + (void)p; + chThdSleepMilliseconds(150); + chMtxLock(&m1); + chMtxUnlock(&m1); +} + +static void mtx4_execute(void) { + tprio_t p, p1, p2; + + 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, chThdGetPriorityX() == p, "wrong priority level"); + chThdSleepMilliseconds(100); + test_assert(2, chThdGetPriorityX() == p1, "wrong priority level"); + chMtxLock(&m1); + test_assert(3, chThdGetPriorityX() == p1, "wrong priority level"); + chThdSleepMilliseconds(100); + test_assert(4, chThdGetPriorityX() == p2, "wrong priority level"); + chMtxUnlock(&m1); + test_assert(5, chThdGetPriorityX() == p1, "wrong priority level"); + chThdSleepMilliseconds(100); + test_assert(6, chThdGetPriorityX() == p1, "wrong priority level"); + chMtxUnlockAll(); + 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, chThdGetPriorityX() == p, "wrong priority level"); + chThdSleepMilliseconds(100); + test_assert(9, chThdGetPriorityX() == p1, "wrong priority level"); + chMtxLock(&m1); + test_assert(10, chThdGetPriorityX() == p1, "wrong priority level"); + chThdSleepMilliseconds(100); + test_assert(11, chThdGetPriorityX() == p2, "wrong priority level"); + chSysLock(); + chMtxUnlockS(&m1); + chSchRescheduleS(); + chSysUnlock(); + test_assert(12, chThdGetPriorityX() == p1, "wrong priority level"); + chThdSleepMilliseconds(100); + test_assert(13, chThdGetPriorityX() == p1, "wrong priority level"); + chMtxUnlockAll(); + test_assert(14, chThdGetPriorityX() == p, "wrong priority level"); + test_wait_threads(); +} + +ROMCONST struct testcase testmtx4 = { + "Mutexes, priority return", + mtx4_setup, + NULL, + mtx4_execute +}; + +/** + * @page test_mtx_005 Mutex status + * + *

Description

+ * Various tests on the mutex structure status after performing some lock and + * unlock operations.
+ * The test expects that the internal mutex status is consistent after each + * operation. + */ + +static void mtx5_setup(void) { + + chMtxObjectInit(&m1); +} + +static void mtx5_execute(void) { + +#if !CH_CFG_USE_MUTEXES_RECURSIVE + bool b; + tprio_t prio = chThdGetPriorityX(); + + b = chMtxTryLock(&m1); + test_assert(1, b, "already locked"); + + b = chMtxTryLock(&m1); + test_assert(2, !b, "not locked"); + + chSysLock(); + chMtxUnlockS(&m1); + chSysUnlock(); + + test_assert(3, queue_isempty(&m1.m_queue), "queue not empty"); + test_assert(4, m1.m_owner == NULL, "still owned"); + test_assert(5, chThdGetPriorityX() == prio, "wrong priority level"); +#endif /* !CH_CFG_USE_MUTEXES_RECURSIVE */ + + chMtxLock(&m1); + chMtxUnlockAll(); + test_assert(6, queue_isempty(&m1.m_queue), "queue not empty"); + test_assert(7, m1.m_owner == NULL, "still owned"); +} + +ROMCONST struct testcase testmtx5 = { + "Mutexes, status", + mtx5_setup, + NULL, + mtx5_execute +}; + +#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) +/** + * @page test_mtx_006 Condition Variable signal test + * + *

Description

+ * Five threads take a mutex and then enter a conditional variable queue, the + * tester thread then proceeds to signal the conditional variable five times + * atomically.
+ * The test expects the threads to reach their goal in increasing priority + * order regardless of the initial order. + */ + +static void mtx6_setup(void) { + + chCondObjectInit(&c1); + chMtxObjectInit(&m1); +} + +static THD_FUNCTION(thread10, p) { + + chMtxLock(&m1); + chCondWait(&c1); + test_emit_token(*(char *)p); + chMtxUnlock(&m1); +} + +static void mtx6_execute(void) { + + 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"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread10, "B"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread10, "A"); + chSysLock(); + chCondSignalI(&c1); + chCondSignalI(&c1); + chCondSignalI(&c1); + chCondSignalI(&c1); + chCondSignalI(&c1); + chSchRescheduleS(); + chSysUnlock(); + test_wait_threads(); + test_assert_sequence(1, "ABCDE"); +} + +ROMCONST struct testcase testmtx6 = { + "CondVar, signal test", + mtx6_setup, + NULL, + mtx6_execute +}; + +/** + * @page test_mtx_007 Condition Variable broadcast test + * + *

Description

+ * Five threads take a mutex and then enter a conditional variable queue, the + * tester thread then proceeds to broadcast the conditional variable.
+ * The test expects the threads to reach their goal in increasing priority + * order regardless of the initial order. + */ + +static void mtx7_setup(void) { + + chCondObjectInit(&c1); + chMtxObjectInit(&m1); +} + +static void mtx7_execute(void) { + + 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"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread10, "B"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread10, "A"); + chCondBroadcast(&c1); + test_wait_threads(); + test_assert_sequence(1, "ABCDE"); +} + +ROMCONST struct testcase testmtx7 = { + "CondVar, broadcast test", + mtx7_setup, + NULL, + mtx7_execute +}; + +/** + * @page test_mtx_008 Condition Variable priority boost test + * + *

Description

+ * This test case verifies the priority boost of a thread waiting on a + * conditional variable queue. It tests this very specific situation in order + * to complete the code coverage. + */ + +static void mtx8_setup(void) { + + chCondObjectInit(&c1); + chMtxObjectInit(&m1); + chMtxObjectInit(&m2); +} + +static THD_FUNCTION(thread11, p) { + + chMtxLock(&m2); + chMtxLock(&m1); +#if CH_CFG_USE_CONDVARS_TIMEOUT || defined(__DOXYGEN__) + chCondWaitTimeout(&c1, TIME_INFINITE); +#else + chCondWait(&c1); +#endif + test_emit_token(*(char *)p); + chMtxUnlock(&m1); + chMtxUnlock(&m2); +} + +static THD_FUNCTION(thread12, p) { + + chMtxLock(&m2); + test_emit_token(*(char *)p); + chMtxUnlock(&m2); +} + +static void mtx8_execute(void) { + + 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"); + chCondSignal(&c1); + chCondSignal(&c1); + test_wait_threads(); + test_assert_sequence(1, "ABC"); +} + +ROMCONST struct testcase testmtx8 = { + "CondVar, boost test", + mtx8_setup, + NULL, + mtx8_execute +}; +#endif /* CH_CFG_USE_CONDVARS */ +#endif /* CH_CFG_USE_MUTEXES */ + +/** + * @brief Test sequence for mutexes. + */ +ROMCONST struct testcase * ROMCONST patternmtx[] = { +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) + &testmtx1, +#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) + &testmtx2, + &testmtx3, +#endif + &testmtx4, + &testmtx5, +#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) + &testmtx6, + &testmtx7, + &testmtx8, +#endif +#endif + NULL +}; diff --git a/ChibiOS_16.1.5/test/rt/testmtx.h b/ChibiOS_16.1.5/test/rt/testmtx.h new file mode 100644 index 0000000..287a674 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testmtx.h @@ -0,0 +1,22 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTMTX_H_ +#define _TESTMTX_H_ + +extern ROMCONST struct testcase * ROMCONST patternmtx[]; + +#endif /* _TESTMTX_H_ */ diff --git a/ChibiOS_16.1.5/test/rt/testpools.c b/ChibiOS_16.1.5/test/rt/testpools.c new file mode 100644 index 0000000..0e11eb0 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testpools.c @@ -0,0 +1,117 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_pools Memory Pools test + * + * File: @ref testpools.c + * + *

Description

+ * This module implements the test sequence for the @ref pools subsystem. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref pools code. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_MEMPOOLS + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_pools_001 + * . + * @file testpools.c + * @brief Memory Pools test source file + * @file testpools.h + * @brief Memory Pools test header file + */ + +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) + +static MEMORYPOOL_DECL(mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL); + +/** + * @page test_pools_001 Allocation and enqueuing test + * + *

Description

+ * Five memory blocks are added to a memory pool then removed.
+ * The test expects to find the pool queue in the proper status after each + * operation. + */ + +static void *null_provider(size_t size) { + + (void)size; + return NULL; +} + +static void pools1_setup(void) { + + chPoolObjectInit(&mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL); +} + +static void pools1_execute(void) { + int i; + + /* Adding the WAs to the pool.*/ + chPoolLoadArray(&mp1, wa[0], MAX_THREADS); + + /* Emptying the pool.*/ + for (i = 0; i < MAX_THREADS; i++) + test_assert(1, chPoolAlloc(&mp1) != NULL, "list empty"); + + /* Now must be empty.*/ + test_assert(2, chPoolAlloc(&mp1) == NULL, "list not empty"); + + /* Adding the WAs to the pool, one by one this time.*/ + for (i = 0; i < MAX_THREADS; i++) + chPoolFree(&mp1, wa[i]); + + /* Emptying the pool again.*/ + for (i = 0; i < MAX_THREADS; i++) + test_assert(3, chPoolAlloc(&mp1) != NULL, "list empty"); + + /* Now must be empty again.*/ + test_assert(4, chPoolAlloc(&mp1) == NULL, "list not empty"); + + /* Covering the case where a provider is unable to return more memory.*/ + chPoolObjectInit(&mp1, 16, null_provider); + test_assert(5, chPoolAlloc(&mp1) == NULL, "provider returned memory"); +} + +ROMCONST struct testcase testpools1 = { + "Memory Pools, queue/dequeue", + pools1_setup, + NULL, + pools1_execute +}; + +#endif /* CH_CFG_USE_MEMPOOLS */ + +/* + * @brief Test sequence for pools. + */ +ROMCONST struct testcase * ROMCONST patternpools[] = { +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) + &testpools1, +#endif + NULL +}; diff --git a/ChibiOS_16.1.5/test/rt/testpools.h b/ChibiOS_16.1.5/test/rt/testpools.h new file mode 100644 index 0000000..7425530 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testpools.h @@ -0,0 +1,22 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTPOOLS_H_ +#define _TESTPOOLS_H_ + +extern ROMCONST struct testcase * ROMCONST patternpools[]; + +#endif /* _TESTPOOLS_H_ */ diff --git a/ChibiOS_16.1.5/test/rt/testqueues.c b/ChibiOS_16.1.5/test/rt/testqueues.c new file mode 100644 index 0000000..50981f2 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testqueues.c @@ -0,0 +1,242 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_queues I/O Queues test + * + * File: @ref testqueues.c + * + *

Description

+ * This module implements the test sequence for the @ref io_queues subsystem. + * The tests are performed by inserting and removing data from queues and by + * checking both the queues status and the correct sequence of the extracted + * data. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref io_queues code.
+ * Note that the @ref io_queues subsystem depends on the @ref semaphores + * subsystem that has to met its testing objectives as well. + * + *

Preconditions

+ * The module requires the following kernel 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. + * + *

Test Cases

+ * - @subpage test_queues_001 + * - @subpage test_queues_002 + * . + * @file testqueues.c + * @brief I/O Queues test source file + * @file testqueues.h + * @brief I/O Queues test header file + */ + +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) + +#define TEST_QUEUES_SIZE 4 + +static void notify(io_queue_t *qp) { + (void)qp; +} + +/* + * Note, the static initializers are not really required because the + * variables are explicitly initialized in each test case. It is done in order + * to test the macros. + */ +static INPUTQUEUE_DECL(iq, test.wa.T0, TEST_QUEUES_SIZE, notify, NULL); +static OUTPUTQUEUE_DECL(oq, test.wa.T1, TEST_QUEUES_SIZE, notify, NULL); + +/** + * @page test_queues_001 Input Queues functionality and APIs + * + *

Description

+ * This test case tests synchronous and asynchronous operations on an + * @p InputQueue object including timeouts. The queue state must remain + * consistent through the whole test. + */ + +static void queues1_setup(void) { + + chIQObjectInit(&iq, wa[0], TEST_QUEUES_SIZE, notify, NULL); +} + +static THD_FUNCTION(thread1, p) { + + (void)p; + chIQGetTimeout(&iq, MS2ST(200)); +} + +static void queues1_execute(void) { + unsigned i; + size_t n; + + /* Initial empty state */ + test_assert_lock(1, chIQIsEmptyI(&iq), "not empty"); + + /* Queue filling */ + chSysLock(); + for (i = 0; i < TEST_QUEUES_SIZE; i++) + chIQPutI(&iq, 'A' + i); + chSysUnlock(); + test_assert_lock(2, chIQIsFullI(&iq), "still has space"); + test_assert_lock(3, chIQPutI(&iq, 0) == Q_FULL, "failed to report Q_FULL"); + + /* Queue emptying */ + for (i = 0; i < TEST_QUEUES_SIZE; i++) + test_emit_token(chIQGet(&iq)); + test_assert_lock(4, chIQIsEmptyI(&iq), "still full"); + test_assert_sequence(5, "ABCD"); + + /* Queue filling again */ + chSysLock(); + for (i = 0; i < TEST_QUEUES_SIZE; i++) + chIQPutI(&iq, 'A' + i); + chSysUnlock(); + + /* Reading the whole thing */ + n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE); + test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size"); + test_assert_lock(7, chIQIsEmptyI(&iq), "still full"); + + /* Queue filling again */ + chSysLock(); + for (i = 0; i < TEST_QUEUES_SIZE; i++) + chIQPutI(&iq, 'A' + i); + chSysUnlock(); + + /* Partial reads */ + n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); + test_assert(8, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); + n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); + test_assert(9, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); + test_assert_lock(10, chIQIsEmptyI(&iq), "still full"); + + /* Testing reset */ + chSysLock(); + chIQPutI(&iq, 0); + chIQResetI(&iq); + chSysUnlock(); + test_assert_lock(11, chIQGetFullI(&iq) == 0, "still full"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL); + test_assert_lock(12, chIQGetFullI(&iq) == 0, "not empty"); + test_wait_threads(); + + /* Timeout */ + test_assert(13, chIQGetTimeout(&iq, 10) == Q_TIMEOUT, "wrong timeout return"); +} + +ROMCONST struct testcase testqueues1 = { + "Queues, input queues", + queues1_setup, + NULL, + queues1_execute +}; + +/** + * @page test_queues_002 Output Queues functionality and APIs + * + *

Description

+ * This test case tests synchronous and asynchronous operations on an + * @p OutputQueue object including timeouts. The queue state must remain + * consistent through the whole test. + */ + +static void queues2_setup(void) { + + chOQObjectInit(&oq, wa[0], TEST_QUEUES_SIZE, notify, NULL); +} + +static THD_FUNCTION(thread2, p) { + + (void)p; + chOQPutTimeout(&oq, 0, MS2ST(200)); +} + +static void queues2_execute(void) { + unsigned i; + size_t n; + + /* Initial empty state */ + test_assert_lock(1, chOQIsEmptyI(&oq), "not empty"); + + /* Queue filling */ + for (i = 0; i < TEST_QUEUES_SIZE; i++) + chOQPut(&oq, 'A' + i); + test_assert_lock(2, chOQIsFullI(&oq), "still has space"); + + /* Queue emptying */ + for (i = 0; i < TEST_QUEUES_SIZE; i++) { + char c; + + chSysLock(); + c = chOQGetI(&oq); + chSysUnlock(); + test_emit_token(c); + } + test_assert_lock(3, chOQIsEmptyI(&oq), "still full"); + test_assert_sequence(4, "ABCD"); + test_assert_lock(5, chOQGetI(&oq) == Q_EMPTY, "failed to report Q_EMPTY"); + + /* Writing the whole thing */ + n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE); + test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size"); + test_assert_lock(7, chOQIsFullI(&oq), "not full"); + 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(); + + /* Testing reset */ + chSysLock(); + chOQResetI(&oq); + chSysUnlock(); + test_assert_lock(9, chOQGetFullI(&oq) == 0, "still full"); + + /* Partial writes */ + n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); + test_assert(10, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); + n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); + test_assert(11, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); + test_assert_lock(12, chOQIsFullI(&oq), "not full"); + + /* Timeout */ + test_assert(13, chOQPutTimeout(&oq, 0, 10) == Q_TIMEOUT, "wrong timeout return"); +} + +ROMCONST struct testcase testqueues2 = { + "Queues, output queues", + queues2_setup, + NULL, + queues2_execute +}; +#endif /* CH_CFG_USE_QUEUES */ + +/** + * @brief Test sequence for queues. + */ +ROMCONST struct testcase * ROMCONST patternqueues[] = { +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) + &testqueues1, + &testqueues2, +#endif + NULL +}; diff --git a/ChibiOS_16.1.5/test/rt/testqueues.h b/ChibiOS_16.1.5/test/rt/testqueues.h new file mode 100644 index 0000000..bef9557 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testqueues.h @@ -0,0 +1,22 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTQUEUES_H_ +#define _TESTQUEUES_H_ + +extern ROMCONST struct testcase * ROMCONST patternqueues[]; + +#endif /* _TESTQUEUES_H_ */ diff --git a/ChibiOS_16.1.5/test/rt/testsem.c b/ChibiOS_16.1.5/test/rt/testsem.c new file mode 100644 index 0000000..c8258b2 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testsem.c @@ -0,0 +1,295 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_sem Semaphores test + * + * File: @ref testsem.c + * + *

Description

+ * This module implements the test sequence for the @ref semaphores subsystem. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref semaphores code. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_SEMAPHORES + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_sem_001 + * - @subpage test_sem_002 + * - @subpage test_sem_003 + * - @subpage test_sem_004 + * . + * @file testsem.c + * @brief Semaphores test source file + * @file testsem.h + * @brief Semaphores test header file + */ + +#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) + +#define ALLOWED_DELAY MS2ST(2) + +/* + * Note, the static initializers are not really required because the + * variables are explicitly initialized in each test case. It is done in order + * to test the macros. + */ +static SEMAPHORE_DECL(sem1, 0); + +/** + * @page test_sem_001 Enqueuing test + * + *

Description

+ * Five threads with randomized priorities are enqueued to a semaphore then + * awakened one at time.
+ * The test expects that the threads reach their goal in FIFO order or + * priority order depending on the CH_CFG_USE_SEMAPHORES_PRIORITY configuration + * setting. + */ + +static void sem1_setup(void) { + + chSemObjectInit(&sem1, 0); +} + +static THD_FUNCTION(thread1, p) { + + chSemWait(&sem1); + test_emit_token(*(char *)p); +} + +static void sem1_execute(void) { + + 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_CFG_USE_SEMAPHORES_PRIORITY + test_assert_sequence(1, "ADCEB"); +#else + test_assert_sequence(1, "ABCDE"); +#endif + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread1, "A"); + chSysLock(); + chSemAddCounterI(&sem1, 2); + chSchRescheduleS(); + chSysUnlock(); + test_wait_threads(); + test_assert_lock(2, chSemGetCounterI(&sem1) == 1, "invalid counter"); +} + +ROMCONST struct testcase testsem1 = { + "Semaphores, enqueuing", + sem1_setup, + NULL, + sem1_execute +}; + +/** + * @page test_sem_002 Timeout test + * + *

Description

+ * The three possible semaphore waiting modes (do not wait, wait with timeout, + * wait without timeout) are explored.
+ * The test expects that the semaphore wait function returns the correct value + * in each of the above scenario and that the semaphore structure status is + * correct after each operation. + */ + +static void sem2_setup(void) { + + chSemObjectInit(&sem1, 0); +} + +static THD_FUNCTION(thread2, p) { + + (void)p; + chThdSleepMilliseconds(50); + chSysLock(); + chSemSignalI(&sem1); /* For coverage reasons */ + chSchRescheduleS(); + chSysUnlock(); +} + +static void sem2_execute(void) { + int i; + systime_t target_time; + msg_t msg; + + /* + * Testing special case TIME_IMMEDIATE. + */ + msg = chSemWaitTimeout(&sem1, TIME_IMMEDIATE); + 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, chThdGetPriorityX() - 1, + thread2, 0); + msg = chSemWaitTimeout(&sem1, MS2ST(500)); + test_wait_threads(); + 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 = chVTGetSystemTime() + MS2ST(5 * 50); + for (i = 0; i < 5; i++) { + test_emit_token('A' + i); + msg = chSemWaitTimeout(&sem1, MS2ST(50)); + 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"); + test_assert_time_window(11, target_time, target_time + ALLOWED_DELAY); +} + +ROMCONST struct testcase testsem2 = { + "Semaphores, timeout", + sem2_setup, + NULL, + sem2_execute +}; + +/** + * @page test_sem_003 Atomic signal-wait test + * + *

Description

+ * This test case explicitly addresses the @p chSemWaitSignal() function. A + * thread is created that performs a wait and a signal operations. + * The tester thread is awakened from an atomic wait/signal operation.
+ * The test expects that the semaphore wait function returns the correct value + * in each of the above scenario and that the semaphore structure status is + * correct after each operation. + */ + +static void sem3_setup(void) { + + chSemObjectInit(&sem1, 0); +} + +static THD_FUNCTION(thread3, p) { + + (void)p; + chSemWait(&sem1); + chSemSignal(&sem1); +} + +static void sem3_execute(void) { + + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread3, 0); + chSemSignalWait(&sem1, &sem1); + 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, queue_isempty(&sem1.s_queue), "queue not empty"); + test_assert(4, sem1.s_cnt == 0, "counter not zero"); +} + +ROMCONST struct testcase testsem3 = { + "Semaphores, atomic signal-wait", + sem3_setup, + NULL, + sem3_execute +}; + +/** + * @page test_sem_004 Binary Wait and Signal + * + *

Description

+ * This test case tests the binary semaphores functionality. The test both + * checks the binary semaphore status and the expected status of the underlying + * counting semaphore. + */ +static THD_FUNCTION(thread4, p) { + + chBSemSignal((binary_semaphore_t *)p); +} + +static void sem4_execute(void) { + binary_semaphore_t bsem; + + /* Creates a taken binary semaphore.*/ + chBSemObjectInit(&bsem, TRUE); + chBSemReset(&bsem, TRUE); + test_assert_lock(1, chBSemGetStateI(&bsem) == TRUE, "not taken"); + + /* Starts a signaler thread at a lower priority.*/ + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, + chThdGetPriorityX()-1, thread4, &bsem); + + /* Waits to be signaled.*/ + chBSemWait(&bsem); + + /* The binary semaphore is expected to be 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_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_lock(3, chBSemGetStateI(&bsem) == FALSE, "taken"); + test_assert_lock(5, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter"); +} + +ROMCONST struct testcase testsem4 = { + "Binary Semaphores, functionality", + NULL, + NULL, + sem4_execute +}; +#endif /* CH_CFG_USE_SEMAPHORES */ + +/** + * @brief Test sequence for semaphores. + */ +ROMCONST struct testcase * ROMCONST patternsem[] = { +#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) + &testsem1, + &testsem2, + &testsem3, + &testsem4, +#endif + NULL +}; diff --git a/ChibiOS_16.1.5/test/rt/testsem.h b/ChibiOS_16.1.5/test/rt/testsem.h new file mode 100644 index 0000000..cdb020b --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testsem.h @@ -0,0 +1,22 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTSEM_H_ +#define _TESTSEM_H_ + +extern ROMCONST struct testcase * ROMCONST patternsem[]; + +#endif /* _TESTSEM_H_ */ diff --git a/ChibiOS_16.1.5/test/rt/testsys.c b/ChibiOS_16.1.5/test/rt/testsys.c new file mode 100644 index 0000000..9a8b0fe --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testsys.c @@ -0,0 +1,177 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_sys System test + * + * File: @ref testsys.c + * + *

Description

+ * This module implements the test sequence for the @ref system subsystem. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref system + * subsystem code. + * + *

Preconditions

+ * None. + * + *

Test Cases

+ * - @subpage test_sys_001 + * - @subpage test_sys_002 + * - @subpage test_sys_003 + * . + * @file testsys.c + * @brief System test source file + * @file testsys.h + * @brief System header file + */ + +/** + * @page test_sys_001 Critical zones check + * + *

Description

+ * The critical zones API is invoked for coverage. + */ + +static void vtcb(void *p) { + syssts_t sts; + + (void)p; + + /* Testing normal case.*/ + chSysLockFromISR(); + chSysUnlockFromISR(); + + /* Reentrant case.*/ + chSysLockFromISR(); + sts = chSysGetStatusAndLockX(); + chSysRestoreStatusX(sts); + chSysUnlockFromISR(); +} + +static void sys1_execute(void) { + syssts_t sts; + virtual_timer_t vt; + + /* Testing normal case.*/ + sts = chSysGetStatusAndLockX(); + chSysRestoreStatusX(sts); + + /* Reentrant case.*/ + chSysLock(); + sts = chSysGetStatusAndLockX(); + chSysRestoreStatusX(sts); + chSysUnlock(); + + /* Unconditional lock.*/ + chSysUnconditionalLock(); + chSysUnconditionalLock(); + chSysUnlock(); + + /* Unconditional unlock.*/ + chSysLock(); + chSysUnconditionalUnlock(); + chSysUnconditionalUnlock(); + + /*/Testing from ISR context using a virtual timer.*/ + chVTObjectInit(&vt); + chVTSet(&vt, 1, vtcb, NULL); + chThdSleep(10); + + test_assert(1, chVTIsArmed(&vt) == false, "timer still armed"); +} + +ROMCONST struct testcase testsys1 = { + "System, critical zones", + NULL, + NULL, + sys1_execute +}; + +/** + * @page test_sys_002 Interrupts handling + * + *

Description

+ * The interrupts handling API is invoked for coverage. + */ + +static void sys2_execute(void) { + + chSysSuspend(); + chSysDisable(); + chSysSuspend(); + chSysEnable(); +} + +ROMCONST struct testcase testsys2 = { + "System, interrupts handling", + NULL, + NULL, + sys2_execute +}; + +/** + * @page test_sys_003 System integrity check + * + *

Description

+ * The chSysIntegrityCheckI() API is invoked in order to asses the state of the + * system data structures. + */ + +static void sys3_execute(void) { + bool result; + + chSysLock(); + result = chSysIntegrityCheckI(CH_INTEGRITY_RLIST); + chSysUnlock(); + test_assert(1, result == false, "ready list check failed"); + + chSysLock(); + result = chSysIntegrityCheckI(CH_INTEGRITY_VTLIST); + chSysUnlock(); + test_assert(2, result == false, "virtual timers list check failed"); + + chSysLock(); + result = chSysIntegrityCheckI(CH_INTEGRITY_REGISTRY); + chSysUnlock(); + test_assert(3, result == false, "registry list check failed"); + + chSysLock(); + result = chSysIntegrityCheckI(CH_INTEGRITY_PORT); + chSysUnlock(); + test_assert(4, result == false, "port layer check failed"); +} + +ROMCONST struct testcase testsys3 = { + "System, integrity", + NULL, + NULL, + sys3_execute +}; + +/** + * @brief Test sequence for messages. + */ +ROMCONST struct testcase * ROMCONST patternsys[] = { + &testsys1, + &testsys2, + &testsys3, + NULL +}; diff --git a/ChibiOS_16.1.5/test/rt/testsys.h b/ChibiOS_16.1.5/test/rt/testsys.h new file mode 100644 index 0000000..562bf97 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testsys.h @@ -0,0 +1,22 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTSYS_H_ +#define _TESTSYS_H_ + +extern ROMCONST struct testcase * ROMCONST patternsys[]; + +#endif /* _TESTSYS_H_ */ diff --git a/ChibiOS_16.1.5/test/rt/testthd.c b/ChibiOS_16.1.5/test/rt/testthd.c new file mode 100644 index 0000000..5b1127a --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testthd.c @@ -0,0 +1,238 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_threads Threads and Scheduler test + * + * File: @ref testthd.c + * + *

Description

+ * This module implements the test sequence for the @ref scheduler, + * @ref threads and @ref time subsystems.
+ * Note that the tests on those subsystems are formally required but most of + * their functionality is already demonstrated because the test suite itself + * depends on them, anyway double check is good. + * + *

Objective

+ * Objective of the test module is to cover 100% of the subsystems code. + * + *

Preconditions

+ * None. + * + *

Test Cases

+ * - @subpage test_threads_001 + * - @subpage test_threads_002 + * - @subpage test_threads_003 + * - @subpage test_threads_004 + * . + * @file testthd.c + * @brief Threads and Scheduler test source file + * @file testthd.h + * @brief Threads and Scheduler test header file + */ + +/** + * @page test_threads_001 Ready List functionality #1 + * + *

Description

+ * Five threads, with increasing priority, are enqueued in the ready list + * and atomically executed.
+ * The test expects the threads to perform their operations in increasing + * priority order regardless of the initial order. + */ + +static THD_FUNCTION(thread, p) { + + test_emit_token(*(char *)p); +} + +static void thd1_execute(void) { + + 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"); +} + +ROMCONST struct testcase testthd1 = { + "Threads, enqueuing test #1", + NULL, + NULL, + thd1_execute +}; + +/** + * @page test_threads_002 Ready List functionality #2 + * + *

Description

+ * Five threads, with pseudo-random priority, are enqueued in the ready list + * and atomically executed.
+ * The test expects the threads to perform their operations in increasing + * priority order regardless of the initial order. + */ + +static void thd2_execute(void) { + + 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, chThdGetPriorityX()-3, thread, "C"); + chSysUnlock(); + chThdStart(threads[2]); + test_wait_threads(); + test_assert_sequence(1, "ABCDE"); +} + +ROMCONST struct testcase testthd2 = { + "Threads, enqueuing test #2", + NULL, + NULL, + thd2_execute +}; + +/** + * @page test_threads_003 Threads priority change test + * + *

Description

+ * A series of priority changes are performed on the current thread in order + * to verify that the priority change happens as expected.
+ * 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 = chThdGetPriorityX(); + p1 = chThdSetPriority(prio + 1); + test_assert(1, p1 == prio, + "unexpected returned priority level"); + 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, chThdGetPriorityX() == prio, + "unexpected priority level"); + +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) + /* Simulates a priority boost situation (p_prio > p_realprio).*/ + chSysLock(); + chThdGetSelfX()->p_prio += 2; + chSysUnlock(); + 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, chThdGetSelfX()->p_prio == prio + 2, + "unexpected priority level"); + 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, chThdGetSelfX()->p_prio == prio + 3, + "unexpected priority level"); + test_assert(11, chThdGetSelfX()->p_realprio == prio + 3, + "unexpected real priority level"); + + chSysLock(); + chThdGetSelfX()->p_prio = prio; + chThdGetSelfX()->p_realprio = prio; + chSysUnlock(); +#endif +} + +ROMCONST struct testcase testthd3 = { + "Threads, priority change", + NULL, + NULL, + thd3_execute +}; + +/** + * @page test_threads_004 Threads delays test + * + *

Description

+ * Delay APIs and associated macros are tested, the invoking thread is verified + * to wake up at the exact expected time. + */ + +static void thd4_execute(void) { + systime_t time; + + test_wait_tick(); + + /* Timeouts in microseconds.*/ + time = chVTGetSystemTime(); + chThdSleepMicroseconds(100000); + test_assert_time_window(1, + time + US2ST(100000), + time + US2ST(100000) + CH_CFG_ST_TIMEDELTA + 1); + + /* Timeouts in milliseconds.*/ + time = chVTGetSystemTime(); + chThdSleepMilliseconds(100); + test_assert_time_window(2, + time + MS2ST(100), + time + MS2ST(100) + CH_CFG_ST_TIMEDELTA + 1); + + /* Timeouts in seconds.*/ + time = chVTGetSystemTime(); + chThdSleepSeconds(1); + test_assert_time_window(3, + time + S2ST(1), + time + S2ST(1) + CH_CFG_ST_TIMEDELTA + 1); + + /* Absolute timelines.*/ + time = chVTGetSystemTime() + MS2ST(100); + chThdSleepUntil(time); + test_assert_time_window(4, + time, + time + CH_CFG_ST_TIMEDELTA + 1); +} + +ROMCONST struct testcase testthd4 = { + "Threads, delays", + NULL, + NULL, + thd4_execute +}; + +/** + * @brief Test sequence for threads. + */ +ROMCONST struct testcase * ROMCONST patternthd[] = { + &testthd1, + &testthd2, + &testthd3, + &testthd4, + NULL +}; diff --git a/ChibiOS_16.1.5/test/rt/testthd.h b/ChibiOS_16.1.5/test/rt/testthd.h new file mode 100644 index 0000000..2f14491 --- /dev/null +++ b/ChibiOS_16.1.5/test/rt/testthd.h @@ -0,0 +1,22 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTRDY_H_ +#define _TESTRDY_H_ + +extern ROMCONST struct testcase * ROMCONST patternthd[]; + +#endif /* _TESTRDY_H_ */ -- cgit v1.2.3