Skip to content

Commit 1397eb5

Browse files
committed
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.
1 parent 140f3e2 commit 1397eb5

File tree

3 files changed

+26
-60
lines changed

3 files changed

+26
-60
lines changed

TESTS/mbedmicro-rtos-mbed/event_flags/main.cpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,6 @@ using utest::v1::Case;
4848

4949
Semaphore sync_sem(0, 1);
5050

51-
/* In order to successfully run this test suite when compiled with --profile=debug
52-
* error() has to be redefined as noop.
53-
*
54-
* EventFlags calls RTX API which uses Event Recorder functionality. When compiled
55-
* with MBED_TRAP_ERRORS_ENABLED=1 (set in debug profile) EvrRtxEventFlagsError() calls error()
56-
* which aborts test program.
57-
*/
58-
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED
59-
void error(const char *format, ...)
60-
{
61-
(void) format;
62-
}
63-
64-
//Override the set_error function to trap the errors
65-
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)
66-
{
67-
return MBED_SUCCESS;
68-
}
69-
#endif
70-
7151
template<uint32_t flags, uint32_t wait_ms>
7252
void send_thread(EventFlags *ef)
7353
{
@@ -167,14 +147,18 @@ void test_prohibited(void)
167147

168148
ev.set(FLAG01 | FLAG02 | FLAG03);
169149

150+
#if !MBED_TRAP_ERRORS_ENABLED
170151
flags = ev.clear(PROHIBITED_FLAG);
171152
TEST_ASSERT_EQUAL(osFlagsErrorParameter, flags);
153+
#endif
172154

173155
flags = ev.get();
174156
TEST_ASSERT_EQUAL(FLAG01 | FLAG02 | FLAG03, flags);
175157

158+
#if !MBED_TRAP_ERRORS_ENABLED
176159
flags = ev.set(PROHIBITED_FLAG);
177160
TEST_ASSERT_EQUAL(osFlagsErrorParameter, flags);
161+
#endif
178162

179163
flags = ev.get();
180164
TEST_ASSERT_EQUAL(FLAG01 | FLAG02 | FLAG03, flags);

TESTS/mbedmicro-rtos-mbed/rtostimer/main.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,6 @@ void sem_callback(Semaphore *sem)
7777
sem->release();
7878
}
7979

