Attention is currently required from: Arne Schwabe.
Hello Arne Schwabe,
I'd like you to reexamine a change. Please visit
https://gerrit.openvpn.net/c/openvpn/+/2394?usp=email
to look at the new patch set (#3).
Change subject: unit_tests: Fix build with CMocka 2.0.3
......................................................................
unit_tests: Fix build with CMocka 2.0.3
As seen in Fedora Rawhide builds.
- mock_assert type for line argument changed, make sure
we avoid sign conversion errors.
- fail_msg doesn't seem to work without and VA_ARGS anymore.
This might or might not be a bug (the documentation hasn't
changed, but work around it either way).
Change-Id: Ifaebb8f5e7245c505a29c87f917f92bf16fa8027
Signed-off-by: Frank Lichtenheld <[email protected]>
---
M dev-tools/openvpn-cppcheck-library.cfg
M tests/unit_tests/openvpn/mock_msg.c
M tests/unit_tests/openvpn/test_common.h
M tests/unit_tests/openvpn/test_provider.c
4 files changed, 25 insertions(+), 3 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/94/2394/3
diff --git a/dev-tools/openvpn-cppcheck-library.cfg
b/dev-tools/openvpn-cppcheck-library.cfg
index 37195d8..9ea9b80 100644
--- a/dev-tools/openvpn-cppcheck-library.cfg
+++ b/dev-tools/openvpn-cppcheck-library.cfg
@@ -32,6 +32,7 @@
<!-- work around macro confusion -->
<define name="CMSG_FIRSTHDR" value="cmsg_firsthdr" />
<define name="CMSG_NXTHDR" value="cmsg_nxthdr" />
+ <define name="CM_VERSION_INT(a, b, c)" value="((a) << 16 | (b)
<< 8 | (c))" />
<!-- otherwise a lot of unused variables are shown for enable-small builds
-->
<define name="DMSG_ALWAYS_AVAILABLE" value="1" />
<!-- cppcheck understands it directly in format string, but not
diff --git a/tests/unit_tests/openvpn/mock_msg.c
b/tests/unit_tests/openvpn/mock_msg.c
index 3e73d19..b3b00a0 100644
--- a/tests/unit_tests/openvpn/mock_msg.c
+++ b/tests/unit_tests/openvpn/mock_msg.c
@@ -37,6 +37,7 @@
#include "errlevel.h"
#include "error.h"
#include "mock_msg.h"
+#include "test_common.h"
msglvl_t x_debug_level = 0; /* Default to (almost) no debugging output */
msglvl_t print_x_debug_level = 0;
@@ -115,7 +116,7 @@
void
assert_failed(const char *filename, int line, const char *condition)
{
- mock_assert(false, condition ? condition : "", filename, line);
+ mock_assert(false, condition ? condition : "", filename,
(ovpn_cmocka_line_t)line);
/* Keep compiler happy. Should not happen, mock_assert() does not return
*/
exit(1);
}
diff --git a/tests/unit_tests/openvpn/test_common.h
b/tests/unit_tests/openvpn/test_common.h
index 85e099f..e8bdf88 100644
--- a/tests/unit_tests/openvpn/test_common.h
+++ b/tests/unit_tests/openvpn/test_common.h
@@ -20,6 +20,9 @@
* with this program; if not, see <https://www.gnu.org/licenses/>.
*/
+#ifndef TEST_COMMON_H
+#define TEST_COMMON_H
+
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
@@ -31,6 +34,7 @@
/* Do we use cmocka < 2.0.0? */
#ifndef HAVE_CMOCKA_VERSION_H
+
#define HAVE_OLD_CMOCKA_API 1
/* compat with various versions of cmocka.h
* Older versions have LargestIntegralType. Newer
@@ -50,6 +54,20 @@
#define cast_ptr_to_cmocka_value(x) (x)
#define assert_int_in_range(value, min, max) assert_in_range((value), (min),
(max))
#define assert_uint_in_range(value, min, max) assert_in_range((value), (min),
(max))
+
+typedef int ovpn_cmocka_line_t;
+
+#else
+
+#include <cmocka_version.h>
+
+/* handle differences in different 2.x versions */
+#if CMOCKA_VERSION_INT >= CM_VERSION_INT(2, 0, 3)
+typedef size_t ovpn_cmocka_line_t;
+#else
+typedef int ovpn_cmocka_line_t;
+#endif
+
#endif
/**
@@ -97,3 +115,5 @@
snprintf(buf, bufsize, "%s/%s", srcdir, filename);
}
+
+#endif
diff --git a/tests/unit_tests/openvpn/test_provider.c
b/tests/unit_tests/openvpn/test_provider.c
index 5d31da3..c2c0a41 100644
--- a/tests/unit_tests/openvpn/test_provider.c
+++ b/tests/unit_tests/openvpn/test_provider.c
@@ -256,7 +256,7 @@
if (!mctx || EVP_DigestSignInit_ex(mctx, &pctx, mdname, NULL, NULL, pkey,
params) <= 0)
{
- fail_msg("Failed to initialize EVP_DigestSignInit_ex()");
+ fail_msg("%s", "Failed to initialize EVP_DigestSignInit_ex()");
goto done;
}
@@ -266,7 +266,7 @@
if ((sig = test_calloc(1, siglen)) == NULL)
{
- fail_msg("Out of memory");
+ fail_msg("%s", "Out of memory");
}
assert_int_equal(EVP_DigestSign(mctx, sig, &siglen, (uint8_t *)test_msg,
strlen(test_msg)), 1);
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2394?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifaebb8f5e7245c505a29c87f917f92bf16fa8027
Gerrit-Change-Number: 2394
Gerrit-PatchSet: 3
Gerrit-Owner: Frank Lichtenheld <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel