This is an old revision of the document!
Testing
We use Google Test as our test framework. Read https://github.com/google/googletest/blob/master/googletest/docs/primer.md to understand how to use the available macros for defining test cases.
Naming
All the tests must be named in the following manner.
TEST(testName, testMethodName) { ... }
testName
should include the name of the package, e.g. controlDeMuxBlock or safetyEventTest. This allows for running only the tests in a certain package. testMethodName
can be any meaningful name to identify the test method.
Running the Tests
Make sure to compile the unit tests with the cmake argument -DUSE_TESTS=TRUE
. Navigate to the directory test
of the build directory of eeros and run the tests as follows.:
$ ./unitTests --library sim // run all the tests using the simulator as hal $ ./unitTests -l sim // run all the tests using the simulator, short option $ ./unitTests -l flink // run all the tests using flink, short option $ ./unitTests -l comedi // run all the tests using comedi, short option $ ./unitTests --gtest_filter=control* // run all the tests in control $ ./unitTests --gtest_filter=math* // run all the tests in math $ ./unitTests --gtest_filter=mathMatrix* // run all the tests in math/Matrix $ ./unitTests --gtest_filter=-hal* // run all the tests without hal $ ./unitTests -l sim --gtest_filter=hal* // run all the tests in hal using the simulator
For the test with the HAL you need to install the simulator and set the library path (see Deploying)so that the simulator library can be found.