From: "cron2 (Code Review)" Date: Sat, 24 Jan 2026 17:41:47 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="ijpuKAtP4nA="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: openvpnserv: Add a first unit test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --ijpuKAtP4nA= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#8) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1459?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: openvpnserv: Add a first unit test ...................................................................... openvpnserv: Add a first unit test This adds the required build infrastructure and adds tests for two functions related to GetItfDnsDomains(). Change-Id: I33583e51e1143c53fbe0aef16546fa3f602b17c0 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1459 Message-Id: <20260119215058.27888-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35= 345.html Signed-off-by: Gert Doering --- M configure.ac M src/openvpnserv/CMakeLists.txt M tests/unit_tests/Makefile.am M tests/unit_tests/openvpn/test_common.h A tests/unit_tests/openvpnserv/Makefile.am A tests/unit_tests/openvpnserv/test_openvpnserv.c 6 files changed, 181 insertions(+), 20 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/59/1459/8 diff --git a/configure.ac b/configure.ac index 2d8de7c..841b0d1 100644 --- a/configure.ac +++ b/configure.ac @@ -1431,6 +1431,7 @@ tests/unit_tests/Makefile tests/unit_tests/example_test/Makefile tests/unit_tests/openvpn/Makefile + tests/unit_tests/openvpnserv/Makefile tests/unit_tests/plugins/Makefile tests/unit_tests/plugins/auth-pam/Makefile sample/Makefile diff --git a/src/openvpnserv/CMakeLists.txt b/src/openvpnserv/CMakeLists.txt index 2c8f310..fc15382 100644 --- a/src/openvpnserv/CMakeLists.txt +++ b/src/openvpnserv/CMakeLists.txt @@ -10,13 +10,29 @@ set(MC_GEN_DIR ${CMAKE_CURRENT_BINARY_DIR}/mc) -target_include_directories(openvpnserv PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/../../ - ../../include/ - ../openvpn/ - ../compat/ - ${MC_GEN_DIR} +function(add_common_options target) + target_include_directories(${target} PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/../../ + ../../include/ + ../openvpn/ + ../compat/ + ${MC_GEN_DIR} ) + target_compile_options(${target} PRIVATE + -D_UNICODE + -UNTDDI_VERSION + -D_WIN32_WINNT=3D_WIN32_WINNT_VISTA + ) + target_link_libraries(${target} PRIVATE + advapi32.lib userenv.lib iphlpapi.lib fwpuclnt.lib rpcrt4.lib + shlwapi.lib netapi32.lib ws2_32.lib ntdll.lib ole32.lib pathcch.li= b) + if (MINGW) + target_compile_options(${target} PRIVATE -municode) + target_link_options(${target} PRIVATE -municode) + endif () +endfunction() + +add_common_options(openvpnserv) target_sources(openvpnserv PRIVATE common.c interactive.c @@ -26,18 +42,6 @@ ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc ) -target_compile_options(openvpnserv PRIVATE - -D_UNICODE - -UNTDDI_VERSION - -D_WIN32_WINNT=3D_WIN32_WINNT_VISTA - ) -target_link_libraries(openvpnserv - advapi32.lib userenv.lib iphlpapi.lib fwpuclnt.lib rpcrt4.lib - shlwapi.lib netapi32.lib ws2_32.lib ntdll.lib ole32.lib pathcch.lib) -if (MINGW) - target_compile_options(openvpnserv PRIVATE -municode) - target_link_options(openvpnserv PRIVATE -municode) -endif () # below we generate a DLL which contains an event source for event log mes= sages from eventmsg.mc template file(MAKE_DIRECTORY ${MC_GEN_DIR}) @@ -74,3 +78,30 @@ endif() add_dependencies(openvpnserv msg_mc_gen) + +if (BUILD_TESTING) + set(unit_tests + "test_openvpnserv" + ) + + foreach (test_name ${unit_tests}) + add_test(${test_name} ${test_name}) + add_executable(${test_name} + ../../tests/unit_tests/openvpnserv/${test_name}.c + ${MC_GEN_DIR}/eventmsg.h + ) + + add_common_options(${test_name}) + target_link_libraries(${test_name} PUBLIC ${CMOCKA_LIBRARIES}) + target_include_directories(${test_name} PRIVATE + . + ../../tests/unit_tests/openvpn + ) + endforeach() + + target_sources(test_openvpnserv PRIVATE + common.c + validate.c + ../openvpn/wfp_block.c ../openvpn/wfp_block.h + ) +endif () diff --git a/tests/unit_tests/Makefile.am b/tests/unit_tests/Makefile.am index 33fefaa..ce6278e 100644 --- a/tests/unit_tests/Makefile.am +++ b/tests/unit_tests/Makefile.am @@ -1,5 +1,5 @@ AUTOMAKE_OPTIONS =3D foreign if ENABLE_UNITTESTS -SUBDIRS =3D example_test openvpn plugins +SUBDIRS =3D example_test openvpn openvpnserv plugins endif diff --git a/tests/unit_tests/openvpn/test_common.h b/tests/unit_tests/open= vpn/test_common.h index f898e89..156e5a9 100644 --- a/tests/unit_tests/openvpn/test_common.h +++ b/tests/unit_tests/openvpn/test_common.h @@ -20,8 +20,9 @@ * with this program; if not, see . */ -#include #include +#include +#include #include /* Do we use cmocka < 2.0.0? */ diff --git a/tests/unit_tests/openvpnserv/Makefile.am b/tests/unit_tests/op= envpnserv/Makefile.am new file mode 100644 index 0000000..6294c52 --- /dev/null +++ b/tests/unit_tests/openvpnserv/Makefile.am @@ -0,0 +1,15 @@ +AUTOMAKE_OPTIONS =3D foreign + +AM_TESTSUITE_SUMMARY_HEADER =3D ' for $(PACKAGE_STRING) service Unit-Tests' + +if WIN32 +test_binaries =3D openvpnserv_testdriver +endif + +openvpnserv_testdriver_CFLAGS =3D -I$(top_srcdir)/include -I$(top_srcdir)= /src/openvpn -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpnserv @TE= ST_CFLAGS@ +openvpnserv_testdriver_LDFLAGS =3D @TEST_LDFLAGS@ -L$(top_srcdir)/src/open= vpn +openvpnserv_testdriver_SOURCES =3D test_openvpnserv.c \ + $(top_srcdir)/src/openvpnserv/common.c \ + $(top_srcdir)/src/openvpnserv/validate.c \ + $(top_srcdir)/src//openvpn/wfp_block.c \ + $(top_srcdir)/src//openvpn/wfp_block.h diff --git a/tests/unit_tests/openvpnserv/test_openvpnserv.c b/tests/unit_t= ests/openvpnserv/test_openvpnserv.c new file mode 100644 index 0000000..348de4f --- /dev/null +++ b/tests/unit_tests/openvpnserv/test_openvpnserv.c @@ -0,0 +1,113 @@ +/* + * 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 compression. + * + * Copyright (C) 2025 Frank Lichtenheld + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by t= he + * Free Software Foundation, either version 2 of the License, + * or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include +#include +#include "test_common.h" + +#include +#include + +#include "interactive.c" + +BOOL +ReportStatusToSCMgr(SERVICE_STATUS_HANDLE service, SERVICE_STATUS *status) +{ + return TRUE; +} + +static void +test_list_contains_domain(void **state) +{ + PCWSTR domain =3D L"openvpn.net"; + size_t domain_len =3D wcslen(domain); + assert_true(ListContainsDomain(domain, domain, domain_len)); + assert_true(ListContainsDomain(L"openvpn.com,openvpn.net", domain, dom= ain_len)); + assert_true(ListContainsDomain(L"openvpn.net,openvpn.com", domain, dom= ain_len)); + + assert_false(ListContainsDomain(L"openvpn.com", domain, domain_len)); + assert_false(ListContainsDomain(L"internal.openvpn.net", domain, domai= n_len)); +} + +#define BUF_SIZE 64 +static void +test_convert_itf_dns_domains(void **state) +{ + DWORD size, orig_size, len, res_len; + LSTATUS err; + const DWORD glyph_size =3D sizeof(wchar_t); + + wchar_t domains_1[BUF_SIZE] =3D L"openvpn.com"; + len =3D (DWORD)wcslen(domains_1) + 1; + size =3D orig_size =3D len * glyph_size; + wchar_t domains_1_res[BUF_SIZE] =3D L".openvpn.com"; + res_len =3D len + 2; /* adds . and \0 */ + err =3D ConvertItfDnsDomains(L"openvpn.net", domains_1, &size, BUF_SIZ= E); + assert_memory_equal(domains_1, domains_1_res, size); + assert_int_equal(size, res_len * glyph_size); + assert_int_equal(err, NO_ERROR); + + wchar_t domains_2[BUF_SIZE] =3D L"openvpn.com,openvpn.net"; + len =3D (DWORD)wcslen(domains_2) + 1; + size =3D orig_size =3D len * glyph_size; + wchar_t domains_2_res[BUF_SIZE] =3D L".openvpn.com"; + res_len =3D (DWORD)wcslen(domains_2_res) + 2; + err =3D ConvertItfDnsDomains(L"openvpn.net", domains_2, &size, BUF_SIZ= E); + assert_memory_equal(domains_2, domains_2_res, size); + assert_int_equal(size, res_len * glyph_size); + assert_int_equal(err, NO_ERROR); + + wchar_t domains_3[BUF_SIZE] =3D L"openvpn.com,openvpn.net"; + len =3D (DWORD)wcslen(domains_3) + 1; + size =3D orig_size =3D len * glyph_size; + wchar_t domains_3_res[BUF_SIZE] =3D L".openvpn.net"; + res_len =3D (DWORD)wcslen(domains_3_res) + 2; + err =3D ConvertItfDnsDomains(L"openvpn.com", domains_3, &size, BUF_SIZ= E); + assert_memory_equal(domains_3, domains_3_res, size); + assert_int_equal(size, res_len * glyph_size); + assert_int_equal(err, NO_ERROR); + + wchar_t domains_4[BUF_SIZE] =3D L"openvpn.com,openvpn.net"; + len =3D (DWORD)wcslen(domains_4) + 1; + size =3D orig_size =3D len * glyph_size; + wchar_t domains_4_res[BUF_SIZE] =3D L".openvpn.com\0.openvpn.net"; + res_len =3D len + 3; /* adds two . and one \0 */ + err =3D ConvertItfDnsDomains(NULL, domains_4, &size, BUF_SIZE); + assert_memory_equal(domains_4, domains_4_res, size); + assert_int_equal(size, res_len * glyph_size); + assert_int_equal(err, NO_ERROR); +} + +int +wmain(void) +{ + openvpn_unit_test_setup(); + const struct CMUnitTest tests[] =3D { + cmocka_unit_test(test_list_contains_domain), + cmocka_unit_test(test_convert_itf_dns_domains), + }; + + int ret =3D cmocka_run_group_tests_name("openvpnserv tests", tests, NU= LL, NULL); + + return ret; +} -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1459?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I33583e51e1143c53fbe0aef16546fa3f602b17c0 Gerrit-Change-Number: 1459 Gerrit-PatchSet: 8 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --ijpuKAtP4nA= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #8 to the change originally created by flichtenhel= d.

