fsfw/unittest
2020-12-01 13:23:51 +01:00
..
core core changes taken over 2020-10-29 15:12:05 +01:00
internal fixes for internal unittest 2020-10-29 17:21:51 +01:00
testcfg updated testcfg 2020-12-01 13:23:51 +01:00
tests include corrections 2020-11-09 00:12:39 +01:00
testtemplate unittest folder added 2020-10-20 17:12:56 +02:00
lcov.sh unittest folder added 2020-10-20 17:12:56 +02:00
README.md master taken over 2020-11-02 15:50:14 +01:00
unlockRealtime.sh unittest folder added 2020-10-20 17:12:56 +02:00

FSFW Testing

This repository contains testing and unit testing components.

Catch2 has been used as a framework, and these unit tests can only be run on a linux host machine. The makefile with default settings creates the unit test binary which can be run in the terminal or in eclipse.

Instructions

To run the fsfw unittests in the project, perform following steps:

  1. Copy the testcfg folder the project root (folder containing the FSFW).
  2. There is a makefile inside the testcfg folder which can be used to have a starting point to compile the unit tests. Copy that Makefile to the project root
  3. Create a folder named catch2 (can have other name which requires Makefile adaption) and copy the Catch2 header files there (NOTE: CMake support not enabled yet!)

Eclipse CDT settings

The default eclipse terminal has issues displaying the colors used when running the unit test binary by catch2. To fix this issue, install the ANSI Escape In Console package from the eclipse marketplace.

GCOV integration

GCOV has been integrated as a code coverage tool. It can be enabled by adding GCOV=1 to the build process as an additional argument. Coverage data will be provided in form of .gcno and .gcda files. These can be displayed in eclipse by looking for a .gcno or .gcda file in the _obj folder, double-clicking it and picking the right source-binary. This will generate information about which lines of a file have run, provided it is open in eclipse.

LCOV integration

The files generated by GCOV can also be processed by the tool LCOV. On ubuntu, the tool can be installed with the following command:

sudo apt-get install lcov

After that, the tool can be run by building the unit tests with GCOV=1, running them at least one time and then executing the lcov.sh script.

Adding unit tests

The catch unit tests are located in unittest/testfw. To add new unit tests, add them to the UnitTestCatch.cpp file or add a new source file which includes catch.hpp.

For writing basics tests, the assertion documentation or the existing examples are a good guideliens. For more advanced tests, refer to the catch2 documentation.