Skip to content

Commit 6ddb4aa

Browse files
jerome-pouillercfriedt
authored andcommitted
tests: portability: cmsis: Fix test_event_flags_signalled()
Until now, the main thread preempted thread2 between k_event_post() and k_event_test(). Then main thread consumed the event before it was tested by thread2. This behavior was not correct since the caller can't know the event is in fact consumed (the CMSIS-RTOS specification says osEventFlagsSet() "returns the event flags stored in the event") This behavior is now fixed. So we can fix the test. Signed-off-by: Jérôme Pouiller <[email protected]>
1 parent 505969a commit 6ddb4aa

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

tests/subsys/portability/cmsis_rtos_v2/src/event_flags.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,7 @@ static void thread2(void *arg)
3232
{
3333
int flags = osEventFlagsSet((osEventFlagsId_t)arg, FLAG2);
3434

35-
/* Please note that as soon as the last flag that a thread is waiting
36-
* on is set, the control shifts to that thread and that thread may
37-
* choose to clear the flags as part of its osEventFlagsWait operation.
38-
* In this test case, the main thread is waiting for FLAG1 and FLAG2.
39-
* FLAG1 gets set first and then FLAG2 gets set. As soon as FLAG2 gets
40-
* set, control shifts to the waiting thread where osEventFlagsWait
41-
* clears FLAG1 and FLAG2 internally. When this thread eventually gets
42-
* scheduled we should hence check if FLAG2 is cleared.
43-
*/
44-
zassert_equal(flags & FLAG2, 0, "");
35+
zassert_equal(flags & FLAG2, FLAG2, "");
4536
}
4637

4738
static K_THREAD_STACK_DEFINE(test_stack1, STACKSZ);

0 commit comments

Comments
 (0)