diff options
author | Vladislavs Sokurenko <vladislavs.sokurenko@zabbix.com> | 2018-01-18 16:38:47 +0300 |
---|---|---|
committer | Vladislavs Sokurenko <vladislavs.sokurenko@zabbix.com> | 2018-01-18 16:38:47 +0300 |
commit | 875111a15fdf91ae2ef18fef05e50e86346eff19 (patch) | |
tree | f8873b27f05ccbd0e8adcd542d0484634eb6108b /tests/libs/zbxcommshigh | |
parent | 9ddbfb72a5ab64d90ac554b5fb486712606d4479 (diff) |
.......... [ZBXNEXT-3581] mock connect function
Diffstat (limited to 'tests/libs/zbxcommshigh')
-rw-r--r-- | tests/libs/zbxcommshigh/Makefile.am | 3 | ||||
-rw-r--r-- | tests/libs/zbxcommshigh/zbx_tcp_recv_ext.c | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/tests/libs/zbxcommshigh/Makefile.am b/tests/libs/zbxcommshigh/Makefile.am index 6eadaa43966..5f6c64e7ff9 100644 --- a/tests/libs/zbxcommshigh/Makefile.am +++ b/tests/libs/zbxcommshigh/Makefile.am @@ -47,7 +47,8 @@ zbx_tcp_recv_ext_SOURCES = \ $(COMMON_SRC_FILES) zbx_tcp_recv_ext_WRAP_FUNCS = \ - -Wl,--wrap=read + -Wl,--wrap=read \ + -Wl,--wrap=connect zbx_tcp_recv_ext_LDADD = \ $(COMMON_LIB_FILES) diff --git a/tests/libs/zbxcommshigh/zbx_tcp_recv_ext.c b/tests/libs/zbxcommshigh/zbx_tcp_recv_ext.c index 6f6b8a64ffc..64174d47db6 100644 --- a/tests/libs/zbxcommshigh/zbx_tcp_recv_ext.c +++ b/tests/libs/zbxcommshigh/zbx_tcp_recv_ext.c @@ -87,6 +87,15 @@ static char *yaml_assemble_binary_data_array(ssize_t expected) return buffer; } +int __wrap_connect(int fd, __CONST_SOCKADDR_ARG addr, socklen_t len) +{ + ZBX_UNUSED(fd); + ZBX_UNUSED(addr); + ZBX_UNUSED(len); + + return 0; +} + ssize_t __wrap_read(int fd, void *buf, size_t nbytes) { zbx_mock_error_t error; @@ -110,6 +119,7 @@ ssize_t __wrap_read(int fd, void *buf, size_t nbytes) void zbx_mock_test_entry(void **state) { #define ZBX_TCP_HEADER_DATALEN_LEN 13 + char *buffer; zbx_socket_t s; ssize_t received, expected; @@ -117,7 +127,8 @@ void zbx_mock_test_entry(void **state) ZBX_UNUSED(state); - zbx_tcp_connect_mock(&s, "127.0.0.2", "127.0.0.1", 10050, 0, 0, NULL, NULL); + if (SUCCEED != zbx_tcp_connect(&s, NULL, "127.0.0.1", 10050, 0, ZBX_TCP_SEC_UNENCRYPTED, NULL, NULL)) + fail_msg("Failed to connect"); if (ZBX_MOCK_SUCCESS != (error = zbx_mock_in_parameter("recv data", &fragments))) fail_msg("Cannot get recv data handle: %s", zbx_mock_error_string(error)); |