esp_netif/ci: Add test to verify dependencies to/from lwip/drivers

This commit is contained in:
David Cermak 2022-07-21 17:54:33 +02:00
parent 36f49f361c
commit 9806dff253
8 changed files with 129 additions and 0 deletions

View File

@ -44,6 +44,12 @@ tools/test_apps/protocols/mqtt/publish_connect_test:
temporary: true
reason: lack of runners
tools/test_apps/protocols/netif_components:
enable:
- if: IDF_TARGET == "esp32"
temporary: true
reason: one target is enough to verify netif component dependencies
tools/test_apps/security/secure_boot:
# disable:
# - if: SOC_SECURE_BOOT_SUPPORTED != 1

View File

@ -0,0 +1,64 @@
# For more information about build system see
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
# The following five 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(driver_components esp_eth esp_wifi openthread)
# Check manually if the ESP_NETIF is configured in sdkconfig
message(STATUS "Checking if sdkconfig contains CONFIG_TESTAPP_COMPONENT related config:")
set(config_file "${CMAKE_CURRENT_SOURCE_DIR}/sdkconfig")
if(EXISTS ${config_file})
# If the config file exists, check for the non-default settings - LWIP
# otherwise (file missing or defalut settings) go with ESP_NETIF
file(READ ${config_file} config_file_content)
string(FIND "${config_file_content}" "CONFIG_TESTAPP_COMPONENT_LWIP=y" match)
if(NOT ${match} EQUAL -1)
set(CONFIG_IS_LWIP 1)
endif()
endif()
if(CONFIG_IS_LWIP)
message(STATUS "CONFIG_TESTAPP_COMPONENT_ESP_LWIP")
set(component_under_test lwip)
set(expected_build_components lwip)
else()
message(STATUS "CONFIG_TESTAPP_COMPONENT_ESP_NETIF")
set(component_under_test esp_netif)
set(expected_build_components esp_netif lwip)
endif()
set(COMPONENTS ${component_under_test} main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
idf_build_set_property(__BUILD_COMPONENT_DEPGRAPH_ENABLED 1)
project(network_components)
# Get the actual build commponents included in the build
idf_build_get_property(build_components BUILD_COMPONENTS)
message(STATUS "Build components needed my main and ${component_under_test}:")
foreach(comp ${build_components})
message(STATUS "${comp}")
endforeach()
# Check for all driver components, these shall not be included
foreach(comp ${driver_components})
if(${comp} IN_LIST build_components)
message(FATAL_ERROR "Component ${comp} shall not be included when building only ${component_under_test}")
else()
message(STATUS "-> OK: ${comp} is not included when building only ${component_under_test}")
endif()
endforeach()
# Check for all needed components, these must be included
foreach(comp ${expected_build_components})
if(${comp} IN_LIST build_components)
message(STATUS "-> OK: ${comp} is pulled by ${component_under_test}")
else()
message(FATAL_ERROR "${comp} is expected by adding ${component_under_test}")
endif()
endforeach()

View File

@ -0,0 +1,28 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
# Networking component dependency
This test application checks the list of components included into the build when:
* `esp_netif` component is added to the build.
* `lwip` component is added to the build.
The test checks that driver components are not included in the build
# Using this test app
* Remove the build artifacts `idf.py fullclean`
* Choose the component to test (either `esp_netif` or `lwip`)
* Build the project `idf.py build`
# Troubleshooting
If you get a build error in this example, please check there's no dependency from the tested component (either `esp_netif` or `lwip`) to any defined driver component.
Please open the project `CMakeLists.txt` to view the expected dependencies and driver's components that must not be included in the list:
* CMake variable `driver_components` contains list of driver's components
* CMake variable `expected_build_components` contains list expected dependecies
Note that this project creates `component_deps.dot`, a simpified dependecy graph that could be used to display and troubleshoot component dependencies.
Note that this test is executed for one target only in CI (ESP32), but shall work correctly for all IDF supported targets.

View File

@ -0,0 +1,2 @@
idf_component_register(SRCS "netif_components.c"
INCLUDE_DIRS ".")

View File

@ -0,0 +1,16 @@
menu "TestApp Configuration"
choice TESTAPP_COMPONENT_TEST
prompt "Component under test"
help
Component for which we check their dependencies
config TESTAPP_COMPONENT_ESP_NETIF
bool "esp_netif"
config TESTAPP_COMPONENT_LWIP
bool "lwip"
endchoice
endmenu

View File

@ -0,0 +1,11 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
void app_main(void)
{
}

View File

@ -0,0 +1 @@
CONFIG_TESTAPP_COMPONENT_ESP_NETIF=y

View File

@ -0,0 +1 @@
CONFIG_TESTAPP_COMPONENT_LWIP=y