mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 20:20:35 +00:00
Add example of gnss-sim usage
This commit is contained in:
parent
8b0d51a965
commit
dda1833646
@ -35,15 +35,18 @@ if(GTEST_INCLUDE_DIRS)
|
||||
set(GTEST_DIR_LOCAL true)
|
||||
endif(GTEST_INCLUDE_DIRS)
|
||||
|
||||
set(GTEST_COMPILER -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER})
|
||||
set(TOOLCHAIN_ARG "")
|
||||
|
||||
if(NOT ${GTEST_DIR_LOCAL})
|
||||
# if GTEST_DIR is not defined, we download and build it
|
||||
set(gtest_RELEASE 1.8.0)
|
||||
set(TOOLCHAIN_ARG "")
|
||||
set(GTEST_COMPILER -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER})
|
||||
|
||||
if(EXISTS $ENV{OECORE_TARGET_SYSROOT})
|
||||
set(GTEST_COMPILER "")
|
||||
set(TOOLCHAIN_ARG -DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Toolchains/oe-sdk_cross.cmake)
|
||||
endif(EXISTS $ENV{OECORE_TARGET_SYSROOT})
|
||||
|
||||
ExternalProject_Add(
|
||||
gtest-${gtest_RELEASE}
|
||||
GIT_REPOSITORY https://github.com/google/googletest
|
||||
@ -130,6 +133,26 @@ if (ENABLE_CUDA)
|
||||
add_definitions(-DCUDA_BLOCKS_TEST=1)
|
||||
endif(ENABLE_CUDA)
|
||||
|
||||
################################################################################
|
||||
# Optional generator
|
||||
################################################################################
|
||||
if(ENABLE_SW_GENERATOR)
|
||||
ExternalProject_Add(
|
||||
gnss-sim
|
||||
GIT_REPOSITORY https://bitbucket.org/jarribas/gnss-simulator
|
||||
GIT_TAG master
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gnss-sim
|
||||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gnss-sim
|
||||
CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG}
|
||||
UPDATE_COMMAND ""
|
||||
PATCH_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
set(SW_GENERATOR_BIN ${CMAKE_CURRENT_BINARY_DIR}/../../gnss-sim/gnss_sim)
|
||||
add_definitions(-DSW_GENERATOR_BIN="${SW_GENERATOR_BIN}")
|
||||
add_definitions(-DDEFAULT_RINEX_NAV="${CMAKE_CURRENT_BINARY_DIR}/../../../thirdparty/gnss-sim/brdc3540.14n")
|
||||
endif(ENABLE_SW_GENERATOR)
|
||||
|
||||
add_definitions(-DTEST_PATH="${CMAKE_SOURCE_DIR}/src/tests/")
|
||||
|
||||
include_directories(
|
||||
@ -429,4 +452,17 @@ if(ENABLE_SYSTEM_TESTING)
|
||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:ttff>
|
||||
${CMAKE_SOURCE_DIR}/install/$<TARGET_FILE_NAME:ttff>
|
||||
)
|
||||
|
||||
add_executable(trk_system_test
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/system-tests/trk_system_test.cc )
|
||||
if(NOT ${GTEST_DIR_LOCAL})
|
||||
add_dependencies(trk_system_test gtest-${gtest_RELEASE})
|
||||
else(NOT ${GTEST_DIR_LOCAL})
|
||||
add_dependencies(trk_system_test gtest)
|
||||
endif(NOT ${GTEST_DIR_LOCAL})
|
||||
add_custom_command(TARGET trk_system_test POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:trk_system_test>
|
||||
${CMAKE_SOURCE_DIR}/install/$<TARGET_FILE_NAME:trk_system_test>
|
||||
)
|
||||
|
||||
endif(ENABLE_SYSTEM_TESTING)
|
||||
|
37
src/tests/system-tests/trk_system_test.cc
Normal file
37
src/tests/system-tests/trk_system_test.cc
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <exception>
|
||||
//#include <gflags/gflags.h>
|
||||
//#include <glog/logging.h>
|
||||
//include <gtest/gtest.h>
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
pid_t wait_result;
|
||||
int child_status;
|
||||
|
||||
// Configure signal
|
||||
std::string str = std::string(SW_GENERATOR_BIN);
|
||||
std::string p1 = std::string("-rinex_nav_file=") + std::string(DEFAULT_RINEX_NAV);
|
||||
std::string p2 = std::string("-static_position=30.286502,120.032669,100,40");
|
||||
|
||||
char *const parmList[] = { &str[0], &str[0], &p1[0], &p2[0], NULL };
|
||||
int pid;
|
||||
if ((pid = fork()) == -1)
|
||||
perror("fork error");
|
||||
else if (pid == 0)
|
||||
{
|
||||
execv(&str[0], parmList);
|
||||
std::cout << "Return not expected. Must be an execv error." << std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
wait_result = waitpid(pid, &child_status, 0);
|
||||
std::cout << "Signal and Observables RINEX files created." << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user