Просмотр исходного кода

efuse: Migrate efuse unit tests from unit-test-app to component test app

KonstantinKondrashov 3 лет назад
Родитель
Сommit
beba771031
26 измененных файлов с 78 добавлено и 28 удалено
  1. 6 8
      .gitlab/ci/target-test.yml
  2. 7 0
      components/efuse/.build-test-rules.yml
  3. 7 0
      components/efuse/test_apps/CMakeLists.txt
  4. 3 0
      components/efuse/test_apps/README.md
  5. 3 4
      components/efuse/test_apps/main/CMakeLists.txt
  6. 0 0
      components/efuse/test_apps/main/one_key_block/esp_efuse_test_table.c
  7. 0 0
      components/efuse/test_apps/main/one_key_block/esp_efuse_test_table.csv
  8. 0 0
      components/efuse/test_apps/main/one_key_block/include/esp_efuse_test_table.h
  9. 0 1
      components/efuse/test_apps/main/one_key_block/test_efuse.c
  10. 0 1
      components/efuse/test_apps/main/one_key_block/test_efuse_keys.c
  11. 14 0
      components/efuse/test_apps/main/test_app_main.c
  12. 7 6
      components/efuse/test_apps/main/test_efuse.c
  13. 0 0
      components/efuse/test_apps/main/three_key_blocks/esp_efuse_test_table.c
  14. 0 0
      components/efuse/test_apps/main/three_key_blocks/esp_efuse_test_table.csv
  15. 0 0
      components/efuse/test_apps/main/three_key_blocks/include/esp_efuse_test_table.h
  16. 0 1
      components/efuse/test_apps/main/three_key_blocks/test_efuse.c
  17. 3 3
      components/efuse/test_apps/main/three_key_blocks/test_efuse_coding_scheme.c
  18. 0 0
      components/efuse/test_apps/main/with_key_purposes/esp_efuse_test_table.c
  19. 0 0
      components/efuse/test_apps/main/with_key_purposes/esp_efuse_test_table.csv
  20. 0 0
      components/efuse/test_apps/main/with_key_purposes/include/esp_efuse_test_table.h
  21. 0 1
      components/efuse/test_apps/main/with_key_purposes/test_efuse.c
  22. 0 1
      components/efuse/test_apps/main/with_key_purposes/test_efuse_keys.c
  23. 15 0
      components/efuse/test_apps/pytest_efuse.py
  24. 11 0
      components/efuse/test_apps/sdkconfig.defaults
  25. 1 1
      tools/unit-test-app/configs/default_2_c2
  26. 1 1
      tools/unit-test-app/configs/default_3_c2

+ 6 - 8
.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

+ 7 - 0
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.

+ 7 - 0
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)

+ 3 - 0
components/efuse/test_apps/README.md

@@ -0,0 +1,3 @@
+| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
+| ----------------- | ----- | -------- | -------- | -------- | -------- |
+

+ 3 - 4
components/efuse/test/CMakeLists.txt → 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)

+ 0 - 0
components/efuse/test/one_key_block/esp_efuse_test_table.c → components/efuse/test_apps/main/one_key_block/esp_efuse_test_table.c


+ 0 - 0
components/efuse/test/one_key_block/esp_efuse_test_table.csv → components/efuse/test_apps/main/one_key_block/esp_efuse_test_table.csv


+ 0 - 0
components/efuse/test/one_key_block/include/esp_efuse_test_table.h → components/efuse/test_apps/main/one_key_block/include/esp_efuse_test_table.h


+ 0 - 1
components/efuse/test/one_key_block/test_efuse.c → 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"

+ 0 - 1
components/efuse/test/one_key_block/test_efuse_keys.c → components/efuse/test_apps/main/one_key_block/test_efuse_keys.c

@@ -10,7 +10,6 @@
 #include <stdio.h>
 #include <string.h>
 #include "unity.h"
-#include "test_utils.h"
 #include "esp_log.h"
 #include "esp_efuse.h"
 #include "esp_efuse_table.h"

+ 14 - 0
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();
+}

+ 7 - 6
components/efuse/test/test_efuse.c → 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) {

+ 0 - 0
components/efuse/test/three_key_blocks/esp_efuse_test_table.c → components/efuse/test_apps/main/three_key_blocks/esp_efuse_test_table.c


+ 0 - 0
components/efuse/test/three_key_blocks/esp_efuse_test_table.csv → components/efuse/test_apps/main/three_key_blocks/esp_efuse_test_table.csv


+ 0 - 0
components/efuse/test/three_key_blocks/include/esp_efuse_test_table.h → components/efuse/test_apps/main/three_key_blocks/include/esp_efuse_test_table.h


+ 0 - 1
components/efuse/test/three_key_blocks/test_efuse.c → 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"

+ 3 - 3
components/efuse/test/three_key_blocks/test_efuse_coding_scheme.c → 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

+ 0 - 0
components/efuse/test/with_key_purposes/esp_efuse_test_table.c → components/efuse/test_apps/main/with_key_purposes/esp_efuse_test_table.c


+ 0 - 0
components/efuse/test/with_key_purposes/esp_efuse_test_table.csv → components/efuse/test_apps/main/with_key_purposes/esp_efuse_test_table.csv


+ 0 - 0
components/efuse/test/with_key_purposes/include/esp_efuse_test_table.h → components/efuse/test_apps/main/with_key_purposes/include/esp_efuse_test_table.h


+ 0 - 1
components/efuse/test/with_key_purposes/test_efuse.c → 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"

+ 0 - 1
components/efuse/test/with_key_purposes/test_efuse_keys.c → components/efuse/test_apps/main/with_key_purposes/test_efuse_keys.c

@@ -10,7 +10,6 @@
 #include <stdio.h>
 #include <string.h>
 #include "unity.h"
-#include "test_utils.h"
 #include "esp_log.h"
 #include "esp_efuse.h"
 #include "esp_efuse_table.h"

+ 15 - 0
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)

+ 11 - 0
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

+ 1 - 1
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

+ 1 - 1
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