diff --git a/README.md b/README.md index e8ccc9e8d..01b9fe829 100644 --- a/README.md +++ b/README.md @@ -171,20 +171,20 @@ $ sudo ldconfig #### Build the [Google C++ Testing Framework](https://github.com/google/googletest "Googletest Homepage"), also known as googletest: ~~~~~~ -$ wget https://github.com/google/googletest/archive/release-1.7.0.zip -$ unzip release-1.7.0.zip -$ cd googletest-release-1.7.0 -$ cmake . +$ wget https://github.com/google/googletest/archive/release-1.8.0.zip +$ unzip release-1.8.0.zip +$ cd googletest-release-1.8.0 +$ cmake -DBUILD_GTEST=ON -DBUILD_GMOCK=OFF . $ make ~~~~~~ Please **DO NOT install** googletest (do *not* type ```sudo make install```). Every user needs to compile his tests using the same compiler flags used to compile the installed Google Test libraries; otherwise he may run into undefined behaviors (i.e. the tests can behave strangely and may even crash for no obvious reasons). The reason is that C++ has this thing called the One-Definition Rule: if two C++ source files contain different definitions of the same class/function/variable, and you link them together, you violate the rule. The linker may or may not catch the error (in many cases it is not required by the C++ standard to catch the violation). If it does not, you get strange run-time behaviors that are unexpected and hard to debug. If you compile Google Test and your test code using different compiler flags, they may see different definitions of the same class/function/variable (e.g. due to the use of ```#if``` in Google Test). Therefore, for your sanity, we recommend to avoid installing pre-compiled Google Test libraries. Instead, each project should compile Google Test itself such that it can be sure that the same flags are used for both Google Test and the tests. The building system of GNSS-SDR does the compilation and linking of googletest to its own tests; it is only required that you tell the system where the googletest folder that you downloaded resides. Just add to your ```$HOME/.bashrc``` file the following line: ~~~~~~ -export GTEST_DIR=/home/username/gtest-1.7.0 +export GTEST_DIR=/home/username/googletest-release-1.8.0/googletest ~~~~~~ -changing /home/username/gtest-1.7.0 by the actual directory where you downloaded googletest. +changing /home/username/googletest-release-1.8.0/googletest by the actual directory where you built googletest. diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 08ad88e94..7ef984dc5 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -36,24 +36,24 @@ endif(GTEST_INCLUDE_DIRS) if(NOT ${GTEST_DIR_LOCAL}) # if GTEST_DIR is not defined, we download and build it - set(gtest_RELEASE 1.7.0) + set(gtest_RELEASE 1.8.0) ExternalProject_Add( gtest-${gtest_RELEASE} GIT_REPOSITORY https://github.com/google/googletest GIT_TAG release-${gtest_RELEASE} SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE} BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE} - CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DBUILD_GTEST=ON -DBUILD_GMOCK=OFF UPDATE_COMMAND "" PATCH_COMMAND "" INSTALL_COMMAND "" ) # Set up variables # Set recently downloaded and build Googletest root folder - set(GTEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE}") + set(GTEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE}/googletest") # Source code ExternalProject_Get_Property(gtest-${gtest_RELEASE} source_dir) - set(GTEST_INCLUDE_DIR ${source_dir}/include) + set(GTEST_INCLUDE_DIR ${source_dir}/googletest/include) set(GTEST_INCLUDE_DIRECTORIES ${GTEST_DIR}/include ${GTEST_DIR} ${GTEST_DIR}/src) # Library ExternalProject_Get_Property(gtest-${gtest_RELEASE} binary_dir) @@ -62,13 +62,13 @@ if(NOT ${GTEST_DIR_LOCAL}) set(binary_dir "${binary_dir}/Debug") endif(CMAKE_GENERATOR STREQUAL Xcode) endif(OS_IS_MACOSX) - set(GTEST_LIBRARY_PATH "${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a;${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a") - set(GTEST_LIBRARY gtest-${gtest_RELEASE}) - set(GTEST_LIBRARIES - ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a - ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a - ) - set(GTEST_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE}") + set(GTEST_LIBRARY_PATH "${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a;${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a") + set(GTEST_LIBRARY gtest-${gtest_RELEASE}) + set(GTEST_LIBRARIES + ${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a + ${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a + ) + set(GTEST_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE}/googletest") else(NOT ${GTEST_DIR_LOCAL}) if(GTEST_INCLUDE_DIRS) set(GTEST_INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIRS} ${LIBGTEST_DEV_DIR}) @@ -106,13 +106,13 @@ endif(Boost_VERSION LESS 105000) if(OPENSSL_FOUND) add_definitions( -DUSE_OPENSSL_FALLBACK=1 ) endif(OPENSSL_FOUND) - + include_directories( ${GTEST_INCLUDE_DIRECTORIES} ${CMAKE_SOURCE_DIR}/src/core/system_parameters ${CMAKE_SOURCE_DIR}/src/core/interfaces ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/core/libs + ${CMAKE_SOURCE_DIR}/src/core/libs ${CMAKE_SOURCE_DIR}/src/core/libs/supl ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-rrlp ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-supl @@ -171,21 +171,21 @@ add_custom_command(TARGET run_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_SOURCE_DIR}/install/$) -target_link_libraries(run_tests ${CLANG_FLAGS} - ${Boost_LIBRARIES} - ${GFLAGS_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${GNURADIO_ANALOG_LIBRARIES} +target_link_libraries(run_tests ${CLANG_FLAGS} + ${Boost_LIBRARIES} + ${GFLAGS_LIBS} + ${GLOG_LIBRARIES} + ${GTEST_LIBRARIES} + ${GNURADIO_RUNTIME_LIBRARIES} + ${GNURADIO_BLOCKS_LIBRARIES} + ${GNURADIO_FILTER_LIBRARIES} + ${GNURADIO_ANALOG_LIBRARIES} ${ARMADILLO_LIBRARIES} ${VOLK_LIBRARIES} channel_fsm - gnss_sp_libs + gnss_sp_libs gnss_rx - gnss_system_parameters + gnss_system_parameters signal_generator_blocks signal_generator_adapters pvt_gr_blocks @@ -202,7 +202,7 @@ set(CMAKE_CTEST_COMMAND ctest -V) add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) add_executable(control_thread_test - ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc + ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc ${CMAKE_CURRENT_SOURCE_DIR}/control_thread/control_message_factory_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/control_thread/control_thread_test.cc ) @@ -210,37 +210,37 @@ if(NOT ${ENABLE_PACKAGING}) set_property(TARGET control_thread_test PROPERTY EXCLUDE_FROM_ALL TRUE) endif(NOT ${ENABLE_PACKAGING}) -target_link_libraries(control_thread_test ${Boost_LIBRARIES} - ${GFLAGS_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} +target_link_libraries(control_thread_test ${Boost_LIBRARIES} + ${GFLAGS_LIBS} + ${GLOG_LIBRARIES} + ${GTEST_LIBRARIES} gnss_sp_libs gnss_system_parameters gnss_rx ${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES} ) - + add_test(control_thread_test control_thread_test) if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(control_thread_test gtest-${gtest_RELEASE}) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(control_thread_test gtest) -endif(NOT ${GTEST_DIR_LOCAL}) +endif(NOT ${GTEST_DIR_LOCAL}) set_property(TEST control_thread_test PROPERTY TIMEOUT 30) -add_executable(flowgraph_test - ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc +add_executable(flowgraph_test + ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc ${CMAKE_CURRENT_SOURCE_DIR}/flowgraph/gnss_flowgraph_test.cc ) if(NOT ${ENABLE_PACKAGING}) set_property(TARGET flowgraph_test PROPERTY EXCLUDE_FROM_ALL TRUE) endif(NOT ${ENABLE_PACKAGING}) -target_link_libraries(flowgraph_test ${Boost_LIBRARIES} - ${GFLAGS_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - gnss_sp_libs +target_link_libraries(flowgraph_test ${Boost_LIBRARIES} + ${GFLAGS_LIBS} + ${GLOG_LIBRARIES} + ${GTEST_LIBRARIES} + gnss_sp_libs gnss_rx gnss_system_parameters ${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES} @@ -251,29 +251,29 @@ if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(flowgraph_test gtest-${gtest_RELEASE}) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(flowgraph_test gtest) -endif(NOT ${GTEST_DIR_LOCAL}) +endif(NOT ${GTEST_DIR_LOCAL}) set_property(TEST flowgraph_test PROPERTY TIMEOUT 30) add_executable(gnss_block_test - ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc + ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/file_signal_source_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/fir_filter_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/flowgraph/pass_through_test.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/gnss_block_factory_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/gnss_block_factory_test.cc ) if(NOT ${ENABLE_PACKAGING}) set_property(TARGET gnss_block_test PROPERTY EXCLUDE_FROM_ALL TRUE) endif(NOT ${ENABLE_PACKAGING}) target_link_libraries(gnss_block_test ${Boost_LIBRARIES} - ${GFLAGS_LIBS} - ${GLOG_LIBRARIES} + ${GFLAGS_LIBS} + ${GLOG_LIBRARIES} ${GTEST_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${GNURADIO_ANALOG_LIBRARIES} - gnss_sp_libs + ${GNURADIO_RUNTIME_LIBRARIES} + ${GNURADIO_BLOCKS_LIBRARIES} + ${GNURADIO_FILTER_LIBRARIES} + ${GNURADIO_ANALOG_LIBRARIES} + gnss_sp_libs gnss_rx gnss_system_parameters # signal_generator_blocks @@ -285,7 +285,7 @@ if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(gnss_block_test gtest-${gtest_RELEASE}) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(gnss_block_test gtest) -endif(NOT ${GTEST_DIR_LOCAL}) +endif(NOT ${GTEST_DIR_LOCAL}) add_executable(gnuradio_block_test ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc @@ -319,24 +319,24 @@ endif(NOT ${GTEST_DIR_LOCAL}) # add_executable(acq_test ${EXCLUDE} -# ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc +# ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc # ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/gps_l1_ca_pcps_acquisition_test.cc # ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/galileo_e1_pcps_ambiguous_acquisition_test.cc # ) # target_link_libraries(acq_test ${Boost_LIBRARIES} -# ${GFLAGS_LIBS} -# ${GLOG_LIBRARIES} +# ${GFLAGS_LIBS} +# ${GLOG_LIBRARIES} # ${GTEST_LIBRARIES} -# ${GNURADIO_RUNTIME_LIBRARIES} -# ${GNURADIO_BLOCKS_LIBRARIES} -# ${GNURADIO_FILTER_LIBRARIES} -# ${GNURADIO_ANALOG_LIBRARIES} -# gnss_sp_libs +# ${GNURADIO_RUNTIME_LIBRARIES} +# ${GNURADIO_BLOCKS_LIBRARIES} +# ${GNURADIO_FILTER_LIBRARIES} +# ${GNURADIO_ANALOG_LIBRARIES} +# gnss_sp_libs # gnss_rx # gnss_system_parameters # signal_generator_blocks # ${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES} -# ) +# ) # add_test(acq_test acq_test) add_executable(trk_test @@ -349,27 +349,26 @@ if(NOT ${ENABLE_PACKAGING}) endif(NOT ${ENABLE_PACKAGING}) target_link_libraries(trk_test ${Boost_LIBRARIES} - ${GFLAGS_LIBS} - ${GLOG_LIBRARIES} + ${GFLAGS_LIBS} + ${GLOG_LIBRARIES} ${GTEST_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${GNURADIO_ANALOG_LIBRARIES} - gnss_sp_libs + ${GNURADIO_RUNTIME_LIBRARIES} + ${GNURADIO_BLOCKS_LIBRARIES} + ${GNURADIO_FILTER_LIBRARIES} + ${GNURADIO_ANALOG_LIBRARIES} + gnss_sp_libs gnss_rx gnss_system_parameters signal_generator_blocks ${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES} ) - + add_test(trk_test trk_test) if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(trk_test gtest-${gtest_RELEASE}) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(trk_test gtest) -endif(NOT ${GTEST_DIR_LOCAL}) +endif(NOT ${GTEST_DIR_LOCAL}) -add_dependencies(check control_thread_test flowgraph_test gnss_block_test +add_dependencies(check control_thread_test flowgraph_test gnss_block_test gnuradio_block_test trk_test) -