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.
pull/8328/head
Kevin Bracey 2018-10-29 11:32:51 +02:00
parent 140f3e20d6
commit 1397eb5110
3 changed files with 26 additions and 60 deletions

View File

@ -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<uint32_t flags, uint32_t wait_ms>
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);

View File

@ -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);

View File

@ -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 <int32_t signals, uint32_t timeout, int32_t test_val>
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();