From: "cron2 (Code Review)" Date: Mon, 3 Nov 2025 15:33:30 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., antonio@...2726... Message-ID: <71892ff514226dc76f186085f67537f33bdeac87-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="ul1koRRDtWQ="; 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: , Cc: flichtenheld , plaisthos , openvpn-devel --ul1koRRDtWQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/13= 42?usp=3Demail ) Change subject: test_networking: use appropriate assert helpers ...................................................................... test_networking: use appropriate assert helpers In all 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 Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1342 Message-Id: <20251103145842.22969-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34= 155.html Signed-off-by: Gert Doering --- M tests/unit_tests/openvpn/test_networking.c 1 file changed, 7 insertions(+), 6 deletions(-) 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: --=20 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: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ie153b3d5bf19200f225cd09131de8583645110be Gerrit-Change-Number: 1342 Gerrit-PatchSet: 2 Gerrit-Owner: ordex Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --ul1koRRDtWQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

test_networking: use appropriate assert helpers<=
br>
In all 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.

Substi= tute them all with assert_*() from CMocka.

Change-Id: Ie153b3d5bf192= 00f225cd09131de8583645110be
Reported-by: Marc Heuse <marc@...2953...&= gt;
Signed-off-by: Antonio Quartulli <antonio@...2726...>
Acked= -by: Frank Lichtenheld <frank@...2641...>
Gerrit URL: https://gerr= it.openvpn.net/c/openvpn/+/1342
Message-Id: <20251103145842.22969-1-g= ert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1697...= .sourceforge.net/msg34155.html
Signed-off-by: Gert Doering <gert@...1386...= 296...>
---
M tests/unit_tests/openvpn/test_networking.c
1 file= changed, 7 insertions(+), 6 deletions(-)

diff --git a/tests/unit_tests/openvpn/test_networking.c b/tests/unit_tes=
ts/openvpn/test_networking.c
index 6a2d09f..1c9cac1 100644<= /span>
--- 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 <assert.h>
+#include <setjmp.h>
<= span style=3D"color: hsl(120, 100%, 40%);">+#include <cmocka.h>

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(ty= pe, 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__ifa= ce_type("dummy0815", NULL) =3D=3D -ENODEV);
+ assert_int_equal(net__iface_n= ew("dummy0815", "dummy"), 0);
+ assert_int_equal(net__iface_type(= "dummy0815", "dummy"), 0);
+ assert_int_equal(net__iface_del(&quo= t;dummy0815"), 0);
+ assert_int_equal(net__iface_type("dummy0815", NUL= L), -ENODEV);
return 0;

default:

To view, = visit ch= ange 1342. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie153b3d5bf19200f225cd09131d= e8583645110be
Gerrit-Change-Number: 1342
Gerrit-PatchSet: 2
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>
= --ul1koRRDtWQ=--