80-
/* In order to successfully run this test suite when compiled with --profile=debug
81-
* error() has to be redefined as noop.
82-
*
83-
* RtosTimer calls RTX API which uses Event Recorder functionality. When compiled
84-
* with MBED_TRAP_ERRORS_ENABLED=1 (set in debug profile) EvrRtxTimerError() calls error()
85-
* which aborts test program.
86-
*/
87-
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED
88-
void error(const char *format, ...)
89-
{
90-
(void) format;
91-
}
92-
93-
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)
94-
{
95-
return MBED_SUCCESS;
96-
}
97-
#endif
98-
9980
/** Test one-shot not restarted when elapsed
10081
*
10182
* Given a one-shot RtosTimer
@@ -121,8 +102,11 @@ void test_oneshot_not_restarted()
121102

122103
slots = stopwatch.wait_until_stopped(DELAY_MS + DELTA_MS);
123104
TEST_ASSERT_EQUAL(0, slots);
105+
106+
#if !MBED_TRAP_ERRORS_ENABLED
124107
status = rtostimer.stop();
125108
TEST_ASSERT_EQUAL(osErrorResource, status);
109+
#endif
126110
}
127111

128112
/** Test periodic repeats continuously
@@ -160,8 +144,11 @@ void test_periodic_repeats()
160144

161145
slots = stopwatch.wait_until_stopped(DELAY_MS + DELTA_MS);
162146
TEST_ASSERT_EQUAL(0, slots);
147+
148+
#if !MBED_TRAP_ERRORS_ENABLED
163149
status = rtostimer.stop();
164150
TEST_ASSERT_EQUAL(osErrorResource, status);
151+
#endif
165152
}
166153

167154
/** Test timer can be started again
@@ -185,17 +172,21 @@ void test_start_again()
185172
int32_t slots = sem.wait(DELAY_MS + DELTA_MS);
186173
TEST_ASSERT_EQUAL(1, slots);
187174

175+
#if !MBED_TRAP_ERRORS_ENABLED
188176
status = rtostimer.stop();
189177
TEST_ASSERT_EQUAL(osErrorResource, status);
178+
#endif
190179

191180
status = rtostimer.start(DELAY_MS);
192181
TEST_ASSERT_EQUAL(osOK, status);
193182

194183
slots = sem.wait(DELAY_MS + DELTA_MS);
195184
TEST_ASSERT_EQUAL(1, slots);
196185

186+
#if !MBED_TRAP_ERRORS_ENABLED
197187
status = rtostimer.stop();
198188
TEST_ASSERT_EQUAL(osErrorResource, status);
189+
#endif
199190
}
200191

201192
/** Test timer restart updates delay
@@ -228,8 +219,10 @@ void test_restart_updates_delay()
228219
TEST_ASSERT_EQUAL(1, slots);
229220
TEST_ASSERT_INT_WITHIN(DELTA_MS, DELAY2_MS, stopwatch.read_ms());
230221

222+
#if !MBED_TRAP_ERRORS_ENABLED
231223
status = rtostimer.stop();
232224
TEST_ASSERT_EQUAL(osErrorResource, status);
225+
#endif
233226
}
234227

235228
/** Test timer is created in stopped state
@@ -241,8 +234,10 @@ void test_restart_updates_delay()
241234
void test_created_stopped()
242235
{
243236
RtosTimer rtostimer(mbed::callback(sem_callback, (Semaphore *) NULL), osTimerOnce);
237+
#if !MBED_TRAP_ERRORS_ENABLED
244238
osStatus status = rtostimer.stop();
245239
TEST_ASSERT_EQUAL(osErrorResource, status);
240+
#endif
246241
}
247242

248243
/** Test one-shot can be stopped
@@ -269,8 +264,10 @@ void test_stop()
269264
slots = sem.wait(DELAY_MS + DELTA_MS);
270265
TEST_ASSERT_EQUAL(0, slots);
271266

267+
#if !MBED_TRAP_ERRORS_ENABLED
272268
status = rtostimer.stop();
273269
TEST_ASSERT_EQUAL(osErrorResource, status);
270+
#endif
274271
}
275272

276273
/** Test timer started with infinite delay
@@ -290,6 +287,7 @@ void test_wait_forever()
290287
TEST_ASSERT_EQUAL(osOK, status);
291288
}
292289

290+
#if !MBED_TRAP_ERRORS_ENABLED
293291
/** Test timer started with zero delay
294292
*
295293
* Given a one-shot RtosTimer
@@ -331,6 +329,7 @@ void test_isr_calls_fail()
331329

332330
wait_ms(DELAY_MS + DELTA_MS);
333331
}
332+
#endif // !MBED_TRAP_ERRORS_ENABLED
334333

335334
utest::v1::status_t test_setup(const size_t number_of_cases)
336335
{
@@ -346,8 +345,10 @@ Case cases[] = {
346345
Case("Timer can be stopped", test_stop),
347346
Case("Timer is created in stopped state", test_created_stopped),
348347
Case("Timer started with infinite delay", test_wait_forever),
348+
#if !MBED_TRAP_ERRORS_ENABLED
349349
Case("Timer started with zero delay", test_no_wait),
350350
Case("Calls from ISR fail", test_isr_calls_fail)
351+
#endif
351352
};
352353

353354
Specification specification(test_setup, cases);

TESTS/mbedmicro-rtos-mbed/signals/main.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,6 @@ struct Sync {
4646
Semaphore &sem_child;
4747
};
4848

49-
50-
/* In order to successfully run this test suite when compiled with --profile=debug
51-
* error() has to be redefined as noop.
52-
*
53-
* ThreadFlags calls RTX API which uses Event Recorder functionality. When compiled
54-
* with MBED_TRAP_ERRORS_ENABLED=1 (set in debug profile) EvrRtxEventFlagsError() calls error()
55-
* which aborts test program.
56-
*/
57-
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED
58-
void error(const char *format, ...)
59-
{
60-
(void) format;
61-
}
62-
63-
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)
64-
{
65-
return MBED_SUCCESS;
66-
}
67-
#endif
68-
69-
7049
template <int32_t signals, uint32_t timeout, int32_t test_val>
7150
void run_signal_wait(void)
7251
{
@@ -214,8 +193,10 @@ void test_set_prohibited(void)
214193
sem_parent.wait();
215194
t.signal_set(ALL_SIGNALS);
216195

196+
#if !MBED_TRAP_ERRORS_ENABLED
217197
ret = t.signal_set(PROHIBITED_SIGNAL);
218198
TEST_ASSERT_EQUAL(osErrorParameter, ret);
199+
#endif
219200

220201
sem_child.release();
221202
t.join();

0 commit comments

Comments
 (0)