Skip to content

Commit e53ca8e

Browse files
committed
fix(lp_core_test): fixed race-condition in lp core tests
1 parent 19ab395 commit e53ca8e

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

components/ulp/test_apps/lp_core/main/lp_core/test_main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ void handle_commands(lp_core_test_commands_t cmd)
7171
break;
7272

7373
case LP_CORE_NO_COMMAND:
74-
main_cpu_reply = LP_CORE_COMMAND_NOK;
7574
break;
7675

7776
default:
78-
main_cpu_reply = LP_CORE_COMMAND_NOK;
7977
break;
8078
}
8179
}

components/ulp/test_apps/lp_core/main/test_lp_core.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ static void load_and_start_lp_core_firmware(ulp_lp_core_cfg_t* cfg, const uint8_
4747

4848
}
4949

50+
static void clear_test_cmds(void)
51+
{
52+
ulp_main_cpu_command = LP_CORE_NO_COMMAND;
53+
ulp_command_resp = LP_CORE_NO_COMMAND;
54+
}
55+
5056
TEST_CASE("LP core and main CPU are able to exchange data", "[lp_core]")
5157
{
5258
const uint32_t test_data = 0x12345678;
@@ -76,9 +82,7 @@ TEST_CASE("LP core and main CPU are able to exchange data", "[lp_core]")
7682
printf("data out: 0x%" PRIx32 ", expected: 0x%" PRIx32 " \n", ulp_test_data_out, test_data);
7783
TEST_ASSERT(test_data == ulp_test_data_out);
7884

79-
/* Clear test data */
80-
ulp_main_cpu_command = LP_CORE_NO_COMMAND;
81-
ulp_command_resp = LP_CORE_NO_COMMAND;
85+
clear_test_cmds();
8286
}
8387

8488
TEST_CASE("Test LP core delay", "[lp_core]")
@@ -113,9 +117,7 @@ TEST_CASE("Test LP core delay", "[lp_core]")
113117
printf("Waited for %" PRIi64 "us, expected: %" PRIi32 "us\n", diff, delay_period_us);
114118
TEST_ASSERT_INT_WITHIN(delta_us, delay_period_us, diff);
115119

116-
/* Clear test data */
117-
ulp_main_cpu_command = LP_CORE_NO_COMMAND;
118-
ulp_command_resp = LP_CORE_NO_COMMAND;
120+
clear_test_cmds();
119121
}
120122

121123
#define LP_TIMER_TEST_DURATION_S (5)
@@ -210,6 +212,8 @@ static void check_reset_reason_and_sleep_duration(void)
210212
printf("CPU slept for %"PRIi64" ms, expected it to sleep approx %"PRIi64" ms\n", sleep_duration, expected_sleep_duration_ms);
211213
/* Rough estimate, as CPU spends quite some time waking up, but will test if lp core is waking up way too often etc */
212214
TEST_ASSERT_INT_WITHIN_MESSAGE(1000, expected_sleep_duration_ms, sleep_duration, "LP Core did not wake up the expected number of times");
215+
216+
clear_test_cmds();
213217
}
214218

215219
TEST_CASE_MULTIPLE_STAGES("LP Timer can wakeup lp core periodically during deep sleep", "[ulp]",

0 commit comments

Comments
 (0)