2020-09-17 02:15:16 +01:00
|
|
|
# SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
|
|
|
|
# SPDX-FileCopyrightText: 2017-2019 Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
# SPDX-FileCopyrightText: 2018 Caio Carvalho <caiojcarvalho@gmail.com>
|
|
|
|
# SPDX-FileCopyrightText: 2019 Yuri Chornoivan <yurchor@ukr.net>
|
|
|
|
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2017-10-02 14:40:41 +01:00
|
|
|
# Tests for KPMcore
|
|
|
|
#
|
|
|
|
# These are not so much "tests" as "small example programs". They illustrate
|
|
|
|
# how to use the library, how to perform common tasks.
|
|
|
|
|
|
|
|
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
|
|
|
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
|
|
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
|
|
|
|
add_compile_options(-fPIC)
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Helper macro to link to the helper (for initialization of kpmcore)
|
|
|
|
# and to add a test with the given name.
|
|
|
|
#
|
2018-03-21 17:01:40 +00:00
|
|
|
add_library(testhelpers STATIC helpers.cpp)
|
2020-11-16 18:16:42 +00:00
|
|
|
target_link_libraries(testhelpers PRIVATE kpmcore)
|
2017-10-02 14:40:41 +01:00
|
|
|
|
|
|
|
macro (kpm_test name)
|
2018-03-21 17:01:40 +00:00
|
|
|
add_executable(${name} ${ARGN})
|
2022-01-16 00:17:46 +00:00
|
|
|
target_link_libraries(${name} testhelpers kpmcore Qt${QT_MAJOR_VERSION}::Core)
|
2017-10-02 14:40:41 +01:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Tests of initialization: try explicitly loading some backends
|
|
|
|
kpm_test(testinit testinit.cpp) # Default backend
|
|
|
|
if(TARGET pmdummybackendplugin)
|
2022-06-12 22:14:51 +01:00
|
|
|
add_test(NAME testinit-dummy COMMAND testinit $<TARGET_FILE_NAME:pmdummybackendplugin>)
|
2017-10-02 14:40:41 +01:00
|
|
|
endif()
|
2018-03-21 17:01:40 +00:00
|
|
|
if(TARGET pmsfdiskbackendplugin)
|
2022-06-12 22:14:51 +01:00
|
|
|
add_test(NAME testinit-sfdisk COMMAND testinit $<TARGET_FILE_NAME:pmsfdiskbackendplugin>)
|
2017-10-02 19:13:47 +01:00
|
|
|
else()
|
|
|
|
return() # All the rest really needs a working backend
|
2017-10-02 14:40:41 +01:00
|
|
|
endif()
|
2017-10-02 19:13:47 +01:00
|
|
|
|
2022-06-12 22:14:51 +01:00
|
|
|
set(BACKEND $<TARGET_FILE_NAME:pmsfdiskbackendplugin>)
|
2017-10-02 19:13:47 +01:00
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Listing devices, partitions
|
|
|
|
kpm_test(testlist testlist.cpp)
|
|
|
|
add_test(NAME testlist COMMAND testlist ${BACKEND})
|
2017-10-03 20:03:35 +01:00
|
|
|
|
|
|
|
kpm_test(testdevicescanner testdevicescanner.cpp)
|
|
|
|
add_test(NAME testdevicescanner COMMAND testdevicescanner ${BACKEND})
|
2017-11-07 22:55:28 +00:00
|
|
|
|
|
|
|
find_package (Threads)
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Execute external commands as root
|
|
|
|
kpm_test(testexternalcommand testexternalcommand.cpp)
|
|
|
|
add_test(NAME testexternalcommand COMMAND testexternalcommand ${BACKEND})
|
2018-01-21 00:56:10 +00:00
|
|
|
|
2019-07-21 20:48:31 +01:00
|
|
|
|
|
|
|
# Test Device
|
|
|
|
kpm_test(testdevice testdevice.cpp)
|
2019-11-22 13:39:14 +00:00
|
|
|
add_test(NAME testdevice COMMAND testdevice ${BACKEND})
|