From 10c715d9215a7fbc6bc5000f10169c128af11854 Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Fri, 21 Feb 2020 15:12:31 +0900 Subject: [PATCH] examples: usrsocktest: Fix errors in NoBlockRecv and BlockRecv tests NOTE: Because sin_zero field is just a padding, so should be ignored. Signed-off-by: Masayuki Ishikawa --- examples/usrsocktest/usrsocktest_block_recv.c | 6 ++++-- examples/usrsocktest/usrsocktest_noblock_recv.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/usrsocktest/usrsocktest_block_recv.c b/examples/usrsocktest/usrsocktest_block_recv.c index 54827d75a..d7a5a005f 100644 --- a/examples/usrsocktest/usrsocktest_block_recv.c +++ b/examples/usrsocktest/usrsocktest_block_recv.c @@ -265,7 +265,8 @@ static void NoBlockConnect(FAR struct usrsocktest_daemon_conf_s *dconf) TEST_ASSERT_EQUAL(1, ret); TEST_ASSERT_EQUAL_UINT8_ARRAY("a", data, 1); TEST_ASSERT_EQUAL(sizeof(remoteaddr), addrlen); - TEST_ASSERT_EQUAL_UINT8_ARRAY(&remoteaddr, &addr, addrlen); + TEST_ASSERT_EQUAL_UINT8_ARRAY(&remoteaddr, &addr, + addrlen - sizeof(addr.sin_zero)); TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_connected_sockets()); TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_active_sockets()); TEST_ASSERT_EQUAL(6, usrsocktest_daemon_get_recv_bytes()); @@ -282,7 +283,8 @@ static void NoBlockConnect(FAR struct usrsocktest_daemon_conf_s *dconf) TEST_ASSERT_EQUAL(5, ret); TEST_ASSERT_EQUAL_UINT8_ARRAY("abcde", data, 5); TEST_ASSERT_EQUAL(sizeof(remoteaddr), addrlen); - TEST_ASSERT_EQUAL_UINT8_ARRAY(&remoteaddr, &addr, addrlen); + TEST_ASSERT_EQUAL_UINT8_ARRAY(&remoteaddr, &addr, + addrlen - sizeof(addr.sin_zero)); TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_connected_sockets()); TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_active_sockets()); TEST_ASSERT_EQUAL(11, usrsocktest_daemon_get_recv_bytes()); diff --git a/examples/usrsocktest/usrsocktest_noblock_recv.c b/examples/usrsocktest/usrsocktest_noblock_recv.c index 2e511796e..4afccbbf2 100644 --- a/examples/usrsocktest/usrsocktest_noblock_recv.c +++ b/examples/usrsocktest/usrsocktest_noblock_recv.c @@ -197,7 +197,8 @@ static void Receive(struct usrsocktest_daemon_conf_s *dconf) TEST_ASSERT_EQUAL(3, ret); TEST_ASSERT_EQUAL_UINT8_ARRAY("abc", data, 3); TEST_ASSERT_EQUAL(addrlen, sizeof(remoteaddr)); - TEST_ASSERT_EQUAL_UINT8_ARRAY(&remoteaddr, &addr, addrlen); + TEST_ASSERT_EQUAL_UINT8_ARRAY(&remoteaddr, &addr, + addrlen - sizeof(addr.sin_zero)); TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_connected_sockets()); TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_active_sockets()); TEST_ASSERT_EQUAL(datalen + ret, usrsocktest_daemon_get_recv_bytes());