Name Date Size #Lines LOC

..--

ConfigFiles/H06-Mar-2024-1,085414

FreeRTOS_ARP/H06-Mar-2024-2,0601,330

FreeRTOS_ARP_DataLenLessThanMinPacket/H06-Mar-2024-619311

FreeRTOS_DHCP/H06-Mar-2024-4,3222,326

FreeRTOS_DNS/H06-Mar-2024-821495

FreeRTOS_DNS_Cache/H06-Mar-2024-482292

FreeRTOS_DNS_Callback/H06-Mar-2024-587356

FreeRTOS_DNS_Networking/H06-Mar-2024-398236

FreeRTOS_DNS_Parser/H06-Mar-2024-2,0021,355

FreeRTOS_ICMP/H06-Mar-2024-535330

FreeRTOS_ICMP_wo_assert/H06-Mar-2024-407239

FreeRTOS_IP/H06-Mar-2024-3,4132,266

FreeRTOS_IP_DiffConfig/H06-Mar-2024-1,8801,077

FreeRTOS_IP_Timers/H06-Mar-2024-929603

FreeRTOS_IP_Utils/H06-Mar-2024-2,1461,513

FreeRTOS_IP_Utils_DiffConfig/H06-Mar-2024-908411

FreeRTOS_Sockets/H06-Mar-2024-9,4575,940

FreeRTOS_Sockets_DiffConfig/H06-Mar-2024-922418

FreeRTOS_Sockets_DiffConfig1/H06-Mar-2024-892400

FreeRTOS_Stream_Buffer/H06-Mar-2024-1,463804

FreeRTOS_TCP_IP/H06-Mar-2024-2,3071,546

FreeRTOS_TCP_IP_DiffConfig/H06-Mar-2024-907400

FreeRTOS_TCP_Reception/H06-Mar-2024-1,073742

FreeRTOS_TCP_State_Handling/H06-Mar-2024-1,9431,393

FreeRTOS_TCP_Transmission/H06-Mar-2024-2,1131,588

FreeRTOS_TCP_Utils/H06-Mar-2024-285172

FreeRTOS_TCP_WIN/H06-Mar-2024-3,0262,119

FreeRTOS_Tiny_TCP/H06-Mar-2024-1,176700

FreeRTOS_UDP_IP/H06-Mar-2024-1,182705

cmock/H06-Mar-2024-314284

CMakeLists.txtHD06-Mar-202412.4 KiB244199

README.mdHD06-Mar-20244 KiB9178

TCPFilePaths.cmakeHD06-Mar-20242.3 KiB4440

catch_assert.hHD06-Mar-20242.9 KiB7839

cmock_build.cmakeHD06-Mar-20242.1 KiB5949

README.md

1# Unit Tests for FreeRTOS-Plus-TCP library
2This directory is made for the purpose of Unit testing and tries to provide the tools for developing unit tests. To that end, this directory submodules the [CMock](https://github.com/ThrowTheSwitch/CMock) framework (which submodules [Unity](https://github.com/throwtheswitch/unity/tree/cf949f45ca6d172a177b00da2.3.1607b97bc7a7)) and the [FreeRTOS-Kernel](https://github.com/FreeRTOS/FreeRTOS-Kernel/).
3
4## Getting Started
5### Prerequisites
6You can run this on any GNU Make compatible systems. But in case of DOS based systems some tweaking is required with the makefile.
7To compile and run this project successfully, you must have the following:
81. Make (You can check whether you have this by typing `make --version`)
9    - Not found? Try `apt-get install make`.
102. Ruby (You can check whether you have this by typing `ruby --version`)
11    - Not found? Try `apt-get install ruby`.
123. CMake version > 3.13.0 (You can check whether you have this by typing `cmake --version`)
13    - Not found? Try `apt-get install cmake`
14    - Try the `cmake --version` command. If still the version number is >= 3.13.0, skip to (4.) or else, continue.
15    - You will need to get the latest CMake version using curl or wget (or similar command).
16        - Uninstall the current version of CMake using `sudo apt remove --purge --auto-remove cmake`.
17        - Download the 3.13.0 version using `wget https://cmake.org/files/v3.13/cmake-3.13.0.tar.gz`.
18        - Extract the cmake download using `tar -xzvf cmake-3.13.0.tar.gz`.
19        - Go to the extracted folder (`cd cmake-3.13.0`) and run `./bootstrap`.
20        - Run `make -j$(nproc)' and then run `sudo make install`.
21        - Check the version using `cmake --version` command.
224. lcov version 1.14 ( check with --version option )
23    - 'sudo apt-get install lcov'
245. unifdef version 2.10 ( check with -V option )
25    - 'sudo apt-get install unifdef'
266. Download the repo and include the submodules using the following commands.
27    - `git clone https://github.com/FreeRTOS/FreeRTOS.git ./FreeRTOS_Dir`
28    - `git submodule update --checkout --init --recursive tools/CMock test/FreeRTOS-Kernel`
29
30### To run the Unit tests:
31Go to the root directory of the FreeRTOS+TCP repo and run the following script:
32~~~
33#!/bin/bash
34# This script should be run from the root directory of the FreeRTOS+TCP repo.
35
36if [[ ! -f FreeRTOS_IP.c ]]; then
37    echo "Please run this script from the root directory of the FreeRTOS+TCP repo."
38    exit 1
39fi
40
41UNIT_TEST_DIR="test/unit-test"
42BUILD_DIR="${UNIT_TEST_DIR}/build/"
43
44# Create the build directory using CMake:
45rm -rf ${BUILD_DIR}
46cmake -S ${UNIT_TEST_DIR} -B ${BUILD_DIR}
47
48# Create the executables:
49make -C ${BUILD_DIR} all
50
51pushd ${BUILD_DIR}
52# Run the tests for all units
53ctest -E system --output-on-failure
54popd
55
56# Calculate the coverage
57make -C ${BUILD_DIR} coverage
58lcov --list --rc lcov_branch_coverage=1 ${BUILD_DIR}coverage.info
59~~~
60
61You should see an output similar to this:
62
63```
64-----------------------
656 Tests 0 Failures 0 Ignored
66OK
67Capturing coverage data from .
68... <Skipped some lines here for the sake of brevity>
69Overall coverage rate:
70  lines......: 84.8% (56 of 66 lines)
71  functions..: 85.7% (12 of 14 functions)
72  branches...: 50.0% (2 of 4 branches)
73```
74
75And also:
76
77```
78Reading tracefile test/unit-test/build/coverage.info
79                                |Lines       |Functions  |Branches
80Filename                        |Rate     Num|Rate    Num|Rate     Num
81======================================================================
82[/home/hein/freertos_plus_tcp/]
83FreeRTOS_ARP.c                  | 100%    238| 100%    14|99.3%    137
84FreeRTOS_DHCP.c                 |98.7%    314|92.9%    14| 100%    150
85FreeRTOS_Sockets.c              | 3.5%   1150| 1.6%    61| 4.2%    722
86FreeRTOS_Stream_Buffer.c        | 100%    107| 100%    12| 100%     54
87FreeRTOS_UDP_IP.c               | 100%     97| 100%     2| 100%     58
88======================================================================
89                          Total:|41.6%   1906|40.8%   103|38.2%   1121
90```
91