fix(lwip): Remove test-only Kconfig options

This commit is contained in:
David Cermak
2026-05-06 20:54:19 +02:00
parent b57a0f58fb
commit d8678b1d3d
6 changed files with 17 additions and 17 deletions
-8
View File
@@ -452,14 +452,6 @@ menu "LWIP"
Enabling this option allows DHCP server to support temporary static ARP entries Enabling this option allows DHCP server to support temporary static ARP entries
for DHCP Client. This will help the DHCP server to send the DHCP OFFER and DHCP ACK using IP unicast. for DHCP Client. This will help the DHCP server to send the DHCP OFFER and DHCP ACK using IP unicast.
config LWIP_DHCPS_TEST_PARSE_OPTIONS
bool "Expose parse_options() for unit testing"
default n
depends on LWIP_DHCPS
help
Enables a non-static wrapper around the internal parse_options() function
so it can be called from test code. Only enable this for testing builds.
endmenu # DHCPS endmenu # DHCPS
menuconfig LWIP_AUTOIP menuconfig LWIP_AUTOIP
+2 -2
View File
@@ -1731,7 +1731,7 @@ bool dhcps_get_hostname_on_mac(dhcps_t *dhcps, const u8_t *mac, char *out, size_
return false; return false;
} }
#endif #endif
#ifdef CONFIG_LWIP_DHCPS_TEST_PARSE_OPTIONS #if LWIP_DHCPS_TEST_PARSE_OPTIONS == 1
u8_t dhcps_test_parse_options(u8_t *optptr, s16_t len) u8_t dhcps_test_parse_options(u8_t *optptr, s16_t len)
{ {
dhcps_t *dhcps = dhcps_new(); dhcps_t *dhcps = dhcps_new();
@@ -1743,6 +1743,6 @@ u8_t dhcps_test_parse_options(u8_t *optptr, s16_t len)
mem_free(dhcps); mem_free(dhcps);
return result; return result;
} }
#endif #endif /* LWIP_DHCPS_TEST_PARSE_OPTIONS == 1 */
#endif // ESP_DHCPS #endif // ESP_DHCPS
+9 -1
View File
@@ -3,7 +3,7 @@
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
* SPDX-FileContributor: 2015-2025 Espressif Systems (Shanghai) CO LTD * SPDX-FileContributor: 2015-2026 Espressif Systems (Shanghai) CO LTD
*/ */
#ifndef LWIP_HDR_ESP_LWIPOPTS_H #ifndef LWIP_HDR_ESP_LWIPOPTS_H
#define LWIP_HDR_ESP_LWIPOPTS_H #define LWIP_HDR_ESP_LWIPOPTS_H
@@ -1707,6 +1707,14 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min)
#define ESP_DHCPS_TIMER 0 #define ESP_DHCPS_TIMER 0
#endif /* CONFIG_LWIP_DHCPS */ #endif /* CONFIG_LWIP_DHCPS */
/**
* LWIP_DHCPS_TEST_PARSE_OPTIONS==1: Expose dhcps_test_parse_options() in dhcpserver.c for
* unit tests. Default 0. Test projects may set -DLWIP_DHCPS_TEST_PARSE_OPTIONS=1
* (e.g. from CMake via idf_build_set_property) — do not use Kconfig for this.
*/
#ifndef LWIP_DHCPS_TEST_PARSE_OPTIONS
#define LWIP_DHCPS_TEST_PARSE_OPTIONS 0
#endif
#if LWIP_NETCONN_SEM_PER_THREAD #if LWIP_NETCONN_SEM_PER_THREAD
#define LWIP_NETCONN_THREAD_SEM_GET() sys_thread_sem_get() #define LWIP_NETCONN_THREAD_SEM_GET() sys_thread_sem_get()
+3
View File
@@ -5,4 +5,7 @@ set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/test_apps/components")
set(COMPONENTS main) set(COMPONENTS main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
# Test-only: enable DHCP options parser test hook in lwip (set before project() so
# all components pick up the compile definition; not in Kconfig)
idf_build_set_property(COMPILE_DEFINITIONS "LWIP_DHCPS_TEST_PARSE_OPTIONS=1" APPEND)
project(lwip_test) project(lwip_test)
+3 -3
View File
@@ -492,7 +492,7 @@ TEST(lwip, sntp_client_time_2048)
* truncated, and malformed inputs. * truncated, and malformed inputs.
*/ */
#ifdef CONFIG_LWIP_DHCPS_TEST_PARSE_OPTIONS #if LWIP_DHCPS_TEST_PARSE_OPTIONS
extern u8_t dhcps_test_parse_options(u8_t *optptr, s16_t len); extern u8_t dhcps_test_parse_options(u8_t *optptr, s16_t len);
@@ -610,7 +610,7 @@ TEST(lwip, dhcps_parse_options_req_ipaddr_truncated)
TEST_ASSERT(state != 0); TEST_ASSERT(state != 0);
} }
#endif /* CONFIG_LWIP_DHCPS_TEST_PARSE_OPTIONS */ #endif /* LWIP_DHCPS_TEST_PARSE_OPTIONS */
TEST_GROUP_RUNNER(lwip) TEST_GROUP_RUNNER(lwip)
{ {
@@ -621,7 +621,7 @@ TEST_GROUP_RUNNER(lwip)
RUN_TEST_CASE(lwip, sntp_client_time_2015) RUN_TEST_CASE(lwip, sntp_client_time_2015)
RUN_TEST_CASE(lwip, sntp_client_time_2048) RUN_TEST_CASE(lwip, sntp_client_time_2048)
RUN_TEST_CASE(lwip, dhcp_arp_probe_self_mac_is_ok) RUN_TEST_CASE(lwip, dhcp_arp_probe_self_mac_is_ok)
#ifdef CONFIG_LWIP_DHCPS_TEST_PARSE_OPTIONS #if LWIP_DHCPS_TEST_PARSE_OPTIONS
RUN_TEST_CASE(lwip, dhcps_parse_options_well_formed_discover) RUN_TEST_CASE(lwip, dhcps_parse_options_well_formed_discover)
RUN_TEST_CASE(lwip, dhcps_parse_options_well_formed_request_ack) RUN_TEST_CASE(lwip, dhcps_parse_options_well_formed_request_ack)
RUN_TEST_CASE(lwip, dhcps_parse_options_pad_bytes_skipped) RUN_TEST_CASE(lwip, dhcps_parse_options_pad_bytes_skipped)
@@ -3,6 +3,3 @@ CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n
# Added to enable compilation of DHCP last IP restore feature # Added to enable compilation of DHCP last IP restore feature
CONFIG_LWIP_DHCP_RESTORE_LAST_IP=y CONFIG_LWIP_DHCP_RESTORE_LAST_IP=y
# Expose DHCP server option parser for unit testing
CONFIG_LWIP_DHCPS_TEST_PARSE_OPTIONS=y