FreeRTOS-Kernel/FreeRTOS/Test/CMock
alfred gedeon 1ac492d6aa
Kernel timers.c tasks.c Unit Test (#539)
* Test: add multi config ability to build system

* Remove Tests that are not implemented yet from the makefile

* Fix header check

* Test: Unit Test tasks.c

* UnitTest: tasks.c Save progress

* saving some work 70% coverage

* coverage 77%

* tasks.c coverage 90%

* tasks.c coverage 95%

* Cleanup and common header

* Cover some extra branches, no_mutex +stack growth

* Fix Makefile not to use modified version of c-preprocessor

* Remove c-preprocessor errros

* Rebase and add some tests

* Fortify_source=1 and O0 are mutually exclusive

* Style: Uncrustify code

* Style: Fix indent

* Fix Header checks

* Add prototypes

* Build: use unifdef instead of the c-preprocessor to generate different configurations

* Build: fix makefile cflags

* Fix UT after upgrading kernel version

* Resolve conflicts and test failures

* Comment fix version number

* Fix build error

* Update FreeRTOS/Test/CMock/Makefile

Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>

Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>
2022-08-16 14:38:26 -07:00
..
CMock@afa294982e Inititial stub for cmock tests (#297) 2020-09-24 17:06:28 -07:00
config Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00
doc Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00
event_groups Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00
list Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00
message_buffer Add unit tests for stream buffer callback overrides (#832) 2022-07-29 13:16:52 -07:00
queue Fix queue/static config for upstream changes 2022-08-09 15:47:46 -07:00
stream_buffer Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00
tasks Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00
timers Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00
tools Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00
.gitignore Clean up CMock makefiles and add coverage filtering (#523) 2021-03-15 17:01:29 -07:00
coverage.mk Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00
lcovrc Clean up CMock makefiles and add coverage filtering (#523) 2021-03-15 17:01:29 -07:00
Makefile Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00
makefile.in Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00
Readme.md Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00
subdir.mk Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00
testdir.mk Kernel timers.c tasks.c Unit Test (#539) 2022-08-16 14:38:26 -07:00

FreeRTOS Kernel Unit Tests

Prerequisites as tested

GCC

gcc: gcc (GCC) 9.2.0

unifdef

version 2.12

LCOV

lcov: LCOV version 1.14-6-g40580cd

Make

GNU Make 3.82

Ruby

ruby 2.0.0p648 (2015-12-16) [x86_64-linux]

Doxygen (optional)

1.8.5

Python (optional, required for coverage filtering)

Python 3.8 or later

Cflow (optional, required for coverage filtering)

cflow (GNU cflow) 1.6

How to run

$ make help
Usage: $ make <unit>

 where <unit> is one of: queue doc all run run_formatted run_col
 run_col_formatted coverage

Explanation

$ make queue

Would build the kernel queue unit tests and put the executable in build/bin

$ make doc

Would generate the doxygen documentation in build/doc

$ make run | run_formatted | run_col | run_col_formatted

Would build all unit tests and runs them one after the other with different options between normal and formatted and colored for easily spotting errors

$ make coverage

Would build all unit tests, runs them one after the other, then generates html code coverage and places them in build/coverage with initial file index.html

Runing tests with Address Sanitizer enabled

The GCC address sanitizer can be enabled by passing in "ENABLE_SANITIZER=1" when calling make.

Note: Enabling the address sanitizer will introduce additional branches that may not be possible to get test coverage of. For this reason, the address sanitizer is not enabled by default. It is recommended that developers enable the address sanitizer when modifying or developing new test cases.

Running individual tests

From each test directory, you can build, run the test, and generate gcov coverage with the default "all" target like so:

$ make -C list

For convenience, a "gcov" target is also provided.

$ make -C list gcov

Alternatively, you can generate filtered coverage with the "lcov" target:

$ make -C list lcov

You can also generate an html coverage report with the lcovhtml target:

$ make -C list lcovhtml

Coverage Filtering

Coverage filtering is meant to remove "unintentional" or "incidental" test coverage that is generated by other test cases which call a specific function but are not meant to test that function. In order to use coverage filtering and the associated lcov and lcovhtml targets, you must install the "optional" requirements listed above.

Additionally, you must also document which functions you are targeting inside each _utest.c file with a tag inside each file similar to the following:

@coverage vFunctionNameHere vAnotherFunctionNameHere