@@ -46,34 +46,34 @@ struct Sync {
4646 Semaphore &sem_child;
4747};
4848
49- template <int32_t signals, uint32_t timeout, int32_t test_val>
49+ template <int32_t signals, uint32_t timeout, uint32_t test_val>
5050void run_signal_wait (void )
5151{
52- osEvent ev = Thread::signal_wait (signals, timeout);
53- TEST_ASSERT_EQUAL (test_val, ev. status );
52+ uint32_t ret = ThisThread::flags_wait_all_for (signals, timeout);
53+ TEST_ASSERT_EQUAL (test_val, ret );
5454}
5555
56- template <int32_t signals, uint32_t timeout, int32_t test_val>
56+ template <int32_t signals, uint32_t timeout, uint32_t test_val>
5757void run_release_signal_wait (Semaphore *sem)
5858{
5959 sem->release ();
60- osEvent ev = Thread::signal_wait (signals, timeout);
61- TEST_ASSERT_EQUAL (test_val, ev. status );
60+ uint32_t ret = ThisThread::flags_wait_all_for (signals, timeout);
61+ TEST_ASSERT_EQUAL (test_val, ret );
6262}
6363
64- template <int32_t signals, uint32_t timeout, int32_t test_val>
64+ template <int32_t signals, uint32_t timeout, uint32_t test_val>
6565void run_release_wait_signal_wait (Sync *sync)
6666{
6767 sync->sem_parent .release ();
6868 sync->sem_child .acquire ();
69- osEvent ev = Thread::signal_wait (signals, timeout);
70- TEST_ASSERT_EQUAL (test_val, ev. status );
69+ uint32_t ret = ThisThread::flags_wait_all_for (signals, timeout);
70+ TEST_ASSERT_EQUAL (test_val, ret );
7171}
7272
7373template <int32_t signals, int32_t test_val>
7474void run_clear (void )
7575{
76- int32_t ret = Thread::signal_clr (signals);
76+ int32_t ret = ThisThread::flags_clear (signals);
7777 TEST_ASSERT_EQUAL (test_val, ret);
7878}
7979
@@ -129,7 +129,7 @@ void test_clear_no_signals(void)
129129 Thread t (osPriorityNormal, TEST_STACK_SIZE);
130130 t.start (callback (run_double_wait_clear<NO_SIGNALS, NO_SIGNALS, ALL_SIGNALS, ALL_SIGNALS>, &sync));
131131 sem_parent.acquire ();
132- t.signal_set (ALL_SIGNALS);
132+ t.flags_set (ALL_SIGNALS);
133133 sem_child.release ();
134134 t.join ();
135135}
@@ -150,7 +150,7 @@ void test_init_state(void)
150150/* * Validate all signals set in one shot
151151
152152 Given two threads A & B are started
153- When thread A call @a signal_set (ALL_SIGNALS) with all possible signals
153+ When thread A call @a flags_set (ALL_SIGNALS) with all possible signals
154154 Then thread B @a signal_clr(NO_SIGNALS) status should be ALL_SIGNALS indicating all signals set correctly
155155 */
156156void test_set_all (void )
@@ -164,17 +164,17 @@ void test_set_all(void)
164164 t.start (callback (run_wait_clear<NO_SIGNALS, ALL_SIGNALS>, &sync));
165165
166166 sem_parent.acquire ();
167- ret = t.signal_set (ALL_SIGNALS);
167+ ret = t.flags_set (ALL_SIGNALS);
168168 TEST_ASSERT_EQUAL (ALL_SIGNALS, ret);
169169
170170 sem_child.release ();
171171 t.join ();
172172}
173173
174- /* * Validate that call signal_set with prohibited signal doesn't change thread signals
174+ /* * Validate that call flags_set with prohibited signal doesn't change thread signals
175175
176176 Given two threads A & B are started, B with all signals set
177- When thread A executes @a signal_set (PROHIBITED_SIGNAL) with prohibited signal
177+ When thread A executes @a flags_set (PROHIBITED_SIGNAL) with prohibited signal
178178 Then thread B @a signal_clr(NO_SIGNALS) status should be ALL_SIGNALS indicating that thread B signals are unchanged
179179
180180 @note Each signal has up to 31 event flags 0x1, 0x2, 0x4, 0x8, ..., 0x40000000
@@ -191,10 +191,10 @@ void test_set_prohibited(void)
191191 t.start (callback (run_wait_clear<NO_SIGNALS, ALL_SIGNALS>, &sync));
192192
193193 sem_parent.acquire ();
194- t.signal_set (ALL_SIGNALS);
194+ t.flags_set (ALL_SIGNALS);
195195
196196#if !MBED_TRAP_ERRORS_ENABLED
197- ret = t.signal_set (PROHIBITED_SIGNAL);
197+ ret = t.flags_set (PROHIBITED_SIGNAL);
198198 TEST_ASSERT_EQUAL (osErrorParameter, ret);
199199#endif
200200
@@ -217,15 +217,15 @@ void test_clear_all(void)
217217 Thread t (osPriorityNormal, TEST_STACK_SIZE);
218218 t.start (callback (run_double_wait_clear<ALL_SIGNALS, NO_SIGNALS, ALL_SIGNALS, NO_SIGNALS>, &sync));
219219 sem_parent.acquire ();
220- t.signal_set (ALL_SIGNALS);
220+ t.flags_set (ALL_SIGNALS);
221221 sem_child.release ();
222222 t.join ();
223223}
224224
225225/* * Validate all signals set one by one in loop
226226
227227 Given two threads A & B are started
228- When thread A executes @a signal_set (signal) in loop with all possible signals
228+ When thread A executes @a flags_set (signal) in loop with all possible signals
229229 */
230230void test_set_all_loop (void )
231231{
@@ -241,7 +241,7 @@ void test_set_all_loop(void)
241241 for (int i = 0 ; i <= MAX_FLAG_POS; i++) {
242242 int32_t signal = 1 << i;
243243
244- ret = t.signal_set (signal);
244+ ret = t.flags_set (signal);
245245 signals |= signal;
246246 TEST_ASSERT_EQUAL (signals, ret);
247247 sem_child.release ();
@@ -253,11 +253,10 @@ void test_set_all_loop(void)
253253/* * Validate signal_wait return status if timeout specified
254254
255255 Given the thread is running
256- When thread executes @a signal_wait(signals, timeout) with specified signals and timeout
257- Then thread @a signal_wait status should be osEventTimeout indicating a timeout
258- thread @a signal_wait status should be osOK indicating 0[ms] timeout set
256+ When thread executes @a flags_wait_all_for(signals, timeout) with specified signals and timeout
257+ Then thread @a flags_wait_all_for return should be 0 indicating no flags set
259258 */
260- template <int32_t signals, uint32_t timeout, int32_t status>
259+ template <int32_t signals, uint32_t timeout, uint32_t status>
261260void test_wait_timeout (void )
262261{
263262 Thread t (osPriorityNormal, TEST_STACK_SIZE);
@@ -269,7 +268,7 @@ void test_wait_timeout(void)
269268
270269 Given two threads A & B are started, B with all signals already set
271270 When thread B executes @a signal_wait(ALL_SIGNALS, osWaitForever),
272- Then thread B @a signal_wait return immediately with status osEventSignal indicating all wait signals was already set
271+ Then thread B @a flags_wait_all_for return immediately with ALL_SIGNALS indicating all wait signals was already set
273272 */
274273void test_wait_all_already_set (void )
275274{
@@ -278,90 +277,90 @@ void test_wait_all_already_set(void)
278277 Sync sync (sem_parent, sem_child);
279278
280279 Thread t (osPriorityNormal, TEST_STACK_SIZE);
281- t.start (callback (run_release_wait_signal_wait<ALL_SIGNALS, osWaitForever, osEventSignal >, &sync));
280+ t.start (callback (run_release_wait_signal_wait<ALL_SIGNALS, osWaitForever, ALL_SIGNALS >, &sync));
282281
283282 sem_parent.acquire ();
284283 TEST_ASSERT_EQUAL (Thread::WaitingSemaphore, t.get_state ());
285- t.signal_set (ALL_SIGNALS);
284+ t.flags_set (ALL_SIGNALS);
286285 sem_child.release ();
287286 t.join ();
288287}
289288
290289/* * Validate if signal_wait return correctly when all signals set
291290
292291 Given two threads A & B are started and B waiting for a thread flag to be set
293- When thread A executes @a signal_set (ALL_SIGNALS) with all possible signals
294- Then thread B @a signal_wait status is osEventSignal indicating all wait signals was set
292+ When thread A executes @a flags_set (ALL_SIGNALS) with all possible signals
293+ Then thread B @a flags_wait_all_for return is ALL_SIGNALS indicating all wait signals was set
295294 */
296295void test_wait_all (void )
297296{
298297 Semaphore sem (0 , 1 );
299298
300299 Thread t (osPriorityNormal, TEST_STACK_SIZE);
301- t.start (callback (run_release_signal_wait<ALL_SIGNALS, osWaitForever, osEventSignal >, &sem));
300+ t.start (callback (run_release_signal_wait<ALL_SIGNALS, osWaitForever, ALL_SIGNALS >, &sem));
302301
303302 sem.acquire ();
304303 TEST_ASSERT_EQUAL (Thread::WaitingThreadFlag, t.get_state ());
305304
306- t.signal_set (ALL_SIGNALS);
305+ t.flags_set (ALL_SIGNALS);
307306 t.join ();
308307}
309308
310309/* * Validate if signal_wait accumulate signals and return correctly when all signals set
311310
312311 Given two threads A & B are started and B waiting for a thread signals to be set
313- When thread A executes @a signal_set setting all signals in loop
314- Then thread B @a signal_wait status is osEventSignal indicating that all wait signals was set
312+ When thread A executes @a flags_set setting all signals in loop
313+ Then thread B @a flags_wait_all_for return is ALL_SIGNALS indicating that all wait signals was set
315314 */
316315void test_wait_all_loop (void )
317316{
318317 int32_t ret;
319318 Semaphore sem (0 , 1 );
320319
321320 Thread t (osPriorityNormal, TEST_STACK_SIZE);
322- t.start (callback (run_release_signal_wait<ALL_SIGNALS, osWaitForever, osEventSignal >, &sem));
321+ t.start (callback (run_release_signal_wait<ALL_SIGNALS, osWaitForever, ALL_SIGNALS >, &sem));
323322
324323 sem.acquire ();
325324 TEST_ASSERT_EQUAL (Thread::WaitingThreadFlag, t.get_state ());
326325
327326 for (int i = 0 ; i < MAX_FLAG_POS; i++) {
328327 int32_t signal = 1 << i;
329- ret = t.signal_set (signal);
328+ ret = t.flags_set (signal);
330329 }
331- ret = t.signal_set (1 << MAX_FLAG_POS);
330+ ret = t.flags_set (1 << MAX_FLAG_POS);
332331 TEST_ASSERT_EQUAL (NO_SIGNALS, ret);
333332 t.join ();
334333}
335334
336335/* * Validate if setting same signal twice cause any unwanted behaviour
337336
338337 Given two threads A & B are started and B waiting for a thread signals to be set
339- When thread A executes @a signal_set twice for the same signal
340- Then thread A @a signal_set status is current signal set
341- thread B @a signal_wait status is osEventSignal indicating that all wait signals was set
338+ When thread A executes @a flags_set twice for the same signal
339+ Then thread A @a flags_set status is current signal set
340+ thread B @a flags_wait_all_for return indicates that all wait signals was set
342341 */
343342void test_set_double (void )
344343{
345344 int32_t ret;
346345 Semaphore sem (0 , 1 );
347346
348347 Thread t (osPriorityNormal, TEST_STACK_SIZE);
349- t.start (callback (run_release_signal_wait < SIGNAL1 | SIGNAL2 | SIGNAL3, osWaitForever, osEventSignal >, &sem));
348+ t.start (callback (run_release_signal_wait < SIGNAL1 | SIGNAL2 | SIGNAL3, osWaitForever, SIGNAL1 | SIGNAL2 | SIGNAL3 >, &sem));
350349
351350 sem.acquire ();
352351 TEST_ASSERT_EQUAL (Thread::WaitingThreadFlag, t.get_state ());
353352
354- ret = t.signal_set (SIGNAL1);
353+ ret = t.flags_set (SIGNAL1);
355354 TEST_ASSERT_EQUAL (SIGNAL1, ret);
356355
357- ret = t.signal_set (SIGNAL2);
356+ ret = t.flags_set (SIGNAL2);
358357 TEST_ASSERT_EQUAL (SIGNAL1 | SIGNAL2, ret);
359358
360- ret = t.signal_set (SIGNAL2);
359+ ret = t.flags_set (SIGNAL2);
361360 TEST_ASSERT_EQUAL (SIGNAL1 | SIGNAL2, ret);
362361 TEST_ASSERT_EQUAL (Thread::WaitingThreadFlag, t.get_state ());
363362
364- ret = t.signal_set (SIGNAL3);
363+ ret = t.flags_set (SIGNAL3);
365364 TEST_ASSERT_EQUAL (NO_SIGNALS, ret);
366365 t.join ();
367366}
@@ -374,20 +373,20 @@ utest::v1::status_t test_setup(const size_t number_of_cases)
374373}
375374
376375Case cases[] = {
377- Case (" Validate that call signal_clr (NO_SIGNALS) doesn't change thread signals and return actual signals " , test_clear_no_signals),
378- Case (" Validate if any signals are set on just created thread" , test_init_state),
379- Case (" Validate all signals set in one shot" , test_set_all),
380- Case (" Validate that call signal_set with prohibited signal doesn't change thread signals " , test_set_prohibited),
381- Case (" Validate all signals clear in one shot" , test_clear_all),
382- Case (" Validate all signals set one by one in loop" , test_set_all_loop),
383- Case (" Validate signal_wait return status if timeout specified: 0[ms] no signals " , test_wait_timeout<0 , 0 , osOK >),
384- Case (" Validate signal_wait return status if timeout specified: 0[ms] all signals " , test_wait_timeout<ALL_SIGNALS, 0 , osOK >),
385- Case (" Validate signal_wait return status if timeout specified: 1[ms] no signals " , test_wait_timeout<0 , 1 , osEventTimeout >),
386- Case (" Validate signal_wait return status if timeout specified: 1[ms] all signals " , test_wait_timeout<ALL_SIGNALS, 1 , osEventTimeout >),
387- Case (" Validate that call of signal_wait return correctly when thread has all signals already set" , test_wait_all_already_set),
388- Case (" Validate if signal_wait return correctly when all signals set" , test_wait_all),
389- Case (" Validate if signal_wait accumulate signals and return correctly when all signals set" , test_wait_all_loop),
390- Case (" Validate if setting same signal twice cause any unwanted behaviour" , test_set_double)
376+ Case (" Validate that call flags_clear (NO_SIGNALS) doesn't change thread flags and return actual flags " , test_clear_no_signals),
377+ Case (" Validate if any flags are set on just created thread" , test_init_state),
378+ Case (" Validate all flags set in one shot" , test_set_all),
379+ Case (" Validate that call flags_set with prohibited flag doesn't change thread flags " , test_set_prohibited),
380+ Case (" Validate all flags clear in one shot" , test_clear_all),
381+ Case (" Validate all flags set one by one in loop" , test_set_all_loop),
382+ Case (" Validate flags_wait return status if timeout specified: 0[ms] no flags " , test_wait_timeout<0 , 0 , 0 >),
383+ Case (" Validate flags_wait return status if timeout specified: 0[ms] all flags " , test_wait_timeout<ALL_SIGNALS, 0 , 0 >),
384+ Case (" Validate flags_wait return status if timeout specified: 1[ms] no flags " , test_wait_timeout<0 , 1 , 0 >),
385+ Case (" Validate flags_wait return status if timeout specified: 1[ms] all flags " , test_wait_timeout<ALL_SIGNALS, 1 , 0 >),
386+ Case (" Validate that call of flags_wait_all_for return correctly when thread has all flags already set" , test_wait_all_already_set),
387+ Case (" Validate if flags_wait_all_for return correctly when all flags set" , test_wait_all),
388+ Case (" Validate if flags_wait_all_for accumulate flags and return correctly when all flags set" , test_wait_all_loop),
389+ Case (" Validate if setting same flag twice cause any unwanted behaviour" , test_set_double)
391390};
392391
393392utest::v1::Specification specification (test_setup, cases);
0 commit comments