forked from espressif/esp-idf
feat(wpa_supplicant): migrate the tests from unit-test-app
This commit is contained in:
@@ -1,14 +0,0 @@
|
|||||||
idf_component_register(SRC_DIRS "."
|
|
||||||
PRIV_INCLUDE_DIRS "." "${CMAKE_CURRENT_BINARY_DIR}"
|
|
||||||
PRIV_INCLUDE_DIRS "../src" "../esp_supplicant/src"
|
|
||||||
PRIV_REQUIRES cmock esp_common test_utils wpa_supplicant mbedtls esp_wifi esp_event)
|
|
||||||
|
|
||||||
idf_component_get_property(esp_supplicant_dir wpa_supplicant COMPONENT_DIR)
|
|
||||||
|
|
||||||
# Calculate MD5 value of header file esp_wifi_driver.h
|
|
||||||
file(MD5 ${esp_supplicant_dir}/esp_supplicant/src/esp_wifi_driver.h WIFI_SUPPLICANT_MD5)
|
|
||||||
string(SUBSTRING "${WIFI_SUPPLICANT_MD5}" 0 7 WIFI_SUPPLICANT_MD5)
|
|
||||||
|
|
||||||
add_definitions(-DWIFI_SUPPLICANT_MD5=\"${WIFI_SUPPLICANT_MD5}\")
|
|
||||||
add_definitions(-DCONFIG_WPA3_SAE)
|
|
||||||
add_definitions(-DCONFIG_DPP)
|
|
11
components/wpa_supplicant/test_apps/.build-test-rules.yml
Normal file
11
components/wpa_supplicant/test_apps/.build-test-rules.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||||
|
|
||||||
|
components/wpa_supplicant/test_apps:
|
||||||
|
disable:
|
||||||
|
- if: SOC_WIFI_SUPPORTED != 1
|
||||||
|
depends_components:
|
||||||
|
- esp_wifi
|
||||||
|
- wpa_supplicant
|
||||||
|
- mbedtls
|
||||||
|
- esp_timer
|
||||||
|
- esp_event
|
9
components/wpa_supplicant/test_apps/CMakeLists.txt
Normal file
9
components/wpa_supplicant/test_apps/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
set(COMPONENTS main)
|
||||||
|
list(PREPEND SDKCONFIG_DEFAULTS
|
||||||
|
"$ENV{IDF_PATH}/tools/test_apps/configs/sdkconfig.debug_helpers"
|
||||||
|
"sdkconfig.defaults")
|
||||||
|
|
||||||
|
project(wpa_supplicant_test)
|
19
components/wpa_supplicant/test_apps/README.md
Normal file
19
components/wpa_supplicant/test_apps/README.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-S2 | ESP32-S3 |
|
||||||
|
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- |
|
||||||
|
|
||||||
|
# wpa_supplicant unit test
|
||||||
|
|
||||||
|
To build and run this test app, using esp32s3 target for example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
idf.py set-target esp32s3
|
||||||
|
idf.py build flash monitor
|
||||||
|
```
|
||||||
|
|
||||||
|
To run tests using pytest:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
idf.py set-target esp32s3
|
||||||
|
idf.py build
|
||||||
|
pytest --target=esp32s3
|
||||||
|
```
|
25
components/wpa_supplicant/test_apps/main/CMakeLists.txt
Normal file
25
components/wpa_supplicant/test_apps/main/CMakeLists.txt
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
idf_component_register(SRCS
|
||||||
|
"test_crypto.c"
|
||||||
|
"test_dpp.c"
|
||||||
|
"test_eloop.c"
|
||||||
|
"test_fast_pbkdf2.c"
|
||||||
|
"test_offchannel.c"
|
||||||
|
"test_sae.c"
|
||||||
|
"test_wpa_supplicant_main.c"
|
||||||
|
PRIV_INCLUDE_DIRS "."
|
||||||
|
PRIV_REQUIRES wpa_supplicant mbedtls esp_wifi esp_event unity
|
||||||
|
WHOLE_ARCHIVE)
|
||||||
|
|
||||||
|
idf_component_get_property(esp_supplicant_dir wpa_supplicant COMPONENT_DIR)
|
||||||
|
|
||||||
|
# Calculate MD5 value of header file esp_wifi_driver.h
|
||||||
|
file(MD5 ${esp_supplicant_dir}/esp_supplicant/src/esp_wifi_driver.h WIFI_SUPPLICANT_MD5)
|
||||||
|
string(SUBSTRING "${WIFI_SUPPLICANT_MD5}" 0 7 WIFI_SUPPLICANT_MD5)
|
||||||
|
|
||||||
|
# Steal some private include directories from wpa_supplicant
|
||||||
|
target_include_directories(${COMPONENT_LIB} PRIVATE ${esp_supplicant_dir}/esp_supplicant/src)
|
||||||
|
target_include_directories(${COMPONENT_LIB} PRIVATE ${esp_supplicant_dir}/src)
|
||||||
|
|
||||||
|
add_definitions(-DWIFI_SUPPLICANT_MD5=\"${WIFI_SUPPLICANT_MD5}\")
|
||||||
|
add_definitions(-DCONFIG_WPA3_SAE)
|
||||||
|
add_definitions(-DCONFIG_DPP)
|
@@ -0,0 +1,3 @@
|
|||||||
|
dependencies:
|
||||||
|
test_utils:
|
||||||
|
path: ${IDF_PATH}/tools/unit-test-app/components/test_utils
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*
|
*
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the leak threshold value for the specific test case
|
||||||
|
*
|
||||||
|
* @param threshold Maximum allowed memory leak in bytes
|
||||||
|
*/
|
||||||
|
void set_leak_threshold(int threshold);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "unity.h"
|
||||||
|
#include "unity_test_runner.h"
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
|
||||||
|
#define TEST_MEMORY_LEAK_THRESHOLD_DEFAULT 0
|
||||||
|
static int leak_threshold = TEST_MEMORY_LEAK_THRESHOLD_DEFAULT;
|
||||||
|
void set_leak_threshold(int threshold)
|
||||||
|
{
|
||||||
|
leak_threshold = -threshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
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, threshold %d)\n", type, before_free, after_free, delta, leak_threshold);
|
||||||
|
TEST_ASSERT_MESSAGE(delta > 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)
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
|
||||||
|
leak_threshold = TEST_MEMORY_LEAK_THRESHOLD_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
printf("Running wpa_supplicant component tests\n");
|
||||||
|
unity_run_menu();
|
||||||
|
}
|
@@ -0,0 +1,25 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from idf_unity_tester import CaseTester
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.generic
|
||||||
|
@pytest.mark.esp32
|
||||||
|
@pytest.mark.esp32s2
|
||||||
|
@pytest.mark.esp32s3
|
||||||
|
@pytest.mark.esp32c3
|
||||||
|
@pytest.mark.esp32c2
|
||||||
|
@pytest.mark.esp32c6
|
||||||
|
def test_wpa_supplicant_ut(dut: Dut) -> None:
|
||||||
|
dut.run_all_single_board_cases()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.esp32
|
||||||
|
@pytest.mark.wifi_two_dut
|
||||||
|
def test_wpa_supplicant_ut_offchan(case_tester: CaseTester) -> None:
|
||||||
|
for case in case_tester.test_menu:
|
||||||
|
if case.attributes.get('test_env') == 'wifi_two_dut':
|
||||||
|
case_tester.run_multi_dev_case(case=case, reset=True)
|
5
components/wpa_supplicant/test_apps/sdkconfig.defaults
Normal file
5
components/wpa_supplicant/test_apps/sdkconfig.defaults
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
|
||||||
|
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n
|
||||||
|
CONFIG_ESP_WIFI_TESTING_OPTIONS=y
|
||||||
|
CONFIG_ESP_WIFI_DPP_SUPPORT=y
|
||||||
|
CONFIG_WPA3_SAE=y
|
Reference in New Issue
Block a user