View Change

The following approvals got outdated and were remove= d: Code-Review+2 by cron2

openvpnserv: Add a first unit test<=
br>
This adds the required build infrastructure
and adds tests for tw= o functions related to
GetItfDnsDomains().

Change-Id: I33583e51e1= 143c53fbe0aef16546fa3f602b17c0
Signed-off-by: Frank Lichtenheld <fran= k@...2641...>
Acked-by: Gert Doering <gert@...1296...>
Gerri= t URL: https://gerrit.openvpn.net/c/openvpn/+/1459
Message-Id: <20260= 119215058.27888-1-gert@...1296...>
URL: https://www.mail-archive.com/= openvpn-devel@lists.sourceforge.net/msg35345.html
Signed-off-by: Gert Do= ering <gert@...1296...>
---
M configure.ac
M src/openvpnserv= /CMakeLists.txt
M tests/unit_tests/Makefile.am
M tests/unit_tests/ope= nvpn/test_common.h
A tests/unit_tests/openvpnserv/Makefile.am
A tests= /unit_tests/openvpnserv/test_openvpnserv.c
6 files changed, 181 insertio= ns(+), 20 deletions(-)

git pull ssh://gerrit.ope=
nvpn.net:29418/openvpn refs/changes/59/1459/8
diff --git a/configur=
e.ac b/configure.ac
index 2d8de7c..841b0d1 100644--- a/configure.ac
+++ b/configure.ac
@@ -1431,6 +1431,7 @@
tests/unit_tests/Makefile<= /span>
tests/unit_tests/example_test/Makefile
<= span> tests/unit_tests/openvpn/Makefile

