Skip to content

Commit 207660c

Browse files
niklarm0xc0170
authored andcommitted
Use shim macros for critical sections in Harness.
1 parent d5cb178 commit 207660c

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

frameworks\utest/source/harness.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void Harness::raise_failure(const failure_reason_t reason)
139139

140140
status_t fail_status = STATUS_ABORT;
141141
{
142-
mbed::util::CriticalSectionLock lock;
142+
UTEST_ENTER_CRITICAL_SECTION;
143143

144144
if (handlers.test_failure) handlers.test_failure(failure_t(reason, location));
145145
if (handlers.case_failure) fail_status = handlers.case_failure(case_current, failure_t(reason, location));
@@ -150,6 +150,7 @@ void Harness::raise_failure(const failure_reason_t reason)
150150
scheduler.cancel(case_timeout_handle);
151151
case_timeout_handle = NULL;
152152
}
153+
UTEST_LEAVE_CRITICAL_SECTION;
153154
}
154155

155156
if (fail_status == STATUS_ABORT || reason & REASON_CASE_SETUP) {
@@ -212,12 +213,13 @@ void Harness::schedule_next_case()
212213
void Harness::handle_timeout()
213214
{
214215
{
215-
mbed::util::CriticalSectionLock lock;
216+
UTEST_ENTER_CRITICAL_SECTION;
216217

217218
if (case_timeout_handle != NULL) {
218219
case_timeout_handle = NULL;
219220
case_timeout_occurred = true;
220221
}
222+
UTEST_LEAVE_CRITICAL_SECTION;
221223
}
222224
if (case_timeout_occurred) {
223225
raise_failure(failure_reason_t(REASON_TIMEOUT | ((case_control.repeat & REPEAT_ON_TIMEOUT) ? REASON_IGNORE : 0)));
@@ -227,7 +229,7 @@ void Harness::handle_timeout()
227229

228230
void Harness::validate_callback(const control_t control)
229231
{
230-
mbed::util::CriticalSectionLock lock;
232+
UTEST_ENTER_CRITICAL_SECTION;
231233
case_validation_count++;
232234

233235
if (case_timeout_handle != NULL || case_control.timeout == TIMEOUT_FOREVER)
@@ -239,15 +241,18 @@ void Harness::validate_callback(const control_t control)
239241
case_control.timeout = TIMEOUT_NONE;
240242
scheduler.post(schedule_next_case, 0);
241243
}
244+
UTEST_LEAVE_CRITICAL_SECTION;
242245
}
243246

244247
bool Harness::is_busy()
245248
{
246-
mbed::util::CriticalSectionLock lock;
249+
UTEST_ENTER_CRITICAL_SECTION;
247250
if (!test_cases) return false;
248251
if (!case_current) return false;
249252

250-
return (case_current < (test_cases + test_length));
253+
bool res = (case_current < (test_cases + test_length));
254+
UTEST_LEAVE_CRITICAL_SECTION;
255+
return res;
251256
}
252257

253258
void Harness::run_next_case()
@@ -267,11 +272,12 @@ void Harness::run_next_case()
267272

268273
repeat_t setup_repeat;
269274
{
270-
mbed::util::CriticalSectionLock lock;
275+
UTEST_ENTER_CRITICAL_SECTION;
271276
case_validation_count = 0;
272277
case_timeout_occurred = false;
273278
setup_repeat = case_control.repeat;
274279
case_control = control_t();
280+
UTEST_LEAVE_CRITICAL_SECTION;
275281
}
276282

277283
if (setup_repeat & REPEAT_SETUP_TEARDOWN) {
@@ -296,7 +302,7 @@ void Harness::run_next_case()
296302
case_repeat_count++;
297303

298304
{
299-
mbed::util::CriticalSectionLock lock;
305+
UTEST_ENTER_CRITICAL_SECTION;
300306
if (case_validation_count) case_control.repeat = repeat_t(case_control.repeat & ~REPEAT_ON_TIMEOUT);
301307

302308
// if timeout valid
@@ -313,6 +319,7 @@ void Harness::run_next_case()
313319
else {
314320
scheduler.post(schedule_next_case, 0);
315321
}
322+
UTEST_LEAVE_CRITICAL_SECTION;
316323
}
317324
}
318325
else if (handlers.test_teardown) {

0 commit comments

Comments
 (0)