More unit tests and unified target for all tests (#6661)

* added general settings tests

* fixed pre-219 switchUnlockState (CPN)

* X7 radio settings tests

* updated X10 model

* patched TESTS_PATH to point directly at the complete tests path

* fixed horus general settings switch conversion

* cpn x10 general settings tests

* fixed horus cpn import

* use x10 model from otx file to ease editing with companion

* added make targets "gtests" and "tests"

gtests builds all the tests (radio & companion)
tests builds and executes all the tests (radio & companion)

* fixed companion tests cmake

* fixed gtests-radio target

* fixed commit tests

* fixed converting LS & RS on X10

* fixed converting global functions on X10

* fixed source conversion on X10

* fixed throttle source on X10

* fixed throttle source on radio and companion

* more checks and re-enabled Horus screenData copy

* more tests (X10)

* [X10] restore correct direction for RS & LS

* [horus] convert "Value" widget source

* fixed conversion of ModelHeader::bitmap length

* added missing X10 radio tests to companion tests

* fixed conversion of telemetry sources in logical switches

* [horus] fixed potential crash

* fixed "AND switch" conversion in logical switches
This commit is contained in:
Raphael Coeffic
2019-08-26 08:36:31 +02:00
committed by Bertrand Songis
parent 274528ee1d
commit 5db30ea7bc
19 changed files with 340 additions and 105 deletions
+25 -10
View File
@@ -4,23 +4,35 @@ find_path(GTEST_INCDIR gtest/gtest.h HINTS "${GTEST_ROOT}/include" DOC "Path to
find_path(GTEST_SRCDIR src/gtest-all.cc HINTS "${GTEST_ROOT}" "${GTEST_ROOT}/src/gtest" DOC "Path of Google Test 'src' folder.")
if(GTEST_INCDIR AND GTEST_SRCDIR AND Qt5Widgets_FOUND)
add_library(gtests-lib STATIC EXCLUDE_FROM_ALL ${GTEST_SRCDIR}/src/gtest-all.cc )
target_include_directories(gtests-lib PUBLIC ${GTEST_INCDIR} ${GTEST_INCDIR}/gtest ${GTEST_SRCDIR})
add_library(gtests-radio-lib STATIC EXCLUDE_FROM_ALL ${GTEST_SRCDIR}/src/gtest-all.cc )
target_include_directories(gtests-radio-lib PUBLIC ${GTEST_INCDIR} ${GTEST_INCDIR}/gtest ${GTEST_SRCDIR})
add_definitions(-DSIMU)
add_definitions(-DGTESTS)
remove_definitions(-DCLI)
set(TESTS_PATH ${RADIO_SRC_DIRECTORY})
set(TESTS_PATH ${RADIO_SRC_DIRECTORY}/tests)
configure_file(${RADIO_SRC_DIRECTORY}/tests/location.h.in ${CMAKE_CURRENT_BINARY_DIR}/location.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if(PCB STREQUAL X12S OR PCB STREQUAL X10)
add_custom_command(
MAIN_DEPENDENCY ${TESTS_PATH}/model_22_x10.otx
OUTPUT ${TESTS_PATH}/model_22_x10/RADIO/radio.bin ${TESTS_PATH}/model_22_x10/RADIO/models.txt ${TESTS_PATH}/model_22_x10/MODELS/model1.bin
COMMAND mkdir -p model_22_x10 && cd model_22_x10 && unzip -o -DD ../model_22_x10.otx
WORKING_DIRECTORY ${TESTS_PATH}
)
add_custom_target(x10-model-test-files
DEPENDS ${TESTS_PATH}/model_22_x10/RADIO/radio.bin ${TESTS_PATH}/model_22_x10/RADIO/models.txt ${TESTS_PATH}/model_22_x10/MODELS/model1.bin
)
endif()
if(WIN32)
target_include_directories(gtests-lib PUBLIC ${WIN_INCLUDE_DIRS})
target_link_libraries(gtests-lib PRIVATE ${WIN_LINK_LIBRARIES})
target_include_directories(gtests-radio-lib PUBLIC ${WIN_INCLUDE_DIRS})
target_link_libraries(gtests-radio-lib PRIVATE ${WIN_LINK_LIBRARIES})
endif(WIN32)
if(SDL_FOUND AND SIMU_AUDIO)
target_include_directories(gtests-lib PUBLIC ${SDL_INCLUDE_DIR})
target_link_libraries(gtests-lib PRIVATE ${SDL_LIBRARY})
target_include_directories(gtests-radio-lib PUBLIC ${SDL_INCLUDE_DIR})
target_link_libraries(gtests-radio-lib PRIVATE ${SDL_LIBRARY})
endif()
foreach(FILE ${SRC})
@@ -38,9 +50,12 @@ if(GTEST_INCDIR AND GTEST_SRCDIR AND Qt5Widgets_FOUND)
use_cxx11() # ensure gnu++11 in CXX_FLAGS with CMake < 3.1
add_executable(gtests EXCLUDE_FROM_ALL ${TEST_SRC_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/location.h ${RADIO_SRC} ../targets/simu/simpgmspace.cpp ../targets/simu/simueeprom.cpp ../targets/simu/simufatfs.cpp)
add_dependencies(gtests ${FIRMWARE_DEPENDENCIES} gtests-lib)
target_link_libraries(gtests gtests-lib pthread Qt5::Core Qt5::Widgets)
add_executable(gtests-radio EXCLUDE_FROM_ALL ${TEST_SRC_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/location.h ${RADIO_SRC} ../targets/simu/simpgmspace.cpp ../targets/simu/simueeprom.cpp ../targets/simu/simufatfs.cpp)
add_dependencies(gtests-radio ${FIRMWARE_DEPENDENCIES} gtests-radio-lib)
if(PCB STREQUAL X12S OR PCB STREQUAL X10)
add_dependencies(gtests-radio x10-model-test-files)
endif()
target_link_libraries(gtests-radio gtests-radio-lib pthread Qt5::Core Qt5::Widgets)
message(STATUS "Added optional gtests target")
else()
message(WARNING "WARNING: gtests target will not be available (check that GTEST_INCDIR, GTEST_SRCDIR, and Qt5Widgets are configured).")