Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1101, Add functional test for NULL RemoteAddr in OS_SocketRecvFrom #1389

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/tests/network-api-test/network-api-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ void TestDatagramNetworkApi(void)
uint32 Buf2 = 0;
uint32 Buf3 = 222;
uint32 Buf4 = 0;
uint32 Buf5 = 333;
uint32 Buf6 = 0;
osal_id_t objid = OS_OBJECT_ID_UNDEFINED;
osal_id_t invalid_fd;
uint16 PortNum = 0;
Expand Down Expand Up @@ -327,6 +329,11 @@ void TestDatagramNetworkApi(void)
UtAssert_True(strcmp(AddrBuffer3, AddrBuffer4) == 0, "AddrBuffer3 (%s) == AddrBuffer4 (%s)", AddrBuffer3,
AddrBuffer4);

/* Send and receive data from peer 1 to peer 2 using a NULL RemoteAddr parameter for OS_SocketRecvFrom */
UtAssert_INT32_EQ(OS_SocketSendTo(p1_socket_id, &Buf5, sizeof(Buf5), &p2_addr), sizeof(Buf5));
UtAssert_INT32_EQ(OS_SocketRecvFrom(p2_socket_id, &Buf6, sizeof(Buf6), NULL, UT_TIMEOUT), sizeof(Buf6));
UtAssert_True(Buf5 == Buf6, "Buf5 (%ld) == Buf6 (%ld)", (long)Buf5, (long)Buf6);

/* Get port from incoming address and verify */
UtAssert_INT32_EQ(OS_SocketAddrGetPort(&PortNum, &p2_addr), OS_SUCCESS);
UtAssert_True(PortNum == 9998, "PortNum (%u) == 9998", (unsigned int)PortNum);
Expand Down