From a3b0201bf0b7cda9850a67cb311d16a72881ee60 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 6 Nov 2026 13:35:04 +0200 Subject: [PATCH] zephyr: test: userspace: do not run standalone suites twice The standalone userspace test suites run themselves from a SYS_INIT hook with ztest_run_test_suite(). Since sof_run_boot_tests() is also called from test_main() on CONFIG_SOF_BOOT_TEST_STANDALONE builds, its ztest_run_all() call runs every suite a second time. Not all suites can be rerun. On PTL the second run of the SSP DAI test finds HDA link DMA state left over from the first run, fails its assertion in the user thread and halts the firmware. Add a ZTEST_SUITE() predicate that always returns false and use it for the self-running suites. ztest_run_test_suite() does not check the predicate, but ztest_run_all() does, so each suite runs once. Signed-off-by: Kai Vehmanen --- src/include/sof/boot_test.h | 12 ++++++++++++ zephyr/test/userspace/test_intel_hda_dma.c | 2 +- zephyr/test/userspace/test_intel_ssp_dai.c | 2 +- zephyr/test/userspace/test_ll_task.c | 2 +- zephyr/test/userspace/test_mailbox.c | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/include/sof/boot_test.h b/src/include/sof/boot_test.h index dfa8671ee55f..fd4fd3df03bd 100644 --- a/src/include/sof/boot_test.h +++ b/src/include/sof/boot_test.h @@ -38,6 +38,18 @@ struct k_thread; void sof_run_boot_tests(void); +/** + * ZTEST_SUITE() predicate for standalone test suites that run themselves + * from a SYS_INIT hook with ztest_run_test_suite(). That call does not + * check the predicate, but ztest_run_all() in sof_run_boot_tests() does, + * so the suite is not run a second time. + */ +static inline bool sof_boot_test_standalone_predicate(const void *state) +{ + (void)state; + return false; +} + /** * Mark a boot-test thread as expected to trigger a fatal error. * diff --git a/zephyr/test/userspace/test_intel_hda_dma.c b/zephyr/test/userspace/test_intel_hda_dma.c index 064cb2b115c0..ac434ce2e9ab 100644 --- a/zephyr/test/userspace/test_intel_hda_dma.c +++ b/zephyr/test/userspace/test_intel_hda_dma.c @@ -280,7 +280,7 @@ ZTEST(userspace_intel_hda_dma, dma_mem_to_host) ztest_test_pass(); } -ZTEST_SUITE(userspace_intel_hda_dma, NULL, NULL, NULL, NULL, NULL); +ZTEST_SUITE(userspace_intel_hda_dma, sof_boot_test_standalone_predicate, NULL, NULL, NULL, NULL); /** * SOF main has booted up and IPC handling is stopped. diff --git a/zephyr/test/userspace/test_intel_ssp_dai.c b/zephyr/test/userspace/test_intel_ssp_dai.c index 6c700c3839bb..fc9d2b4bd356 100644 --- a/zephyr/test/userspace/test_intel_ssp_dai.c +++ b/zephyr/test/userspace/test_intel_ssp_dai.c @@ -333,7 +333,7 @@ ZTEST(userspace_intel_dai_ssp, dai_ssp_loopback_setup) ztest_test_pass(); } -ZTEST_SUITE(userspace_intel_dai_ssp, NULL, NULL, NULL, NULL, NULL); +ZTEST_SUITE(userspace_intel_dai_ssp, sof_boot_test_standalone_predicate, NULL, NULL, NULL, NULL); /** * SOF main has booted up and IPC handling is stopped. diff --git a/zephyr/test/userspace/test_ll_task.c b/zephyr/test/userspace/test_ll_task.c index f6a63b7194bd..2599ce0ec859 100644 --- a/zephyr/test/userspace/test_ll_task.c +++ b/zephyr/test/userspace/test_ll_task.c @@ -130,7 +130,7 @@ ZTEST(userspace_ll, pipeline_check) pipeline_check(); } -ZTEST_SUITE(userspace_ll, NULL, NULL, NULL, NULL, NULL); +ZTEST_SUITE(userspace_ll, sof_boot_test_standalone_predicate, NULL, NULL, NULL, NULL); /** * SOF main has booted up and IPC handling is stopped. diff --git a/zephyr/test/userspace/test_mailbox.c b/zephyr/test/userspace/test_mailbox.c index 766dababb553..64ef3075014f 100644 --- a/zephyr/test/userspace/test_mailbox.c +++ b/zephyr/test/userspace/test_mailbox.c @@ -88,7 +88,7 @@ ZTEST(userspace_mailbox, mailbox_test) ztest_test_pass(); } -ZTEST_SUITE(userspace_mailbox, NULL, NULL, NULL, NULL, NULL); +ZTEST_SUITE(userspace_mailbox, sof_boot_test_standalone_predicate, NULL, NULL, NULL, NULL); /** * SOF main has booted up and IPC handling is stopped.