diff --git a/app/boards/intel_adsp/Kconfig.defconfig b/app/boards/intel_adsp/Kconfig.defconfig index a2ba2db15db6..f12d9e183fba 100644 --- a/app/boards/intel_adsp/Kconfig.defconfig +++ b/app/boards/intel_adsp/Kconfig.defconfig @@ -164,3 +164,9 @@ config LOG_FUNC_NAME_PREFIX_DBG config LOG_TIMESTAMP_64BIT default y + +# Zephyr / debugging +# ---------------------------------------- + +config ZTEST + default SOF_BOOT_TEST_SUPPORTED && SOF_BOOT_TEST_ALLOWED diff --git a/app/boards/intel_adsp_ace15_mtpm.conf b/app/boards/intel_adsp_ace15_mtpm.conf index 5266f38386d3..1e661fbf4592 100644 --- a/app/boards/intel_adsp_ace15_mtpm.conf +++ b/app/boards/intel_adsp_ace15_mtpm.conf @@ -34,6 +34,7 @@ CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS=y CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS=y CONFIG_ZEPHYR_TWB_SCHEDULER=y CONFIG_COLD_STORE_EXECUTE_DRAM=y +CONFIG_SOF_BOOT_TEST_SUPPORTED=n # SOF / loadable modules CONFIG_INTEL_MODULES=y diff --git a/app/debug_overlay.conf b/app/debug_overlay.conf index 650b3c09f7f2..914210d4184d 100644 --- a/app/debug_overlay.conf +++ b/app/debug_overlay.conf @@ -1,9 +1,10 @@ CONFIG_DEBUG=y CONFIG_ASSERT=y -# Disabled until DSP panic #8621 is fixed -# CONFIG_ZTEST=y -# CONFIG_SOF_BOOT_TEST=y +CONFIG_ZTEST_NO_YIELD=n +CONFIG_ZTEST_SUMMARY=n +CONFIG_SOF_BOOT_TEST_ALLOWED=y +CONFIG_TEST_EXTRA_STACK_SIZE=7168 CONFIG_DAI_VERBOSE_GLITCH_WARNINGS=y diff --git a/app/src/main.c b/app/src/main.c index 0f5c1f84fe0e..30f755f6a9c6 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -54,7 +54,6 @@ static int sof_app_main(void) void test_main(void) { sof_app_main(); - k_sleep(K_FOREVER); } #else int main(void) diff --git a/src/include/sof/boot_test.h b/src/include/sof/boot_test.h index 965eec06a6a9..1af6e7f2d8e0 100644 --- a/src/include/sof/boot_test.h +++ b/src/include/sof/boot_test.h @@ -6,8 +6,14 @@ #ifndef __SOF_BOOT_TEST_H__ #define __SOF_BOOT_TEST_H__ +#if !CONFIG_LIBRARY +#include +#else +#define LOG_ERR(...) do {} while (0) +#endif #include +#if CONFIG_SOF_BOOT_TEST #define TEST_RUN_ONCE(fn, ...) do { \ static bool once; \ if (!once) { \ @@ -15,6 +21,9 @@ fn(__VA_ARGS__); \ } \ } while (0) +#else +#define TEST_RUN_ONCE(fn, ...) do {} while (0) +#endif #define TEST_CHECK_RET(ret, testname) do { \ if ((ret) < 0) { \ @@ -25,4 +34,6 @@ } \ } while (0) +void sof_run_boot_tests(void); + #endif diff --git a/src/ipc/ipc4/handler.c b/src/ipc/ipc4/handler.c index 3eea8f623081..fccc6be601f0 100644 --- a/src/ipc/ipc4/handler.c +++ b/src/ipc/ipc4/handler.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -39,11 +38,6 @@ #include #include -#if CONFIG_SOF_BOOT_TEST -/* CONFIG_SOF_BOOT_TEST depends on Zephyr */ -#include -#endif - #include #include #include diff --git a/src/ipc/ipc4/logging.c b/src/ipc/ipc4/logging.c index 2e0f6fd5088e..e582eb342666 100644 --- a/src/ipc/ipc4/logging.c +++ b/src/ipc/ipc4/logging.c @@ -9,6 +9,7 @@ #endif #include +#include #include #include #include @@ -152,6 +153,9 @@ int ipc4_logging_enable_logs(bool first_block, LOG_WRN("Too small aging timer value, limiting to %u\n", mtrace_aging_timer); } + + /* Logs enabled, this is the best place to run boot-tests */ + TEST_RUN_ONCE(sof_run_boot_tests); } else { k_work_flush_delayable(&log_work, &ipc4_log_work_sync); adsp_mtrace_log_init(NULL); diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 854eb211e904..96dbbf009f1b 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -147,9 +147,21 @@ config CROSS_CORE_STREAM can be processed on different cores, however, each stream is processed entirely on single core. +config SOF_BOOT_TEST_ALLOWED + bool "Enable SOF boot-time testing" + help + boot-time testing enabled if supported by the platform + +config SOF_BOOT_TEST_SUPPORTED + bool "Platform supports boot-time testing" + default y + help + boot-time testing supported by the platform + config SOF_BOOT_TEST - bool "enable SOF run-time testing" + bool depends on ZTEST + default y help Run tests during boot. This enables an SOF boot-time self-test. When enabled, the resulting image will run a number of self-tests when the diff --git a/zephyr/boot_test.c b/zephyr/boot_test.c index 4cbbfa597d8b..020072856ecb 100644 --- a/zephyr/boot_test.c +++ b/zephyr/boot_test.c @@ -12,9 +12,7 @@ LOG_MODULE_REGISTER(sof_boot_test, LOG_LEVEL_DBG); ZTEST_SUITE(sof_boot, NULL, NULL, NULL, NULL, NULL); -void sys_run_boot_tests(void) +void sof_run_boot_tests(void) { ztest_run_all(NULL, false, 1, 1); } -SYS_INIT(sys_run_boot_tests, APPLICATION, 99); - diff --git a/zephyr/test/vmh.c b/zephyr/test/vmh.c index 26e044a2d9f0..4a1b7365c4be 100644 --- a/zephyr/test/vmh.c +++ b/zephyr/test/vmh.c @@ -110,7 +110,6 @@ static void test_vmh_multiple_allocs(struct vmh_heap *heap, int num_allocs, { void *ptrs[num_allocs]; uint32_t alloc_size; - bool success; int ret; /* Perform multiple allocations */ @@ -192,7 +191,7 @@ static void test_vmh_alloc_free(bool allocating_continuously) /* Test case for vmh_alloc and vmh_free with and without config */ static void test_heap_creation(void) { - test_vmh_init_and_free_heap(NULL, 0, false, true); + test_vmh_init_and_free_heap(NULL, false, true); /* Try to setup with pre defined heap config */ struct vmh_heap_config config = {0}; @@ -205,7 +204,7 @@ static void test_heap_creation(void) config.block_bundles_table[1].number_of_blocks = 512; - test_vmh_init_and_free_heap(&config, 0, false, true); + test_vmh_init_and_free_heap(&config, false, true); } /* Test case for alloc/free on configured heap */