Skip to content

Commit 9aa0d0f

Browse files
nordicjmcarlescufi
authored andcommitted
tests: mgmt: mcumgr: cb_notifications: Fix SMP sync issue
Fixes an issue with a test whereby the reponse on the dummy device can be fully send and processed prior to a callback being ran which updates a variable, add a delay in the test to wait for the sync to finish. Signed-off-by: Jamie McCrae <[email protected]>
1 parent a18761e commit 9aa0d0f

File tree

1 file changed

+14
-0
lines changed
  • tests/subsys/mgmt/mcumgr/cb_notifications/src

1 file changed

+14
-0
lines changed

tests/subsys/mgmt/mcumgr/cb_notifications/src/main.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ static void destroy_callbacks(void *p)
8383
mgmt_callback_unregister(&mgmt_event_callback);
8484
}
8585

86+
static inline void wait_for_sync(void)
87+
{
88+
#ifdef CONFIG_SMP
89+
/* For SMP systems, it is possible that a dummy response is fully received and processed
90+
* prior to the callback code being executed, therefore implement a dummy wait to wait
91+
* for callback synchronisation to take place.
92+
*/
93+
k_sleep(K_MSEC(1));
94+
#endif
95+
}
96+
8697
ZTEST(callback_disabled, test_notifications_disabled)
8798
{
8899
uint8_t buffer[ZCBOR_BUFFER_SIZE];
@@ -122,6 +133,7 @@ ZTEST(callback_disabled, test_notifications_disabled)
122133
smp_dummy_disable();
123134

124135
/* Check events */
136+
wait_for_sync();
125137
zassert_false(cmd_recv_got, "Did not expect received command callback\n");
126138
zassert_false(cmd_status_got, "Did not expect IMG status callback\n");
127139
zassert_false(cmd_done_got, "Did not expect done command callback\n");
@@ -167,6 +179,7 @@ ZTEST(callback_enabled, test_notifications_enabled)
167179
smp_dummy_disable();
168180

169181
/* Check events */
182+
wait_for_sync();
170183
zassert_true(cmd_recv_got, "Expected received command callback\n");
171184
zassert_false(cmd_status_got, "Did not expect IMG status callback\n");
172185
zassert_true(cmd_done_got, "Expected done command callback\n");
@@ -212,6 +225,7 @@ ZTEST(callback_disabled_verify, test_notifications_disabled_verify)
212225
smp_dummy_disable();
213226

214227
/* Check events */
228+
wait_for_sync();
215229
zassert_false(cmd_recv_got, "Did not expect received command callback\n");
216230
zassert_false(cmd_status_got, "Did not expect IMG status callback\n");
217231
zassert_false(cmd_done_got, "Did not expect done command callback\n");

0 commit comments

Comments
 (0)