Skip to content

Commit f65bba9

Browse files
committed
Adapt tests-mbedmicro-rtos-mbed-mutex test - use new lock(void) function instead of deprecated one.
1 parent 8482cdc commit f65bba9

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

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

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ volatile bool mutex_defect = false;
4848
bool manipulate_protected_zone(const int thread_delay)
4949
{
5050
bool result = true;
51+
osStatus stat;
5152

52-
osStatus stat = stdio_mutex.lock();
53-
TEST_ASSERT_EQUAL(osOK, stat);
53+
stdio_mutex.lock();
5454

5555
core_util_critical_section_enter();
5656
if (changing_counter == true) {
@@ -118,8 +118,8 @@ void test_multiple_threads(void)
118118

119119
void test_dual_thread_nolock_lock_thread(Mutex *mutex)
120120
{
121-
osStatus stat = mutex->lock(osWaitForever);
122-
TEST_ASSERT_EQUAL(osOK, stat);
121+
osStatus stat;
122+
mutex->lock();
123123

124124
stat = mutex->unlock();
125125
TEST_ASSERT_EQUAL(osOK, stat);
@@ -161,8 +161,7 @@ void test_dual_thread_nolock(void)
161161

162162
void test_dual_thread_lock_unlock_thread(Mutex *mutex)
163163
{
164-
osStatus stat = mutex->lock(osWaitForever);
165-
TEST_ASSERT_EQUAL(osOK, stat);
164+
mutex->lock();
166165
}
167166

168167
/** Test dual thread lock unlock
@@ -180,8 +179,7 @@ void test_dual_thread_lock_unlock(void)
180179
osStatus stat;
181180
Thread thread(osPriorityNormal, TEST_STACK_SIZE);
182181

183-
stat = mutex.lock();
184-
TEST_ASSERT_EQUAL(osOK, stat);
182+
mutex.lock();
185183

186184
thread.start(callback(test_dual_thread_lock_unlock_thread, &mutex));
187185

@@ -202,9 +200,9 @@ void test_dual_thread_lock_lock_thread(Mutex *mutex)
202200
Timer timer;
203201
timer.start();
204202

205-
osStatus stat = mutex->lock(TEST_DELAY);
206-
TEST_ASSERT_EQUAL(osErrorTimeout, stat);
207-
TEST_ASSERT_UINT32_WITHIN(5000, TEST_DELAY * 1000, timer.read_us());
203+
bool stat = mutex->trylock_for(TEST_DELAY);
204+
TEST_ASSERT_EQUAL(false, stat);
205+
TEST_ASSERT_UINT32_WITHIN(5000, TEST_DELAY*1000, timer.read_us());
208206
}
209207

210208
/** Test dual thread lock
@@ -228,8 +226,7 @@ void test_dual_thread_lock(void)
228226
osStatus stat;
229227
Thread thread(osPriorityNormal, TEST_STACK_SIZE);
230228

231-
stat = mutex.lock();
232-
TEST_ASSERT_EQUAL(osOK, stat);
229+
mutex.lock();
233230

234231
thread.start(callback(F, &mutex));
235232

@@ -250,11 +247,9 @@ void test_single_thread_lock_recursive(void)
250247
Mutex mutex;
251248
osStatus stat;
252249

253-
stat = mutex.lock();
254-
TEST_ASSERT_EQUAL(osOK, stat);
250+
mutex.lock();
255251

256-
stat = mutex.lock();
257-
TEST_ASSERT_EQUAL(osOK, stat);
252+
mutex.lock();
258253

259254
stat = mutex.unlock();
260255
TEST_ASSERT_EQUAL(osOK, stat);
@@ -291,8 +286,7 @@ void test_single_thread_lock(void)
291286
Mutex mutex;
292287
osStatus stat;
293288

294-
stat = mutex.lock();
295-
TEST_ASSERT_EQUAL(osOK, stat);
289+
mutex.lock();
296290

297291
stat = mutex.unlock();
298292
TEST_ASSERT_EQUAL(osOK, stat);

0 commit comments

Comments
 (0)