Skip to contentSkip to conversation

Change in openvpn[master]: test_networking: use appropriate assert helpers

Openvpn-devel In review ordex (Code Review) 2 participants 6 messages Nov 3, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1762179991000.Ie153b3d5bf19200f225cd09131de8583645110be@...2715...

#1 lore raw

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=email

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

---
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

tests/unit_tests/openvpn/test_networking.c +7 -6
index 6a2d09f..1c9cac1 100644
@@ -2,7 +2,8 @@
 #include "syshead.h"
 #include "networking.h"
 
-#include <assert.h>
+#include <setjmp.h>
+#include <cmocka.h>
 
 static char *iface = "ovpn-dummy0";
 
@@ -27,7 +28,7 @@
     int ret = net_iface_type(NULL, name, ret_type);
     if (ret == 0)
     {
-        assert(strcmp(type, ret_type) == 0);
+        assert_string_equal(type, ret_type);
     }
 
     return ret;
@@ -265,10 +266,10 @@
 
         /* following tests are standalone and do not print any CMD= */
         case 8:
-            assert(net__iface_new("dummy0815", "dummy") == 0);
-            assert(net__iface_type("dummy0815", "dummy") == 0);
-            assert(net__iface_del("dummy0815") == 0);
-            assert(net__iface_type("dummy0815", NULL) == -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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie153b3d5bf19200f225cd09131de8583645110be
Gerrit-Change-Number: 1342
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: ordex, plaisthos.

flichtenheld has posted comments on this change by ordex. ( http://gerrit.openvpn.net/c/openvpn/+/1342?usp=email )

Change subject: test_networking: use appropriate assert helpers
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1342?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: Ie153b3d5bf19200f225cd09131de8583645110be
Gerrit-Change-Number: 1342
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Mon, 03 Nov 2025 14:35:08 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH 1/1 test_networking: use appropriate assert helpers

In reply to a message not in the archive

From: Antonio Quartulli <[email protected]...>

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

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1342
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1342
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>

tests/unit_tests/openvpn/test_networking.c +7 -6
index 6a2d09f..1c9cac1 100644
@@ -2,7 +2,8 @@
 #include "syshead.h"
 #include "networking.h"
 
-#include <assert.h>
+#include <setjmp.h>
+#include <cmocka.h>
 
 static char *iface = "ovpn-dummy0";
 
@@ -27,7 +28,7 @@
     int ret = net_iface_type(NULL, name, ret_type);
     if (ret == 0)
     {
-        assert(strcmp(type, ret_type) == 0);
+        assert_string_equal(type, ret_type);
     }
 
     return ret;
@@ -265,10 +266,10 @@
 
         /* following tests are standalone and do not print any CMD= */
         case 8:
-            assert(net__iface_new("dummy0815", "dummy") == 0);
-            assert(net__iface_type("dummy0815", "dummy") == 0);
-            assert(net__iface_del("dummy0815") == 0);
-            assert(net__iface_type("dummy0815", NULL) == -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:
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: test_networking: use appropriate assert helpers

Your patch has been applied to the master branch.

(As this is test code, and not a "real bug", I think it's fine to not pull it up to release/2.6)

commit 21b943734f1911a158b7b465d11a04bb6de7f1a8

Author: Antonio Quartulli
Date:   Mon Nov 3 15:58:37 2025 +0100
     test_networking: use appropriate assert helpers

     Signed-off-by: Antonio Quartulli <[email protected]...>
     Acked-by: Frank Lichtenheld <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1342
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg34155.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by ordex. ( http://gerrit.openvpn.net/c/openvpn/+/1342?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld

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

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1342
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34155.html

---
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/2

tests/unit_tests/openvpn/test_networking.c +7 -6
index 6a2d09f..1c9cac1 100644
@@ -2,7 +2,8 @@
 #include "syshead.h"
 #include "networking.h"
 
-#include <assert.h>
+#include <setjmp.h>
+#include <cmocka.h>
 
 static char *iface = "ovpn-dummy0";
 
@@ -27,7 +28,7 @@
     int ret = net_iface_type(NULL, name, ret_type);
     if (ret == 0)
     {
-        assert(strcmp(type, ret_type) == 0);
+        assert_string_equal(type, ret_type);
     }
 
     return ret;
@@ -265,10 +266,10 @@
 
         /* following tests are standalone and do not print any CMD= */
         case 8:
-            assert(net__iface_new("dummy0815", "dummy") == 0);
-            assert(net__iface_type("dummy0815", "dummy") == 0);
-            assert(net__iface_del("dummy0815") == 0);
-            assert(net__iface_type("dummy0815", NULL) == -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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie153b3d5bf19200f225cd09131de8583645110be
Gerrit-Change-Number: 1342
Gerrit-PatchSet: 2
Gerrit-Owner: ordex <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1342?usp=email )

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

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1342
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34155.html

---
M tests/unit_tests/openvpn/test_networking.c

1 file changed, 7 insertions(+), 6 deletions(-)
tests/unit_tests/openvpn/test_networking.c +7 -6
index 6a2d09f..1c9cac1 100644
@@ -2,7 +2,8 @@
 #include "syshead.h"
 #include "networking.h"
 
-#include <assert.h>
+#include <setjmp.h>
+#include <cmocka.h>
 
 static char *iface = "ovpn-dummy0";
 
@@ -27,7 +28,7 @@
     int ret = net_iface_type(NULL, name, ret_type);
     if (ret == 0)
     {
-        assert(strcmp(type, ret_type) == 0);
+        assert_string_equal(type, ret_type);
     }
 
     return ret;
@@ -265,10 +266,10 @@
 
         /* following tests are standalone and do not print any CMD= */
         case 8:
-            assert(net__iface_new("dummy0815", "dummy") == 0);
-            assert(net__iface_type("dummy0815", "dummy") == 0);
-            assert(net__iface_del("dummy0815") == 0);
-            assert(net__iface_type("dummy0815", NULL) == -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:
Signature · 13 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1342?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie153b3d5bf19200f225cd09131de8583645110be
Gerrit-Change-Number: 1342
Gerrit-PatchSet: 2
Gerrit-Owner: ordex <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>