@@ -46,34 +46,34 @@ struct Sync {
46
46
Semaphore &sem_child;
47
47
};
48
48
49
- template <int32_t signals, uint32_t timeout, int32_t test_val>
49
+ template <int32_t signals, uint32_t timeout, uint32_t test_val>
50
50
void run_signal_wait (void )
51
51
{
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 );
54
54
}
55
55
56
- template <int32_t signals, uint32_t timeout, int32_t test_val>
56
+ template <int32_t signals, uint32_t timeout, uint32_t test_val>
57
57
void run_release_signal_wait (Semaphore *sem)
58
58
{
59
59
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 );
62
62
}
63
63
64
- template <int32_t signals, uint32_t timeout, int32_t test_val>
64
+ template <int32_t signals, uint32_t timeout, uint32_t test_val>
65
65
void run_release_wait_signal_wait (Sync *sync)
66
66
{
67
67
sync ->sem_parent .release ();
68
68
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 );
71
71
}
72
72
73
73
template <int32_t signals, int32_t test_val>
74
74
void run_clear (void )
75
75
{
76
- int32_t ret = Thread::signal_clr (signals);
76
+ int32_t ret = ThisThread::flags_clear (signals);
77
77
TEST_ASSERT_EQUAL (test_val, ret);
78
78
}
79
79
@@ -129,7 +129,7 @@ void test_clear_no_signals(void)
129
129
Thread t (osPriorityNormal, TEST_STACK_SIZE);
130
130
t.start (callback (run_double_wait_clear<NO_SIGNALS, NO_SIGNALS, ALL_SIGNALS, ALL_SIGNALS>, &sync ));
131
131
sem_parent.acquire ();
132
- t.signal_set (ALL_SIGNALS);
132
+ t.flags_set (ALL_SIGNALS);
133
133
sem_child.release ();
134
134
t.join ();
135
135
}
@@ -150,7 +150,7 @@ void test_init_state(void)
150
150
/* * Validate all signals set in one shot
151
151
152
152
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
154
154
Then thread B @a signal_clr(NO_SIGNALS) status should be ALL_SIGNALS indicating all signals set correctly
155
155
*/
156
156
void test_set_all (void )
@@ -164,17 +164,17 @@ void test_set_all(void)
164
164
t.start (callback (run_wait_clear<NO_SIGNALS, ALL_SIGNALS>, &sync ));
165
165
166
166
sem_parent.acquire ();
167
- ret = t.signal_set (ALL_SIGNALS);
167
+ ret = t.flags_set (ALL_SIGNALS);
168
168
TEST_ASSERT_EQUAL (ALL_SIGNALS, ret);
169
169
170
170
sem_child.release ();
171
171
t.join ();
172
172
}
173
173
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
175
175
176
176
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
178
178
Then thread B @a signal_clr(NO_SIGNALS) status should be ALL_SIGNALS indicating that thread B signals are unchanged
179
179
180
180
@note Each signal has up to 31 event flags 0x1, 0x2, 0x4, 0x8, ..., 0x40000000
@@ -191,10 +191,10 @@ void test_set_prohibited(void)
191
191
t.start (callback (run_wait_clear<NO_SIGNALS, ALL_SIGNALS>, &sync ));
192
192
193
193
sem_parent.acquire ();
194
- t.signal_set (ALL_SIGNALS);
194
+ t.flags_set (ALL_SIGNALS);
195
195
196
196
#if !MBED_TRAP_ERRORS_ENABLED
197
- ret = t.signal_set (PROHIBITED_SIGNAL);
197
+ ret = t.flags_set (PROHIBITED_SIGNAL);
198
198
TEST_ASSERT_EQUAL (osErrorParameter, ret);
199
199
#endif
200
200
@@ -217,15 +217,15 @@ void test_clear_all(void)
217
217
Thread t (osPriorityNormal, TEST_STACK_SIZE);
218
218
t.start (callback (run_double_wait_clear<ALL_SIGNALS, NO_SIGNALS, ALL_SIGNALS, NO_SIGNALS>, &sync ));
219
219
sem_parent.acquire ();
220
- t.signal_set (ALL_SIGNALS);
220
+ t.flags_set (ALL_SIGNALS);
221
221
sem_child.release ();
222
222
t.join ();
223
223
}
224
224
225
225
/* * Validate all signals set one by one in loop
226
226
227
227
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
229
229
*/
230
230
void test_set_all_loop (void )
231
231
{
@@ -241,7 +241,7 @@ void test_set_all_loop(void)
241
241
for (int i = 0 ; i <= MAX_FLAG_POS; i++) {
242
242
int32_t signal = 1 << i;
243
243
244
- ret = t.signal_set (signal );
244
+ ret = t.flags_set (signal );
245
245
signals |= signal ;
246
246
TEST_ASSERT_EQUAL (signals, ret);
247
247
sem_child.release ();
@@ -253,11 +253,10 @@ void test_set_all_loop(void)
253
253
/* * Validate signal_wait return status if timeout specified
254
254
255
255
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
259
258
*/
260
- template <int32_t signals, uint32_t timeout, int32_t status>
259
+ template <int32_t signals, uint32_t timeout, uint32_t status>
261
260
void test_wait_timeout (void )
262
261
{
263
262
Thread t (osPriorityNormal, TEST_STACK_SIZE);
@@ -269,7 +268,7 @@ void test_wait_timeout(void)
269
268
270
269
Given two threads A & B are started, B with all signals already set
271
270
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
273
272
*/
274
273
void test_wait_all_already_set (void )
275
274
{
@@ -278,90 +277,90 @@ void test_wait_all_already_set(void)
278
277
Sync sync (sem_parent, sem_child);
279
278
280
279
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 ));
282
281
283
282
sem_parent.acquire ();
284
283
TEST_ASSERT_EQUAL (Thread::WaitingSemaphore, t.get_state ());
285
- t.signal_set (ALL_SIGNALS);
284
+ t.flags_set (ALL_SIGNALS);
286
285
sem_child.release ();
287
286
t.join ();
288
287
}
289
288
290
289
/* * Validate if signal_wait return correctly when all signals set
291
290
292
291
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
295
294
*/
296
295
void test_wait_all (void )
297
296
{
298
297
Semaphore sem (0 , 1 );
299
298
300
299
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));
302
301
303
302
sem.acquire ();
304
303
TEST_ASSERT_EQUAL (Thread::WaitingThreadFlag, t.get_state ());
305
304
306
- t.signal_set (ALL_SIGNALS);
305
+ t.flags_set (ALL_SIGNALS);
307
306
t.join ();
308
307
}
309
308
310
309
/* * Validate if signal_wait accumulate signals and return correctly when all signals set
311
310
312
311
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
315
314
*/
316
315
void test_wait_all_loop (void )
317
316
{
318
317
int32_t ret;
319
318
Semaphore sem (0 , 1 );
320
319
321
320
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));
323
322
324
323
sem.acquire ();
325
324
TEST_ASSERT_EQUAL (Thread::WaitingThreadFlag, t.get_state ());
326
325
327
326
for (int i = 0 ; i < MAX_FLAG_POS; i++) {
328
327
int32_t signal = 1 << i;
329
- ret = t.signal_set (signal );
328
+ ret = t.flags_set (signal );
330
329
}
331
- ret = t.signal_set (1 << MAX_FLAG_POS);
330
+ ret = t.flags_set (1 << MAX_FLAG_POS);
332
331
TEST_ASSERT_EQUAL (NO_SIGNALS, ret);
333
332
t.join ();
334
333
}
335
334
336
335
/* * Validate if setting same signal twice cause any unwanted behaviour
337
336
338
337
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
342
341
*/
343
342
void test_set_double (void )
344
343
{
345
344
int32_t ret;
346
345
Semaphore sem (0 , 1 );
347
346
348
347
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));
350
349
351
350
sem.acquire ();
352
351
TEST_ASSERT_EQUAL (Thread::WaitingThreadFlag, t.get_state ());
353
352
354
- ret = t.signal_set (SIGNAL1);
353
+ ret = t.flags_set (SIGNAL1);
355
354
TEST_ASSERT_EQUAL (SIGNAL1, ret);
356
355
357
- ret = t.signal_set (SIGNAL2);
356
+ ret = t.flags_set (SIGNAL2);
358
357
TEST_ASSERT_EQUAL (SIGNAL1 | SIGNAL2, ret);
359
358
360
- ret = t.signal_set (SIGNAL2);
359
+ ret = t.flags_set (SIGNAL2);
361
360
TEST_ASSERT_EQUAL (SIGNAL1 | SIGNAL2, ret);
362
361
TEST_ASSERT_EQUAL (Thread::WaitingThreadFlag, t.get_state ());
363
362
364
- ret = t.signal_set (SIGNAL3);
363
+ ret = t.flags_set (SIGNAL3);
365
364
TEST_ASSERT_EQUAL (NO_SIGNALS, ret);
366
365
t.join ();
367
366
}
@@ -374,20 +373,20 @@ utest::v1::status_t test_setup(const size_t number_of_cases)
374
373
}
375
374
376
375
Case 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)
391
390
};
392
391
393
392
utest::v1::Specification specification (test_setup, cases);
0 commit comments