From: "ordex (Code Review)" Date: Mon, 3 Nov 2025 14:26:33 +0000 References: Reply-To: antonio@...2726..., 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="6/WE3IXSqJA="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: test_networking: use appropriate assert helpers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --6/WE3IXSqJA= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1342?usp=3Demail to review the following change. Change subject: test_networking: use appropriate assert helpers ...................................................................... test_networking: use appropriate assert helpers Inall unit tests we rely on CMocka's provided assert helpers. However, test_networking.c was still on the default assert() call, which we try to avoid in favour of more appropriate helpers. Substitute them all with assert_*() from CMocka. Change-Id: Ie153b3d5bf19200f225cd09131de8583645110be Reported-by: Marc Heuse Signed-off-by: Antonio Quartulli --- M tests/unit_tests/openvpn/test_networking.c 1 file changed, 7 insertions(+), 6 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/42/1342/1 diff --git a/tests/unit_tests/openvpn/test_networking.c b/tests/unit_tests/= openvpn/test_networking.c index 6a2d09f..1c9cac1 100644 --- a/tests/unit_tests/openvpn/test_networking.c +++ b/tests/unit_tests/openvpn/test_networking.c @@ -2,7 +2,8 @@ #include "syshead.h" #include "networking.h" -#include +#include +#include static char *iface =3D "ovpn-dummy0"; @@ -27,7 +28,7 @@ int ret =3D net_iface_type(NULL, name, ret_type); if (ret =3D=3D 0) { - assert(strcmp(type, ret_type) =3D=3D 0); + assert_string_equal(type, ret_type); } return ret; @@ -265,10 +266,10 @@ /* following tests are standalone and do not print any CMD=3D */ case 8: - assert(net__iface_new("dummy0815", "dummy") =3D=3D 0); - assert(net__iface_type("dummy0815", "dummy") =3D=3D 0); - assert(net__iface_del("dummy0815") =3D=3D 0); - assert(net__iface_type("dummy0815", NULL) =3D=3D -ENODEV); + assert_int_equal(net__iface_new("dummy0815", "dummy"), 0); + assert_int_equal(net__iface_type("dummy0815", "dummy"), 0); + assert_int_equal(net__iface_del("dummy0815"), 0); + assert_int_equal(net__iface_type("dummy0815", NULL), -ENODEV); return 0; default: -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1342?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ie153b3d5bf19200f225cd09131de8583645110be Gerrit-Change-Number: 1342 Gerrit-PatchSet: 1 Gerrit-Owner: ordex Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld --6/WE3IXSqJA= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: flichtenheld, plaisthos.

ordex would like plaisthos and flichtenheld to review t= his change.

V= iew Change

test_networking: use appropriate assert hel=
pers

Inall unit tests we rely on CMocka's provided assert
hel= pers.
However, test_networking.c was still on the default
assert() ca= ll, which we try to avoid in favour of more
appropriate helpers.

= Substitute them all with assert_*() from CMocka.

Change-Id: Ie153b3d= 5bf19200f225cd09131de8583645110be
Reported-by: Marc Heuse <marc@...2924...= 53...>
Signed-off-by: Antonio Quartulli <antonio@...2726...>---
M tests/unit_tests/openvpn/test_networking.c
1 file changed, 7 i= nsertions(+), 6 deletions(-)

git pull ssh://gerr=
it.openvpn.net:29418/openvpn refs/changes/42/1342/1
diff --git a/te=
sts/unit_tests/openvpn/test_networking.c b/tests/unit_tests/openvpn/test_ne=
tworking.c
index 6a2d09f..1c9cac1 100644
--= - a/tests/unit_tests/openvpn/test_networking.c
+++ b/tests/= unit_tests/openvpn/test_networking.c
@@ -2,7 +2,8 @@=
#include "syshead.h"
#include "n= etworking.h"

-#include <assert.h>
+#include <setjmp.h>
+#include <cmocka.h>

static char *iface =3D "ovpn-dummy0";

@@ -27,7 +28,7 @@
int ret =3D net_i= face_type(NULL, name, ret_type);
if (ret =3D=3D 0)
{
- = assert(strcmp(type, ret_type) =3D=3D 0);
+ assert_string_equal(type, ret_type);
}

return ret;
@@ -265,10 +266,10 @@

= /* following tests are standalone and do not print any CMD=3D */ case 8:
- = assert(net__iface_type("dummy0815", "dummy") =3D= =3D 0);
- as= sert(net__iface_del("dummy0815") =3D=3D 0);
- assert(net__iface_type("du= mmy0815", NULL) =3D=3D -ENODEV);
+ assert_int_equal(net__iface_new("dummy08= 15", "dummy"), 0);
+ assert_int_equal(net__iface_type("dummy0815&= quot;, "dummy"), 0);
+ assert_int_equal(net__iface_del("dummy0815"= ;), 0);
+ = assert_int_equal(net__iface_type("dummy0815", NULL), -ENODEV);
return 0;

= default:

To view, visit change 1342. T= o unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie153b3d5bf19200f225cd09131d= e8583645110be
Gerrit-Change-Number: 1342
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <antonio@...2726...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
= --6/WE3IXSqJA=--