Skip to content

Commit

Permalink
unit-test: Fix missing symbol in a few tests (linker error)
Browse files Browse the repository at this point in the history
I don't know why I get to resolve these, but in all cases,
it is FreeRTOS_Sockets.c that is dragging in a dependency on
xTCPWindowLoggingLevel, causing a few tests to fail to link:

    FreeRTOS_Sockets.c:5118:(.text+0x18fa2):
    undefined reference to `xTCPWindowLoggingLevel'

Since it's one external variable, let's add it to the necessary unittests.

Also under the headline of extern variables:
The IPv6 address, which was not there for linkage, could be made const.
  • Loading branch information
anordal committed Jun 4, 2024
1 parent 28d5fa8 commit 24b4705
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ BaseType_t xRNGStatus;
BaseType_t xLocalReceiveCallback_Return;
uint8_t xLocalReceiveCallback_Called = 0;

BaseType_t xTCPWindowLoggingLevel = 0;

/* ======================== Stub Callback Functions ========================= */

EventBits_t xStubForEventGroupWaitBits( EventGroupHandle_t xEventGroup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@

#include "catch_assert.h"

/* ============================== Test Cases ============================== */
/* ============================ EXTERN VARIABLES ============================ */

BaseType_t xTCPWindowLoggingLevel = 0;

/* =============================== Test Cases =============================== */

/**
* @brief Binding successful.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
/* ============================ EXTERN VARIABLES ============================ */

/* 2001::1 */
static IPv6_Address_t xIPv6Address = { { 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 } };
static const IPv6_Address_t xIPv6Address = { { 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 } };

BaseType_t xTCPWindowLoggingLevel = 0;

/* ============================== Test Cases ============================== */

Expand Down Expand Up @@ -231,7 +233,7 @@ void test_FreeRTOS_connect_SocketValuesNULL_NullDestinationAddress( void )
void test_prvSocketProps_UDPv6()
{
FreeRTOS_Socket_t xSocket;
IPv6_Address_t * pxIPv6SrcAddress = &xIPv6Address; /* 2001::1 */
const IPv6_Address_t * pxIPv6SrcAddress = &xIPv6Address; /* 2001::1 */
uint16_t usSrcPort = 1024U;
const char * pcReturn;

Expand All @@ -251,7 +253,7 @@ void test_prvSocketProps_UDPv6()
void test_prvSocketProps_TCPv6()
{
FreeRTOS_Socket_t xSocket;
IPv6_Address_t * pxIPv6SrcAddress = &xIPv6Address; /* 2001::1 */
const IPv6_Address_t * pxIPv6SrcAddress = &xIPv6Address; /* 2001::1 */
IPv6_Address_t xIPv6RemoteAddress = { { 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 } }; /* 2001::2 */
uint16_t usSrcPort = 1024U;
uint16_t usRemotePort = 2048U;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
/* ============================ EXTERN VARIABLES ============================ */

/* 2001::1 */
static IPv6_Address_t xIPv6Address = { { 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 } };
static const IPv6_Address_t xIPv6Address = { { 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 } };

BaseType_t xTCPWindowLoggingLevel = 0;

/* =============================== Test Cases =============================== */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

#define TEST_MAX_UDPV4_PAYLOAD_LENGTH ipconfigNETWORK_MTU - ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_UDP_HEADER )

BaseType_t xTCPWindowLoggingLevel = 0;

/* =============================== Test Cases =============================== */

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ BaseType_t prvDetermineSocketSize( BaseType_t xDomain,
BaseType_t xProtocol,
size_t * pxSocketSize );

BaseType_t xTCPWindowLoggingLevel = 0;

/* ============================== Test Cases ============================== */

/**
Expand Down

0 comments on commit 24b4705

Please sign in to comment.