test_tls_crypt: Improve mock() usage to be more portable
PATCH 1/1 test_tls_crypt: Improve mock() usage to be more portable
Use the casting variants of mock(). Using the mock_ptr_type fixes an existing bug where test_tls_crypt.c couldn't build in MinGW 32bit:
test_tls_crypt.c:127:27: error:
cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
127 | const char *pem_str = (const char *) mock();
--- tests/unit_tests/openvpn/test_tls_crypt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/unit_tests/openvpn/test_tls_crypt.c +2 -2
@@ -116,7 +116,7 @@ __wrap_buffer_write_file(const char *filename, const struct buffer *buf)check_expected (filename);check_expected (pem); -return mock (); +return mock_type (bool); }struct buffer
@@ -124,7 +124,7 @@ __wrap_buffer_read_from_file(const char *filename, struct gc_arena *gc) {check_expected (filename); -const char *pem_str = (const char *)mock (); + const char *pem_str = mock_ptr_type(const char *);struct buffer ret =alloc_buf_gc (strlen (pem_str) +1 , gc);buf_write (&ret, pem_str,strlen (pem_str) +1 );
Signature · 1 line
2.34.1
Am 30.06.23 um 15:39 schrieb Frank Lichtenheld:
Quoted 3 lines
Use the casting variants of
mock(). Using themock_ptr_typefixes an existing bug wheretest_tls_crypt.ccouldn't build in MinGW 32bit:
I tried to read up what mock() and the rest of these functions do, and it seems the necessary amount of coffee has worn out... but anyway, you and Arne understand that stuff, it's testing code, and it passes (Linux) "make check", so good enough.
Your patch has been applied to the master and release/2.6 branch.
commit e87e44f7bcdffc208292cce9d314e2e52a175026 (master) commit 4f24f71f6a1f491fe404370707cc6a4f549fcab3 (release/2.6)
Author: Frank Lichtenheld Date: Fri Jun 30 14:39:08 2023 +0200
test_tls_crypt: Improve mock() usage to be more portable
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg26796.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering