[Openvpn-devel] [M] Change in openvpn[master]: test_dhcp: Start a dhcp helper functions UT
Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email to review the following change. Change subject: test_dhcp: Start a dhcp helper functions UT .. test_dhcp: Start a dhcp helper functions UT Use extra define to allow testing code only used on Windows but not actually dependent on Windows. Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615 Signed-off-by: Frank Lichtenheld --- M CMakeLists.txt M src/openvpn/dhcp.c M src/openvpn/dhcp.h M src/openvpn/tun.h M tests/unit_tests/openvpn/Makefile.am M tests/unit_tests/openvpn/mock_msg.h A tests/unit_tests/openvpn/test_dhcp.c 7 files changed, 154 insertions(+), 4 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/67/1267/1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 37bfc03..811a324 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -658,6 +658,7 @@ "test_auth_token" "test_buffer" "test_crypto" +"test_dhcp" "test_misc" "test_ncp" "test_packet_id" @@ -918,6 +919,11 @@ ) endif () +target_compile_definitions(test_dhcp PRIVATE DHCP_UNIT_TEST) +target_sources(test_dhcp PRIVATE +tests/unit_tests/openvpn/mock_get_random.c +) + if (TARGET test_networking) target_link_options(test_networking PRIVATE -Wl,--wrap=parse_line) target_compile_options(test_networking PRIVATE -UNDEBUG) diff --git a/src/openvpn/dhcp.c b/src/openvpn/dhcp.c index 56f03f2..0893ec7 100644 --- a/src/openvpn/dhcp.c +++ b/src/openvpn/dhcp.c @@ -186,7 +186,7 @@ return 0; } -#if defined(_WIN32) +#if defined(_WIN32) || defined(DHCP_UNIT_TEST) #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push diff --git a/src/openvpn/dhcp.h b/src/openvpn/dhcp.h index 3fcd2b6..2ad31a6 100644 --- a/src/openvpn/dhcp.h +++ b/src/openvpn/dhcp.h @@ -93,7 +93,7 @@ in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf); -#if defined(_WIN32) +#if defined(_WIN32) || defined(DHCP_UNIT_TEST) #include "tun.h" bool build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o); diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index 6562c22..741798d 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -59,7 +59,7 @@ #define DCO_WIN_REFERENCE_STRING "ovpn-dco" #endif -#if defined(_WIN32) || defined(TARGET_ANDROID) +#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST) #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1) diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/Makefile.am index 8e94665..79987ad 100644 --- a/tests/unit_tests/openvpn/Makefile.am +++ b/tests/unit_tests/openvpn/Makefile.am @@ -4,7 +4,7 @@ AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests' -test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \ +test_binaries = argv_testdriver buffer_testdriver crypto_testdriver dhcp_testdriver packet_id_testdriver auth_token_testdriver \ ncp_testdriver misc_testdriver pkt_testdriver ssl_testdriver \ user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver @@ -71,6 +71,15 @@ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/openvpn/mss.c +dhcp_testdriver_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST +dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn +dhcp_testdriver_SOURCES = test_dhcp.c \ + mock_msg.c mock_msg.h test_common.h \ + mock_get_random.c \ + $(top_srcdir)/src/openvpn/platform.c \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/win32-util.c + ssl_testdriver_CFLAGS = \ -I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \ @TEST_CFLAGS@ diff --git a/tests/unit_tests/openvpn/mock_msg.h b/tests/unit_tests/openvpn/mock_msg.h index c6321dc..62afde5 100644 --- a/tests/unit_tests/openvpn/mock_msg.h +++ b/tests/unit_tests/openvpn/mock_msg.h @@ -23,6 +23,8 @@ #ifndef MOCK_MSG_H #define MOCK_MSG_H +#include "error.h" + /** * Mock debug level defaults to 0, which gives clean(-ish) test reports. Call * this function from your test driver to increase debug output when you diff --git a/tests/unit_tests/openvpn/test_dhcp.c b/tests/unit_tests/openvpn/test_dhcp.c new file mode 100644 index 000..1219a7e --- /dev/null +++ b/tests/unit_tests/openvpn/test_dhcp.c @@ -0,0 +1,133 @@ +/* + * OpenVPN -- An application to securely tunnel IP networks + * over a single UDP port, with support for SSL/TLS-based + * session authentication and key exchange, + * packet encryption, packet authentication, and + * packet compressio
[Openvpn-devel] [M] Change in openvpn[master]: test_dhcp: Start a dhcp helper functions UT
Attention is currently required from: flichtenheld, plaisthos. Hello cron2, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email to look at the new patch set (#4). Change subject: test_dhcp: Start a dhcp helper functions UT .. test_dhcp: Start a dhcp helper functions UT Use extra define to allow testing code only used on Windows but not actually dependent on Windows. Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615 Signed-off-by: Frank Lichtenheld --- M CMakeLists.txt M src/openvpn/dhcp.c M src/openvpn/dhcp.h M src/openvpn/tun.h M tests/unit_tests/openvpn/Makefile.am M tests/unit_tests/openvpn/mock_msg.h A tests/unit_tests/openvpn/test_dhcp.c 7 files changed, 155 insertions(+), 4 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/67/1267/4 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e0b46e..b773dcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -658,6 +658,7 @@ "test_auth_token" "test_buffer" "test_crypto" +"test_dhcp" "test_misc" "test_ncp" "test_options_parse" @@ -910,6 +911,11 @@ ) endif () +target_compile_definitions(test_dhcp PRIVATE DHCP_UNIT_TEST) +target_sources(test_dhcp PRIVATE +tests/unit_tests/openvpn/mock_get_random.c +) + if (TARGET test_networking) target_link_options(test_networking PRIVATE -Wl,--wrap=parse_line) target_compile_options(test_networking PRIVATE -UNDEBUG) diff --git a/src/openvpn/dhcp.c b/src/openvpn/dhcp.c index 56f03f2..0893ec7 100644 --- a/src/openvpn/dhcp.c +++ b/src/openvpn/dhcp.c @@ -186,7 +186,7 @@ return 0; } -#if defined(_WIN32) +#if defined(_WIN32) || defined(DHCP_UNIT_TEST) #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push diff --git a/src/openvpn/dhcp.h b/src/openvpn/dhcp.h index 3fcd2b6..2ad31a6 100644 --- a/src/openvpn/dhcp.h +++ b/src/openvpn/dhcp.h @@ -93,7 +93,7 @@ in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf); -#if defined(_WIN32) +#if defined(_WIN32) || defined(DHCP_UNIT_TEST) #include "tun.h" bool build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o); diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index 6562c22..741798d 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -59,7 +59,7 @@ #define DCO_WIN_REFERENCE_STRING "ovpn-dco" #endif -#if defined(_WIN32) || defined(TARGET_ANDROID) +#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST) #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1) diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/Makefile.am index 50f4a11..17aa0ce 100644 --- a/tests/unit_tests/openvpn/Makefile.am +++ b/tests/unit_tests/openvpn/Makefile.am @@ -6,7 +6,7 @@ AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt; -test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \ +test_binaries = argv_testdriver buffer_testdriver crypto_testdriver dhcp_testdriver packet_id_testdriver auth_token_testdriver \ ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \ user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver @@ -72,6 +72,15 @@ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/openvpn/mss.c +dhcp_testdriver_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST +dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn +dhcp_testdriver_SOURCES = test_dhcp.c \ + mock_msg.c mock_msg.h test_common.h \ + mock_get_random.c \ + $(top_srcdir)/src/openvpn/platform.c \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/win32-util.c + ssl_testdriver_CFLAGS = \ -I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \ @TEST_CFLAGS@ diff --git a/tests/unit_tests/openvpn/mock_msg.h b/tests/unit_tests/openvpn/mock_msg.h index c6321dc..62afde5 100644 --- a/tests/unit_tests/openvpn/mock_msg.h +++ b/tests/unit_tests/openvpn/mock_msg.h @@ -23,6 +23,8 @@ #ifndef MOCK_MSG_H #define MOCK_MSG_H +#include "error.h" + /** * Mock debug level defaults to 0, which gives clean(-ish) test reports. Call * this function from your test driver to increase debug output when you diff --git a/tests/unit_tests/openvpn/test_dhcp.c b/tests/unit_tests/openvpn/test_dhcp.c new file mode 100644 index 000..729ca58 --- /dev/null +++ b/tests/unit_tests/openvpn/test_dhcp.c @@ -0,0 +1,134 @@ +/* + * OpenVPN -- An application to securely tunnel IP networks + * over a single UDP port, with support for SSL/TLS-based + * session authentication and key exchange, + * p
[Openvpn-devel] [M] Change in openvpn[master]: test_dhcp: Start a dhcp helper functions UT
Attention is currently required from: flichtenheld, plaisthos. Hello cron2, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email to look at the new patch set (#2). Change subject: test_dhcp: Start a dhcp helper functions UT .. test_dhcp: Start a dhcp helper functions UT Use extra define to allow testing code only used on Windows but not actually dependent on Windows. Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615 Signed-off-by: Frank Lichtenheld --- M CMakeLists.txt M src/openvpn/dhcp.c M src/openvpn/dhcp.h M src/openvpn/tun.h M tests/unit_tests/openvpn/Makefile.am M tests/unit_tests/openvpn/mock_msg.h A tests/unit_tests/openvpn/test_dhcp.c 7 files changed, 154 insertions(+), 4 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/67/1267/2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e0b46e..b773dcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -658,6 +658,7 @@ "test_auth_token" "test_buffer" "test_crypto" +"test_dhcp" "test_misc" "test_ncp" "test_options_parse" @@ -910,6 +911,11 @@ ) endif () +target_compile_definitions(test_dhcp PRIVATE DHCP_UNIT_TEST) +target_sources(test_dhcp PRIVATE +tests/unit_tests/openvpn/mock_get_random.c +) + if (TARGET test_networking) target_link_options(test_networking PRIVATE -Wl,--wrap=parse_line) target_compile_options(test_networking PRIVATE -UNDEBUG) diff --git a/src/openvpn/dhcp.c b/src/openvpn/dhcp.c index 56f03f2..0893ec7 100644 --- a/src/openvpn/dhcp.c +++ b/src/openvpn/dhcp.c @@ -186,7 +186,7 @@ return 0; } -#if defined(_WIN32) +#if defined(_WIN32) || defined(DHCP_UNIT_TEST) #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push diff --git a/src/openvpn/dhcp.h b/src/openvpn/dhcp.h index 3fcd2b6..2ad31a6 100644 --- a/src/openvpn/dhcp.h +++ b/src/openvpn/dhcp.h @@ -93,7 +93,7 @@ in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf); -#if defined(_WIN32) +#if defined(_WIN32) || defined(DHCP_UNIT_TEST) #include "tun.h" bool build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o); diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index 6562c22..741798d 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -59,7 +59,7 @@ #define DCO_WIN_REFERENCE_STRING "ovpn-dco" #endif -#if defined(_WIN32) || defined(TARGET_ANDROID) +#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST) #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1) diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/Makefile.am index 50f4a11..17aa0ce 100644 --- a/tests/unit_tests/openvpn/Makefile.am +++ b/tests/unit_tests/openvpn/Makefile.am @@ -6,7 +6,7 @@ AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt; -test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \ +test_binaries = argv_testdriver buffer_testdriver crypto_testdriver dhcp_testdriver packet_id_testdriver auth_token_testdriver \ ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \ user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver @@ -72,6 +72,15 @@ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/openvpn/mss.c +dhcp_testdriver_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST +dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn +dhcp_testdriver_SOURCES = test_dhcp.c \ + mock_msg.c mock_msg.h test_common.h \ + mock_get_random.c \ + $(top_srcdir)/src/openvpn/platform.c \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/win32-util.c + ssl_testdriver_CFLAGS = \ -I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \ @TEST_CFLAGS@ diff --git a/tests/unit_tests/openvpn/mock_msg.h b/tests/unit_tests/openvpn/mock_msg.h index c6321dc..62afde5 100644 --- a/tests/unit_tests/openvpn/mock_msg.h +++ b/tests/unit_tests/openvpn/mock_msg.h @@ -23,6 +23,8 @@ #ifndef MOCK_MSG_H #define MOCK_MSG_H +#include "error.h" + /** * Mock debug level defaults to 0, which gives clean(-ish) test reports. Call * this function from your test driver to increase debug output when you diff --git a/tests/unit_tests/openvpn/test_dhcp.c b/tests/unit_tests/openvpn/test_dhcp.c new file mode 100644 index 000..e645133 --- /dev/null +++ b/tests/unit_tests/openvpn/test_dhcp.c @@ -0,0 +1,133 @@ +/* + * OpenVPN -- An application to securely tunnel IP networks + * over a single UDP port, with support for SSL/TLS-based + * session authentication and key exchange, + * p
[Openvpn-devel] [M] Change in openvpn[master]: test_dhcp: Start a dhcp helper functions UT
Attention is currently required from: cron2, plaisthos. flichtenheld has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email ) Change subject: test_dhcp: Start a dhcp helper functions UT .. Patch Set 4: (1 comment) Patchset: PS1: > ``` […] Done -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615 Gerrit-Change-Number: 1267 Gerrit-PatchSet: 4 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: cron2 Gerrit-Comment-Date: Mon, 13 Oct 2025 15:20:40 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: cron2 ___ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
[Openvpn-devel] [M] Change in openvpn[master]: test_dhcp: Start a dhcp helper functions UT
Attention is currently required from: flichtenheld, plaisthos. cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email ) Change subject: test_dhcp: Start a dhcp helper functions UT .. Patch Set 4: Code-Review+2 -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615 Gerrit-Change-Number: 1267 Gerrit-PatchSet: 4 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-Comment-Date: Mon, 13 Oct 2025 15:47:41 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes ___ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
[Openvpn-devel] [M] Change in openvpn[master]: test_dhcp: Start a dhcp helper functions UT
cron2 has uploaded a new patch set (#5) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: test_dhcp: Start a dhcp helper functions UT .. test_dhcp: Start a dhcp helper functions UT Use extra define to allow testing code only used on Windows but not actually dependent on Windows. Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1267 Message-Id: <[email protected]> URL: https://sourceforge.net/p/openvpn/mailman/message/59246199/ Signed-off-by: Gert Doering --- M CMakeLists.txt M src/openvpn/dhcp.c M src/openvpn/dhcp.h M src/openvpn/tun.h M tests/unit_tests/openvpn/Makefile.am M tests/unit_tests/openvpn/mock_msg.h A tests/unit_tests/openvpn/test_dhcp.c 7 files changed, 155 insertions(+), 4 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/67/1267/5 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e0b46e..b773dcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -658,6 +658,7 @@ "test_auth_token" "test_buffer" "test_crypto" +"test_dhcp" "test_misc" "test_ncp" "test_options_parse" @@ -910,6 +911,11 @@ ) endif () +target_compile_definitions(test_dhcp PRIVATE DHCP_UNIT_TEST) +target_sources(test_dhcp PRIVATE +tests/unit_tests/openvpn/mock_get_random.c +) + if (TARGET test_networking) target_link_options(test_networking PRIVATE -Wl,--wrap=parse_line) target_compile_options(test_networking PRIVATE -UNDEBUG) diff --git a/src/openvpn/dhcp.c b/src/openvpn/dhcp.c index 56f03f2..0893ec7 100644 --- a/src/openvpn/dhcp.c +++ b/src/openvpn/dhcp.c @@ -186,7 +186,7 @@ return 0; } -#if defined(_WIN32) +#if defined(_WIN32) || defined(DHCP_UNIT_TEST) #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push diff --git a/src/openvpn/dhcp.h b/src/openvpn/dhcp.h index 3fcd2b6..2ad31a6 100644 --- a/src/openvpn/dhcp.h +++ b/src/openvpn/dhcp.h @@ -93,7 +93,7 @@ in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf); -#if defined(_WIN32) +#if defined(_WIN32) || defined(DHCP_UNIT_TEST) #include "tun.h" bool build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o); diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index 6562c22..741798d 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -59,7 +59,7 @@ #define DCO_WIN_REFERENCE_STRING "ovpn-dco" #endif -#if defined(_WIN32) || defined(TARGET_ANDROID) +#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST) #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1) diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/Makefile.am index 50f4a11..17aa0ce 100644 --- a/tests/unit_tests/openvpn/Makefile.am +++ b/tests/unit_tests/openvpn/Makefile.am @@ -6,7 +6,7 @@ AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt; -test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \ +test_binaries = argv_testdriver buffer_testdriver crypto_testdriver dhcp_testdriver packet_id_testdriver auth_token_testdriver \ ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \ user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver @@ -72,6 +72,15 @@ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/openvpn/mss.c +dhcp_testdriver_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST +dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn +dhcp_testdriver_SOURCES = test_dhcp.c \ + mock_msg.c mock_msg.h test_common.h \ + mock_get_random.c \ + $(top_srcdir)/src/openvpn/platform.c \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/win32-util.c + ssl_testdriver_CFLAGS = \ -I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \ @TEST_CFLAGS@ diff --git a/tests/unit_tests/openvpn/mock_msg.h b/tests/unit_tests/openvpn/mock_msg.h index c6321dc..62afde5 100644 --- a/tests/unit_tests/openvpn/mock_msg.h +++ b/tests/unit_tests/openvpn/mock_msg.h @@ -23,6 +23,8 @@ #ifndef MOCK_MSG_H #define MOCK_MSG_H +#include "error.h" + /** * Mock debug level defaults to 0, which gives clean(-ish) test reports. Call * this function from your test driver to increase debug output when you diff --git a/tests/unit_tests/openvpn/test_dhcp.c b/tests/unit_tests/openvpn/test_dhcp.c new file mode 100644 index 000..729ca58 --- /dev/null +++ b/tests/unit_tests/openvpn/test_dhcp.c @@
[Openvpn-devel] [M] Change in openvpn[master]: test_dhcp: Start a dhcp helper functions UT
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by flichtenheld. (
http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email )
Change subject: test_dhcp: Start a dhcp helper functions UT
..
Patch Set 1: Code-Review-2
(1 comment)
Patchset:
PS1:
```
test_dhcp.c: In function ‘test_write_dhcp_search_str’:
test_dhcp.c:71:83: error: \x used with no following hex digits
71 | const char output_1[27] =
"\x77\x1a\x07openvpn\x03net\x00\x07openvpn\x{03}com";
|
^
test_dhcp.c:71:31: error: initializer-string for array of ‘char’ is too long
[-Werror]
71 | const char output_1[27] =
"\x77\x1a\x07openvpn\x03net\x00\x07openvpn\x{03}com";
|
^~~~
test_dhcp.c:116:64: error: \x used with no following hex digits
116 | const char output_5[15] = "\x77\x0d\x03sub\x00\x{06}domain";
|^
test_dhcp.c:116:31: error: initializer-string for array of ‘char’ is too long
[-Werror]
116 | const char output_5[15] = "\x77\x0d\x03sub\x00\x{06}domain";
| ^
cc1: all warnings being treated as errors
make[2]: *** [Makefile:3164: dhcp_testdriver-test_dhcp.o] Error 1
```
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email
To unsubscribe, or for help writing mail filters, visit
http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615
Gerrit-Change-Number: 1267
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld
Gerrit-Reviewer: cron2
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-Attention: plaisthos
Gerrit-Attention: flichtenheld
Gerrit-Comment-Date: Sat, 11 Oct 2025 09:06:22 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
___
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
[Openvpn-devel] [M] Change in openvpn[master]: test_dhcp: Start a dhcp helper functions UT
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email ) Change subject: test_dhcp: Start a dhcp helper functions UT .. test_dhcp: Start a dhcp helper functions UT Use extra define to allow testing code only used on Windows but not actually dependent on Windows. Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1267 Message-Id: <[email protected]> URL: https://sourceforge.net/p/openvpn/mailman/message/59246199/ Signed-off-by: Gert Doering --- M CMakeLists.txt M src/openvpn/dhcp.c M src/openvpn/dhcp.h M src/openvpn/tun.h M tests/unit_tests/openvpn/Makefile.am M tests/unit_tests/openvpn/mock_msg.h A tests/unit_tests/openvpn/test_dhcp.c 7 files changed, 155 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e0b46e..b773dcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -658,6 +658,7 @@ "test_auth_token" "test_buffer" "test_crypto" +"test_dhcp" "test_misc" "test_ncp" "test_options_parse" @@ -910,6 +911,11 @@ ) endif () +target_compile_definitions(test_dhcp PRIVATE DHCP_UNIT_TEST) +target_sources(test_dhcp PRIVATE +tests/unit_tests/openvpn/mock_get_random.c +) + if (TARGET test_networking) target_link_options(test_networking PRIVATE -Wl,--wrap=parse_line) target_compile_options(test_networking PRIVATE -UNDEBUG) diff --git a/src/openvpn/dhcp.c b/src/openvpn/dhcp.c index 56f03f2..0893ec7 100644 --- a/src/openvpn/dhcp.c +++ b/src/openvpn/dhcp.c @@ -186,7 +186,7 @@ return 0; } -#if defined(_WIN32) +#if defined(_WIN32) || defined(DHCP_UNIT_TEST) #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push diff --git a/src/openvpn/dhcp.h b/src/openvpn/dhcp.h index 3fcd2b6..2ad31a6 100644 --- a/src/openvpn/dhcp.h +++ b/src/openvpn/dhcp.h @@ -93,7 +93,7 @@ in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf); -#if defined(_WIN32) +#if defined(_WIN32) || defined(DHCP_UNIT_TEST) #include "tun.h" bool build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o); diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index 6562c22..741798d 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -59,7 +59,7 @@ #define DCO_WIN_REFERENCE_STRING "ovpn-dco" #endif -#if defined(_WIN32) || defined(TARGET_ANDROID) +#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST) #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1) diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/Makefile.am index 50f4a11..17aa0ce 100644 --- a/tests/unit_tests/openvpn/Makefile.am +++ b/tests/unit_tests/openvpn/Makefile.am @@ -6,7 +6,7 @@ AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt; -test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \ +test_binaries = argv_testdriver buffer_testdriver crypto_testdriver dhcp_testdriver packet_id_testdriver auth_token_testdriver \ ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \ user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver @@ -72,6 +72,15 @@ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/openvpn/mss.c +dhcp_testdriver_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST +dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn +dhcp_testdriver_SOURCES = test_dhcp.c \ + mock_msg.c mock_msg.h test_common.h \ + mock_get_random.c \ + $(top_srcdir)/src/openvpn/platform.c \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/win32-util.c + ssl_testdriver_CFLAGS = \ -I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \ @TEST_CFLAGS@ diff --git a/tests/unit_tests/openvpn/mock_msg.h b/tests/unit_tests/openvpn/mock_msg.h index c6321dc..62afde5 100644 --- a/tests/unit_tests/openvpn/mock_msg.h +++ b/tests/unit_tests/openvpn/mock_msg.h @@ -23,6 +23,8 @@ #ifndef MOCK_MSG_H #define MOCK_MSG_H +#include "error.h" + /** * Mock debug level defaults to 0, which gives clean(-ish) test reports. Call * this function from your test driver to increase debug output when you diff --git a/tests/unit_tests/openvpn/test_dhcp.c b/tests/unit_tests/openvpn/test_dhcp.c new file mode 100644 index 000..729ca58 --- /dev/null +++ b/tests/unit_tests/openvpn/test_dhcp.c @@ -0,0 +1,134 @@ +/* + * OpenVPN -- An application to securely tunnel IP networks + * over a single UDP port, with support for SSL/TLS-based + * session authentication and key exchange,
[Openvpn-devel] [M] Change in openvpn[master]: test_dhcp: Start a dhcp helper functions UT
Attention is currently required from: flichtenheld, plaisthos. Hello cron2, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email to look at the new patch set (#3). Change subject: test_dhcp: Start a dhcp helper functions UT .. test_dhcp: Start a dhcp helper functions UT Use extra define to allow testing code only used on Windows but not actually dependent on Windows. Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615 Signed-off-by: Frank Lichtenheld --- M CMakeLists.txt M src/openvpn/dhcp.c M src/openvpn/dhcp.h M src/openvpn/tun.h M tests/unit_tests/openvpn/Makefile.am M tests/unit_tests/openvpn/mock_msg.h A tests/unit_tests/openvpn/test_dhcp.c 7 files changed, 154 insertions(+), 4 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/67/1267/3 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e0b46e..b773dcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -658,6 +658,7 @@ "test_auth_token" "test_buffer" "test_crypto" +"test_dhcp" "test_misc" "test_ncp" "test_options_parse" @@ -910,6 +911,11 @@ ) endif () +target_compile_definitions(test_dhcp PRIVATE DHCP_UNIT_TEST) +target_sources(test_dhcp PRIVATE +tests/unit_tests/openvpn/mock_get_random.c +) + if (TARGET test_networking) target_link_options(test_networking PRIVATE -Wl,--wrap=parse_line) target_compile_options(test_networking PRIVATE -UNDEBUG) diff --git a/src/openvpn/dhcp.c b/src/openvpn/dhcp.c index 56f03f2..0893ec7 100644 --- a/src/openvpn/dhcp.c +++ b/src/openvpn/dhcp.c @@ -186,7 +186,7 @@ return 0; } -#if defined(_WIN32) +#if defined(_WIN32) || defined(DHCP_UNIT_TEST) #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push diff --git a/src/openvpn/dhcp.h b/src/openvpn/dhcp.h index 3fcd2b6..2ad31a6 100644 --- a/src/openvpn/dhcp.h +++ b/src/openvpn/dhcp.h @@ -93,7 +93,7 @@ in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf); -#if defined(_WIN32) +#if defined(_WIN32) || defined(DHCP_UNIT_TEST) #include "tun.h" bool build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o); diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index 6562c22..741798d 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -59,7 +59,7 @@ #define DCO_WIN_REFERENCE_STRING "ovpn-dco" #endif -#if defined(_WIN32) || defined(TARGET_ANDROID) +#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST) #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1) diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/Makefile.am index 50f4a11..17aa0ce 100644 --- a/tests/unit_tests/openvpn/Makefile.am +++ b/tests/unit_tests/openvpn/Makefile.am @@ -6,7 +6,7 @@ AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt; -test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \ +test_binaries = argv_testdriver buffer_testdriver crypto_testdriver dhcp_testdriver packet_id_testdriver auth_token_testdriver \ ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \ user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver @@ -72,6 +72,15 @@ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/openvpn/mss.c +dhcp_testdriver_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST +dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn +dhcp_testdriver_SOURCES = test_dhcp.c \ + mock_msg.c mock_msg.h test_common.h \ + mock_get_random.c \ + $(top_srcdir)/src/openvpn/platform.c \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/win32-util.c + ssl_testdriver_CFLAGS = \ -I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \ @TEST_CFLAGS@ diff --git a/tests/unit_tests/openvpn/mock_msg.h b/tests/unit_tests/openvpn/mock_msg.h index c6321dc..62afde5 100644 --- a/tests/unit_tests/openvpn/mock_msg.h +++ b/tests/unit_tests/openvpn/mock_msg.h @@ -23,6 +23,8 @@ #ifndef MOCK_MSG_H #define MOCK_MSG_H +#include "error.h" + /** * Mock debug level defaults to 0, which gives clean(-ish) test reports. Call * this function from your test driver to increase debug output when you diff --git a/tests/unit_tests/openvpn/test_dhcp.c b/tests/unit_tests/openvpn/test_dhcp.c new file mode 100644 index 000..2c4d32a --- /dev/null +++ b/tests/unit_tests/openvpn/test_dhcp.c @@ -0,0 +1,133 @@ +/* + * OpenVPN -- An application to securely tunnel IP networks + * over a single UDP port, with support for SSL/TLS-based + * session authentication and key exchange, + * p
