Skip to content

Commit

Permalink
Fix nasa#1101, Add functional test for NULL RemoteAddr in `OS_Soc…
Browse files Browse the repository at this point in the history
…ketRecvFrom`
  • Loading branch information
thnkslprpt committed May 18, 2023
1 parent 5036fed commit c824b3e
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit c824b3e

Please sign in to comment.