diff options
author | Vladislavs Sokurenko <vladislavs.sokurenko@zabbix.com> | 2021-09-13 15:03:52 +0300 |
---|---|---|
committer | Vladislavs Sokurenko <vladislavs.sokurenko@zabbix.com> | 2021-09-13 15:09:25 +0300 |
commit | 84efddb04ec9ceb7743d30c711c0afac12bbf777 (patch) | |
tree | 97c4021608670763f0f9f662ef8bbe26dfff6c57 /tests | |
parent | 5e91100067cd5eb57f4f1edde434bb89d55e7e97 (diff) |
...G...PS. [ZBXNEXT-6840] cherry picked from 5.0 and fixed conflict in trapper.c
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libs/zbxcommshigh/zbx_tcp_recv_ext.c | 9 | ||||
-rw-r--r-- | tests/libs/zbxcommshigh/zbx_tcp_recv_ext_zlib.yaml | 10 |
2 files changed, 16 insertions, 3 deletions
diff --git a/tests/libs/zbxcommshigh/zbx_tcp_recv_ext.c b/tests/libs/zbxcommshigh/zbx_tcp_recv_ext.c index b26df85823a..56a5dbeba31 100644 --- a/tests/libs/zbxcommshigh/zbx_tcp_recv_ext.c +++ b/tests/libs/zbxcommshigh/zbx_tcp_recv_ext.c @@ -33,7 +33,7 @@ void zbx_mock_test_entry(void **state) char *buffer; zbx_socket_t s; ssize_t received; - int expected_ret; + int expected_ret, offset = ZBX_TCP_HEADER_DATALEN_LEN; ZBX_UNUSED(state); @@ -41,7 +41,7 @@ void zbx_mock_test_entry(void **state) zbx_tcp_connect(&s, NULL, "127.0.0.1", 10050, 0, ZBX_TCP_SEC_UNENCRYPTED, NULL, NULL)); expected_ret = zbx_mock_str_to_return_code(zbx_mock_get_parameter_string("out.return")); - received = zbx_tcp_recv_ext(&s, 0); + received = zbx_tcp_recv_ext(&s, 0, ZBX_TCP_LARGE); if (FAIL == expected_ret) { @@ -58,7 +58,10 @@ void zbx_mock_test_entry(void **state) buffer = zbx_yaml_assemble_binary_sequence("out.fragments", received); - if (0 != memcmp(buffer + ZBX_TCP_HEADER_DATALEN_LEN, s.buffer, received - ZBX_TCP_HEADER_DATALEN_LEN)) + if (0 != (ZBX_TCP_LARGE & s.protocol)) + offset += 8; + + if (0 != memcmp(buffer + offset, s.buffer, received - offset)) fail_msg("Received message mismatch expected"); zbx_tcp_close(&s); diff --git a/tests/libs/zbxcommshigh/zbx_tcp_recv_ext_zlib.yaml b/tests/libs/zbxcommshigh/zbx_tcp_recv_ext_zlib.yaml index b14cd5d351d..048210547d8 100644 --- a/tests/libs/zbxcommshigh/zbx_tcp_recv_ext_zlib.yaml +++ b/tests/libs/zbxcommshigh/zbx_tcp_recv_ext_zlib.yaml @@ -35,3 +35,13 @@ out: fragments: - 'ZBXD\x03\x12\x00\x00\x00\x0A\x00\x00\x00agent.ping' return: FAIL +--- +test case: Compressed data with large length fields +in: + fragments: &fragments + - 'ZBXD\x07\x12\x00\x00\x00\x00\x00\x00\x00\x0A\x00\x00\x00\x00\x00\x00\x00\x78\x9C\x4B\x4C\x4F\xCD\x2B\xD1\x2B\xC8\xCC\x4B\x07\x00\x15\x79\x03\xEC' +out: + fragments: + - 'ZBXD\x07\x12\x00\x00\x00\x00\x00\x00\x00\x0A\x00\x00\x00\x00\x00\x00\x00agent.ping' + return: SUCCEED + bytes: 31 |