Skip to content

Commit 129a50c

Browse files
committed
Update scripts to run unit tests with respect to Ubunut 24.04
1 parent 7680800 commit 129a50c

File tree

2 files changed

+87
-39
lines changed

2 files changed

+87
-39
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: 84 additions & 38 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
@@ -33,18 +37,15 @@ project successfully, you must have the following:
3337
- Run `make -j$(nproc)' and then run `sudo make install`.
3438
- Check the version using `cmake --version` command.
3539
4. lcov version 1.14 ( check with --version option )
36-
- 'sudo apt-get install lcov'
40+
- `sudo apt-get install lcov`
3741
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`
42+
- `sudo apt-get install unifdef`
4243

4344
### To run the Unit tests:
4445

4546
Go to the root directory of the FreeRTOS+TCP repo and run the following script:
4647

47-
```
48+
``` sh
4849
#!/bin/bash
4950
# This script should be run from the root directory of the FreeRTOS+TCP repo.
5051

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

5960
# Create the build directory using CMake:
6061
rm -rf ${BUILD_DIR}
61-
cmake -S ${UNIT_TEST_DIR} -B ${BUILD_DIR}
62+
cmake --fresh -G Ninja -S ${UNIT_TEST_DIR} -B ${UNIT_TEST_DIR}/build/ -DSANITIZE=
6263

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

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

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

7682
You should see an output similar to this:
7783

7884
```
79-
-----------------------
80-
6 Tests 0 Failures 0 Ignored
81-
OK
82-
Capturing coverage data from .
8385
... <Skipped some lines here for the sake of brevity>
8486
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)
87+
lines......: 100.0% (9388 of 9388 lines)
88+
functions......: 100.0% (525 of 525 functions)
89+
branches......: 100.0% (4920 of 4920 branches)
8890
```
8991

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

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

0 commit comments

Comments
 (0)