diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5bf113b94..6b49ee1c6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,7 +26,7 @@ variables: # If the "recursive" strategy is used we have a problem with using relative URLs for sub-submodules. GIT_SUBMODULE_STRATEGY: normal - UNIT_TEST_BUILD_SYSTEM: make + UNIT_TEST_BUILD_SYSTEM: cmake # IDF environment IDF_PATH: "$CI_PROJECT_DIR" diff --git a/tools/ci/config/assign-test.yml b/tools/ci/config/assign-test.yml index 92dc8cad2..40826ef7f 100644 --- a/tools/ci/config/assign-test.yml +++ b/tools/ci/config/assign-test.yml @@ -13,6 +13,7 @@ assign_test: variables: TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw" EXAMPLE_CONFIG_OUTPUT_PATH: "$CI_PROJECT_DIR/examples/test_configs" + UNIT_TEST_CASE_FILE: "${CI_PROJECT_DIR}/components/idf_test/unit_test/TestCaseAll.yml" artifacts: paths: - components/idf_test/*/CIConfigs @@ -29,7 +30,7 @@ assign_test: # assign example tests - python $TEST_FW_PATH/CIAssignExampleTest.py $IDF_PATH/examples $CI_TARGET_TEST_CONFIG_FILE $EXAMPLE_CONFIG_OUTPUT_PATH # assign unit test cases - - python $TEST_FW_PATH/CIAssignUnitTest.py $IDF_PATH/components/idf_test/unit_test/TestCaseAll.yml $CI_TARGET_TEST_CONFIG_FILE $IDF_PATH/components/idf_test/unit_test/CIConfigs + - python $TEST_FW_PATH/CIAssignUnitTest.py $UNIT_TEST_CASE_FILE $CI_TARGET_TEST_CONFIG_FILE $IDF_PATH/components/idf_test/unit_test/CIConfigs # clone test script to assign tests - git clone $TEST_SCRIPT_REPOSITORY - python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script diff --git a/tools/ci/config/build.yml b/tools/ci/config/build.yml index 64cc1846b..50cf87e5d 100644 --- a/tools/ci/config/build.yml +++ b/tools/ci/config/build.yml @@ -91,6 +91,7 @@ build_esp_idf_tests_make: script: - export EXTRA_CFLAGS=${PEDANTIC_CFLAGS} - export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS} + - export IDF_TARGET=esp32 - cd $CI_PROJECT_DIR/tools/unit-test-app - MAKEFLAGS= make help # make sure kconfig tools are built in single process - make ut-clean-all-configs diff --git a/tools/ci/config/target-test.yml b/tools/ci/config/target-test.yml index 6aa25316e..368f207ac 100644 --- a/tools/ci/config/target-test.yml +++ b/tools/ci/config/target-test.yml @@ -3,8 +3,8 @@ # we need to convert to pattern "job_name_index.yml" .define_config_file_name: &define_config_file_name | JOB_NAME_PREFIX=$(echo ${CI_JOB_NAME} | awk '{print $1}') - JOG_FULL_NAME="${JOB_NAME_PREFIX}_${CI_NODE_INDEX}" - CONFIG_FILE="${CONFIG_FILE_PATH}/${JOG_FULL_NAME}.yml" + JOB_FULL_NAME="${JOB_NAME_PREFIX}_${CI_NODE_INDEX}" + CONFIG_FILE="${CONFIG_FILE_PATH}/${JOB_FULL_NAME}.yml" .example_test_template: stage: target_test @@ -113,7 +113,7 @@ - python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script - cd auto_test_script # run test - - python CIRunner.py -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH + - python CIRunner.py -l "$LOG_PATH/$JOB_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH test_weekend_mqtt: extends: .example_test_template @@ -412,6 +412,48 @@ UT_030: - ESP32_IDF - UT_T1_1 +UT_031: + extends: .unit_test_template + parallel: 34 + tags: + - 7.2.2 + - UT_T1_1 + +UT_032: + extends: .unit_test_template + parallel: 3 + tags: + - 7.2.2 + - UT_T2_1 + +UT_033: + extends: .unit_test_template + parallel: 4 + tags: + - 7.2.2 + - Example_SPI_Multi_device + +UT_034: + extends: .unit_test_template + parallel: 4 + tags: + - 7.2.2 + - UT_T1_RMT + +UT_035: + extends: .unit_test_template + parallel: 4 + tags: + - 7.2.2 + - UT_T2_I2C + +UT_036: + extends: .unit_test_template + parallel: 4 + tags: + - 7.2.2 + - UT_T2_RS485 + nvs_compatible_test: extends: .test_template artifacts: @@ -437,7 +479,7 @@ nvs_compatible_test: # prepare nvs bins - ./Tools/prepare_nvs_bin.sh # run test - - python CIRunner.py -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH + - python CIRunner.py -l "$LOG_PATH/$JOB_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH IT_001: extends: .test_template diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index bcc257b3d..6c259a10d 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -79,6 +79,7 @@ tools/test_check_kconfigs.py tools/test_idf_monitor/run_test_idf_monitor.py tools/test_idf_size/test.sh tools/test_idf_tools/test_idf_tools.py +tools/unit-test-app/tools/get_available_configs.sh tools/unit-test-app/unit_test.py tools/windows/eclipse_make.sh tools/windows/tool_setup/build_installer.sh diff --git a/tools/unit-test-app/Makefile b/tools/unit-test-app/Makefile index 006bf9753..5aef4f953 100644 --- a/tools/unit-test-app/Makefile +++ b/tools/unit-test-app/Makefile @@ -15,7 +15,7 @@ all: # Each file in configs/ directory defines a configuration. The format is the # same as sdkconfig file. Configuration is applied on top of sdkconfig.defaults # file from the project directory -CONFIG_NAMES := $(notdir $(wildcard configs/*)) +CONFIG_NAMES := $(shell ${IDF_PATH}/tools/unit-test-app/tools/get_available_configs.sh esp32) # Per-config targets CONFIG_BUILD_TARGETS := $(addprefix ut-build-,$(CONFIG_NAMES)) diff --git a/tools/unit-test-app/components/test_utils/CMakeLists.txt b/tools/unit-test-app/components/test_utils/CMakeLists.txt index f6174b15a..c099725c1 100644 --- a/tools/unit-test-app/components/test_utils/CMakeLists.txt +++ b/tools/unit-test-app/components/test_utils/CMakeLists.txt @@ -1,4 +1,4 @@ -idf_component_register(SRCS "ref_clock_${CONFIG_IDF_TARGET}.c" +idf_component_register(SRCS "ref_clock.c" "test_runner.c" "test_utils.c" INCLUDE_DIRS include diff --git a/tools/unit-test-app/components/test_utils/component.mk b/tools/unit-test-app/components/test_utils/component.mk index 012356620..e69de29bb 100644 --- a/tools/unit-test-app/components/test_utils/component.mk +++ b/tools/unit-test-app/components/test_utils/component.mk @@ -1 +0,0 @@ -COMPONENT_OBJEXCLUDE := ref_clock_esp32s2beta.o diff --git a/tools/unit-test-app/components/test_utils/ref_clock_esp32.c b/tools/unit-test-app/components/test_utils/ref_clock.c similarity index 94% rename from tools/unit-test-app/components/test_utils/ref_clock_esp32.c rename to tools/unit-test-app/components/test_utils/ref_clock.c index ef7545f75..a0ecd887b 100644 --- a/tools/unit-test-app/components/test_utils/ref_clock_esp32.c +++ b/tools/unit-test-app/components/test_utils/ref_clock.c @@ -39,9 +39,9 @@ #include "freertos/FreeRTOS.h" #include "driver/periph_ctrl.h" #include "esp32/rom/gpio.h" +#include "sdkconfig.h" /* Select which RMT and PCNT channels, and GPIO to use */ -#define REF_CLOCK_RMT_CHANNEL 7 #define REF_CLOCK_PCNT_UNIT 0 #define REF_CLOCK_GPIO 21 @@ -53,7 +53,25 @@ static intr_handle_t s_intr_handle; static portMUX_TYPE s_lock = portMUX_INITIALIZER_UNLOCKED; static volatile uint32_t s_milliseconds; -void ref_clock_init(void) +#if CONFIG_IDF_TARGET_ESP32 +#define REF_CLOCK_RMT_CHANNEL 7 + +static int get_pcnt_sig(void) +{ + return (REF_CLOCK_PCNT_UNIT < 5) ? + PCNT_SIG_CH0_IN0_IDX + 4 * REF_CLOCK_PCNT_UNIT : + PCNT_SIG_CH0_IN5_IDX + 4 * (REF_CLOCK_PCNT_UNIT - 5); +} +#elif CONFIG_IDF_TARGET_ESP32S2BETA +#define REF_CLOCK_RMT_CHANNEL 3 + +static int get_pcnt_sig(void) +{ + return PCNT_SIG_CH0_IN0_IDX + 4 * REF_CLOCK_PCNT_UNIT; +} +#endif + +void ref_clock_init() { assert(s_intr_handle == NULL && "already initialized"); @@ -87,9 +105,7 @@ void ref_clock_init(void) RMT.conf_ch[REF_CLOCK_RMT_CHANNEL].conf1.tx_start = 1; // Route signal to PCNT - int pcnt_sig_idx = (REF_CLOCK_PCNT_UNIT < 5) ? - PCNT_SIG_CH0_IN0_IDX + 4 * REF_CLOCK_PCNT_UNIT : - PCNT_SIG_CH0_IN5_IDX + 4 * (REF_CLOCK_PCNT_UNIT - 5); + int pcnt_sig_idx = get_pcnt_sig(); gpio_matrix_in(REF_CLOCK_GPIO, pcnt_sig_idx, false); if (REF_CLOCK_GPIO != 20) { PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[REF_CLOCK_GPIO]); @@ -133,7 +149,7 @@ static void IRAM_ATTR pcnt_isr(void* arg) portEXIT_CRITICAL_ISR(&s_lock); } -void ref_clock_deinit(void) +void ref_clock_deinit() { assert(s_intr_handle && "deinit called without init"); @@ -152,7 +168,7 @@ void ref_clock_deinit(void) periph_module_disable(PERIPH_PCNT_MODULE); } -uint64_t ref_clock_get(void) +uint64_t ref_clock_get() { portENTER_CRITICAL(&s_lock); uint32_t microseconds = PCNT.cnt_unit[REF_CLOCK_PCNT_UNIT].cnt_val; diff --git a/tools/unit-test-app/components/test_utils/ref_clock_esp32s2beta.c b/tools/unit-test-app/components/test_utils/ref_clock_esp32s2beta.c deleted file mode 100644 index deaef88af..000000000 --- a/tools/unit-test-app/components/test_utils/ref_clock_esp32s2beta.c +++ /dev/null @@ -1 +0,0 @@ -#warning "unit_test_app ref_clock not implemented for esp32s2beta" diff --git a/tools/unit-test-app/configs/aes_no_hw_s2 b/tools/unit-test-app/configs/aes_no_hw_s2 new file mode 100644 index 000000000..69071c545 --- /dev/null +++ b/tools/unit-test-app/configs/aes_no_hw_s2 @@ -0,0 +1,4 @@ +TEST_EXCLUDE_COMPONENTS=libsodium bt app_update +TEST_COMPONENTS=mbedtls +CONFIG_MBEDTLS_HARDWARE_AES=n +CONFIG_IDF_TARGET="esp32s2beta" diff --git a/tools/unit-test-app/configs/default_2_s2 b/tools/unit-test-app/configs/default_2_s2 new file mode 100644 index 000000000..c07c0833c --- /dev/null +++ b/tools/unit-test-app/configs/default_2_s2 @@ -0,0 +1,2 @@ +TEST_EXCLUDE_COMPONENTS=libsodium bt app_update freertos esp32s2beta driver heap pthread soc spi_flash vfs +CONFIG_IDF_TARGET="esp32s2beta" \ No newline at end of file diff --git a/tools/unit-test-app/configs/default_s2 b/tools/unit-test-app/configs/default_s2 new file mode 100644 index 000000000..e55c68be0 --- /dev/null +++ b/tools/unit-test-app/configs/default_s2 @@ -0,0 +1,2 @@ +TEST_COMPONENTS=freertos esp32s2beta driver heap pthread soc spi_flash vfs +CONFIG_IDF_TARGET="esp32s2beta" \ No newline at end of file diff --git a/tools/unit-test-app/configs/freertos_compliance_s2 b/tools/unit-test-app/configs/freertos_compliance_s2 new file mode 100644 index 000000000..e94fa8863 --- /dev/null +++ b/tools/unit-test-app/configs/freertos_compliance_s2 @@ -0,0 +1,3 @@ +TEST_COMPONENTS=driver esp32s2beta spi_flash +CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE=y +CONFIG_IDF_TARGET="esp32s2beta" diff --git a/tools/unit-test-app/configs/libsodium_s2 b/tools/unit-test-app/configs/libsodium_s2 new file mode 100644 index 000000000..9485da494 --- /dev/null +++ b/tools/unit-test-app/configs/libsodium_s2 @@ -0,0 +1,4 @@ +TEST_COMPONENTS=libsodium +TEST_EXCLUDE_COMPONENTS=bt app_update +CONFIG_UNITY_FREERTOS_STACK_SIZE=12288 +CONFIG_IDF_TARGET="esp32s2beta" \ No newline at end of file diff --git a/tools/unit-test-app/configs/release_2_s2 b/tools/unit-test-app/configs/release_2_s2 new file mode 100644 index 000000000..b392e48fd --- /dev/null +++ b/tools/unit-test-app/configs/release_2_s2 @@ -0,0 +1,4 @@ +TEST_EXCLUDE_COMPONENTS=libsodium bt app_update freertos esp32s2beta driver heap pthread soc spi_flash vfs +CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y +CONFIG_IDF_TARGET="esp32s2beta" diff --git a/tools/unit-test-app/configs/release_s2 b/tools/unit-test-app/configs/release_s2 new file mode 100644 index 000000000..aaa50b0ce --- /dev/null +++ b/tools/unit-test-app/configs/release_s2 @@ -0,0 +1,4 @@ +TEST_COMPONENTS=freertos esp32s2beta driver heap pthread soc spi_flash vfs +CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y +CONFIG_IDF_TARGET="esp32s2beta" diff --git a/tools/unit-test-app/configs/single_core_2_s2 b/tools/unit-test-app/configs/single_core_2_s2 new file mode 100644 index 000000000..b9bbf882d --- /dev/null +++ b/tools/unit-test-app/configs/single_core_2_s2 @@ -0,0 +1,5 @@ +TEST_EXCLUDE_COMPONENTS=libsodium bt app_update freertos esp32s2beta driver heap pthread soc spi_flash vfs +CONFIG_MEMMAP_SMP=n +CONFIG_FREERTOS_UNICORE=y +CONFIG_ESP32_RTCDATA_IN_FAST_MEM=y +CONFIG_IDF_TARGET="esp32s2beta" diff --git a/tools/unit-test-app/configs/single_core_s2 b/tools/unit-test-app/configs/single_core_s2 new file mode 100644 index 000000000..e7353a499 --- /dev/null +++ b/tools/unit-test-app/configs/single_core_s2 @@ -0,0 +1,5 @@ +TEST_COMPONENTS=freertos esp32s2beta driver heap pthread soc spi_flash vfs +CONFIG_MEMMAP_SMP=n +CONFIG_FREERTOS_UNICORE=y +CONFIG_ESP32_RTCDATA_IN_FAST_MEM=y +CONFIG_IDF_TARGET="esp32s2beta" diff --git a/tools/unit-test-app/disabled_configs/app_update_s2 b/tools/unit-test-app/disabled_configs/app_update_s2 new file mode 100644 index 000000000..9a714628d --- /dev/null +++ b/tools/unit-test-app/disabled_configs/app_update_s2 @@ -0,0 +1,14 @@ +TEST_COMPONENTS=app_update +TEST_EXCLUDE_COMPONENTS=libsodium bt +CONFIG_UNITY_FREERTOS_STACK_SIZE=12288 +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partition_table_unit_test_two_ota.csv" +CONFIG_PARTITION_TABLE_FILENAME="partition_table_unit_test_two_ota.csv" +CONFIG_PARTITION_TABLE_OFFSET=0x18000 +CONFIG_BOOTLOADER_FACTORY_RESET=y +CONFIG_BOOTLOADER_APP_TEST=y +CONFIG_BOOTLOADER_HOLD_TIME_GPIO=2 +CONFIG_BOOTLOADER_OTA_DATA_ERASE=y +CONFIG_BOOTLOADER_NUM_PIN_FACTORY_RESET=4 +CONFIG_BOOTLOADER_NUM_PIN_APP_TEST=32 +CONFIG_IDF_TARGET="esp32s2beta" \ No newline at end of file diff --git a/tools/unit-test-app/disabled_configs/psram_2_s2 b/tools/unit-test-app/disabled_configs/psram_2_s2 new file mode 100644 index 000000000..69bb6ff1b --- /dev/null +++ b/tools/unit-test-app/disabled_configs/psram_2_s2 @@ -0,0 +1,3 @@ +TEST_COMPONENTS=driver esp32s2beta spi_flash +CONFIG_ESP32S2_SPIRAM_SUPPORT=y +CONFIG_IDF_TARGET="esp32s2beta" diff --git a/tools/unit-test-app/disabled_configs/psram_8m_s2 b/tools/unit-test-app/disabled_configs/psram_8m_s2 new file mode 100644 index 000000000..68661d877 --- /dev/null +++ b/tools/unit-test-app/disabled_configs/psram_8m_s2 @@ -0,0 +1,5 @@ +TEST_COMPONENTS=esp32s2beta +CONFIG_ESP32S2_SPIRAM_SUPPORT=y +CONFIG_SPIRAM_BANKSWITCH_ENABLE=y +CONFIG_SPIRAM_BANKSWITCH_RESERVE=8 +CONFIG_IDF_TARGET="esp32s2beta" diff --git a/tools/unit-test-app/disabled_configs/psram_s2 b/tools/unit-test-app/disabled_configs/psram_s2 new file mode 100644 index 000000000..be364cff7 --- /dev/null +++ b/tools/unit-test-app/disabled_configs/psram_s2 @@ -0,0 +1,3 @@ +TEST_EXCLUDE_COMPONENTS=libsodium bt app_update driver esp32s2beta spi_flash +CONFIG_ESP32S2_SPIRAM_SUPPORT=y +CONFIG_IDF_TARGET="esp32s2beta" diff --git a/tools/unit-test-app/idf_ext.py b/tools/unit-test-app/idf_ext.py index 9fea43046..d2bcc5fc4 100644 --- a/tools/unit-test-app/idf_ext.py +++ b/tools/unit-test-app/idf_ext.py @@ -66,12 +66,19 @@ def action_extensions(base_actions, project_path=os.getcwd()): config_path = os.path.join(project_path, "configs", config_name) config = parse_config(config_path) + target = config.get("CONFIG_IDF_TARGET", "esp32").strip("'").strip('"') + + print("Reconfigure: config %s, target %s" % (config_name, target)) + + # Clean up and set idf-target + base_actions["actions"]["set-target"]["callback"]("set-target", ctx, args, target) + new_cache_values["EXCLUDE_COMPONENTS"] = config.get("EXCLUDE_COMPONENTS", "''") new_cache_values["TEST_EXCLUDE_COMPONENTS"] = config.get("TEST_EXCLUDE_COMPONENTS", "''") new_cache_values["TEST_COMPONENTS"] = config.get("TEST_COMPONENTS", "''") new_cache_values["TESTS_ALL"] = int(new_cache_values["TEST_COMPONENTS"] == "''") - - with tempfile.NamedTemporaryFile() as sdkconfig_temp: + # When delete=True, the file is invisible to kconfiglib on Windows + with tempfile.NamedTemporaryFile(delete=False) as sdkconfig_temp: # Use values from the combined defaults and the values from # config folder to build config sdkconfig_default = os.path.join(project_path, "sdkconfig.defaults") @@ -89,8 +96,8 @@ def action_extensions(base_actions, project_path=os.getcwd()): args.define_cache_entry.extend(["%s=%s" % (k, v) for k, v in new_cache_values.items()]) - reconfigure = base_actions["actions"]["reconfigure"]["callback"] - reconfigure(None, ctx, args) + base_actions["actions"]["fullclean"]["callback"]("fullclean", ctx, args) + base_actions["actions"]["reconfigure"]["callback"](None, ctx, args) # This target builds the configuration. It does not currently track dependencies, # but is good enough for CI builds if used together with clean-all-configs. diff --git a/tools/unit-test-app/tools/ConfigDependency.yml b/tools/unit-test-app/tools/ConfigDependency.yml index 2e720089a..c9b2d4690 100644 --- a/tools/unit-test-app/tools/ConfigDependency.yml +++ b/tools/unit-test-app/tools/ConfigDependency.yml @@ -1,2 +1,4 @@ "psram": '{CONFIG_ESP32_SPIRAM_SUPPORT=y} and not {CONFIG_SPIRAM_BANKSWITCH_ENABLE=y}' "8Mpsram": "CONFIG_SPIRAM_BANKSWITCH_ENABLE=y" +"ESP32_IDF": "CONFIG_IDF_TARGET_ESP32=y" +"7.2.2": "CONFIG_IDF_TARGET_ESP32S2BETA=y" \ No newline at end of file diff --git a/tools/unit-test-app/tools/get_available_configs.sh b/tools/unit-test-app/tools/get_available_configs.sh new file mode 100755 index 000000000..c5161bd29 --- /dev/null +++ b/tools/unit-test-app/tools/get_available_configs.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +cd ${IDF_PATH}/tools/unit-test-app + +AVAL_CONFIGS="" +CONFIGS=$(ls configs) +if [ $1 == "esp32" ]; then + #echo 'Searching for configs for target "'$1'"' + for FILE in $CONFIGS + do + grep 'CONFIG_IDF_TARGET' /dev/null + if [ $? -ne 0 ]; then + # If CONFIG_IDF_TARGET not found, implies ESP32 + AVAL_CONFIGS="$AVAL_CONFIGS $FILE" + fi + grep -E '^CONFIG_IDF_TARGET="?'$1'"?$' /dev/null + if [ $? -eq 0 ]; then + AVAL_CONFIGS="$AVAL_CONFIGS $FILE" + fi + done +else + #echo 'Searching for configs for target "'$1'"' + for FILE in $CONFIGS + do + grep -E '^CONFIG_IDF_TARGET="?'$1'"?$' /dev/null + if [ $? -eq 0 ]; then + AVAL_CONFIGS="$AVAL_CONFIGS $FILE" + fi + done +fi + +echo $AVAL_CONFIGS