Skip to content

Commit

Permalink
Merge branch 'feature/efuse_migrate_from_ut_app_to_test_app' into 'ma…
Browse files Browse the repository at this point in the history
…ster'

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

Closes IDF-5570

See merge request espressif/esp-idf!20756
  • Loading branch information
KonstantinKondrashov committed Oct 26, 2022
2 parents 8dd900d + beba771 commit 554f3bd
Show file tree
Hide file tree
Showing 26 changed files with 78 additions and 28 deletions.
14 changes: 6 additions & 8 deletions .gitlab/ci/target-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -918,15 +918,14 @@ UT_001:

UT_002:
extends: .unit_test_esp32_template
parallel: 14
parallel: 12
tags:
- ESP32_IDF
- UT_T1_1
- psram

UT_003:
extends: .unit_test_esp32_template
parallel: 2
tags:
- ESP32_IDF
- UT_T1_SDMODE
Expand Down Expand Up @@ -1008,7 +1007,7 @@ UT_034:

UT_035:
extends: .unit_test_esp32s2_template
parallel: 41
parallel: 32
tags:
- ESP32S2_IDF
- UT_T1_1
Expand Down Expand Up @@ -1096,7 +1095,7 @@ UT_S2_SDSPI:

UT_C2:
extends: .unit_test_esp32c2_template
parallel: 17
parallel: 15
tags:
- ESP32C2_IDF
- UT_T1_1
Expand Down Expand Up @@ -1128,7 +1127,7 @@ UT_C2_FLASH:

UT_C3:
extends: .unit_test_esp32c3_template
parallel: 24
parallel: 21
tags:
- ESP32C3_IDF
- UT_T1_1
Expand Down Expand Up @@ -1165,7 +1164,7 @@ UT_C3_SDSPI:

UT_S3:
extends: .unit_test_esp32s3_template
parallel: 22
parallel: 19
tags:
- ESP32S3_IDF
- UT_T1_1
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions components/efuse/.build-test-rules.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 7 additions & 0 deletions components/efuse/test_apps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions components/efuse/test_apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- |

Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 14 additions & 0 deletions components/efuse/test_apps/main/test_app_main.c
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -29,6 +28,8 @@
#define MAC_FACTORY_HAS_CRC 1
#endif

#define TASK_PRIORITY (5)

__attribute__((unused)) static const char* TAG = "efuse_test";


Expand Down Expand Up @@ -707,17 +708,17 @@ 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);

esp_efuse_utility_reset();
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);

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 15 additions & 0 deletions components/efuse/test_apps/pytest_efuse.py
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions components/efuse/test_apps/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_2_c2
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_3_c2
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 554f3bd

Please sign in to comment.