diff --git a/tools/test_apps/.build-test-rules.yml b/tools/test_apps/.build-test-rules.yml index b93515d9f3..c57cb458fa 100644 --- a/tools/test_apps/.build-test-rules.yml +++ b/tools/test_apps/.build-test-rules.yml @@ -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 diff --git a/tools/test_apps/protocols/netif_components/CMakeLists.txt b/tools/test_apps/protocols/netif_components/CMakeLists.txt new file mode 100644 index 0000000000..3908b881f3 --- /dev/null +++ b/tools/test_apps/protocols/netif_components/CMakeLists.txt @@ -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() diff --git a/tools/test_apps/protocols/netif_components/README.md b/tools/test_apps/protocols/netif_components/README.md new file mode 100644 index 0000000000..14a15f8017 --- /dev/null +++ b/tools/test_apps/protocols/netif_components/README.md @@ -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. diff --git a/tools/test_apps/protocols/netif_components/main/CMakeLists.txt b/tools/test_apps/protocols/netif_components/main/CMakeLists.txt new file mode 100644 index 0000000000..f7aed4f8bc --- /dev/null +++ b/tools/test_apps/protocols/netif_components/main/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "netif_components.c" + INCLUDE_DIRS ".") diff --git a/tools/test_apps/protocols/netif_components/main/Kconfig.projbuild b/tools/test_apps/protocols/netif_components/main/Kconfig.projbuild new file mode 100644 index 0000000000..f3575e5bdf --- /dev/null +++ b/tools/test_apps/protocols/netif_components/main/Kconfig.projbuild @@ -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 diff --git a/tools/test_apps/protocols/netif_components/main/netif_components.c b/tools/test_apps/protocols/netif_components/main/netif_components.c new file mode 100644 index 0000000000..c104b5973d --- /dev/null +++ b/tools/test_apps/protocols/netif_components/main/netif_components.c @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include + +void app_main(void) +{ + +} diff --git a/tools/test_apps/protocols/netif_components/sdkconfig.ci.esp_netif b/tools/test_apps/protocols/netif_components/sdkconfig.ci.esp_netif new file mode 100644 index 0000000000..550b6099a8 --- /dev/null +++ b/tools/test_apps/protocols/netif_components/sdkconfig.ci.esp_netif @@ -0,0 +1 @@ +CONFIG_TESTAPP_COMPONENT_ESP_NETIF=y diff --git a/tools/test_apps/protocols/netif_components/sdkconfig.ci.lwip b/tools/test_apps/protocols/netif_components/sdkconfig.ci.lwip new file mode 100644 index 0000000000..b4ef2787d1 --- /dev/null +++ b/tools/test_apps/protocols/netif_components/sdkconfig.ci.lwip @@ -0,0 +1 @@ +CONFIG_TESTAPP_COMPONENT_LWIP=y