Commit 9c913fa0 authored by Bartosz Podrygajlo's avatar Bartosz Podrygajlo

Introduce googletest library

The library will be either found in the system or downloaded via FetchContent.
parent 9fab2124
...@@ -2507,6 +2507,21 @@ if(ENABLE_TESTS) ...@@ -2507,6 +2507,21 @@ if(ENABLE_TESTS)
# meta-target: each test is supposed to add_dependencies(tests ${NEWTEST}) # meta-target: each test is supposed to add_dependencies(tests ${NEWTEST})
# then, it is possible to build and execute all tests using "ninja tests && ctest" # then, it is possible to build and execute all tests using "ninja tests && ctest"
add_custom_target(tests) add_custom_target(tests)
find_package(GTest)
if (NOT GTest_FOUND)
message(STATUS "GTest package not found, will download googletest automatically. To prevent that install google test on your system (libgtest-dev)")
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG 58d77fa8070e8cec2dc1ed015d66b454c8d78850 # 1.12.1
)
set(BUILD_GMOCK OFF)
set(INSTALL_GTEST OFF)
FetchContent_MakeAvailable(googletest)
add_library(GTest::gtest ALIAS gtest)
add_library(GTest::gtest_main ALIAS gtest_main)
endif()
endif() endif()
add_subdirectory(common) add_subdirectory(common)
......
...@@ -8,8 +8,9 @@ explaining how to test with cmake and ctest; it is a suggested read, and the ...@@ -8,8 +8,9 @@ explaining how to test with cmake and ctest; it is a suggested read, and the
following just lists the main points of how to compile the tests and how to add following just lists the main points of how to compile the tests and how to add
new ones. new ones.
At the time of writing, only the NR RLC tests have been integrated. The author GoogleTest is a C++ unit testing framework that has been added as an external dependency. While using GoogleTest is not a requirement it can simplify writing unit tests.
hopes that more tests follow suit. See [primer](http://google.github.io/googletest/primer.html) for a quick introduction. To add it to your test executable link against
`GTest::gtest` or `GTest::gtest_main`.
# How to compile tests # How to compile tests
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment