forked from espressif/esp-idf
Merge branch 'feature/esp_pm_unit_test_migration' into 'master'
esp_pm: Migrate unit tests to test app Closes IDF-5581 See merge request espressif/esp-idf!21229
This commit is contained in:
7
components/esp_pm/.build-test-rules.yml
Normal file
7
components/esp_pm/.build-test-rules.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||||
|
|
||||||
|
components/esp_pm/test_apps/esp_pm:
|
||||||
|
disable:
|
||||||
|
- if: IDF_TARGET in ["esp32c6"]
|
||||||
|
temporary: true
|
||||||
|
reason: Not supported yet
|
@@ -1,2 +0,0 @@
|
|||||||
idf_component_register(SRC_DIRS .
|
|
||||||
PRIV_REQUIRES unity esp_pm ulp driver esp_timer test_utils)
|
|
12
components/esp_pm/test_apps/esp_pm/CMakeLists.txt
Normal file
12
components/esp_pm/test_apps/esp_pm/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# The following lines of boilerplate have to be in your project's
|
||||||
|
# CMakeLists in this exact order for cmake to work correctly
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
set(SDKCONFIG_DEFAULTS "$ENV{IDF_PATH}/tools/test_apps/configs/sdkconfig.debug_helpers")
|
||||||
|
list(APPEND SDKCONFIG_DEFAULTS "sdkconfig.defaults")
|
||||||
|
|
||||||
|
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
|
||||||
|
set(COMPONENTS main)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(test_esp_pm)
|
2
components/esp_pm/test_apps/esp_pm/README.md
Normal file
2
components/esp_pm/test_apps/esp_pm/README.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
|
||||||
|
| ----------------- | ----- | -------- | -------- | -------- | -------- |
|
9
components/esp_pm/test_apps/esp_pm/main/CMakeLists.txt
Normal file
9
components/esp_pm/test_apps/esp_pm/main/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
set(sources "test_app_main.c"
|
||||||
|
"test_pm.c")
|
||||||
|
|
||||||
|
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||||
|
# the component must be registered as a WHOLE_ARCHIVE
|
||||||
|
idf_component_register(SRCS ${sources}
|
||||||
|
INCLUDE_DIRS "."
|
||||||
|
PRIV_REQUIRES unity esp_pm ulp driver esp_timer
|
||||||
|
WHOLE_ARCHIVE)
|
46
components/esp_pm/test_apps/esp_pm/main/test_app_main.c
Normal file
46
components/esp_pm/test_apps/esp_pm/main/test_app_main.c
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "unity.h"
|
||||||
|
#include "unity_test_runner.h"
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
|
||||||
|
// esp_timer_init() lazily allocates memory
|
||||||
|
#define TEST_MEMORY_LEAK_THRESHOLD (-512)
|
||||||
|
|
||||||
|
static size_t before_free_8bit;
|
||||||
|
static size_t before_free_32bit;
|
||||||
|
|
||||||
|
static void check_leak(size_t before_free, size_t after_free, const char *type)
|
||||||
|
{
|
||||||
|
ssize_t delta = after_free - before_free;
|
||||||
|
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta);
|
||||||
|
TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak");
|
||||||
|
}
|
||||||
|
|
||||||
|
void setUp(void)
|
||||||
|
{
|
||||||
|
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tearDown(void)
|
||||||
|
{
|
||||||
|
// Add a short delay of 10ms to allow the idle task to free an remaining memory
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||||
|
check_leak(before_free_8bit, after_free_8bit, "8BIT");
|
||||||
|
check_leak(before_free_32bit, after_free_32bit, "32BIT");
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
printf("ESP Power Manager Tests\n");
|
||||||
|
unity_run_menu();
|
||||||
|
}
|
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -19,7 +25,6 @@
|
|||||||
#include "soc/rtc_periph.h"
|
#include "soc/rtc_periph.h"
|
||||||
#include "esp_rom_sys.h"
|
#include "esp_rom_sys.h"
|
||||||
#include "esp_private/esp_clk.h"
|
#include "esp_private/esp_clk.h"
|
||||||
#include "test_utils.h"
|
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
19
components/esp_pm/test_apps/esp_pm/pytest_esp_pm.py
Normal file
19
components/esp_pm/test_apps/esp_pm/pytest_esp_pm.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
CONFIGS = [
|
||||||
|
pytest.param('default', marks=[pytest.mark.supported_targets, pytest.mark.temp_skip_ci(targets=['esp32c6'], reason='c6 support TBD')]),
|
||||||
|
pytest.param('limits', marks=[pytest.mark.supported_targets, pytest.mark.temp_skip_ci(targets=['esp32c6'], reason='c6 support TBD')]),
|
||||||
|
pytest.param('options', marks=[pytest.mark.supported_targets, pytest.mark.temp_skip_ci(targets=['esp32c6'], reason='c6 support TBD')]),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.generic
|
||||||
|
@pytest.mark.parametrize('config', CONFIGS, indirect=True)
|
||||||
|
def test_esp_pm(dut: Dut) -> None:
|
||||||
|
dut.expect_exact('Press ENTER to see the list of tests')
|
||||||
|
dut.write('*')
|
||||||
|
dut.expect_unity_test_output()
|
1
components/esp_pm/test_apps/esp_pm/sdkconfig.ci.default
Normal file
1
components/esp_pm/test_apps/esp_pm/sdkconfig.ci.default
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# This is left intentionally blank. It inherits all configurations from sdkconfg.defaults
|
14
components/esp_pm/test_apps/esp_pm/sdkconfig.ci.limits
Normal file
14
components/esp_pm/test_apps/esp_pm/sdkconfig.ci.limits
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Test configuration for limit testing esp_pm (i.e., maximizing various parameters such as speed, frequency etc)
|
||||||
|
|
||||||
|
# Limit test esp_pm auto light sleep logic with faster ticks and faster code
|
||||||
|
CONFIG_FREERTOS_HZ=1000
|
||||||
|
CONFIG_COMPILER_OPTIMIZATION_PERF=y
|
||||||
|
# Minimize the automatic light sleep entry threshold
|
||||||
|
CONFIG_FREERTOS_IDLE_TIME_BEFORE_SLEEP=2
|
||||||
|
|
||||||
|
# Enable PM options for automatic sleeping and DFS
|
||||||
|
CONFIG_PM_DFS_INIT_AUTO=y
|
||||||
|
CONFIG_PM_SLP_DISABLE_GPIO=y
|
||||||
|
|
||||||
|
# Limit test PM to see if it can XIP from flash
|
||||||
|
CONFIG_PM_SLP_IRAM_OPT=n
|
9
components/esp_pm/test_apps/esp_pm/sdkconfig.ci.options
Normal file
9
components/esp_pm/test_apps/esp_pm/sdkconfig.ci.options
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Test configuration for enabling optional features that are supported on esp_pm. Tested on all targets
|
||||||
|
|
||||||
|
# Enable optional features
|
||||||
|
CONFIG_PM_DFS_INIT_AUTO=y
|
||||||
|
CONFIG_PM_PROFILING=y
|
||||||
|
CONFIG_PM_TRACE=y
|
||||||
|
CONFIG_PM_SLP_IRAM_OPT=y
|
||||||
|
CONFIG_PM_RTOS_IDLE_OPT=y
|
||||||
|
CONFIG_PM_SLP_DISABLE_GPIO=y
|
8
components/esp_pm/test_apps/esp_pm/sdkconfig.defaults
Normal file
8
components/esp_pm/test_apps/esp_pm/sdkconfig.defaults
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# This "default" configuration is appended to all other configurations
|
||||||
|
# The contents of "sdkconfig.debug_helpers" is also appended to all other configurations (see CMakeLists.txt)
|
||||||
|
CONFIG_PM_ENABLE=y
|
||||||
|
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
||||||
|
CONFIG_ESP_TASK_WDT_INIT=n
|
||||||
|
|
||||||
|
# SMP FreeRTOS currently does not support power management IDF-4997
|
||||||
|
CONFIG_FREERTOS_SMP=n
|
@@ -0,0 +1,4 @@
|
|||||||
|
# Target specific default configurations
|
||||||
|
|
||||||
|
# Enable the ULP FSM to test it as a wake up source
|
||||||
|
CONFIG_ULP_COPROC_TYPE_FSM=y
|
@@ -0,0 +1,4 @@
|
|||||||
|
# Target specific default configurations
|
||||||
|
|
||||||
|
# Enable the ULP FSM to test it as a wake up source
|
||||||
|
CONFIG_ULP_COPROC_TYPE_FSM=y
|
@@ -0,0 +1,4 @@
|
|||||||
|
# Target specific default configurations
|
||||||
|
|
||||||
|
# Enable the ULP FSM to test it as a wake up source
|
||||||
|
CONFIG_ULP_COPROC_TYPE_FSM=y
|
@@ -1,3 +1,3 @@
|
|||||||
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
|
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
|
||||||
CONFIG_IDF_TARGET="esp32"
|
CONFIG_IDF_TARGET="esp32"
|
||||||
TEST_EXCLUDE_COMPONENTS=bt esp_pm esp_system driver soc spi_flash vfs test_utils experimental_cpp_component
|
TEST_EXCLUDE_COMPONENTS=bt esp_system driver soc spi_flash vfs test_utils experimental_cpp_component
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
# This config is split between targets since different component needs to be excluded
|
# This config is split between targets since different component needs to be excluded
|
||||||
CONFIG_IDF_TARGET="esp32c3"
|
CONFIG_IDF_TARGET="esp32c3"
|
||||||
TEST_EXCLUDE_COMPONENTS=bt esp_pm esp_system driver soc spi_flash vfs lwip spiffs experimental_cpp_component perfmon test_utils
|
TEST_EXCLUDE_COMPONENTS=bt esp_system driver soc spi_flash vfs lwip spiffs experimental_cpp_component perfmon test_utils
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
|
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
|
||||||
CONFIG_IDF_TARGET="esp32s2"
|
CONFIG_IDF_TARGET="esp32s2"
|
||||||
TEST_EXCLUDE_COMPONENTS=bt esp_pm esp_system driver soc spi_flash vfs experimental_cpp_component
|
TEST_EXCLUDE_COMPONENTS=bt esp_system driver soc spi_flash vfs experimental_cpp_component
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
|
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
|
||||||
CONFIG_IDF_TARGET="esp32s3"
|
CONFIG_IDF_TARGET="esp32s3"
|
||||||
TEST_EXCLUDE_COMPONENTS=bt esp32s3 esp_pm esp_system driver soc spi_flash vfs experimental_cpp_component test_utils
|
TEST_EXCLUDE_COMPONENTS=bt esp32s3 esp_system driver soc spi_flash vfs experimental_cpp_component test_utils
|
||||||
|
@@ -1,7 +0,0 @@
|
|||||||
CONFIG_IDF_TARGET="esp32"
|
|
||||||
TEST_COMPONENTS=esp_pm
|
|
||||||
CONFIG_PM_ENABLE=y
|
|
||||||
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
|
||||||
CONFIG_ULP_COPROC_TYPE_FSM=y
|
|
||||||
# SMP FreeRTOS currently does not support power management IDF-4997
|
|
||||||
CONFIG_FREERTOS_SMP=n
|
|
@@ -1,6 +0,0 @@
|
|||||||
CONFIG_IDF_TARGET="esp32c2"
|
|
||||||
TEST_COMPONENTS=esp_pm
|
|
||||||
CONFIG_PM_ENABLE=y
|
|
||||||
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
|
||||||
# SMP FreeRTOS currently does not support power management IDF-4997
|
|
||||||
CONFIG_FREERTOS_SMP=n
|
|
@@ -1,6 +0,0 @@
|
|||||||
CONFIG_IDF_TARGET="esp32c3"
|
|
||||||
TEST_COMPONENTS=esp_pm
|
|
||||||
CONFIG_PM_ENABLE=y
|
|
||||||
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
|
||||||
# SMP FreeRTOS currently does not support power management IDF-4997
|
|
||||||
CONFIG_FREERTOS_SMP=n
|
|
@@ -1,6 +0,0 @@
|
|||||||
CONFIG_IDF_TARGET="esp32c6"
|
|
||||||
TEST_COMPONENTS=esp_pm
|
|
||||||
CONFIG_PM_ENABLE=y
|
|
||||||
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
|
||||||
# SMP FreeRTOS currently does not support power management IDF-4997
|
|
||||||
CONFIG_FREERTOS_SMP=n
|
|
@@ -1,7 +0,0 @@
|
|||||||
CONFIG_IDF_TARGET="esp32s2"
|
|
||||||
TEST_COMPONENTS=esp_pm
|
|
||||||
CONFIG_PM_ENABLE=y
|
|
||||||
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
|
||||||
CONFIG_ULP_COPROC_TYPE_FSM=y
|
|
||||||
# SMP FreeRTOS currently does not support power management IDF-4997
|
|
||||||
CONFIG_FREERTOS_SMP=n
|
|
@@ -1,7 +0,0 @@
|
|||||||
CONFIG_IDF_TARGET="esp32s3"
|
|
||||||
TEST_COMPONENTS=esp_pm
|
|
||||||
CONFIG_PM_ENABLE=y
|
|
||||||
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
|
||||||
CONFIG_ULP_COPROC_TYPE_FSM=y
|
|
||||||
# SMP FreeRTOS currently does not support power management IDF-4997
|
|
||||||
CONFIG_FREERTOS_SMP=n
|
|
@@ -1,5 +1,5 @@
|
|||||||
CONFIG_IDF_TARGET="esp32"
|
CONFIG_IDF_TARGET="esp32"
|
||||||
TEST_EXCLUDE_COMPONENTS=bt driver esp_pm esp_system spi_flash test_utils soc experimental_cpp_component esp-tls sdmmc
|
TEST_EXCLUDE_COMPONENTS=bt driver esp_system spi_flash test_utils soc experimental_cpp_component esp-tls sdmmc
|
||||||
CONFIG_SPIRAM=y
|
CONFIG_SPIRAM=y
|
||||||
CONFIG_ESP_INT_WDT_TIMEOUT_MS=800
|
CONFIG_ESP_INT_WDT_TIMEOUT_MS=800
|
||||||
CONFIG_SPIRAM_OCCUPY_NO_HOST=y
|
CONFIG_SPIRAM_OCCUPY_NO_HOST=y
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# This config is split between targets since different component needs to be included (esp32, esp32s2)
|
# This config is split between targets since different component needs to be included (esp32, esp32s2)
|
||||||
CONFIG_IDF_TARGET="esp32"
|
CONFIG_IDF_TARGET="esp32"
|
||||||
TEST_EXCLUDE_COMPONENTS=bt esp_pm esp_system driver soc spi_flash vfs test_utils experimental_cpp_component
|
TEST_EXCLUDE_COMPONENTS=bt esp_system driver soc spi_flash vfs test_utils experimental_cpp_component
|
||||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
|
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
|
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
|
||||||
CONFIG_IDF_TARGET="esp32s2"
|
CONFIG_IDF_TARGET="esp32s2"
|
||||||
TEST_EXCLUDE_COMPONENTS=bt esp_pm esp_system driver soc spi_flash vfs test_utils experimental_cpp_component
|
TEST_EXCLUDE_COMPONENTS=bt esp_system driver soc spi_flash vfs test_utils experimental_cpp_component
|
||||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
|
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
|
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
|
||||||
CONFIG_IDF_TARGET="esp32"
|
CONFIG_IDF_TARGET="esp32"
|
||||||
TEST_EXCLUDE_COMPONENTS=bt esp_system esp_pm driver soc spi_flash vfs test_utils experimental_cpp_component
|
TEST_EXCLUDE_COMPONENTS=bt esp_system driver soc spi_flash vfs test_utils experimental_cpp_component
|
||||||
CONFIG_FREERTOS_UNICORE=y
|
CONFIG_FREERTOS_UNICORE=y
|
||||||
CONFIG_ESP32_RTCDATA_IN_FAST_MEM=y
|
CONFIG_ESP32_RTCDATA_IN_FAST_MEM=y
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
|
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
|
||||||
CONFIG_IDF_TARGET="esp32s2"
|
CONFIG_IDF_TARGET="esp32s2"
|
||||||
TEST_EXCLUDE_COMPONENTS=bt esp_system esp_pm driver soc spi_flash vfs experimental_cpp_component
|
TEST_EXCLUDE_COMPONENTS=bt esp_system driver soc spi_flash vfs experimental_cpp_component
|
||||||
CONFIG_FREERTOS_UNICORE=y
|
CONFIG_FREERTOS_UNICORE=y
|
||||||
CONFIG_ESP32S2_RTCDATA_IN_FAST_MEM=y
|
CONFIG_ESP32S2_RTCDATA_IN_FAST_MEM=y
|
||||||
|
Reference in New Issue
Block a user