Skip to content

Commit

Permalink
Unit Test for DHCP (FreeRTOS#902)
Browse files Browse the repository at this point in the history
* 100% coverage for DHCP

* Fix multiple redefinition issue

* Fix spell check error

* fix spelling

* Fix 100% coverage for DNS_cache and DNS_Parser

* Add workflow for coverage check

* Fix Format issue

* Fix source code

* Add test case for Malformed packet in xProcessCheckOption
  • Loading branch information
kar-rahul-aws authored Jun 9, 2023
1 parent 2ece7fe commit 9e525be
Show file tree
Hide file tree
Showing 7 changed files with 2,651 additions and 793 deletions.
3 changes: 3 additions & 0 deletions .github/lexicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ dff
dhcp
dhcpbroadcast
dhcpcookie
dhcpmsg
dhcpserveraddress
didn
diff
Expand Down Expand Up @@ -552,6 +553,7 @@ macobject
macobjhandle
macobjstatus
macvlantr
malformed
malloc
malloclarge
mallocsocket
Expand Down Expand Up @@ -1410,6 +1412,7 @@ ulflag
ulflags
ulgateway
ulgatewayaddress
ulgenericlength
ulgetruntimecountervalue
ulhighestrxallowed
ulhighestsequencenumber
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
run: |
make -C test/unit-test/build/ coverage
lcov --list --rc lcov_branch_coverage=1 test/unit-test/build/coverage.info
# - name: Check Coverage
# uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main
# with:
# path: ./test/unit-test/build/coverage.info
- name: Check Coverage
uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main
with:
path: ./test/unit-test/build/coverage.info

spell-check:
runs-on: ubuntu-latest
Expand Down
7 changes: 1 addition & 6 deletions source/FreeRTOS_DHCP.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,6 @@
/* Bind to the standard DHCP client port. */
xAddress.sin_port = ( uint16_t ) dhcpCLIENT_PORT_IPv4;
xReturn = vSocketBind( xDHCPv4Socket, &xAddress, sizeof( xAddress ), pdFALSE );
configASSERT( xReturn == 0 );
xDHCPSocketUserCount = 1;
FreeRTOS_printf( ( "DHCP-socket[%02x-%02x]: DHCP Socket Create\n",
pxEndPoint->xMACAddress.ucBytes[ 4 ],
Expand Down Expand Up @@ -1043,11 +1042,7 @@
{
EP_IPv4_SETTINGS.ulDNSServerAddresses[ uxTargetIndex ] = pxSet->ulParameter;
uxTargetIndex++;

if( uxTargetIndex >= ipconfigENDPOINT_DNS_ADDRESS_COUNT )
{
break;
}
/* uxDNSCount <= ipconfigENDPOINT_DNS_ADDRESS_COUNT , hence check is removed. */
}

uxByteIndex += sizeof( uint32_t );
Expand Down
2 changes: 1 addition & 1 deletion test/unit-test/ConfigFiles/FreeRTOSIPConfig.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
* a socket.
*/
#define ipconfigUSE_DNS_CACHE ( 1 )
#define ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY ( 2 )
#define ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY ( 1 )
#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )

#define ipconfigDNS_CACHE_NAME_LENGTH ( 254 )
Expand Down
Loading

0 comments on commit 9e525be

Please sign in to comment.