Skip to content

Commit 21b9437

Browse files
ordexcron2
authored andcommitted
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 <marc@srlabs.de> Signed-off-by: Antonio Quartulli <antonio@mandelbit.com> Acked-by: Frank Lichtenheld <frank@lichtenheld.com> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1342 Message-Id: <20251103145842.22969-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34155.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
1 parent a3d8c40 commit 21b9437

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

tests/unit_tests/openvpn/test_networking.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#include "syshead.h"
33
#include "networking.h"
44

5-
#include <assert.h>
5+
#include <setjmp.h>
6+
#include <cmocka.h>
67

78
static char *iface = "ovpn-dummy0";
89

@@ -27,7 +28,7 @@ net__iface_type(const char *name, const char *type)
2728
int ret = net_iface_type(NULL, name, ret_type);
2829
if (ret == 0)
2930
{
30-
assert(strcmp(type, ret_type) == 0);
31+
assert_string_equal(type, ret_type);
3132
}
3233

3334
return ret;
@@ -265,10 +266,10 @@ main(int argc, char *argv[])
265266

266267
/* following tests are standalone and do not print any CMD= */
267268
case 8:
268-
assert(net__iface_new("dummy0815", "dummy") == 0);
269-
assert(net__iface_type("dummy0815", "dummy") == 0);
270-
assert(net__iface_del("dummy0815") == 0);
271-
assert(net__iface_type("dummy0815", NULL) == -ENODEV);
269+
assert_int_equal(net__iface_new("dummy0815", "dummy"), 0);
270+
assert_int_equal(net__iface_type("dummy0815", "dummy"), 0);
271+
assert_int_equal(net__iface_del("dummy0815"), 0);
272+
assert_int_equal(net__iface_type("dummy0815", NULL), -ENODEV);
272273
return 0;
273274

274275
default:

0 commit comments

Comments
 (0)