+ tests/unit_tests/openvpnserv/Makefile
tests/unit_tests/plugins/Makefile
= tests/unit_tests/plugins/auth-pam/Makefile
sample= /Makefile
diff --git a/src/openvpnserv/CMakeLists.txt b/src= /openvpnserv/CMakeLists.txt
index 2c8f310..fc15382 100644
--- a/src/openvpnserv/CMakeLists.txt
+++ b/s= rc/openvpnserv/CMakeLists.txt
@@ -10,13 +10,29 @@
set(MC_GEN_DIR ${CMAKE_CURRENT_BINARY_DIR}/mc)

-target= _include_directories(openvpnserv PRIVATE
- ${CMAKE_CURRENT_BINARY_DIR}/../../
- ../../include/
- ../openvpn/
- ../compat/
- ${MC_GEN_DIR}
+function(add_common_options target)
+ target_include_directories(${target} = PRIVATE
+ ${CM= AKE_CURRENT_BINARY_DIR}/../../
+ ../../include/
+ ../openvpn/
+ ../compat/
+ ${MC_GEN_DIR}
)
+ target_compile_options(${target} = PRIVATE
+ -D_U= NICODE
+ -UNTD= DI_VERSION
+ -= D_WIN32_WINNT=3D_WIN32_WINNT_VISTA
+ )
= + target_link_libraries(${target} PRIVATE
+ advapi32.lib userenv.lib iphlpapi.lib fwpu= clnt.lib rpcrt4.lib
+= shlwapi.lib netapi32.lib ws2_32.lib ntdll.lib ole32.lib pathcch.lib= )
+ if (MINGW)
+ target_compile_= options(${target} PRIVATE -municode)
+ target_link_options(${target} PRIVATE -municode)
+ endif ()+endfunction()
+

+add_common_options(openvpnserv)
targ= et_sources(openvpnserv PRIVATE
common.c
interactive.c

@@ -26,18 +42,6 @@
= ../openvpn/wfp_block.c ../openvpn/wfp_block.h
openvp= nserv_resources.rc
)
-target_compile_options(openvpnserv PRIVATE
- -D_UNICODE

- -UNTDDI_VERSION
- -D_WIN32_WINNT=3D_WIN32_WINNT_VISTA
- )
-target_link_libraries(openvpnserv<= br>- advapi32.lib userenv.lib = iphlpapi.lib fwpuclnt.lib rpcrt4.lib
- shlwapi.lib netapi32.lib ws2_32.lib ntdll.lib ole32.lib = pathcch.lib)
-if (MINGW= )
- target_compile_o= ptions(openvpnserv PRIVATE -municode)
- target_link_options(openvpnserv PRIVATE -municode)

-endif ()
=
# below we generate a DLL which contains an event source = for event log messages from eventmsg.mc template
file(MAKE= _DIRECTORY ${MC_GEN_DIR})
@@ -74,3 +78,30 @@
endif()

add_dependencies(openvpnserv = msg_mc_gen)
+<= br>+if (BUILD_TESTING)+ set(unit_tests+ "test_openvpnser= v"
+ )=
+
+ foreach (test_name ${unit_tests})<= br>+ add_test(${test_nam= e} ${test_name})
+ = add_executable(${test_name}
+ ../../tests/unit_tests/openvpnserv/${test_name}.c<= /span>
+ ${MC_GEN= _DIR}/eventmsg.h
+ = )
+
+ add_common_options(${tes= t_name})

+ tar= get_link_libraries(${test_name} PUBLIC ${CMOCKA_LIBRARIES})
+ target_include_directories(= ${test_name} PRIVATE
= + .
+ = ../../tests/unit_tests/openvpn
+ )
+ endforeach()
+
+ target_sou= rces(test_openvpnserv PRIVATE
+ common.c
+ validate.c
+ ../openvpn/wfp_block.c ../openvpn/wfp_block.h
+ )
+endif ()
diff --git a/tests/unit_= tests/Makefile.am b/tests/unit_tests/Makefile.am
index 33fe= faa..ce6278e 100644
--- a/tests/unit_tests/Makefile.am

+++ b/tests/unit_tests/Makefile.am
@@ -1,5 +1,5= @@
AUTOMAKE_OPTIONS =3D foreign
<= br> if ENABLE_UNITTESTS
-SUBDIRS =3D example_test openvpn plugins
+SUBDIRS =3D example_test openvpn openvpnserv p= lugins
endif
diff --git a/tests/unit_tests= /openvpn/test_common.h b/tests/unit_tests/openvpn/test_common.h
<= span>index f898e89..156e5a9 100644
--- a/tests/unit_tests/o= penvpn/test_common.h
+++ b/tests/unit_tests/openvpn/test_co= mmon.h
@@ -20,8 +20,9 @@
* with this pro= gram; if not, see <https://www.gnu.org/licenses/>.
= */

-#= include <stdio.h>
#include <setjmp.h>+#include <stdio.h>
+#include <stdlib.h&g= t;
#include <cmocka.h>

<= span> /* Do we use cmocka < 2.0.0? */

diff --git a/tests= /unit_tests/openvpnserv/Makefile.am b/tests/unit_tests/openvpnserv/Makefile= .am
new file mode 100644
index 0000000..629= 4c52
--- /dev/null
+++ b/tests/unit_tests/o= penvpnserv/Makefile.am
@@ -0,0 +1,15 @@
+AUTOMAKE_OPTIONS =3D foreign
= +
+AM_TESTSUITE_SUMMARY_HEADER =3D ' for $(PACKA= GE_STRING) service Unit-Tests'
+
+if W= IN32
+test_binaries = =3D openvpnserv_testdriver
+endif
+=
+openvpnserv_testdriver_CFL= AGS =3D -I$(top_srcdir)/include -I$(top_srcdir)/src/openvpn -I$(top_srcdir= )/src/compat -I$(top_srcdir)/src/openvpnserv @TEST_CFLAGS@
+openvpnserv_testdriver_LDFLAGS =3D @= TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
+openvpnserv_testdriver_SOURCES =3D test_openvpnserv.c= \
+ $(top_srcdir)/sr= c/openvpnserv/common.c \
+ $(top_srcdir)/src/openvpnserv/validate.c \
+ $(top_srcdir)/src//openvpn/wfp_block.c \
+ $(top_srcdir)/src//open= vpn/wfp_block.h
diff --git a/tests/unit_tests/openvpnserv/t= est_openvpnserv.c b/tests/unit_tests/openvpnserv/test_openvpnserv.c<= br>new file mode 100644
index 0000000..348de4f=
--- /dev/null
+++ b/tests/unit_tests/openvpnserv/= test_openvpnserv.c
@@ -0,0 +1,113 @@
+/*
+ * OpenVPN -- An application to securely tunnel IP networ= ks
+ * ov= er a single UDP port, with support for SSL/TLS-based
+ * session authentication and= key exchange,
+ * = packet encryption, packet authentication, and
+ * packet compression.
+ *
+ * Copyright (C) 2025 Frank Lichtenheld = <frank@...2641...>
+ *
+ * This pro= gram is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU = General Public License as published by the

+ * Free Software Foundation, either version 2 of th= e License,
+ * or (a= t your option) any later version.
+ *
+ * = This program is distributed in the hope that it will be useful,
= + * but WITHOUT ANY WARRANTY; = without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. = See the
+ * GNU Gene= ral Public License for more details.
+ *
+= * You should have received a copy of the GNU General Public License along=
+ * with this progr= am; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+= #include <setjmp.h>
+#include <cmocka.h>
+#include "test_common.h"
+
+#include <winsock2.h>
+#include <windows.h>
+
+#include "interactive.c"
+
+= BOOL
+ReportStatusToS= CMgr(SERVICE_STATUS_HANDLE service, SERVICE_STATUS *status)
+{

+ return TRUE;
+}
= +
+static void=
+test_list_contains_domain(= void **state)
+{
+ PCWSTR domain =3D L&= quot;openvpn.net";
+ size_t domain_len =3D wcslen(domain);
+ assert_true(ListContainsDomain(domain, domain= , domain_len));
+ = assert_true(ListContainsDomain(L"openvpn.com,openvpn.net", domain= , domain_len));
+ = assert_true(ListContainsDomain(L"openvpn.net,openvpn.com", domain= , domain_len));
+
+ assert_false(ListCo= ntainsDomain(L"openvpn.com", domain, domain_len));
+ assert_false(ListContainsDomai= n(L"internal.openvpn.net", domain, domain_len));

+}
+
+#define BUF_SIZE 64
+static void
+test_c= onvert_itf_dns_domains(void **state)
+{
+ = DWORD size, orig_size, len, res_len;
+ LSTATUS err;
+ const DWORD glyph_size =3D sizeof(wchar_t);
= +
+ wchar_t domains_1[BUF_SIZE] =3D L"openvp= n.com";
+ len= =3D (DWORD)wcslen(domains_1) + 1;
+ size =3D orig_size =3D len * glyph_size;
+ wchar_t domains_1_res[BUF_SIZE]= =3D L".openvpn.com";

+ res_len =3D len + 2; /* adds . and \0 */
+ err =3D ConvertItfDnsDomains(L&quo= t;openvpn.net", domains_1, &size, BUF_SIZE);
+ assert_memory_equal(domains_1, domain= s_1_res, size);
+ = assert_int_equal(size, res_len * glyph_size);
+ assert_int_equal(err, NO_ERROR);
+
+ wchar_t domains_2[BUF_SIZE] =3D L"openvpn.= com,openvpn.net";
+ size =3D orig_size =3D len * glyph_size;
+ wchar_t domains_2_res= [BUF_SIZE] =3D L".openvpn.com";
+ res_len =3D (DWORD)wcslen(domains_2_res) + 2;
+ err =3D ConvertItfD= nsDomains(L"openvpn.net", domains_2, &size, BUF_SIZE);=
+ assert_memory_equal(do= mains_2, domains_2_res, size);
+ assert_int_equal(size, res_len * glyph_size);
+ assert_int_equal(err, NO_ERROR= );

+
+ wchar_t domains_3[BUF_SIZE] =3D = L"openvpn.com,openvpn.net";
+ len =3D (DWORD)wcslen(domains_3) + 1;
+ size =3D orig_size =3D len * gl= yph_size;

+ wchar_= t domains_3_res[BUF_SIZE] =3D L".openvpn.net";
+ res_len =3D (DWORD)wcslen(domains_= 3_res) + 2;
+ err = =3D ConvertItfDnsDomains(L"openvpn.com", domains_3, &size, BU= F_SIZE);
+ assert_= memory_equal(domains_3, domains_3_res, size);
+ assert_int_equal(size, res_len * glyph_size);=
+ assert_int_equa= l(err, NO_ERROR);
+
+ wchar_t domains_4= [BUF_SIZE] =3D L"openvpn.com,openvpn.net";
+ len =3D (DWORD)wcslen(domains_4) + 1;=
+ size =3D orig_s= ize =3D len * glyph_size;
+ wchar_t domains_4_res[BUF_SIZE] =3D L".openvpn.com\0.openvpn= .net";
+ res_= len =3D len + 3; /* adds two . and one \0 */
+ err =3D ConvertItfDnsDomains(NULL, domains_4, = &size, BUF_SIZE);
+ assert_memory_equal(domains_4, domains_4_res, size);
+ assert_int_equal(size, res_len *= glyph_size);
+ as= sert_int_equal(err, NO_ERROR);
+}
+=
+int
+wmain(void)
+{
+ openvpn_unit_test_setup();
+ const struct CMUnitTest tests[] =3D {
+ cmocka_unit_test(test_list= _contains_domain),

+ = cmocka_unit_test(test_convert_itf_dns_domains),
+ };
+
+ return ret;<= /span>
+}

To view, visit change 1459. To unsubscribe, or for help writi= ng mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I33583e51e1143c53fbe0aef1654= 6fa3f602b17c0
Gerrit-Change-Number: 1459
Gerrit-PatchSet: 8
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --ijpuKAtP4nA=--