From 1397eb5110670443f0f667671302ea1c1f3e9235 Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Mon, 29 Oct 2018 11:32:51 +0200 Subject: [PATCH] Disable RTOS error tests if error traps are enabled It will be too hard to try to intercept and continue from a trapped error once error functions are marked [[noreturn]], so make the error return tests conditional on error trapping being disabled. --- .../mbedmicro-rtos-mbed/event_flags/main.cpp | 24 ++---------- TESTS/mbedmicro-rtos-mbed/rtostimer/main.cpp | 39 ++++++++++--------- TESTS/mbedmicro-rtos-mbed/signals/main.cpp | 23 +---------- 3 files changed, 26 insertions(+), 60 deletions(-) diff --git a/TESTS/mbedmicro-rtos-mbed/event_flags/main.cpp b/TESTS/mbedmicro-rtos-mbed/event_flags/main.cpp index 7d98c21a2e..0cba8c5dde 100644 --- a/TESTS/mbedmicro-rtos-mbed/event_flags/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/event_flags/main.cpp @@ -48,26 +48,6 @@ using utest::v1::Case; Semaphore sync_sem(0, 1); -/* In order to successfully run this test suite when compiled with --profile=debug - * error() has to be redefined as noop. - * - * EventFlags calls RTX API which uses Event Recorder functionality. When compiled - * with MBED_TRAP_ERRORS_ENABLED=1 (set in debug profile) EvrRtxEventFlagsError() calls error() - * which aborts test program. - */ -#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED -void error(const char *format, ...) -{ - (void) format; -} - -//Override the set_error function to trap the errors -mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) -{ - return MBED_SUCCESS; -} -#endif - template void send_thread(EventFlags *ef) { @@ -167,14 +147,18 @@ void test_prohibited(void) ev.set(FLAG01 | FLAG02 | FLAG03); +#if !MBED_TRAP_ERRORS_ENABLED flags = ev.clear(PROHIBITED_FLAG); TEST_ASSERT_EQUAL(osFlagsErrorParameter, flags); +#endif flags = ev.get(); TEST_ASSERT_EQUAL(FLAG01 | FLAG02 | FLAG03, flags); +#if !MBED_TRAP_ERRORS_ENABLED flags = ev.set(PROHIBITED_FLAG); TEST_ASSERT_EQUAL(osFlagsErrorParameter, flags); +#endif flags = ev.get(); TEST_ASSERT_EQUAL(FLAG01 | FLAG02 | FLAG03, flags); diff --git a/TESTS/mbedmicro-rtos-mbed/rtostimer/main.cpp b/TESTS/mbedmicro-rtos-mbed/rtostimer/main.cpp index 74cfb51f54..a06561afc8 100644 --- a/TESTS/mbedmicro-rtos-mbed/rtostimer/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/rtostimer/main.cpp @@ -77,25 +77,6 @@ void sem_callback(Semaphore *sem) sem->release(); } -/* In order to successfully run this test suite when compiled with --profile=debug - * error() has to be redefined as noop. - * - * RtosTimer calls RTX API which uses Event Recorder functionality. When compiled - * with MBED_TRAP_ERRORS_ENABLED=1 (set in debug profile) EvrRtxTimerError() calls error() - * which aborts test program. - */ -#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED -void error(const char *format, ...) -{ - (void) format; -} - -mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) -{ - return MBED_SUCCESS; -} -#endif - /** Test one-shot not restarted when elapsed * * Given a one-shot RtosTimer @@ -121,8 +102,11 @@ void test_oneshot_not_restarted() slots = stopwatch.wait_until_stopped(DELAY_MS + DELTA_MS); TEST_ASSERT_EQUAL(0, slots); + +#if !MBED_TRAP_ERRORS_ENABLED status = rtostimer.stop(); TEST_ASSERT_EQUAL(osErrorResource, status); +#endif } /** Test periodic repeats continuously @@ -160,8 +144,11 @@ void test_periodic_repeats() slots = stopwatch.wait_until_stopped(DELAY_MS + DELTA_MS); TEST_ASSERT_EQUAL(0, slots); + +#if !MBED_TRAP_ERRORS_ENABLED status = rtostimer.stop(); TEST_ASSERT_EQUAL(osErrorResource, status); +#endif } /** Test timer can be started again @@ -185,8 +172,10 @@ void test_start_again() int32_t slots = sem.wait(DELAY_MS + DELTA_MS); TEST_ASSERT_EQUAL(1, slots); +#if !MBED_TRAP_ERRORS_ENABLED status = rtostimer.stop(); TEST_ASSERT_EQUAL(osErrorResource, status); +#endif status = rtostimer.start(DELAY_MS); TEST_ASSERT_EQUAL(osOK, status); @@ -194,8 +183,10 @@ void test_start_again() slots = sem.wait(DELAY_MS + DELTA_MS); TEST_ASSERT_EQUAL(1, slots); +#if !MBED_TRAP_ERRORS_ENABLED status = rtostimer.stop(); TEST_ASSERT_EQUAL(osErrorResource, status); +#endif } /** Test timer restart updates delay @@ -228,8 +219,10 @@ void test_restart_updates_delay() TEST_ASSERT_EQUAL(1, slots); TEST_ASSERT_INT_WITHIN(DELTA_MS, DELAY2_MS, stopwatch.read_ms()); +#if !MBED_TRAP_ERRORS_ENABLED status = rtostimer.stop(); TEST_ASSERT_EQUAL(osErrorResource, status); +#endif } /** Test timer is created in stopped state @@ -241,8 +234,10 @@ void test_restart_updates_delay() void test_created_stopped() { RtosTimer rtostimer(mbed::callback(sem_callback, (Semaphore *) NULL), osTimerOnce); +#if !MBED_TRAP_ERRORS_ENABLED osStatus status = rtostimer.stop(); TEST_ASSERT_EQUAL(osErrorResource, status); +#endif } /** Test one-shot can be stopped @@ -269,8 +264,10 @@ void test_stop() slots = sem.wait(DELAY_MS + DELTA_MS); TEST_ASSERT_EQUAL(0, slots); +#if !MBED_TRAP_ERRORS_ENABLED status = rtostimer.stop(); TEST_ASSERT_EQUAL(osErrorResource, status); +#endif } /** Test timer started with infinite delay @@ -290,6 +287,7 @@ void test_wait_forever() TEST_ASSERT_EQUAL(osOK, status); } +#if !MBED_TRAP_ERRORS_ENABLED /** Test timer started with zero delay * * Given a one-shot RtosTimer @@ -331,6 +329,7 @@ void test_isr_calls_fail() wait_ms(DELAY_MS + DELTA_MS); } +#endif // !MBED_TRAP_ERRORS_ENABLED utest::v1::status_t test_setup(const size_t number_of_cases) { @@ -346,8 +345,10 @@ Case cases[] = { Case("Timer can be stopped", test_stop), Case("Timer is created in stopped state", test_created_stopped), Case("Timer started with infinite delay", test_wait_forever), +#if !MBED_TRAP_ERRORS_ENABLED Case("Timer started with zero delay", test_no_wait), Case("Calls from ISR fail", test_isr_calls_fail) +#endif }; Specification specification(test_setup, cases); diff --git a/TESTS/mbedmicro-rtos-mbed/signals/main.cpp b/TESTS/mbedmicro-rtos-mbed/signals/main.cpp index 07499a8a50..4f340a646e 100644 --- a/TESTS/mbedmicro-rtos-mbed/signals/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/signals/main.cpp @@ -46,27 +46,6 @@ struct Sync { Semaphore &sem_child; }; - -/* In order to successfully run this test suite when compiled with --profile=debug - * error() has to be redefined as noop. - * - * ThreadFlags calls RTX API which uses Event Recorder functionality. When compiled - * with MBED_TRAP_ERRORS_ENABLED=1 (set in debug profile) EvrRtxEventFlagsError() calls error() - * which aborts test program. - */ -#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED -void error(const char *format, ...) -{ - (void) format; -} - -mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) -{ - return MBED_SUCCESS; -} -#endif - - template void run_signal_wait(void) { @@ -214,8 +193,10 @@ void test_set_prohibited(void) sem_parent.wait(); t.signal_set(ALL_SIGNALS); +#if !MBED_TRAP_ERRORS_ENABLED ret = t.signal_set(PROHIBITED_SIGNAL); TEST_ASSERT_EQUAL(osErrorParameter, ret); +#endif sem_child.release(); t.join();