From e9e7ad388da7122a6193845be4eff48c19bbe618 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Mon, 5 Sep 2022 18:04:31 +0000 Subject: [PATCH] tests: drivers: can: add a delay for the shell backend to initialize The CAN shell test is flaky on some qemu platform (qemu_riscv64_smp in particular), where the first test command occasionally fails as it tries to run with the backend not initialized. The tests for subsys/shell/shell/src/main.c have a setup delay, copying it to the CAN shell test seems to make it work reliably. Tested with: ./scripts/twister -v -n -M -p qemu_riscv64_smp -T tests/drivers/can/shell Signed-off-by: Fabio Baltieri --- tests/drivers/can/shell/src/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/drivers/can/shell/src/main.c b/tests/drivers/can/shell/src/main.c index 69ec593d926..8cf67d30123 100644 --- a/tests/drivers/can/shell/src/main.c +++ b/tests/drivers/can/shell/src/main.c @@ -578,4 +578,11 @@ static void can_shell_before(void *fixture) memset(&frame_capture, 0, sizeof(frame_capture)); } -ZTEST_SUITE(can_shell, NULL, NULL, can_shell_before, NULL, NULL); +static void *can_shell_setup(void) +{ + /* Let the shell backend initialize. */ + k_msleep(20); + return NULL; +} + +ZTEST_SUITE(can_shell, NULL, can_shell_setup, can_shell_before, NULL, NULL);