Attention is currently required from: Arne Schwabe.
Hello Arne Schwabe,
I'd like you to do a code review.
Please visit
https://gerrit.openvpn.net/c/openvpn/+/2405?usp=email
to review the following change.
Change subject: unit_tests: Fix build with CMocka 2.0.3 (2.7)
......................................................................
unit_tests: Fix build with CMocka 2.0.3 (2.7)
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]>
(cherry picked from commit 0ef03ce6abcdc821fd3e281505cffa2fa7cd1d73)
---
M tests/unit_tests/openvpn/mock_msg.c
M tests/unit_tests/openvpn/test_common.h
M tests/unit_tests/openvpn/test_provider.c
3 files changed, 33 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/05/2405/1
diff --git a/tests/unit_tests/openvpn/mock_msg.c
b/tests/unit_tests/openvpn/mock_msg.c
index 8176d2a..926c906 100644
--- a/tests/unit_tests/openvpn/mock_msg.c
+++ b/tests/unit_tests/openvpn/mock_msg.c
@@ -25,19 +25,22 @@
#endif
#include <stdarg.h>
-#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <setjmp.h>
-#include <stdint.h>
-#ifndef NO_CMOCKA
-#include <cmocka.h>
-#endif
#include "errlevel.h"
#include "error.h"
#include "mock_msg.h"
+#ifndef NO_CMOCKA
+#include <stddef.h>
+#include <setjmp.h>
+#include <stdint.h>
+#include <cmocka.h>
+
+#include "test_common.h"
+#endif
+
msglvl_t x_debug_level = 0; /* Default to (almost) no debugging output */
msglvl_t print_x_debug_level = 0;
@@ -106,7 +109,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 fb070aa..cbead68 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
@@ -48,6 +52,20 @@
#define expect_uint_value expect_value
#define expect_check_data expect_check
#define cast_ptr_to_cmocka_value(x) (x)
+
+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
/**
@@ -78,7 +96,7 @@
* @param filename name of the filename to retrieve relative to the
* unit test source directory
*/
-void
+static inline void
openvpn_test_get_srcdir_dir(char *buf, size_t bufsize, const char *filename)
{
const char *srcdir = getenv("srcdir");
@@ -93,3 +111,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 038b3cf..9573f8c 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/+/2405?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: release/2.7
Gerrit-Change-Id: Ifaebb8f5e7245c505a29c87f917f92bf16fa8027
Gerrit-Change-Number: 2405
Gerrit-PatchSet: 1
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