2015-09-03 20:10:50 +00:00
|
|
|
# QTest based tests
|
2022-02-09 23:02:30 +00:00
|
|
|
if(NOT USINGQT6)
|
|
|
|
qt5_add_resources(SUBSURFACE_TEST_RESOURCES ../subsurface.qrc)
|
|
|
|
else()
|
|
|
|
qt_add_resources(SUBSURFACE_TEST_RESOURCES ../subsurface.qrc)
|
|
|
|
endif()
|
2016-04-05 17:22:00 +00:00
|
|
|
|
2017-02-24 06:52:07 +00:00
|
|
|
# Access test data (dive folder) from SUBSURFACE_SOURCE by default.
|
|
|
|
# In cross compilation cases or when test will not be executed at build time
|
|
|
|
# a differnt value can be set via cmake -DSUBSURFACE_TEST_DATA.
|
|
|
|
if(NOT SUBSURFACE_TEST_DATA)
|
2017-02-25 15:52:22 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
# For windows case we expect tests to be executed
|
|
|
|
# with WORKING_DIRECTORY pointing to folder where test data can be found
|
|
|
|
set(SUBSURFACE_TEST_DATA .)
|
|
|
|
else()
|
|
|
|
set(SUBSURFACE_TEST_DATA ${SUBSURFACE_SOURCE})
|
|
|
|
endif()
|
2017-02-24 06:52:07 +00:00
|
|
|
endif()
|
|
|
|
|
2016-04-05 17:22:00 +00:00
|
|
|
add_library(RESOURCE_LIBRARY STATIC ${SUBSURFACE_TEST_RESOURCES})
|
|
|
|
|
2017-02-25 15:52:22 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
|
|
|
|
# Prepare a staging_tests folder
|
|
|
|
# Test can run accessing data and dependecies for build time testing
|
|
|
|
# or can be deployed for target testing
|
|
|
|
# It inludes:
|
|
|
|
# - test data
|
|
|
|
# - test binaries (see TEST macro)
|
|
|
|
# - test binaries dependencies (see TEST macro)
|
|
|
|
set(WINDOWS_STAGING_TESTS ${CMAKE_BINARY_DIR}/staging_tests)
|
|
|
|
install(DIRECTORY ${SUBSURFACE_SOURCE}/dives DESTINATION ${WINDOWS_STAGING_TESTS})
|
|
|
|
|
|
|
|
# Check if we can run tests locally using wine
|
|
|
|
# Add a fake test used to ensure data is deployed to WINDOWS_STAGING_TESTS before running
|
|
|
|
find_program(WINE_PROGRAM wine)
|
|
|
|
if(WINE_PROGRAM)
|
|
|
|
add_test(
|
|
|
|
NAME InstallTestsDataAndDependencies
|
|
|
|
COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_CURRENT_BINARY_DIR} --target install
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-12-25 15:00:54 +00:00
|
|
|
# define libraries to use, due to the fact that some library names are different between mobile and desktop
|
|
|
|
# extra settings are needed
|
|
|
|
# even though the targets are test executable the overall target is the same
|
|
|
|
if (SUBSURFACE_TARGET_EXECUTABLE MATCHES "DesktopExecutable")
|
|
|
|
set(TEST_SPECIFIC_LIBRARIES subsurface_models_desktop)
|
|
|
|
else()
|
|
|
|
set(TEST_SPECIFIC_LIBRARIES subsurface_models_mobile )
|
|
|
|
endif()
|
|
|
|
|
2019-03-25 20:34:19 +00:00
|
|
|
# Helper function TEST used to created rules to build, link, install and run tests
|
|
|
|
function(TEST NAME FILE)
|
2020-10-24 18:36:45 +00:00
|
|
|
if(DEFINED ARGV2)
|
|
|
|
set(CFGARG "CONFIGURATIONS" ${ARGV2})
|
|
|
|
endif()
|
2019-03-25 20:34:19 +00:00
|
|
|
get_filename_component(HDR "${FILE}" NAME_WE)
|
|
|
|
add_executable(${NAME} ${FILE} ${HDR}.h)
|
2017-02-25 15:52:22 +00:00
|
|
|
target_link_libraries(
|
|
|
|
${NAME}
|
2019-12-25 15:00:54 +00:00
|
|
|
subsurface_backend_shared
|
|
|
|
${TEST_SPECIFIC_LIBRARIES}
|
2017-02-25 15:52:22 +00:00
|
|
|
subsurface_corelib
|
|
|
|
RESOURCE_LIBRARY
|
|
|
|
${QT_TEST_LIBRARIES}
|
|
|
|
${SUBSURFACE_LINK_LIBRARIES}
|
|
|
|
)
|
|
|
|
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
# Re-install dependencies in WINDOWS_STAGING_TESTS (and not in WINDOWSSTAGING)
|
|
|
|
# to avoid packing testing related dlls in the installer
|
2017-03-11 04:41:56 +00:00
|
|
|
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DSUBSURFACE_TARGET=${NAME} -DSUBSURFACE_SOURCE=${SUBSURFACE_SOURCE} -DSTAGING=${WINDOWS_STAGING_TESTS} -P ${CMAKE_SOURCE_DIR}/cmake/Modules/dlllist.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
|
2017-02-25 15:52:22 +00:00
|
|
|
|
|
|
|
# Run test using wine
|
|
|
|
if(WINE_PROGRAM)
|
|
|
|
add_test(
|
2020-10-24 18:36:45 +00:00
|
|
|
NAME ${NAME} ${CFGARG}
|
2017-02-25 15:52:22 +00:00
|
|
|
COMMAND "$<TARGET_FILE:${NAME}>"
|
|
|
|
WORKING_DIRECTORY ${WINDOWS_STAGING_TESTS}
|
|
|
|
)
|
|
|
|
# Set WINEPATH (%PATH%) to WINDOWS_STAGING_TESTS allowing wine to find dlls
|
|
|
|
# WINEDEBUG=-all is used to avoid anoying winde debug outputs
|
|
|
|
set_tests_properties(${NAME} PROPERTIES ENVIRONMENT "WINEPATH=${WINDOWS_STAGING_TESTS};WINEDEBUG=-all")
|
|
|
|
set_tests_properties(${NAME} PROPERTIES DEPENDS PrepareTests)
|
|
|
|
endif()
|
|
|
|
else()
|
2020-10-24 18:36:45 +00:00
|
|
|
add_test(NAME ${NAME} ${CFGARG} COMMAND $<TARGET_FILE:${NAME}>)
|
2017-02-25 15:52:22 +00:00
|
|
|
endif()
|
2019-03-25 20:34:19 +00:00
|
|
|
endfunction()
|
2015-09-03 20:10:50 +00:00
|
|
|
|
|
|
|
add_definitions(-g)
|
2017-02-24 06:52:07 +00:00
|
|
|
add_definitions(-DSUBSURFACE_TEST_DATA="${SUBSURFACE_TEST_DATA}")
|
2017-02-25 15:52:22 +00:00
|
|
|
|
2018-07-07 16:55:24 +00:00
|
|
|
# Build QML test runner
|
2020-03-31 12:55:11 +00:00
|
|
|
add_executable(TestQML testqml.cpp)
|
2018-07-07 16:55:24 +00:00
|
|
|
target_link_libraries(
|
|
|
|
TestQML
|
|
|
|
subsurface_corelib
|
|
|
|
RESOURCE_LIBRARY
|
|
|
|
${QT_TEST_LIBRARIES}
|
|
|
|
${SUBSURFACE_LINK_LIBRARIES}
|
|
|
|
)
|
|
|
|
|
|
|
|
# SSRF test cases (TBD, convert to standard qTest setup)
|
2015-09-03 20:10:50 +00:00
|
|
|
TEST(TestUnitConversion testunitconversion.cpp)
|
|
|
|
TEST(TestProfile testprofile.cpp)
|
|
|
|
TEST(TestGpsCoords testgpscoords.cpp)
|
|
|
|
TEST(TestParse testparse.cpp)
|
2019-04-30 10:42:33 +00:00
|
|
|
TEST(TestAirPressure testAirPressure.cpp)
|
2018-10-08 18:35:28 +00:00
|
|
|
if (BTSUPPORT)
|
|
|
|
TEST(TestHelper testhelper.cpp)
|
|
|
|
endif()
|
2018-08-30 21:01:03 +00:00
|
|
|
TEST(TestParsePerformance testparseperformance.cpp)
|
2015-09-03 20:10:50 +00:00
|
|
|
TEST(TestPlan testplan.cpp)
|
|
|
|
TEST(TestDiveSiteDuplication testdivesiteduplication.cpp)
|
|
|
|
TEST(TestRenumber testrenumber.cpp)
|
2020-01-27 00:29:14 +00:00
|
|
|
# this keeps randomly failing and I don't understand why
|
|
|
|
# too many false positives, so disabling this test for now
|
2020-10-24 18:36:45 +00:00
|
|
|
TEST(TestGitStorage testgitstorage.cpp storageconfig)
|
2020-11-19 03:54:30 +00:00
|
|
|
if (SUBSURFACE_TARGET_EXECUTABLE MATCHES "DesktopExecutable")
|
2017-02-21 09:27:31 +00:00
|
|
|
TEST(TestPicture testpicture.cpp)
|
2020-11-19 03:54:30 +00:00
|
|
|
set(TEST_PICTURE TestPicture)
|
|
|
|
endif()
|
2017-02-22 01:23:19 +00:00
|
|
|
TEST(TestMerge testmerge.cpp)
|
2018-04-09 08:09:34 +00:00
|
|
|
TEST(TestTagList testtaglist.cpp)
|
2018-07-15 16:58:22 +00:00
|
|
|
|
2020-02-10 18:33:25 +00:00
|
|
|
#if (SUBSURFACE_TARGET_EXECUTABLE MATCHES "MobileExecutable")
|
|
|
|
#TEST(TestPlannerShared testplannershared.cpp)
|
|
|
|
#endif()
|
2019-12-25 15:30:13 +00:00
|
|
|
|
2018-07-14 15:31:51 +00:00
|
|
|
TEST(TestQPrefCloudStorage testqPrefCloudStorage.cpp)
|
2018-07-15 16:58:22 +00:00
|
|
|
TEST(TestQPrefDisplay testqPrefDisplay.cpp)
|
2018-07-22 15:02:26 +00:00
|
|
|
TEST(TestQPrefDiveComputer testqPrefDiveComputer.cpp)
|
2018-08-02 16:17:14 +00:00
|
|
|
TEST(TestQPrefDivePlanner testqPrefDivePlanner.cpp)
|
2018-08-13 15:40:17 +00:00
|
|
|
TEST(TestQPrefGeneral testqPrefGeneral.cpp)
|
2019-12-11 17:50:17 +00:00
|
|
|
TEST(TestQPrefLog testqPrefLog.cpp)
|
2019-12-07 18:27:25 +00:00
|
|
|
TEST(TestQPrefEquipment testqPrefEquipment.cpp)
|
2019-12-08 10:03:10 +00:00
|
|
|
TEST(TestQPrefMedia testqPrefMedia.cpp)
|
2018-08-10 15:57:48 +00:00
|
|
|
TEST(TestQPrefGeocoding testqPrefGeocoding.cpp)
|
2018-08-08 15:13:31 +00:00
|
|
|
TEST(TestQPrefLanguage testqPrefLanguage.cpp)
|
2018-08-11 18:21:19 +00:00
|
|
|
TEST(TestQPrefPartialPressureGas testqPrefPartialPressureGas.cpp)
|
2018-07-27 20:22:51 +00:00
|
|
|
TEST(TestQPrefProxy testqPrefProxy.cpp)
|
2018-08-05 12:13:37 +00:00
|
|
|
TEST(TestQPrefTechnicalDetails testqPrefTechnicalDetails.cpp)
|
2018-07-31 17:15:54 +00:00
|
|
|
TEST(TestQPrefUnits testqPrefUnits.cpp)
|
2018-08-03 19:07:44 +00:00
|
|
|
TEST(TestQPrefUpdateManager testqPrefUpdateManager.cpp)
|
2023-10-12 19:38:54 +00:00
|
|
|
TEST(TestformatDiveGasString testformatDiveGasString.cpp)
|
2018-09-08 16:18:16 +00:00
|
|
|
add_test(NAME TestQML COMMAND $<TARGET_FILE:TestQML> -input ${SUBSURFACE_SOURCE}/tests)
|
2017-02-21 09:27:31 +00:00
|
|
|
|
2020-02-10 18:33:25 +00:00
|
|
|
# this is currently broken
|
|
|
|
#if (SUBSURFACE_TARGET_EXECUTABLE MATCHES "MobileExecutable")
|
|
|
|
# set(TEST_PLANNER_SHARED TestPlannerShared)
|
|
|
|
#endif()
|
2015-09-03 20:10:50 +00:00
|
|
|
|
|
|
|
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
|
|
|
|
DEPENDS
|
|
|
|
TestUnitConversion
|
|
|
|
TestProfile
|
|
|
|
TestGpsCoords
|
|
|
|
TestParse
|
|
|
|
TestPlan
|
2019-04-30 10:42:33 +00:00
|
|
|
TestAirPressure
|
2015-09-03 20:10:50 +00:00
|
|
|
TestDiveSiteDuplication
|
2016-08-28 22:26:42 +00:00
|
|
|
TestRenumber
|
2020-11-19 03:54:30 +00:00
|
|
|
${TEST_PICTURE}
|
2017-02-22 01:23:19 +00:00
|
|
|
TestMerge
|
2018-04-09 08:09:34 +00:00
|
|
|
TestTagList
|
2019-12-28 16:46:45 +00:00
|
|
|
${TEST_PLANNER_SHARED}
|
2018-07-14 15:31:51 +00:00
|
|
|
TestQPrefCloudStorage
|
2018-07-15 16:58:22 +00:00
|
|
|
TestQPrefDisplay
|
2018-07-22 15:02:26 +00:00
|
|
|
TestQPrefDiveComputer
|
2018-08-02 16:17:14 +00:00
|
|
|
TestQPrefDivePlanner
|
2018-08-13 15:40:17 +00:00
|
|
|
TestQPrefGeneral
|
2019-12-11 17:50:17 +00:00
|
|
|
TestQPrefLog
|
2019-12-07 18:27:25 +00:00
|
|
|
TestQPrefEquipment
|
2019-12-08 10:03:10 +00:00
|
|
|
TestQPrefMedia
|
2018-08-10 15:57:48 +00:00
|
|
|
TestQPrefGeocoding
|
2018-08-08 15:13:31 +00:00
|
|
|
TestQPrefLanguage
|
2018-08-11 18:21:19 +00:00
|
|
|
TestQPrefPartialPressureGas
|
2018-07-27 20:22:51 +00:00
|
|
|
TestQPrefProxy
|
2018-08-05 12:13:37 +00:00
|
|
|
TestQPrefTechnicalDetails
|
2018-07-31 17:15:54 +00:00
|
|
|
TestQPrefUnits
|
2018-08-03 19:07:44 +00:00
|
|
|
TestQPrefUpdateManager
|
2018-07-07 16:55:24 +00:00
|
|
|
TestQML
|
2016-08-28 22:26:42 +00:00
|
|
|
)
|
2017-02-25 15:27:43 +00:00
|
|
|
|
|
|
|
# useful for debugging CMake issues
|
|
|
|
# print_all_variables()
|