Adding Unit Tests with GoogleTest
You can create unit tests using the GoogleTest framework and CMake for Knowledge Packs downloaded as the Source format.
Recommended
Recommended Platform: Ubuntu
Packages: gtest and cmake
Install GoogleTest and CMake
apt-get install libgtest-dev
apt-get install cmake
Build the GoogleTest Library
cd /usr/src/gtest
cmake CMakeLists.txt
make
cp *.a /usr/lib
Reference for simple test if you would like to try: https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/
Building and Running Unit Tests
Re-run cmake and rebuild everything
./build.sh
Rebuild only with your modifications
./update.sh
How to Clean
./clean.sh
The executable is built in the folder
/sensiml_sdk/utest/out/kbgtest
Additional Notes
build.sh will build and run all tests once
clean.sh will delete out
You can run the test multiple times with
--gtest_repeat=N
You can capture test output with
--gtest_output="xml:filename.xml"
You can run specific tests with
--gtest_filter=MEAN_CALCULATION_TEST.*
Find more info about using GoogleTest: https://www.ibm.com/developerworks/aix/library/au-googletestingframework.html
Adding New Tests
You can add new tests by updating the SENSIML_SDK and KB_UTEST variables in the CMakeLists.txt file
SENSIML_SDK - update with new .c files
KB_UTEST - update with corresponding unit tests new test_*.cpp files