mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
Merge branch 'ci/add_base_size_metric_apps' into 'master'
ci(size_metrics): add base size metric test apps See merge request espressif/esp-idf!46208
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||
|
||||
components/esp_timer/test_apps:
|
||||
components/esp_timer/test_apps/esp_timer_tests:
|
||||
enable:
|
||||
- if: INCLUDE_DEFAULT == 1 or IDF_TARGET == "linux"
|
||||
reason: run existing default build targets and include Linux
|
||||
@@ -14,3 +14,10 @@ components/esp_timer/test_apps:
|
||||
reason: The test requires the XTAL32K clock to measure the esp_timer timing accuracy
|
||||
- if: CONFIG_NAME == "dfs" and SOC_PM_SUPPORTED != 1
|
||||
reason: The test requires the PM functionality
|
||||
|
||||
components/esp_timer/test_apps/size_metrics:
|
||||
enable:
|
||||
- if: IDF_TARGET in ["esp32", "esp32c6"]
|
||||
reason: Size metrics tracked on one RISC-V (esp32c6) and one Xtensa (esp32) target
|
||||
depends_components:
|
||||
- esp_timer
|
||||
|
||||
@@ -27,7 +27,7 @@ else()
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_INCLUDE_DIRS "../../private_include" "../include"
|
||||
PRIV_INCLUDE_DIRS "../../../private_include" "../../include"
|
||||
PRIV_REQUIRES "${priv_requires}"
|
||||
WHOLE_ARCHIVE)
|
||||
|
||||
12
components/esp_timer/test_apps/size_metrics/CMakeLists.txt
Normal file
12
components/esp_timer/test_apps/size_metrics/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
# Size metrics test app for esp_timer component
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
list(PREPEND SDKCONFIG_DEFAULTS
|
||||
"$ENV{IDF_PATH}/tools/test_apps/configs/sdkconfig.size_metrics"
|
||||
"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(size_metrics)
|
||||
2
components/esp_timer/test_apps/size_metrics/README.md
Normal file
2
components/esp_timer/test_apps/size_metrics/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
| Supported Targets | ESP32 | ESP32-C6 |
|
||||
| ----------------- | ----- | -------- |
|
||||
@@ -0,0 +1,3 @@
|
||||
idf_component_register(SRCS "main.c"
|
||||
PRIV_REQUIRES esp_timer
|
||||
WHOLE_ARCHIVE)
|
||||
@@ -0,0 +1,18 @@
|
||||
menu "Size Metrics Test App Configuration"
|
||||
|
||||
choice SIZE_METRICS_FUNCTION_SET
|
||||
prompt "Function set to compile"
|
||||
default SIZE_METRICS_FUNCTION_SET_MINIMAL
|
||||
help
|
||||
Select which set of functions to compile for size metrics comparison.
|
||||
Minimal set includes only basic functions, full set includes all features.
|
||||
|
||||
config SIZE_METRICS_FUNCTION_SET_MINIMAL
|
||||
bool "Minimal function set"
|
||||
|
||||
config SIZE_METRICS_FUNCTION_SET_FULL
|
||||
bool "Full function set"
|
||||
|
||||
endchoice
|
||||
|
||||
endmenu
|
||||
85
components/esp_timer/test_apps/size_metrics/main/main.c
Normal file
85
components/esp_timer/test_apps/size_metrics/main/main.c
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "esp_timer.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_SIZE_METRICS_FUNCTION_SET_MINIMAL
|
||||
// Minimal function set - basic timer operations only
|
||||
static void minimal_timer_callback(void* arg)
|
||||
{
|
||||
// Minimal callback implementation
|
||||
}
|
||||
|
||||
static void minimal_functions(void)
|
||||
{
|
||||
esp_timer_handle_t timer;
|
||||
esp_timer_create_args_t timer_args = {
|
||||
.callback = minimal_timer_callback,
|
||||
.name = "minimal_timer"
|
||||
};
|
||||
esp_timer_create(&timer_args, &timer);
|
||||
esp_timer_start_once(timer, 1000);
|
||||
esp_timer_stop(timer);
|
||||
esp_timer_delete(timer);
|
||||
}
|
||||
#endif // CONFIG_SIZE_METRICS_FUNCTION_SET_MINIMAL
|
||||
|
||||
#if CONFIG_SIZE_METRICS_FUNCTION_SET_FULL
|
||||
// Full function set - all timer features
|
||||
static void full_timer_callback(void* arg)
|
||||
{
|
||||
// Full callback implementation with more features
|
||||
}
|
||||
|
||||
static void full_periodic_timer_callback(void* arg)
|
||||
{
|
||||
// Periodic timer callback
|
||||
}
|
||||
|
||||
static void full_functions(void)
|
||||
{
|
||||
esp_timer_handle_t oneshot_timer;
|
||||
esp_timer_handle_t periodic_timer;
|
||||
|
||||
// One-shot timer
|
||||
esp_timer_create_args_t oneshot_args = {
|
||||
.callback = full_timer_callback,
|
||||
.name = "oneshot_timer"
|
||||
};
|
||||
esp_timer_create(&oneshot_args, &oneshot_timer);
|
||||
esp_timer_start_once(oneshot_timer, 1000);
|
||||
|
||||
// Periodic timer
|
||||
esp_timer_create_args_t periodic_args = {
|
||||
.callback = full_periodic_timer_callback,
|
||||
.name = "periodic_timer"
|
||||
};
|
||||
esp_timer_create(&periodic_args, &periodic_timer);
|
||||
esp_timer_start_periodic(periodic_timer, 5000);
|
||||
|
||||
// Timer operations
|
||||
esp_timer_stop(oneshot_timer);
|
||||
esp_timer_stop(periodic_timer);
|
||||
esp_timer_delete(oneshot_timer);
|
||||
esp_timer_delete(periodic_timer);
|
||||
}
|
||||
#endif // CONFIG_SIZE_METRICS_FUNCTION_SET_FULL
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
printf("size_metrics app_main started\n");
|
||||
|
||||
#if CONFIG_SIZE_METRICS_FUNCTION_SET_MINIMAL
|
||||
minimal_functions();
|
||||
#endif
|
||||
|
||||
#if CONFIG_SIZE_METRICS_FUNCTION_SET_FULL
|
||||
full_functions();
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
# SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
import pytest
|
||||
from pytest_embedded_idf.dut import IdfDut
|
||||
from pytest_embedded_idf.utils import idf_parametrize
|
||||
|
||||
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.parametrize('config', ['minimal', 'full'], indirect=True)
|
||||
@idf_parametrize('target', ['esp32', 'esp32c6'], indirect=['target'])
|
||||
def test_esp_timer_size_metrics_boots(dut: IdfDut) -> None:
|
||||
dut.expect_exact('size_metrics app_main started', timeout=30)
|
||||
@@ -0,0 +1,3 @@
|
||||
# Full configuration for size metrics
|
||||
CONFIG_SIZE_METRICS_FUNCTION_SET_MINIMAL=n
|
||||
CONFIG_SIZE_METRICS_FUNCTION_SET_FULL=y
|
||||
@@ -0,0 +1,3 @@
|
||||
# Minimal configuration for size metrics
|
||||
CONFIG_SIZE_METRICS_FUNCTION_SET_MINIMAL=y
|
||||
CONFIG_SIZE_METRICS_FUNCTION_SET_FULL=n
|
||||
@@ -0,0 +1,2 @@
|
||||
# App-specific defaults for esp_timer size metrics
|
||||
CONFIG_ESP_TIMER_PROFILING=n
|
||||
@@ -49,8 +49,14 @@
|
||||
#
|
||||
# Entries below define the apps that publish size metrics:
|
||||
|
||||
examples/get-started/hello_world:
|
||||
tools/test_apps/size_metrics/minimal_baseline:
|
||||
libs: all
|
||||
bootloader: true
|
||||
configs:
|
||||
- default
|
||||
|
||||
components/esp_timer/test_apps/size_metrics:
|
||||
libs: all
|
||||
configs:
|
||||
- minimal
|
||||
- full
|
||||
|
||||
8
tools/test_apps/configs/sdkconfig.size_metrics
Normal file
8
tools/test_apps/configs/sdkconfig.size_metrics
Normal file
@@ -0,0 +1,8 @@
|
||||
# Shared production-style defaults for apps that publish size metrics
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y
|
||||
CONFIG_COMPILER_NO_MERGE_CONSTANTS=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL_WARN=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y
|
||||
7
tools/test_apps/size_metrics/.build-test-rules.yml
Normal file
7
tools/test_apps/size_metrics/.build-test-rules.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||
|
||||
tools/test_apps/size_metrics/minimal_baseline:
|
||||
disable_test:
|
||||
- if: IDF_TARGET == "linux"
|
||||
temporary: true
|
||||
reason: Not a real hardware target
|
||||
12
tools/test_apps/size_metrics/minimal_baseline/CMakeLists.txt
Normal file
12
tools/test_apps/size_metrics/minimal_baseline/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
# This is the project CMakeLists.txt file for the minimal_baseline size metrics test app
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
list(PREPEND SDKCONFIG_DEFAULTS
|
||||
"$ENV{IDF_PATH}/tools/test_apps/configs/sdkconfig.size_metrics"
|
||||
"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(minimal_baseline)
|
||||
35
tools/test_apps/size_metrics/minimal_baseline/README.md
Normal file
35
tools/test_apps/size_metrics/minimal_baseline/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-H21 | ESP32-H4 | ESP32-P4 | ESP32-S2 | ESP32-S3 | ESP32-S31 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | --------- | -------- | -------- | -------- | -------- | --------- |
|
||||
|
||||
# Minimal Baseline Size Metrics App
|
||||
|
||||
This is a **build-only** integration app for size metrics tracking. It exercises the absolute minimum SDK stack:
|
||||
- `app_main()` entry point
|
||||
- `esp_system` and its core dependencies
|
||||
|
||||
## Purpose
|
||||
|
||||
Establish a floor measurement for the core ESP-IDF SDK and detect regressions in:
|
||||
- Toolchain changes (compiler, linker)
|
||||
- newlib updates
|
||||
- Linker script changes
|
||||
- Core system component dependencies
|
||||
|
||||
## Source Frozen
|
||||
|
||||
This app is **source-frozen**. The application code should never change unless forced by SDK API changes (e.g., breaking API changes at major version boundaries). Any size change detected in CI is attributable to SDK changes, not application code evolution.
|
||||
|
||||
## Configuration
|
||||
|
||||
- Built with `-Os` (size optimization)
|
||||
- Disables WDT, assertions, and other noise-inducing features
|
||||
- Trimmed build: only includes `main` component and its dependencies
|
||||
- Targets: ESP32 (Xtensa) and ESP32-C6 (RISC-V)
|
||||
|
||||
## Metrics Tracked
|
||||
|
||||
- Total flash usage
|
||||
- Total DRAM usage
|
||||
- Total IRAM usage
|
||||
|
||||
Metrics are collected from the `.map` file using `esp_idf_size` and uploaded via `esp-metrics-cli`.
|
||||
@@ -0,0 +1,2 @@
|
||||
idf_component_register(SRCS "main.c"
|
||||
WHOLE_ARCHIVE)
|
||||
26
tools/test_apps/size_metrics/minimal_baseline/main/main.c
Normal file
26
tools/test_apps/size_metrics/minimal_baseline/main/main.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
* Minimal baseline integration app for size metrics.
|
||||
*
|
||||
* This app exercises only the absolute minimum SDK stack - app_main + esp_system.
|
||||
* It establishes a floor measurement for the core SDK and catches regressions in:
|
||||
* - Toolchain changes
|
||||
* - newlib updates
|
||||
* - Linker script changes
|
||||
* - Core esp_system dependencies
|
||||
*
|
||||
* This app keeps runtime behavior minimal and source-frozen.
|
||||
* Any size change is attributable to SDK changes, not application code changes.
|
||||
*/
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
printf("minimal_baseline app_main started\n");
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
# SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
import pytest
|
||||
from pytest_embedded_idf.dut import IdfDut
|
||||
from pytest_embedded_idf.utils import idf_parametrize
|
||||
|
||||
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.parametrize('config', ['default'], indirect=True)
|
||||
@idf_parametrize('target', ['supported_targets'], indirect=['target'])
|
||||
def test_minimal_baseline_boots(dut: IdfDut) -> None:
|
||||
dut.expect_exact('minimal_baseline app_main started', timeout=30)
|
||||
@@ -0,0 +1 @@
|
||||
# App-specific defaults for minimal_baseline size metrics
|
||||
Reference in New Issue
Block a user