From 8ae7fd7bd97cf839e4f6c4c3b164031ee6ca2918 Mon Sep 17 00:00:00 2001 From: Enjia Mai Date: Tue, 23 Aug 2022 18:21:06 +0800 Subject: [PATCH] tests: board: esp32: move the cache_coex test to new ztest API Migrate the testsuite tests/boards/espressif_esp32/cache_coex/ to the new ztest API. Signed-off-by: Enjia Mai --- .../espressif_esp32/cache_coex/prj.conf | 1 + .../cache_coex/src/cache_coex.c | 26 ++++++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/tests/boards/espressif_esp32/cache_coex/prj.conf b/tests/boards/espressif_esp32/cache_coex/prj.conf index 730428729f..c0b89c2964 100644 --- a/tests/boards/espressif_esp32/cache_coex/prj.conf +++ b/tests/boards/espressif_esp32/cache_coex/prj.conf @@ -6,3 +6,4 @@ CONFIG_ESP_HEAP_SEARCH_ALL_REGIONS=n CONFIG_FLASH=y CONFIG_ENTROPY_GENERATOR=y CONFIG_ZTEST=y +CONFIG_ZTEST_NEW_API=y diff --git a/tests/boards/espressif_esp32/cache_coex/src/cache_coex.c b/tests/boards/espressif_esp32/cache_coex/src/cache_coex.c index 8258026697..68ec2b658a 100644 --- a/tests/boards/espressif_esp32/cache_coex/src/cache_coex.c +++ b/tests/boards/espressif_esp32/cache_coex/src/cache_coex.c @@ -179,7 +179,7 @@ static bool check_psram(int value) return true; } -void psram_test(void) +static void psram_test(void) { uint32_t sleep_ms = 10; int rand_val; @@ -199,7 +199,7 @@ void psram_test(void) } } -void psram_init(void) +static void psram_init(void) { mem = k_malloc(SPIRAM_ALLOC_SIZE); if (!mem) { @@ -216,7 +216,7 @@ void psram_init(void) psram_test(); } -void flash_test(void) +static void flash_test(void) { uint32_t sleep_ms = 15; @@ -239,7 +239,7 @@ void flash_test(void) } } -void flash_init(void) +static void flash_init(void) { if (!device_is_ready(flash_dev)) { TC_ERROR("flash controller not ready\n"); @@ -247,36 +247,32 @@ void flash_init(void) flash_test(); } -void test_using_spiram(void) +ZTEST(cache_coex, test_using_spiram) { zassert_equal(true, coex_result.using_ext_ram, "external RAM is not being used"); } -void test_flash_integrity(void) +ZTEST(cache_coex, test_flash_integrity) { zassert_equal(FLASH_READBACK_LEN, coex_result.flash_cnt, "flash integrity test failed"); } -void test_ram_integrity(void) +ZTEST(cache_coex, test_ram_integrity) { zassert_equal(true, coex_result.psram_ok, "SPIRAM integrity test failed"); } -void test_main(void) +void *cache_coex_setup(void) { while (unfinished_tasks) { k_usleep(1); } - ztest_test_suite(cache_coex_test, - ztest_unit_test(test_using_spiram), - ztest_unit_test(test_flash_integrity), - ztest_unit_test(test_ram_integrity) - ); - - ztest_run_test_suite(cache_coex_test); + return NULL; } K_THREAD_DEFINE(psram_id, STACKSIZE, psram_init, NULL, NULL, NULL, PRIORITY, 0, 0); K_THREAD_DEFINE(flash_id, STACKSIZE, flash_init, NULL, NULL, NULL, PRIORITY, 0, 0); K_THREAD_DEFINE(buffer_id, STACKSIZE, buffer_fill, NULL, NULL, NULL, PRIORITY, 0, 0); + +ZTEST_SUITE(cache_coex, NULL, cache_coex_setup, NULL, NULL, NULL);