From a032dfaefd4e57c8ce52666a050bb5d0e1b513b4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 28 Dec 2012 15:40:03 +0000 Subject: [PATCH] Enabling CTest git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@301 64b25241-fba3-4117-9849-534c7e92360d --- CMakeLists.txt | 2 ++ src/tests/CMakeLists.txt | 29 ++++++++++++++++++- src/tests/single_test_main.cc | 53 +++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 src/tests/single_test_main.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 213668381..0b5e98a9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O2") ################################################################################ # Googletest - http://code.google.com/p/googletest/ ################################################################################ +enable_testing() set(GTEST_DIR $ENV{GTEST_DIR}) if(GTEST_DIR) message("GTEST root folder at ${GTEST_DIR}") @@ -67,6 +68,7 @@ else() endif(GTEST_DIR) + ################################################################################ # Boost - http://www.boost.org ################################################################################ diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 4600ad327..a70504627 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -84,7 +84,34 @@ include_directories( add_executable(run_tests ${CMAKE_CURRENT_SOURCE_DIR}/test_main.cc) target_link_libraries(run_tests ${Boost_LIBRARIES} glog gflags ${GTEST_LIBRARIES} gnss_sp_libs gnss_rx) install(TARGETS run_tests DESTINATION ${CMAKE_SOURCE_DIR}/install) - +######################################################### +# Adding Tests to Ctest +######################################################### + + +set(CMAKE_CTEST_COMMAND ctest -V) +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) + +add_executable(control_thread_test EXCLUDE_FROM_ALL + ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc + ${CMAKE_CURRENT_SOURCE_DIR}/control_thread/control_message_factory_test.cc +) +target_link_libraries(control_thread_test ${Boost_LIBRARIES} glog gflags ${GTEST_LIBRARIES} gnss_sp_libs gnss_rx) +add_test(control_thread_test control_thread_test) + +add_executable(gnss_block_test EXCLUDE_FROM_ALL + ${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}/gnss_block/gps_l1_ca_pcps_acquisition_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/galileo_e1_pcps_ambiguous_acquisition_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc + #${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/galileo_e1_dll_pll_veml_tracking_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/file_output_filter_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/gnss_block_factory_test.cc +) +target_link_libraries(gnss_block_test ${Boost_LIBRARIES} gflags glog ${GTEST_LIBRARIES} gnss_sp_libs gnss_rx) +add_test(gnss_block_test gnss_block_test) diff --git a/src/tests/single_test_main.cc b/src/tests/single_test_main.cc new file mode 100644 index 000000000..90a46bd48 --- /dev/null +++ b/src/tests/single_test_main.cc @@ -0,0 +1,53 @@ +/*! + * \file single_test_main.cc + * \brief This file contains the main function for tests (used with CTest). + * \author Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2013 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "concurrent_queue.h" +#include "gps_navigation_message.h" + +concurrent_queue global_gps_nav_msg_queue; + +int main(int argc, char **argv) +{ + google::ParseCommandLineFlags(&argc, &argv, true); + testing::InitGoogleTest(&argc, argv); + google::InitGoogleLogging(argv[0]); + return RUN_ALL_TESTS(); +}