diff --git a/.github/lexicon.txt b/.github/lexicon.txt old mode 100644 new mode 100755 index 2c0031c48..47106730b --- a/.github/lexicon.txt +++ b/.github/lexicon.txt @@ -954,6 +954,7 @@ pvsource pxackmessage pxaddr pxaddress +pxaddresses pxaddressinfo pxaddresslength pxaddresstolookup diff --git a/source/FreeRTOS_DNS_Cache.c b/source/FreeRTOS_DNS_Cache.c index b1eec57d6..5021306fa 100644 --- a/source/FreeRTOS_DNS_Cache.c +++ b/source/FreeRTOS_DNS_Cache.c @@ -48,21 +48,6 @@ #if ( ( ipconfigUSE_DNS != 0 ) && ( ipconfigUSE_DNS_CACHE == 1 ) ) -/** - * @brief cache entry format structure - */ - typedef struct xDNS_CACHE_TABLE_ROW - { - IPv46_Address_t xAddresses[ ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY ]; /*!< The IP address(es) of an ARP cache entry. */ - char pcName[ ipconfigDNS_CACHE_NAME_LENGTH ]; /*!< The name of the host */ - uint32_t ulTTL; /*!< Time-to-Live (in seconds) from the DNS server. */ - uint32_t ulTimeWhenAddedInSeconds; /*!< time at which the entry was added */ - #if ( ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY > 1 ) - uint8_t ucNumIPAddresses; /*!< number of ip addresses for the same entry */ - uint8_t ucCurrentIPAddress; /*!< current ip address index */ - #endif - } DNSCacheRow_t; - /*! * @brief DNS cache structure instantiation */ @@ -521,7 +506,7 @@ { pxAddresses = &( xDNSCache[ uxIndex ].xAddresses[ uxIPAddressIndex ] ); - switch( pxAddresses->xIs_IPv6 ) + switch( pxAddresses->xIs_IPv6 ) /* LCOV_EXCL_BR_LINE - xIs_IPv6 is always either pdFALSE or pdTRUE. */ { #if ( ipconfigUSE_IPv4 != 0 ) case pdFALSE: @@ -538,10 +523,10 @@ break; #endif /* ( ipconfigUSE_IPv6 != 0 ) */ - default: + default: /* LCOV_EXCL_LINE - xIs_IPv6 is always either pdFALSE or FREERTOS_AF_INET6. */ /* MISRA 16.4 Compliance */ FreeRTOS_debug_printf( ( "prvReadDNSCache: Undefined IP Type \n" ) ); - break; + break; /* LCOV_EXCL_LINE - xIs_IPv6 is always either pdFALSE or FREERTOS_AF_INET6. */ } if( pxNewAddress == NULL ) diff --git a/source/FreeRTOS_DNS_Parser.c b/source/FreeRTOS_DNS_Parser.c old mode 100644 new mode 100755 diff --git a/source/include/FreeRTOS_DNS_Cache.h b/source/include/FreeRTOS_DNS_Cache.h old mode 100644 new mode 100755 index 873f3c174..13aa42ec8 --- a/source/include/FreeRTOS_DNS_Cache.h +++ b/source/include/FreeRTOS_DNS_Cache.h @@ -38,6 +38,21 @@ #if ( ( ipconfigUSE_DNS_CACHE == 1 ) && ( ipconfigUSE_DNS != 0 ) ) +/** + * @brief cache entry format structure + */ + typedef struct xDNS_CACHE_TABLE_ROW + { + IPv46_Address_t xAddresses[ ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY ]; /*!< The IP address(es) of an ARP cache entry. */ + char pcName[ ipconfigDNS_CACHE_NAME_LENGTH ]; /*!< The name of the host */ + uint32_t ulTTL; /*!< Time-to-Live (in seconds) from the DNS server. */ + uint32_t ulTimeWhenAddedInSeconds; /*!< time at which the entry was added */ + #if ( ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY > 1 ) + uint8_t ucNumIPAddresses; /*!< number of ip addresses for the same entry */ + uint8_t ucCurrentIPAddress; /*!< current ip address index */ + #endif + } DNSCacheRow_t; + /* Look for the indicated host name in the DNS cache. Returns the IPv4 * address if present, or 0x0 otherwise. */ uint32_t FreeRTOS_dnslookup( const char * pcHostName ); diff --git a/test/unit-test/FreeRTOS_DNS_Cache/FreeRTOS_DNS_Cache_utest.c b/test/unit-test/FreeRTOS_DNS_Cache/FreeRTOS_DNS_Cache_utest.c old mode 100644 new mode 100755 index 4526aadb9..7907b4206 --- a/test/unit-test/FreeRTOS_DNS_Cache/FreeRTOS_DNS_Cache_utest.c +++ b/test/unit-test/FreeRTOS_DNS_Cache/FreeRTOS_DNS_Cache_utest.c @@ -43,8 +43,9 @@ #include "mock_FreeRTOS_DNS_Parser.h" #include "mock_FreeRTOS_DNS_Networking.h" #include "mock_NetworkBufferManagement.h" -#include "FreeRTOS_DNS.h" +#include "mock_FreeRTOS_DNS.h" +#include "FreeRTOS_DNS_Cache.h" #include "catch_assert.h" @@ -71,8 +72,11 @@ static void dns_callback( const char * pcName, callback_called = 1; } +/* =========================== EXTERN VARIABLES =========================== */ +extern pucAddrBuffer[ 2 ]; +extern pucSockAddrBuffer[ 1 ]; -/* ============================ TEST FIXTURES ============================= */ +/* ============================ UNITY FIXTURES ============================= */ /** * @brief calls at the beginning of each test case @@ -90,6 +94,11 @@ void tearDown( void ) { } +/*! + * @brief DNS cache structure instantiation + */ +static DNSCacheRow_t xDNSCache[ ipconfigDNS_CACHE_ENTRIES ]; + /* ============================= TEST CASES =============================== */ @@ -107,7 +116,7 @@ void test_processDNS_CACHE_CatchAssert( void ) } /** - * @brief Ensures that the same entry is inserted into the cache and retrieved + * @brief Ensures that the same entry is inserted into the cache and retrieved. */ void test_processDNS_CACHE_Success( void ) { @@ -116,7 +125,7 @@ void test_processDNS_CACHE_Success( void ) IPv46_Address_t pxIP; pxIP.xIPAddress.ulIP_IPv4 = pulIP; - pxIP.xIs_IPv6 = 0; + pxIP.xIs_IPv6 = pdFALSE; xTaskGetTickCount_ExpectAndReturn( 3000 ); /* 3 seconds */ FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); @@ -133,6 +142,87 @@ void test_processDNS_CACHE_Success( void ) TEST_ASSERT_EQUAL( pulIP, x ); } +/** + * @brief Ensures that the same entry is inserted into the cache and retrieved for IPv6 + */ +void test_processDNS_CACHE_Success2( void ) +{ + uint32_t ulReturn = 0U; + uint32_t pulIP = 1234; + IPv46_Address_t pxIP; + + pxIP.xIPAddress.ulIP_IPv4 = pulIP; + pxIP.xIs_IPv6 = pdTRUE; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); /* 3 seconds */ + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "hello", + &pxIP, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); /* lives 3 seconds */ + + xTaskGetTickCount_ExpectAndReturn( 5000 ); /* 5 seconds */ + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + ulReturn = FreeRTOS_dnslookup6( "hello", &pxIP ); + + TEST_ASSERT_EQUAL( ulReturn, 1 ); +} + +/** + * @brief Ensures that failure occurs when different entry is inserted into the cache and retrieved for IPv6 + */ +void test_processDNS_CACHE_Fail_IPv6( void ) +{ + uint32_t ulReturn = 0U; + uint32_t pulIP = 1234; + IPv46_Address_t pxIP; + + pxIP.xIPAddress.ulIP_IPv4 = pulIP; + pxIP.xIs_IPv6 = pdFALSE; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); /* 3 seconds */ + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "hello", + &pxIP, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); /* lives 3 seconds */ + + xTaskGetTickCount_ExpectAndReturn( 10000 ); /* 10 seconds */ + + ulReturn = FreeRTOS_dnslookup6( "helloworld", &pxIP ); + + TEST_ASSERT_EQUAL( ulReturn, 0 ); +} + +/** + * @brief Cannot Confirm that the record in the DNS Cache is still fresh. + */ +void test_processDNS_CACHE_Entry_NotFresh( void ) +{ + BaseType_t x; + uint32_t pulIP = 1234; + IPv46_Address_t pxIP; + + pxIP.xIPAddress.ulIP_IPv4 = pulIP; + pxIP.xIs_IPv6 = 0; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); /* 3 seconds */ + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "hello", + &pxIP, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); /* lives 3 seconds */ + + + xTaskGetTickCount_ExpectAndReturn( 8000 ); /* 8 seconds */ + + x = FreeRTOS_dnslookup( "hello" ); + + TEST_ASSERT_EQUAL( 0, x ); +} + + /** * @brief Ensures empty cache returns zero */ @@ -339,3 +429,353 @@ void test_processDNS_CACHE_exceed_dns_name_limit( void ) TEST_ASSERT_EQUAL( 0, x ); } + +/** + * @brief DNS Lookup success + */ + +void test_prepare_DNSLookup( void ) +{ + BaseType_t x = 0U; + BaseType_t xFamily; + struct freertos_addrinfo * pxAddressInfo = &pucAddrBuffer[ 0 ]; + struct freertos_addrinfo ** ppxAddressInfo = &pucAddrBuffer[ 1 ]; + IPv46_Address_t xAddress; + uint32_t ulIP = 1234U; + + struct freertos_sockaddr * sockaddr = &pucSockAddrBuffer[ 0 ]; + + sockaddr->sin_address.ulIP_IPv4 = ulIP; + + pxAddressInfo->ai_addr = sockaddr; + *ppxAddressInfo = pxAddressInfo; + + xFamily = FREERTOS_AF_INET; + xAddress.xIs_IPv6 = pdFALSE; + xAddress.xIPAddress.ulIP_IPv4 = ulIP; + + struct freertos_addrinfo * pxAddrInfo = &pucAddrBuffer[ 2 ]; + + ( void ) memset( pxAddrInfo, 0, sizeof( *pxAddrInfo ) ); + pxAddrInfo->ai_canonname = pxAddrInfo->xPrivateStorage.ucName; + ( void ) strncpy( pxAddrInfo->xPrivateStorage.ucName, "hello", sizeof( pxAddrInfo->xPrivateStorage.ucName ) ); + + pxAddrInfo->ai_addr = ( ( struct freertos_sockaddr * ) &( pxAddrInfo->xPrivateStorage.sockaddr ) ); + + pxAddrInfo->ai_addr = sockaddr; + pxAddrInfo->ai_family = FREERTOS_AF_INET4; + pxAddrInfo->ai_addrlen = ipSIZE_OF_IPv4_ADDRESS; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "hello", + &xAddress, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); + + xTaskGetTickCount_ExpectAndReturn( 5000 ); + pxNew_AddrInfo_ExpectAnyArgsAndReturn( pxAddrInfo ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + xDNSCache[ 0 ].xAddresses[ 0 ] = xAddress; + + x = Prepare_CacheLookup( "hello", xFamily, ppxAddressInfo ); + TEST_ASSERT_EQUAL( ulIP, x ); +} + + +/** + * @brief DNS Lookup fail : pxAddressInfo = NULL + */ + +void test_prepare_DNSLookup2( void ) +{ + BaseType_t x = 0U; + BaseType_t xFamily; + struct freertos_addrinfo * pxAddressInfo = NULL; + struct freertos_addrinfo ** ppxAddressInfo = &pucAddrBuffer[ 0 ]; + IPv46_Address_t xAddress; + + xFamily = FREERTOS_AF_INET; + xAddress.xIs_IPv6 = pdFALSE; + ppxAddressInfo = &pxAddressInfo; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); /* 3 seconds */ + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "helloman", + &xAddress, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); /* lives 3 seconds */ + + xTaskGetTickCount_ExpectAndReturn( 5000 ); /* 5 seconds */ + pxNew_AddrInfo_ExpectAnyArgsAndReturn( NULL ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + x = Prepare_CacheLookup( "helloman", xFamily, ppxAddressInfo ); + TEST_ASSERT_EQUAL( 0, x ); +} + +/** + * @brief DNS Lookup fail : (*ppxAddressInfo) == NULL, ( *pxAddressInfo = NULL ) + */ +void test_prepare_DNSLookup3( void ) +{ + BaseType_t x = 0U; + BaseType_t xFamily; + struct freertos_addrinfo ** ppxAddressInfo = NULL; + struct freertos_addrinfo * pxAddressInfo = NULL; + IPv46_Address_t xAddress; + + xFamily = FREERTOS_AF_INET; + xAddress.xIs_IPv6 = pdFALSE; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "helloman", + &xAddress, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); + + xTaskGetTickCount_ExpectAndReturn( 5000 ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + x = Prepare_CacheLookup( "helloman", xFamily, ppxAddressInfo ); + TEST_ASSERT_EQUAL( 0, x ); +} + +/** + * @brief DNS Lookup fail : (*ppxAddressInfo) == NULL + */ +void test_prepare_DNSLookup4( void ) +{ + BaseType_t x = 0U; + BaseType_t xFamily; + struct freertos_addrinfo ** ppxAddressInfo = NULL; + struct freertos_addrinfo * pxAddressInfo = &pucAddrBuffer[ 0 ]; + IPv46_Address_t xAddress; + + xFamily = FREERTOS_AF_INET; + xAddress.xIs_IPv6 = pdFALSE; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "hello", + &xAddress, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); + + xTaskGetTickCount_ExpectAndReturn( 5000 ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + x = Prepare_CacheLookup( "hello", xFamily, ppxAddressInfo ); + TEST_ASSERT_EQUAL( 0, x ); +} + +/** + * @brief DNS Lookup fail : Different entry lookup + */ +void test_prepare_DNSLookup5( void ) +{ + BaseType_t x = 0U; + BaseType_t xFamily; + struct freertos_addrinfo ** ppxAddressInfo = &pucAddrBuffer[ 0 ]; + struct freertos_addrinfo * pxAddressInfo = &pucAddrBuffer[ 1 ]; + IPv46_Address_t xAddress; + + xFamily = FREERTOS_AF_INET; + xAddress.xIs_IPv6 = pdFALSE; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "hello", + &xAddress, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); + + xTaskGetTickCount_ExpectAndReturn( 5000 ); + + x = Prepare_CacheLookup( "aws", xFamily, ppxAddressInfo ); + TEST_ASSERT_EQUAL( 0, x ); +} + +/** + * @brief DNS Lookup fail : xFamily invalid + */ +void test_prepare_DNSLookup6( void ) +{ + BaseType_t x = 0U; + BaseType_t xFamily; + struct freertos_addrinfo ** ppxAddressInfo = NULL; + struct freertos_addrinfo * pxAddressInfo = &pucAddrBuffer[ 0 ]; + IPv46_Address_t xAddress; + + xFamily = FREERTOS_AF_INET ^ FREERTOS_AF_INET6; + xAddress.xIs_IPv6 = pdFALSE; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "hello", + &xAddress, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); + + x = Prepare_CacheLookup( "hello", xFamily, ppxAddressInfo ); + TEST_ASSERT_EQUAL( 0, x ); +} + +/** + * @brief DNS Lookup success : IPv6 + */ +void test_prepare_DNSLookup_IPv6( void ) +{ + BaseType_t x = 0U; + BaseType_t xFamily; + struct freertos_addrinfo * pxAddressInfo = &pucAddrBuffer[ 0 ]; + struct freertos_addrinfo ** ppxAddressInfo = &pucAddrBuffer[ 1 ]; + IPv46_Address_t xAddress; + + xFamily = FREERTOS_AF_INET6; + xAddress.xIs_IPv6 = pdTRUE; + + *ppxAddressInfo = pxAddressInfo; + + struct freertos_addrinfo * pxAddrInfo = &pucAddrBuffer[ 2 ]; + + ( void ) memset( pxAddrInfo, 0, sizeof( *pxAddrInfo ) ); + pxAddrInfo->ai_canonname = pxAddrInfo->xPrivateStorage.ucName; + ( void ) strncpy( pxAddrInfo->xPrivateStorage.ucName, "hello", sizeof( pxAddrInfo->xPrivateStorage.ucName ) ); + + pxAddrInfo->ai_addr = ( ( struct freertos_sockaddr * ) &( pxAddrInfo->xPrivateStorage.sockaddr ) ); + + pxAddrInfo->ai_family = FREERTOS_AF_INET6; + pxAddrInfo->ai_addrlen = ipSIZE_OF_IPv6_ADDRESS; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); /* 3 seconds */ + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "hello", + &xAddress, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); /* lives 3 seconds */ + + xTaskGetTickCount_ExpectAndReturn( 5000 ); /* 5 seconds */ + pxNew_AddrInfo_ExpectAnyArgsAndReturn( pxAddrInfo ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + x = Prepare_CacheLookup( "hello", xFamily, ppxAddressInfo ); + TEST_ASSERT_EQUAL( 1, x ); +} + +/** + * @brief DNS IPv6 Lookup fail : pxAddressInfo = NULL + */ + +void test_prepare_DNSLookup2_IPv6( void ) +{ + BaseType_t x = 0U; + BaseType_t xFamily; + struct freertos_addrinfo * pxAddressInfo = NULL; + struct freertos_addrinfo ** ppxAddressInfo = &pucAddrBuffer[ 0 ]; + IPv46_Address_t xAddress; + + xFamily = FREERTOS_AF_INET6; + xAddress.xIs_IPv6 = pdTRUE; + ppxAddressInfo = &pxAddressInfo; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); /* 3 seconds */ + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "helloman", + &xAddress, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); /* lives 3 seconds */ + + xTaskGetTickCount_ExpectAndReturn( 5000 ); /* 5 seconds */ + pxNew_AddrInfo_ExpectAnyArgsAndReturn( NULL ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + x = Prepare_CacheLookup( "helloman", xFamily, ppxAddressInfo ); + TEST_ASSERT_EQUAL( 0, x ); +} + +/** + * @brief DNS IPv6 Lookup fail : (*ppxAddressInfo) == NULL, ( *pxAddressInfo = NULL ) + */ +void test_prepare_DNSLookup3_IPv6( void ) +{ + BaseType_t x = 0U; + BaseType_t xFamily; + struct freertos_addrinfo ** ppxAddressInfo = NULL; + struct freertos_addrinfo * pxAddressInfo = NULL; + IPv46_Address_t xAddress; + + xFamily = FREERTOS_AF_INET6; + xAddress.xIs_IPv6 = pdTRUE; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "helloman", + &xAddress, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); + + xTaskGetTickCount_ExpectAndReturn( 5000 ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + x = Prepare_CacheLookup( "helloman", xFamily, ppxAddressInfo ); + TEST_ASSERT_EQUAL( 0, x ); +} + +/** + * @brief DNS IPv6 Lookup fail : (*ppxAddressInfo) == NULL + */ +void test_prepare_DNSLookup4_IPv6( void ) +{ + BaseType_t x = 0U; + BaseType_t xFamily; + struct freertos_addrinfo ** ppxAddressInfo = NULL; + struct freertos_addrinfo * pxAddressInfo = &pucAddrBuffer[ 0 ]; + IPv46_Address_t xAddress; + + + xFamily = FREERTOS_AF_INET6; + xAddress.xIs_IPv6 = pdTRUE; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "hello", + &xAddress, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); + + xTaskGetTickCount_ExpectAndReturn( 5000 ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + + x = Prepare_CacheLookup( "hello", xFamily, ppxAddressInfo ); + TEST_ASSERT_EQUAL( 0, x ); +} + +/** + * @brief DNS IPv6 Lookup fail : Different entry lookup + */ +void test_prepare_DNSLookup5_IPv6( void ) +{ + BaseType_t x = 0U; + BaseType_t xFamily; + struct freertos_addrinfo ** ppxAddressInfo = &pucAddrBuffer[ 0 ]; + struct freertos_addrinfo * pxAddressInfo = &pucAddrBuffer[ 1 ]; + IPv46_Address_t xAddress; + + xFamily = FREERTOS_AF_INET6; + xAddress.xIs_IPv6 = pdTRUE; + + xTaskGetTickCount_ExpectAndReturn( 3000 ); + FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL ); + + FreeRTOS_dns_update( "hello", + &xAddress, + FreeRTOS_htonl( 3 ), pdFALSE, NULL ); + + xTaskGetTickCount_ExpectAndReturn( 5000 ); + + x = Prepare_CacheLookup( "aws", xFamily, ppxAddressInfo ); + TEST_ASSERT_EQUAL( 0, x ); +} diff --git a/test/unit-test/FreeRTOS_DNS_Cache/FreeRTOS_UDP_IP_stubs.c b/test/unit-test/FreeRTOS_DNS_Cache/FreeRTOS_UDP_IP_stubs.c old mode 100644 new mode 100755 index 3a829a372..4d27b46d2 --- a/test/unit-test/FreeRTOS_DNS_Cache/FreeRTOS_UDP_IP_stubs.c +++ b/test/unit-test/FreeRTOS_DNS_Cache/FreeRTOS_UDP_IP_stubs.c @@ -42,6 +42,13 @@ const BaseType_t xBufferAllocFixedSize = pdTRUE; +/* =========================== EXTERN VARIABLES =========================== */ + +struct freertos_addrinfo pucAddrBuffer[ 2 ]; +struct freertos_sockaddr pucSockAddrBuffer[ 1 ]; + +/* ======================== Stub Callback Functions ========================= */ + void vPortEnterCritical( void ) { } @@ -56,12 +63,6 @@ BaseType_t xApplicationDNSQueryHook_Multi( struct xNetworkEndPoint * pxEndPoint, return pdFALSE; } -struct freertos_addrinfo * pxNew_AddrInfo( const char * pcName, - BaseType_t xFamily, - const uint8_t * pucAddress ) -{ -} - #define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) UDPPacketHeader_t xDefaultPartUDPPacketHeader = { diff --git a/test/unit-test/FreeRTOS_DNS_Cache/ut.cmake b/test/unit-test/FreeRTOS_DNS_Cache/ut.cmake old mode 100644 new mode 100755 index cbfa5150a..c69aa7b42 --- a/test/unit-test/FreeRTOS_DNS_Cache/ut.cmake +++ b/test/unit-test/FreeRTOS_DNS_Cache/ut.cmake @@ -17,6 +17,7 @@ list(APPEND mock_list "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Private.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/NetworkBufferManagement.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_UDP_IP.h" + "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DNS.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DNS_Callback.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DNS_Networking.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DNS_Parser.h"