Skip to content

Commit 565cca2

Browse files
committed
Merge branch 'ci/add_size_check_for_wifi_configs' into 'master'
ci: add compare wifi bin size between different components See merge request espressif/esp-idf!38499
2 parents 386a390 + 685a6d4 commit 565cca2

File tree

10 files changed

+133
-5
lines changed

10 files changed

+133
-5
lines changed
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
22

3-
components/esp_wifi/test_apps/wifi_connect:
4-
disable:
5-
- if: SOC_WIFI_SUPPORTED != 1
6-
7-
components/esp_wifi/test_apps/wifi_function:
3+
components/esp_wifi/test_apps/:
84
disable:
95
- if: SOC_WIFI_SUPPORTED != 1
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The following five lines of boilerplate have to be in your project's
2+
# CMakeLists in this exact order for cmake to work correctly
3+
cmake_minimum_required(VERSION 3.16)
4+
5+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
6+
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
7+
idf_build_set_property(MINIMAL_BUILD ON)
8+
project(bin_size)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 |
2+
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- |
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
idf_component_register(SRCS "main.c"
2+
PRIV_REQUIRES esp_wifi nvs_flash
3+
INCLUDE_DIRS ".")
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Unlicense OR CC0-1.0
5+
*/
6+
7+
#include <string.h>
8+
#include "esp_wifi.h"
9+
#include "esp_event.h"
10+
#include "esp_log.h"
11+
#include "nvs_flash.h"
12+
13+
static const char *TAG = "wifi-bin-size";
14+
15+
void app_main(void)
16+
{
17+
//Initialize NVS
18+
esp_err_t ret = nvs_flash_init();
19+
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
20+
ESP_ERROR_CHECK(nvs_flash_erase());
21+
ret = nvs_flash_init();
22+
}
23+
ESP_ERROR_CHECK(ret);
24+
25+
ESP_ERROR_CHECK(esp_netif_init());
26+
ESP_ERROR_CHECK(esp_event_loop_create_default());
27+
esp_netif_create_default_wifi_ap();
28+
esp_netif_create_default_wifi_sta();
29+
30+
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
31+
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
32+
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA));
33+
ESP_ERROR_CHECK(esp_wifi_start());
34+
35+
ESP_LOGI(TAG, "wifi_init finished.");
36+
ESP_LOGI(TAG, "FREE_HEAP_SIZE: %u", esp_get_free_heap_size());
37+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
2+
# SPDX-License-Identifier: Unlicense OR CC0-1.0
3+
import os
4+
from typing import Callable
5+
from typing import Tuple
6+
7+
import pytest
8+
from pytest_embedded import Dut
9+
from pytest_embedded_idf.utils import idf_parametrize
10+
11+
# The standard value has 30~100 bytes fault tolerance
12+
SAVE_BIN_SIZE_TH = {
13+
'disable_sae_h2e': {
14+
'esp32': 16800,
15+
'esp32c2': 19700,
16+
'esp32c3': 19600,
17+
'esp32c5': 19650,
18+
'esp32c6': 19650,
19+
'esp32c61': 19700,
20+
'esp32s2': 16600,
21+
'esp32s3': 16550,
22+
'default': 16000,
23+
},
24+
'disable_nan': {
25+
'esp32': 29600,
26+
'esp32c5': 32400,
27+
'esp32c61': 32400,
28+
'esp32s2': 28000,
29+
# other chips does not support nan
30+
'default': 0,
31+
},
32+
}
33+
34+
35+
def _get_diff_th(
36+
config_name: str,
37+
target: str,
38+
) -> int:
39+
assert config_name in SAVE_BIN_SIZE_TH
40+
diff_threshold = SAVE_BIN_SIZE_TH[config_name]
41+
return diff_threshold.get(target) or diff_threshold['default']
42+
43+
44+
@pytest.mark.wifi_two_dut
45+
@pytest.mark.parametrize(
46+
'count, config, skip_autoflash',
47+
[
48+
(2, 'default|disable_sae_h2e', 'y'),
49+
(2, 'default|enable_nan', 'y'),
50+
],
51+
indirect=True,
52+
)
53+
@idf_parametrize(
54+
'target',
55+
['esp32', 'esp32c2', 'esp32c3', 'esp32s2', 'esp32s3', 'esp32c5', 'esp32c6', 'esp32c61'],
56+
indirect=['target'],
57+
)
58+
def test_wifi_bin_size_apsta(
59+
dut: Tuple[Dut, Dut],
60+
config: Tuple[str, str],
61+
log_performance: Callable[[str, object], None],
62+
) -> None:
63+
# dut logs are not needed
64+
dut[0].serial.close()
65+
dut[1].serial.close()
66+
target = dut[0].target
67+
config_name = config[1]
68+
69+
app_default = dut[0].app
70+
app_config = dut[1].app
71+
72+
diff = os.path.getsize(app_default.bin_file) - os.path.getsize(app_config.bin_file)
73+
if 'enable' in config_name:
74+
# always log disable-xxx performance
75+
config_name = config_name.replace('enable', 'disable')
76+
diff = -diff
77+
log_performance(f'wifi_{config_name}_save_bin_size', f'{diff} bytes')
78+
79+
diff_threshold = _get_diff_th(config_name, target)
80+
assert diff >= diff_threshold

components/esp_wifi/test_apps/bin_size_apsta/sdkconfig.ci.default

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_ESP_WIFI_ENABLE_SAE_H2E=n
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_ESP_WIFI_NAN_ENABLE=y

components/esp_wifi/test_apps/bin_size_apsta/sdkconfig.defaults

Whitespace-only changes.

0 commit comments

Comments
 (0)