Skip to content

Commit 22292b7

Browse files
authored
Merge branch 'main' into FreeRTOS_MatchingEndpointFix
2 parents 1c28341 + 5cd9e83 commit 22292b7

File tree

2 files changed

+90
-40
lines changed

2 files changed

+90
-40
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ jobs:
106106
echo "::endgroup::"
107107
echo -e "${{ env.bashPass }} Built Coverage Tests ${{ env.bashEnd }}"
108108
109-
lcov --list --rc lcov_branch_coverage=1 test/unit-test/build/coverage.info
109+
wget https://github.com/linux-test-project/lcov/releases/download/v2.3.1/lcov-2.3.1.tar.gz
110+
tar -xvzf lcov-2.3.1.tar.gz
111+
./lcov-2.3.1/bin/lcov --list --rc branch_coverage=1 test/unit-test/build/coverage.info
110112
111113
echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}"
112114

test/unit-test/README.md

Lines changed: 87 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ tools for developing unit tests. To that end, this directory submodules the
66
[Unity](https://github.com/throwtheswitch/unity/))
77
and the [FreeRTOS-Kernel](https://github.com/FreeRTOS/FreeRTOS-Kernel/).
88

9+
Note: The following steps are tested on Ubuntu 24.04
10+
911
## Getting Started
1012

1113
### Prerequisites
@@ -15,12 +17,14 @@ systems some tweaking is required with the makefile. To compile and run this
1517
project successfully, you must have the following:
1618

1719
1. Make (You can check whether you have this by typing `make --version`)
18-
- Not found? Try `apt-get install make`.
20+
- Not found? Try `sudo apt-get install make`.
1921
2. Ruby (You can check whether you have this by typing `ruby --version`)
20-
- Not found? Try `apt-get install ruby`.
22+
- Not found? Try `sudo apt-get install ruby`.
23+
3. Ninja (You can check whether you have this by typing `ninja --version`)
24+
- Not found? Try `sudo apt install ninja-build`.
2125
3. CMake version > 3.15.0 (You can check whether you have this by typing
2226
`cmake --version`)
23-
- Not found? Try `apt-get install cmake`
27+
- Not found? Try `sudo apt-get install cmake`
2428
- Try the `cmake --version` command. If still the version number is >=
2529
3.15.0, skip to (4.) or else, continue.
2630
- You will need to get the latest CMake version using curl or wget (or
@@ -32,19 +36,18 @@ project successfully, you must have the following:
3236
- Go to the extracted folder (`cd cmake-3.15.0`) and run `./bootstrap`.
3337
- Run `make -j$(nproc)' and then run `sudo make install`.
3438
- Check the version using `cmake --version` command.
35-
4. lcov version 1.14 ( check with --version option )
36-
- 'sudo apt-get install lcov'
39+
4. lcov ( check with `lcov --version` option )
40+
- `sudo apt-get install lcov`
41+
- If file specific coverage list is required check the note in the below section
42+
for the required version.
3743
5. unifdef version 2.10 ( check with -V option )
38-
- 'sudo apt-get install unifdef'
39-
6. Download the repo and include the submodules using the following commands.
40-
- `git clone https://github.com/FreeRTOS/FreeRTOS.git ./FreeRTOS_Dir`
41-
- `git submodule update --checkout --init --recursive tools/CMock test/FreeRTOS-Kernel`
44+
- `sudo apt-get install unifdef`
4245

4346
### To run the Unit tests:
4447

4548
Go to the root directory of the FreeRTOS+TCP repo and run the following script:
4649

47-
```
50+
``` sh
4851
#!/bin/bash
4952
# This script should be run from the root directory of the FreeRTOS+TCP repo.
5053

@@ -58,48 +61,93 @@ BUILD_DIR="${UNIT_TEST_DIR}/build/"
5861

5962
# Create the build directory using CMake:
6063
rm -rf ${BUILD_DIR}
61-
cmake -S ${UNIT_TEST_DIR} -B ${BUILD_DIR}
64+
cmake --fresh -G Ninja -S ${UNIT_TEST_DIR} -B ${UNIT_TEST_DIR}/build/ -DSANITIZE=
6265

6366
# Create the executables:
64-
make -C ${BUILD_DIR} all
67+
ninja -C ${UNIT_TEST_DIR}/build/
68+
69+
# Run tests
70+
ctest --test-dir ${BUILD_DIR} -E system --output-on-failure
71+
72+
# Make and calculate the coverage
73+
cmake --build ${BUILD_DIR} --target coverage
74+
lcov --summary --rc branch_coverage=1 ${BUILD_DIR}/coverage.info
6575

66-
pushd ${BUILD_DIR}
67-
# Run the tests for all units
68-
ctest -E system --output-on-failure
69-
popd
76+
# For file specific coverage list uncomment the following lines
77+
78+
# wget https://github.com/linux-test-project/lcov/releases/download/v2.3.1/lcov-2.3.1.tar.gz
79+
# tar -xvzf lcov-2.3.1.tar.gz
80+
# ./lcov-2.3.1/bin/lcov --list --rc branch_coverage=1 ${BUILD_DIR}/coverage.info
7081

71-
# Calculate the coverage
72-
make -C ${BUILD_DIR} coverage
73-
lcov --list --rc lcov_branch_coverage=1 ${BUILD_DIR}coverage.info
7482
```
7583

7684
You should see an output similar to this:
7785

7886
```
79-
-----------------------
80-
6 Tests 0 Failures 0 Ignored
81-
OK
82-
Capturing coverage data from .
8387
... <Skipped some lines here for the sake of brevity>
8488
Overall coverage rate:
85-
lines......: 84.8% (56 of 66 lines)
86-
functions..: 85.7% (12 of 14 functions)
87-
branches...: 50.0% (2 of 4 branches)
89+
lines......: 100.0% (9388 of 9388 lines)
90+
functions......: 100.0% (525 of 525 functions)
91+
branches......: 100.0% (4920 of 4920 branches)
8892
```
8993

90-
And also:
94+
Note: If file specific coverage list is required the lcov version should be updated to
95+
the newer version (for example, [v2.3.1](https://github.com/linux-test-project/lcov/releases/tag/v2.3.1))
96+
as the default version of `lcov` in Ubuntu 24.04 results in incorrect parsing of
97+
`coverage.info`.
98+
99+
Sample file specific coverage data:
100+
91101

92102
```
93-
Reading tracefile test/unit-test/build/coverage.info
94-
|Lines |Functions |Branches
95-
Filename |Rate Num|Rate Num|Rate Num
96-
======================================================================
97-
[/home/hein/freertos_plus_tcp/]
98-
FreeRTOS_ARP.c | 100% 238| 100% 14|99.3% 137
99-
FreeRTOS_DHCP.c |98.7% 314|92.9% 14| 100% 150
100-
FreeRTOS_Sockets.c | 3.5% 1150| 1.6% 61| 4.2% 722
101-
FreeRTOS_Stream_Buffer.c | 100% 107| 100% 12| 100% 54
102-
FreeRTOS_UDP_IP.c | 100% 97| 100% 2| 100% 58
103-
======================================================================
104-
Total:|41.6% 1906|40.8% 103|38.2% 1121
103+
|Lines |Functions |Branches
104+
Filename |Rate Num|Rate Num|Rate Num
105+
=====================================================================
106+
[/home/ubuntu/FreeRTOS-Plus-TCP/source/]
107+
FreeRTOS_ARP.c | 100% 358| 100% 21| 100% 241
108+
FreeRTOS_DNS.c | 100% 361| 100% 23| 100% 184
109+
FreeRTOS_DNS_Cache.c | 100% 126| 100% 11| 100% 54
110+
FreeRTOS_DNS_Callback.c | 100% 80| 100% 4| 100% 34
111+
FreeRTOS_DNS_Networking.c | 100% 31| 100% 5| 100% 4
112+
FreeRTOS_DNS_Parser.c | 100% 366| 100% 6| 100% 192
113+
FreeRTOS_Stream_Buffer.c | 100% 101| 100% 12| 100% 46
114+
FreeRTOS_Tiny_TCP.c | 100% 92| 100% 12| 100% 40
115+
116+
[/home/ubuntu/FreeRTOS-Plus-TCP/test/unit-test/build/Annexed_TCP_Sources/]
117+
FreeRTOS_BitConfig.c | 100% 87| 100% 11| 100% 30
118+
FreeRTOS_DHCP.c | 100% 444| 100% 19| 100% 256
119+
FreeRTOS_DHCPv6.c | 100% 576| 100% 18| 100% 252
120+
FreeRTOS_ICMP.c | 100% 44| 100% 3| 100% 11
121+
FreeRTOS_IP.c | 100% 642| 100% 46| 100% 331
122+
FreeRTOS_IP_Timers.c | 100% 152| 100% 21| 100% 84
123+
FreeRTOS_IP_Utils.c | 100% 472| 100% 33| 100% 256
124+
FreeRTOS_IPv4.c | 100% 148| 100% 7| 100% 110
125+
FreeRTOS_IPv4_Sockets.c | 100% 62| 100% 4| 100% 40
126+
FreeRTOS_IPv4_Utils.c | 100% 40| 100% 2| 100% 16
127+
FreeRTOS_IPv6.c | 100% 201| 100% 10| 100% 126
128+
FreeRTOS_IPv6_Sockets.c | 100% 189| 100% 12| 100% 106
129+
FreeRTOS_IPv6_Utils.c | 100% 99| 100% 5| 100% 49
130+
FreeRTOS_ND.c | 100% 431| 100% 18| 100% 187
131+
FreeRTOS_RA.c | 100% 198| 100% 9| 100% 80
132+
FreeRTOS_Routing.c | 100% 360| 100% 24| 100% 213
133+
FreeRTOS_Sockets.c | 100% 1542| 100% 89| 100% 841
134+
FreeRTOS_TCP_IP.c | 100% 243| 100% 10| 100% 196
135+
FreeRTOS_TCP_Reception.c | 100% 157| 100% 5| 100% 87
136+
FreeRTOS_TCP_State_Handling.c | 100% 277| 100% 9| 100% 124
137+
FreeRTOS_TCP_State_Handling_IPv4.c | 100% 52| 100% 1| 100% 30
138+
FreeRTOS_TCP_State_Handling_IPv6.c | 100% 50| 100% 1| 100% 32
139+
FreeRTOS_TCP_Transmission.c | 100% 331| 100% 19| 100% 154
140+
FreeRTOS_TCP_Transmission_IPv4.c | 100% 131| 100% 3| 100% 36
141+
FreeRTOS_TCP_Transmission_IPv6.c | 100% 145| 100% 3| 100% 50
142+
FreeRTOS_TCP_Utils.c | 100% 21| 100% 2| 100% 16
143+
FreeRTOS_TCP_Utils_IPv4.c | 100% 9| 100% 1| 100% 4
144+
FreeRTOS_TCP_Utils_IPv6.c | 100% 15| 100% 1| 100% 6
145+
FreeRTOS_TCP_WIN.c | 100% 456| 100% 37| 100% 222
146+
FreeRTOS_UDP_IP.c | 100% 28| 100% 2| 100% 12
147+
FreeRTOS_UDP_IPv4.c | 100% 128| 100% 2| 100% 84
148+
FreeRTOS_UDP_IPv6.c | 100% 143| 100% 4| 100% 84
149+
=====================================================================
150+
Total:| 100% 9388| 100% 525| 100% 4920
151+
Message summary:
152+
no messages were reported
105153
```

0 commit comments

Comments
 (0)