2010-08-13 16:08:06 +00:00
|
|
|
# Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
|
|
|
|
#
|
|
|
|
# This program 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 2 or (at your option)
|
|
|
|
# version 3 of the License.
|
|
|
|
#
|
|
|
|
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-10-29 15:17:24 +00:00
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/../src)
|
2010-08-13 16:08:06 +00:00
|
|
|
|
2011-11-20 09:12:49 +00:00
|
|
|
add_definitions(-DQT_TEST_LIB)
|
|
|
|
|
2012-05-21 21:37:29 +00:00
|
|
|
set(KEEPASSX_TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)
|
|
|
|
configure_file(config-keepassx-tests.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepassx-tests.h)
|
|
|
|
|
|
|
|
macro(parse_arguments prefix arg_names option_names)
|
|
|
|
set(DEFAULT_ARGS)
|
|
|
|
foreach(arg_name ${arg_names})
|
|
|
|
set(${prefix}_${arg_name})
|
|
|
|
endforeach(arg_name)
|
|
|
|
foreach(option ${option_names})
|
|
|
|
set(${prefix}_${option} FALSE)
|
|
|
|
endforeach(option)
|
|
|
|
|
|
|
|
set(current_arg_name DEFAULT_ARGS)
|
|
|
|
set(current_arg_list)
|
|
|
|
foreach(arg ${ARGN})
|
|
|
|
set(larg_names ${arg_names})
|
|
|
|
list(FIND larg_names "${arg}" is_arg_name)
|
|
|
|
if(is_arg_name GREATER -1)
|
|
|
|
set(${prefix}_${current_arg_name} ${current_arg_list})
|
|
|
|
set(current_arg_name ${arg})
|
|
|
|
set(current_arg_list)
|
|
|
|
else()
|
|
|
|
set(loption_names ${option_names})
|
|
|
|
list(FIND loption_names "${arg}" is_option)
|
|
|
|
if(is_option GREATER -1)
|
|
|
|
set(${prefix}_${arg} TRUE)
|
|
|
|
else(is_option GREATER -1)
|
|
|
|
set(current_arg_list ${current_arg_list} ${arg})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach(arg)
|
|
|
|
set(${prefix}_${current_arg_name} ${current_arg_list})
|
|
|
|
endmacro(parse_arguments)
|
|
|
|
|
|
|
|
macro(add_unit_test)
|
2015-07-22 14:59:38 +00:00
|
|
|
parse_arguments(TEST "NAME;SOURCES;LIBS" "" ${ARGN})
|
2012-05-21 21:37:29 +00:00
|
|
|
set(_test_NAME ${TEST_NAME})
|
|
|
|
set(_srcList ${TEST_SOURCES})
|
|
|
|
add_executable(${_test_NAME} ${_srcList})
|
|
|
|
target_link_libraries(${_test_NAME} ${TEST_LIBS})
|
|
|
|
|
|
|
|
if(NOT TEST_OUTPUT)
|
|
|
|
set(TEST_OUTPUT plaintext)
|
|
|
|
endif(NOT TEST_OUTPUT)
|
|
|
|
set(TEST_OUTPUT ${TEST_OUTPUT} CACHE STRING "The output to generate when running the QTest unit tests")
|
|
|
|
|
|
|
|
if(KDE4_TEST_OUTPUT STREQUAL "xml")
|
2015-02-26 05:30:06 +00:00
|
|
|
add_test(${_test_NAME} ${_test_NAME} -xml -o ${_test_NAME}.tml)
|
2012-05-21 21:37:29 +00:00
|
|
|
else(KDE4_TEST_OUTPUT STREQUAL "xml")
|
2015-02-26 05:30:06 +00:00
|
|
|
add_test(${_test_NAME} ${_test_NAME})
|
2012-05-21 21:37:29 +00:00
|
|
|
endif(KDE4_TEST_OUTPUT STREQUAL "xml")
|
|
|
|
|
|
|
|
if(NOT MSVC_IDE) #not needed for the ide
|
|
|
|
# if the tests are EXCLUDE_FROM_ALL, add a target "buildtests" to build all tests
|
|
|
|
if(NOT WITH_TESTS)
|
|
|
|
get_directory_property(_buildtestsAdded BUILDTESTS_ADDED)
|
|
|
|
if(NOT _buildtestsAdded)
|
|
|
|
add_custom_target(buildtests)
|
|
|
|
set_directory_properties(PROPERTIES BUILDTESTS_ADDED TRUE)
|
|
|
|
endif()
|
|
|
|
add_dependencies(buildtests ${_test_NAME})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro(add_unit_test)
|
2010-08-13 16:08:06 +00:00
|
|
|
|
2010-11-21 22:06:30 +00:00
|
|
|
set(TEST_LIBRARIES
|
|
|
|
keepassx_core
|
2016-12-04 18:57:24 +00:00
|
|
|
${keepasshttp_LIB}
|
2016-12-13 20:14:39 +00:00
|
|
|
${autotype_LIB}
|
2015-07-22 14:59:38 +00:00
|
|
|
Qt5::Core
|
2015-07-22 15:22:31 +00:00
|
|
|
Qt5::Concurrent
|
2015-07-22 14:59:38 +00:00
|
|
|
Qt5::Widgets
|
|
|
|
Qt5::Test
|
2011-11-12 13:30:16 +00:00
|
|
|
${GCRYPT_LIBRARIES}
|
2017-01-26 00:15:12 +00:00
|
|
|
${GPGERROR_LIBRARIES}
|
2010-11-21 22:06:30 +00:00
|
|
|
${ZLIB_LIBRARIES}
|
|
|
|
)
|
2010-09-11 17:49:30 +00:00
|
|
|
|
2018-01-24 12:22:20 +00:00
|
|
|
set(testsupport_SOURCES TestGlobal.h modeltest.cpp FailDevice.cpp)
|
2015-07-20 19:32:07 +00:00
|
|
|
add_library(testsupport STATIC ${testsupport_SOURCES})
|
2017-06-29 17:54:49 +00:00
|
|
|
target_link_libraries(testsupport Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Test)
|
2010-08-14 12:26:25 +00:00
|
|
|
|
2014-05-26 07:46:41 +00:00
|
|
|
if(YUBIKEY_FOUND)
|
|
|
|
set(TEST_LIBRARIES ${TEST_LIBRARIES} ${YUBIKEY_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testgroup SOURCES TestGroup.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2010-09-19 22:16:30 +00:00
|
|
|
|
2018-01-17 19:52:29 +00:00
|
|
|
add_unit_test(NAME testkdbx2 SOURCES TestKdbx2.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2010-08-15 10:31:48 +00:00
|
|
|
|
2018-01-17 19:52:29 +00:00
|
|
|
add_unit_test(NAME testkdbx3 SOURCES TestKeePass2Format.cpp FailDevice.cpp TestKdbx3.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2018-01-05 15:41:29 +00:00
|
|
|
|
2018-03-01 20:25:29 +00:00
|
|
|
add_unit_test(NAME testkdbx4 SOURCES TestKeePass2Format.cpp FailDevice.cpp mock/MockChallengeResponseKey.cpp TestKdbx4.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2011-11-13 13:52:43 +00:00
|
|
|
|
2018-03-01 19:07:19 +00:00
|
|
|
add_unit_test(NAME testkeys SOURCES TestKeys.cpp mock/MockChallengeResponseKey.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2010-08-18 14:22:48 +00:00
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testgroupmodel SOURCES TestGroupModel.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
2010-09-11 17:49:30 +00:00
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testentrymodel SOURCES TestEntryModel.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
2010-09-11 17:49:30 +00:00
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testcryptohash SOURCES TestCryptoHash.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2010-09-18 15:19:42 +00:00
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testsymmetriccipher SOURCES TestSymmetricCipher.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2010-11-21 22:06:30 +00:00
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testhashedblockstream SOURCES TestHashedBlockStream.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
2011-07-06 22:08:37 +00:00
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testkeepass2randomstream SOURCES TestKeePass2RandomStream.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2011-12-26 18:18:21 +00:00
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testmodified SOURCES TestModified.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2012-04-18 11:27:16 +00:00
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testdeletedobjects SOURCES TestDeletedObjects.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2012-04-21 21:17:26 +00:00
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testkeepass1reader SOURCES TestKeePass1Reader.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2011-12-26 18:18:21 +00:00
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testwildcardmatcher SOURCES TestWildcardMatcher.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2012-07-22 12:04:50 +00:00
|
|
|
|
2016-12-04 18:57:24 +00:00
|
|
|
if(WITH_XC_AUTOTYPE)
|
|
|
|
add_unit_test(NAME testautotype SOURCES TestAutoType.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2016-12-04 18:57:24 +00:00
|
|
|
set_target_properties(testautotype PROPERTIES ENABLE_EXPORTS ON)
|
|
|
|
endif()
|
2012-10-28 14:31:57 +00:00
|
|
|
|
2017-10-29 15:17:24 +00:00
|
|
|
if(WITH_XC_SSHAGENT)
|
|
|
|
add_unit_test(NAME testopensshkey SOURCES TestOpenSSHKey.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS sshagent ${TEST_LIBRARIES})
|
2017-10-29 15:17:24 +00:00
|
|
|
endif()
|
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testentry SOURCES TestEntry.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2013-03-24 20:21:06 +00:00
|
|
|
|
2017-09-05 14:28:47 +00:00
|
|
|
add_unit_test(NAME testmerge SOURCES TestMerge.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2017-09-05 14:28:47 +00:00
|
|
|
|
2017-04-13 10:05:36 +00:00
|
|
|
add_unit_test(NAME testtotp SOURCES TestTotp.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2017-04-13 10:05:36 +00:00
|
|
|
|
2017-09-24 22:00:12 +00:00
|
|
|
add_unit_test(NAME testbase32 SOURCES TestBase32.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2017-09-24 22:00:12 +00:00
|
|
|
|
2017-01-09 00:33:21 +00:00
|
|
|
add_unit_test(NAME testcsvparser SOURCES TestCsvParser.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2017-01-09 00:33:21 +00:00
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testrandom SOURCES TestRandom.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2013-10-09 21:11:18 +00:00
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testentrysearcher SOURCES TestEntrySearcher.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2014-05-15 21:48:54 +00:00
|
|
|
|
2015-07-22 14:59:38 +00:00
|
|
|
add_unit_test(NAME testcsvexporter SOURCES TestCsvExporter.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2015-07-14 20:14:34 +00:00
|
|
|
|
2014-05-26 07:46:41 +00:00
|
|
|
add_unit_test(NAME testykchallengeresponsekey
|
2018-01-24 12:22:20 +00:00
|
|
|
SOURCES TestYkChallengeResponseKey.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2014-05-26 07:46:41 +00:00
|
|
|
|
2017-04-22 07:02:59 +00:00
|
|
|
add_unit_test(NAME testdatabase SOURCES TestDatabase.cpp
|
2018-01-17 17:15:37 +00:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2017-04-22 07:02:59 +00:00
|
|
|
|
2011-12-26 18:18:21 +00:00
|
|
|
if(WITH_GUI_TESTS)
|
2012-05-21 21:37:29 +00:00
|
|
|
add_subdirectory(gui)
|
2011-12-26 18:18:21 +00:00
|
|
|
endif(WITH_GUI_TESTS)
|