Skip to content

Commit 4730a9b

Browse files
vantinashif
authored andcommitted
tests: net: trickle: use separate semaphore for second trickle timer
A second semaphore is used for the second trickle timer, so that if the first timer expires twice before the second one, the test would still wait before proceeding to check on cb_2_called. Fixes #18598. Backported to v1.14 in order to fix PR #24300 Fixes #24300 Signed-off-by: Vincent Wan <[email protected]>
1 parent 0f852f0 commit 4730a9b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/net/trickle/src/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_TRICKLE_LOG_LEVEL);
3737
static int token1 = 1, token2 = 2;
3838

3939
static struct k_sem wait;
40+
static struct k_sem wait2;
4041
static bool cb_1_called;
4142
static bool cb_2_called;
4243

@@ -76,7 +77,7 @@ static void cb_2(struct net_trickle *trickle, bool do_suppress,
7677
{
7778
TC_PRINT("Trickle 2 %p callback called\n", trickle);
7879

79-
k_sem_give(&wait);
80+
k_sem_give(&wait2);
8081

8182
cb_2_called = true;
8283
}
@@ -166,7 +167,7 @@ static void test_trickle_1_wait_long(void)
166167

167168
static void test_trickle_2_wait(void)
168169
{
169-
k_sem_take(&wait, WAIT_TIME);
170+
k_sem_take(&wait2, WAIT_TIME);
170171

171172
zassert_true(cb_2_called, "Trickle 2 no timeout");
172173

@@ -194,6 +195,7 @@ static void test_trickle_1_update(void)
194195
static void test_init(void)
195196
{
196197
k_sem_init(&wait, 0, UINT_MAX);
198+
k_sem_init(&wait2, 0, UINT_MAX);
197199
}
198200

199201
/*test case main entry*/

0 commit comments

Comments
 (0)