From beba771031246a6be12d45e50cb203be8944a9cd Mon Sep 17 00:00:00 2001 From: KonstantinKondrashov Date: Fri, 21 Oct 2022 23:48:03 +0800 Subject: [PATCH] efuse: Migrate efuse unit tests from unit-test-app to component test app --- .gitlab/ci/target-test.yml | 14 ++++++-------- components/efuse/.build-test-rules.yml | 7 +++++++ components/efuse/test_apps/CMakeLists.txt | 7 +++++++ components/efuse/test_apps/README.md | 3 +++ .../efuse/{test => test_apps/main}/CMakeLists.txt | 7 +++---- .../main}/one_key_block/esp_efuse_test_table.c | 0 .../main}/one_key_block/esp_efuse_test_table.csv | 0 .../one_key_block/include/esp_efuse_test_table.h | 0 .../main}/one_key_block/test_efuse.c | 1 - .../main}/one_key_block/test_efuse_keys.c | 1 - components/efuse/test_apps/main/test_app_main.c | 14 ++++++++++++++ .../efuse/{test => test_apps/main}/test_efuse.c | 13 +++++++------ .../main}/three_key_blocks/esp_efuse_test_table.c | 0 .../three_key_blocks/esp_efuse_test_table.csv | 0 .../include/esp_efuse_test_table.h | 0 .../main}/three_key_blocks/test_efuse.c | 1 - .../three_key_blocks/test_efuse_coding_scheme.c | 6 +++--- .../with_key_purposes/esp_efuse_test_table.c | 0 .../with_key_purposes/esp_efuse_test_table.csv | 0 .../include/esp_efuse_test_table.h | 0 .../main}/with_key_purposes/test_efuse.c | 1 - .../main}/with_key_purposes/test_efuse_keys.c | 1 - components/efuse/test_apps/pytest_efuse.py | 15 +++++++++++++++ components/efuse/test_apps/sdkconfig.defaults | 11 +++++++++++ tools/unit-test-app/configs/default_2_c2 | 2 +- tools/unit-test-app/configs/default_3_c2 | 2 +- 26 files changed, 78 insertions(+), 28 deletions(-) create mode 100644 components/efuse/.build-test-rules.yml create mode 100644 components/efuse/test_apps/CMakeLists.txt create mode 100644 components/efuse/test_apps/README.md rename components/efuse/{test => test_apps/main}/CMakeLists.txt (64%) rename components/efuse/{test => test_apps/main}/one_key_block/esp_efuse_test_table.c (100%) rename components/efuse/{test => test_apps/main}/one_key_block/esp_efuse_test_table.csv (100%) rename components/efuse/{test => test_apps/main}/one_key_block/include/esp_efuse_test_table.h (100%) rename components/efuse/{test => test_apps/main}/one_key_block/test_efuse.c (99%) rename components/efuse/{test => test_apps/main}/one_key_block/test_efuse_keys.c (99%) create mode 100644 components/efuse/test_apps/main/test_app_main.c rename components/efuse/{test => test_apps/main}/test_efuse.c (98%) rename components/efuse/{test => test_apps/main}/three_key_blocks/esp_efuse_test_table.c (100%) rename components/efuse/{test => test_apps/main}/three_key_blocks/esp_efuse_test_table.csv (100%) rename components/efuse/{test => test_apps/main}/three_key_blocks/include/esp_efuse_test_table.h (100%) rename components/efuse/{test => test_apps/main}/three_key_blocks/test_efuse.c (99%) rename components/efuse/{test => test_apps/main}/three_key_blocks/test_efuse_coding_scheme.c (98%) rename components/efuse/{test => test_apps/main}/with_key_purposes/esp_efuse_test_table.c (100%) rename components/efuse/{test => test_apps/main}/with_key_purposes/esp_efuse_test_table.csv (100%) rename components/efuse/{test => test_apps/main}/with_key_purposes/include/esp_efuse_test_table.h (100%) rename components/efuse/{test => test_apps/main}/with_key_purposes/test_efuse.c (99%) rename components/efuse/{test => test_apps/main}/with_key_purposes/test_efuse_keys.c (99%) create mode 100644 components/efuse/test_apps/pytest_efuse.py create mode 100644 components/efuse/test_apps/sdkconfig.defaults diff --git a/.gitlab/ci/target-test.yml b/.gitlab/ci/target-test.yml index 8075cb7c75..fa36c001c0 100644 --- a/.gitlab/ci/target-test.yml +++ b/.gitlab/ci/target-test.yml @@ -909,7 +909,7 @@ test_app_test_eth: UT_001: extends: .unit_test_esp32_template - parallel: 40 + parallel: 32 tags: - ESP32_IDF - UT_T1_1 @@ -918,7 +918,7 @@ UT_001: UT_002: extends: .unit_test_esp32_template - parallel: 14 + parallel: 12 tags: - ESP32_IDF - UT_T1_1 @@ -926,7 +926,6 @@ UT_002: UT_003: extends: .unit_test_esp32_template - parallel: 2 tags: - ESP32_IDF - UT_T1_SDMODE @@ -1008,7 +1007,7 @@ UT_034: UT_035: extends: .unit_test_esp32s2_template - parallel: 41 + parallel: 32 tags: - ESP32S2_IDF - UT_T1_1 @@ -1096,7 +1095,7 @@ UT_S2_SDSPI: UT_C2: extends: .unit_test_esp32c2_template - parallel: 17 + parallel: 15 tags: - ESP32C2_IDF - UT_T1_1 @@ -1128,7 +1127,7 @@ UT_C2_FLASH: UT_C3: extends: .unit_test_esp32c3_template - parallel: 24 + parallel: 21 tags: - ESP32C3_IDF - UT_T1_1 @@ -1165,7 +1164,7 @@ UT_C3_SDSPI: UT_S3: extends: .unit_test_esp32s3_template - parallel: 22 + parallel: 19 tags: - ESP32S3_IDF - UT_T1_1 @@ -1186,7 +1185,6 @@ UT_S3_SPI_DUAL: UT_S3_FLASH: extends: .unit_test_esp32s3_template - parallel: 2 tags: - ESP32S3_IDF - UT_T1_ESP_FLASH diff --git a/components/efuse/.build-test-rules.yml b/components/efuse/.build-test-rules.yml new file mode 100644 index 0000000000..498c17a761 --- /dev/null +++ b/components/efuse/.build-test-rules.yml @@ -0,0 +1,7 @@ +# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps + +components/efuse/test_apps: + disable_test: + - if: IDF_TARGET in ["esp32s2", "esp32s3"] + temporary: true + reason: eFuse for S2 and S3 is similar to the C3 chip, so we only test for C3. diff --git a/components/efuse/test_apps/CMakeLists.txt b/components/efuse/test_apps/CMakeLists.txt new file mode 100644 index 0000000000..f943c2c062 --- /dev/null +++ b/components/efuse/test_apps/CMakeLists.txt @@ -0,0 +1,7 @@ +#This is the project CMakeLists.txt file for the test subproject +cmake_minimum_required(VERSION 3.16) + +set(COMPONENTS main) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(efuse_test) diff --git a/components/efuse/test_apps/README.md b/components/efuse/test_apps/README.md new file mode 100644 index 0000000000..27995c13b2 --- /dev/null +++ b/components/efuse/test_apps/README.md @@ -0,0 +1,3 @@ +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | + diff --git a/components/efuse/test/CMakeLists.txt b/components/efuse/test_apps/main/CMakeLists.txt similarity index 64% rename from components/efuse/test/CMakeLists.txt rename to components/efuse/test_apps/main/CMakeLists.txt index 8181bbe86d..4aad97d4aa 100644 --- a/components/efuse/test/CMakeLists.txt +++ b/components/efuse/test_apps/main/CMakeLists.txt @@ -13,7 +13,6 @@ endif() set(src_dirs "." "${dir}") idf_component_register(SRC_DIRS "${src_dirs}" - PRIV_INCLUDE_DIRS "." "${dir}/include" "../private_include" "../${target}/private_include" - PRIV_REQUIRES cmock test_utils efuse bootloader_support esp_timer - ) - target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") + PRIV_INCLUDE_DIRS "." "${dir}/include" "../../private_include" "../../${target}/private_include" + PRIV_REQUIRES cmock efuse bootloader_support esp_timer + WHOLE_ARCHIVE) diff --git a/components/efuse/test/one_key_block/esp_efuse_test_table.c b/components/efuse/test_apps/main/one_key_block/esp_efuse_test_table.c similarity index 100% rename from components/efuse/test/one_key_block/esp_efuse_test_table.c rename to components/efuse/test_apps/main/one_key_block/esp_efuse_test_table.c diff --git a/components/efuse/test/one_key_block/esp_efuse_test_table.csv b/components/efuse/test_apps/main/one_key_block/esp_efuse_test_table.csv similarity index 100% rename from components/efuse/test/one_key_block/esp_efuse_test_table.csv rename to components/efuse/test_apps/main/one_key_block/esp_efuse_test_table.csv diff --git a/components/efuse/test/one_key_block/include/esp_efuse_test_table.h b/components/efuse/test_apps/main/one_key_block/include/esp_efuse_test_table.h similarity index 100% rename from components/efuse/test/one_key_block/include/esp_efuse_test_table.h rename to components/efuse/test_apps/main/one_key_block/include/esp_efuse_test_table.h diff --git a/components/efuse/test/one_key_block/test_efuse.c b/components/efuse/test_apps/main/one_key_block/test_efuse.c similarity index 99% rename from components/efuse/test/one_key_block/test_efuse.c rename to components/efuse/test_apps/main/one_key_block/test_efuse.c index da6f30ad57..8b2f3e10c1 100644 --- a/components/efuse/test/one_key_block/test_efuse.c +++ b/components/efuse/test_apps/main/one_key_block/test_efuse.c @@ -19,7 +19,6 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" -#include "test_utils.h" #include "sdkconfig.h" #include "esp_rom_efuse.h" #include "bootloader_common.h" diff --git a/components/efuse/test/one_key_block/test_efuse_keys.c b/components/efuse/test_apps/main/one_key_block/test_efuse_keys.c similarity index 99% rename from components/efuse/test/one_key_block/test_efuse_keys.c rename to components/efuse/test_apps/main/one_key_block/test_efuse_keys.c index 43b29ed5b1..7ef8c4091c 100644 --- a/components/efuse/test/one_key_block/test_efuse_keys.c +++ b/components/efuse/test_apps/main/one_key_block/test_efuse_keys.c @@ -10,7 +10,6 @@ #include #include #include "unity.h" -#include "test_utils.h" #include "esp_log.h" #include "esp_efuse.h" #include "esp_efuse_table.h" diff --git a/components/efuse/test_apps/main/test_app_main.c b/components/efuse/test_apps/main/test_app_main.c new file mode 100644 index 0000000000..3a2a27060e --- /dev/null +++ b/components/efuse/test_apps/main/test_app_main.c @@ -0,0 +1,14 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ +#include "unity.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +void app_main(void) +{ + vTaskPrioritySet(NULL, 5); + unity_run_menu(); +} diff --git a/components/efuse/test/test_efuse.c b/components/efuse/test_apps/main/test_efuse.c similarity index 98% rename from components/efuse/test/test_efuse.c rename to components/efuse/test_apps/main/test_efuse.c index 34465f2840..3b4db06d76 100644 --- a/components/efuse/test/test_efuse.c +++ b/components/efuse/test_apps/main/test_efuse.c @@ -20,7 +20,6 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" -#include "test_utils.h" #include "sdkconfig.h" #include "esp_rom_efuse.h" #include "bootloader_common.h" @@ -29,6 +28,8 @@ #define MAC_FACTORY_HAS_CRC 1 #endif +#define TASK_PRIORITY (5) + __attribute__((unused)) static const char* TAG = "efuse_test"; @@ -707,8 +708,8 @@ TEST_CASE("Batch mode is thread-safe", "[efuse]") sema = xSemaphoreCreateBinary(); printf("\n"); - xTaskCreatePinnedToCore(task1, "task1", 3072, NULL, UNITY_FREERTOS_PRIORITY - 1, NULL, 0); - xTaskCreatePinnedToCore(task2, "task2", 3072, NULL, UNITY_FREERTOS_PRIORITY - 1, NULL, 1); + xTaskCreatePinnedToCore(task1, "task1", 3072, NULL, TASK_PRIORITY - 1, NULL, 0); + xTaskCreatePinnedToCore(task2, "task2", 3072, NULL, TASK_PRIORITY - 1, NULL, 1); vTaskDelay(3000 / portTICK_PERIOD_MS); xSemaphoreTake(sema, portMAX_DELAY); @@ -716,8 +717,8 @@ TEST_CASE("Batch mode is thread-safe", "[efuse]") esp_efuse_utility_erase_virt_blocks(); printf("\n"); - xTaskCreatePinnedToCore(task1, "task1", 3072, NULL, UNITY_FREERTOS_PRIORITY - 1, NULL, 0); - xTaskCreatePinnedToCore(task3, "task3", 3072, NULL, UNITY_FREERTOS_PRIORITY - 1, NULL, 1); + xTaskCreatePinnedToCore(task1, "task1", 3072, NULL, TASK_PRIORITY - 1, NULL, 0); + xTaskCreatePinnedToCore(task3, "task3", 3072, NULL, TASK_PRIORITY - 1, NULL, 1); vTaskDelay(3000 / portTICK_PERIOD_MS); xSemaphoreTake(sema, portMAX_DELAY); @@ -810,7 +811,7 @@ TEST_CASE("Check a case when ESP_ERR_DAMAGED_READING occurs during reading efuse TEST_ESP_OK(esp_efuse_read_field_blob(ESP_EFUSE_MAC_FACTORY, &mac, sizeof(mac) * 8)); ESP_LOGI(TAG, "read MAC address: %02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - xTaskCreatePinnedToCore(reset_task, "reset_task", 3072, NULL, UNITY_FREERTOS_PRIORITY - 1, NULL, 1); + xTaskCreatePinnedToCore(reset_task, "reset_task", 3072, NULL, TASK_PRIORITY - 1, NULL, 1); uint8_t new_mac[6]; for (int i = 0; i < 1000; ++i) { diff --git a/components/efuse/test/three_key_blocks/esp_efuse_test_table.c b/components/efuse/test_apps/main/three_key_blocks/esp_efuse_test_table.c similarity index 100% rename from components/efuse/test/three_key_blocks/esp_efuse_test_table.c rename to components/efuse/test_apps/main/three_key_blocks/esp_efuse_test_table.c diff --git a/components/efuse/test/three_key_blocks/esp_efuse_test_table.csv b/components/efuse/test_apps/main/three_key_blocks/esp_efuse_test_table.csv similarity index 100% rename from components/efuse/test/three_key_blocks/esp_efuse_test_table.csv rename to components/efuse/test_apps/main/three_key_blocks/esp_efuse_test_table.csv diff --git a/components/efuse/test/three_key_blocks/include/esp_efuse_test_table.h b/components/efuse/test_apps/main/three_key_blocks/include/esp_efuse_test_table.h similarity index 100% rename from components/efuse/test/three_key_blocks/include/esp_efuse_test_table.h rename to components/efuse/test_apps/main/three_key_blocks/include/esp_efuse_test_table.h diff --git a/components/efuse/test/three_key_blocks/test_efuse.c b/components/efuse/test_apps/main/three_key_blocks/test_efuse.c similarity index 99% rename from components/efuse/test/three_key_blocks/test_efuse.c rename to components/efuse/test_apps/main/three_key_blocks/test_efuse.c index e9a7b708ec..68a1216397 100644 --- a/components/efuse/test/three_key_blocks/test_efuse.c +++ b/components/efuse/test_apps/main/three_key_blocks/test_efuse.c @@ -19,7 +19,6 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" -#include "test_utils.h" #include "sdkconfig.h" #include "esp_rom_efuse.h" #include "bootloader_common.h" diff --git a/components/efuse/test/three_key_blocks/test_efuse_coding_scheme.c b/components/efuse/test_apps/main/three_key_blocks/test_efuse_coding_scheme.c similarity index 98% rename from components/efuse/test/three_key_blocks/test_efuse_coding_scheme.c rename to components/efuse/test_apps/main/three_key_blocks/test_efuse_coding_scheme.c index 97cb17a437..44d78dc2a6 100644 --- a/components/efuse/test/three_key_blocks/test_efuse_coding_scheme.c +++ b/components/efuse/test_apps/main/three_key_blocks/test_efuse_coding_scheme.c @@ -160,16 +160,16 @@ TEST_CASE("Test Coding Scheme for efuse manager", "[efuse]") esp_efuse_utility_debug_dump_blocks(); printf("Data from encoded\n"); for (int j = 0; j < 8; ++j) { - printf("0x%08x ", encoded[j]); + printf("0x%08lx ", encoded[j]); } printf("\nData from w_data_after_coding\n"); for (int j = 0; j < 8; ++j) { - printf("0x%08x ", w_data_after_coding[j]); + printf("0x%08lx ", w_data_after_coding[j]); } printf("\nData from buf\n"); for (int j = 0; j < 8; ++j) { - printf("0x%08x ", *((uint32_t*)buf + j)); + printf("0x%08lx ", *((uint32_t*)buf + j)); } printf("\n"); #endif diff --git a/components/efuse/test/with_key_purposes/esp_efuse_test_table.c b/components/efuse/test_apps/main/with_key_purposes/esp_efuse_test_table.c similarity index 100% rename from components/efuse/test/with_key_purposes/esp_efuse_test_table.c rename to components/efuse/test_apps/main/with_key_purposes/esp_efuse_test_table.c diff --git a/components/efuse/test/with_key_purposes/esp_efuse_test_table.csv b/components/efuse/test_apps/main/with_key_purposes/esp_efuse_test_table.csv similarity index 100% rename from components/efuse/test/with_key_purposes/esp_efuse_test_table.csv rename to components/efuse/test_apps/main/with_key_purposes/esp_efuse_test_table.csv diff --git a/components/efuse/test/with_key_purposes/include/esp_efuse_test_table.h b/components/efuse/test_apps/main/with_key_purposes/include/esp_efuse_test_table.h similarity index 100% rename from components/efuse/test/with_key_purposes/include/esp_efuse_test_table.h rename to components/efuse/test_apps/main/with_key_purposes/include/esp_efuse_test_table.h diff --git a/components/efuse/test/with_key_purposes/test_efuse.c b/components/efuse/test_apps/main/with_key_purposes/test_efuse.c similarity index 99% rename from components/efuse/test/with_key_purposes/test_efuse.c rename to components/efuse/test_apps/main/with_key_purposes/test_efuse.c index 42f1d8a03f..4217a903c9 100644 --- a/components/efuse/test/with_key_purposes/test_efuse.c +++ b/components/efuse/test_apps/main/with_key_purposes/test_efuse.c @@ -19,7 +19,6 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" -#include "test_utils.h" #include "sdkconfig.h" #include "esp_rom_efuse.h" #include "bootloader_common.h" diff --git a/components/efuse/test/with_key_purposes/test_efuse_keys.c b/components/efuse/test_apps/main/with_key_purposes/test_efuse_keys.c similarity index 99% rename from components/efuse/test/with_key_purposes/test_efuse_keys.c rename to components/efuse/test_apps/main/with_key_purposes/test_efuse_keys.c index b7a4994e1e..f4bdad6431 100644 --- a/components/efuse/test/with_key_purposes/test_efuse_keys.c +++ b/components/efuse/test_apps/main/with_key_purposes/test_efuse_keys.c @@ -10,7 +10,6 @@ #include #include #include "unity.h" -#include "test_utils.h" #include "esp_log.h" #include "esp_efuse.h" #include "esp_efuse_table.h" diff --git a/components/efuse/test_apps/pytest_efuse.py b/components/efuse/test_apps/pytest_efuse.py new file mode 100644 index 0000000000..ef910095dc --- /dev/null +++ b/components/efuse/test_apps/pytest_efuse.py @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 + +import pytest +from pytest_embedded import Dut + + +@pytest.mark.esp32 +@pytest.mark.esp32c2 +@pytest.mark.esp32c3 +@pytest.mark.generic +def test_efuse(dut: Dut) -> None: + dut.expect_exact('Press ENTER to see the list of tests') + dut.write('*') + dut.expect_unity_test_output(timeout=200) diff --git a/components/efuse/test_apps/sdkconfig.defaults b/components/efuse/test_apps/sdkconfig.defaults new file mode 100644 index 0000000000..968dea3828 --- /dev/null +++ b/components/efuse/test_apps/sdkconfig.defaults @@ -0,0 +1,11 @@ +# General options for additional checks +CONFIG_HEAP_POISONING_COMPREHENSIVE=y +CONFIG_COMPILER_WARN_WRITE_STRINGS=y +CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y +CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y +CONFIG_COMPILER_STACK_CHECK_MODE_STRONG=y +CONFIG_COMPILER_STACK_CHECK=y + +CONFIG_ESP_TASK_WDT_INIT=n + +CONFIG_EFUSE_VIRTUAL=y diff --git a/tools/unit-test-app/configs/default_2_c2 b/tools/unit-test-app/configs/default_2_c2 index 74ca32bac7..d022d6ceb9 100644 --- a/tools/unit-test-app/configs/default_2_c2 +++ b/tools/unit-test-app/configs/default_2_c2 @@ -1,3 +1,3 @@ # This config is split between targets since different component needs to be included CONFIG_IDF_TARGET="esp32c2" -TEST_COMPONENTS=app_trace efuse esp_common esp_eth esp_hid esp_netif esp_phy esp_wifi espcoredump hal lwip mdns mqtt newlib nvs_flash partition_table sdmmc +TEST_COMPONENTS=app_trace esp_common esp_eth esp_hid esp_netif esp_phy esp_wifi espcoredump hal lwip mdns mqtt newlib nvs_flash partition_table sdmmc diff --git a/tools/unit-test-app/configs/default_3_c2 b/tools/unit-test-app/configs/default_3_c2 index 6d2a2958e8..ef2946d119 100644 --- a/tools/unit-test-app/configs/default_3_c2 +++ b/tools/unit-test-app/configs/default_3_c2 @@ -1,3 +1,3 @@ # This config is split between targets since different component needs to be included CONFIG_IDF_TARGET="esp32c2" -TEST_EXCLUDE_COMPONENTS=app_trace efuse esp_common esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns mqtt newlib nvs_flash partition_table sdmmc esp_hw_support esp_ipc esp_system esp_timer driver soc spi_flash vfs +TEST_EXCLUDE_COMPONENTS=app_trace esp_common esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns mqtt newlib nvs_flash partition_table sdmmc esp_hw_support esp_ipc esp_system esp_timer driver soc spi_flash vfs