Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 1 | project(velia LANGUAGES CXX) |
Tomáš Pecka | a06d74d | 2020-06-14 18:18:13 +0200 | [diff] [blame] | 2 | cmake_minimum_required(VERSION 3.15) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 3 | |
| 4 | # Build options |
| 5 | set(CMAKE_CXX_STANDARD 17) |
| 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 7 | |
| 8 | set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}") |
| 9 | set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Woverloaded-virtual ${CMAKE_CXX_FLAGS}") |
| 10 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
| 11 | set(CMAKE_CXX_FLAGS "-Wsuggest-override ${CMAKE_CXX_FLAGS}") |
| 12 | endif() |
| 13 | |
Tomáš Pecka | 5d4cf2a | 2020-07-13 13:19:41 +0200 | [diff] [blame] | 14 | if(CMAKE_CXX_FLAGS MATCHES "-stdlib=libc\\+\\+" AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) |
| 15 | set(STD_FILESYSTEM_LIBRARY c++fs) |
| 16 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.1) |
| 17 | set(STD_FILESYSTEM_LIBRARY stdc++fs) |
| 18 | endif() |
| 19 | |
| 20 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 21 | add_custom_target(velia-version-cmake-ide |
| 22 | cmake/ProjectGitVersion.cmake |
| 23 | cmake/ProjectGitVersionRunner.cmake |
| 24 | ) |
| 25 | include(cmake/ProjectGitVersion.cmake) |
| 26 | prepare_git_version(VELIA_VERSION "0.0") |
| 27 | |
| 28 | find_package(Doxygen) |
| 29 | option(WITH_DOCS "Create and install internal documentation (needs Doxygen)" ${DOXYGEN_FOUND}) |
| 30 | |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 31 | find_package(Boost REQUIRED COMPONENTS filesystem) |
Tomáš Pecka | a193c03 | 2020-06-22 17:33:31 +0200 | [diff] [blame] | 32 | find_package(docopt REQUIRED) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 33 | find_package(spdlog REQUIRED) |
Tomáš Pecka | 0a2e890 | 2020-06-09 21:11:20 +0200 | [diff] [blame] | 34 | find_package(sdbus-c++ REQUIRED) |
Tomáš Pecka | a433681 | 2020-07-24 15:32:58 +0200 | [diff] [blame] | 35 | find_package(PkgConfig) |
| 36 | |
| 37 | pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd) |
Tomáš Pecka | 1f42cfe | 2020-10-21 18:38:27 +0200 | [diff] [blame] | 38 | if(${SYSTEMD_VERSION} VERSION_EQUAL 245) |
| 39 | message(FATAL_ERROR "Systemd 245 has a bug affecting DBus method calls using sdbus-c++. Please see https://github.com/Kistler-Group/sdbus-cpp/issues/106.") |
| 40 | endif() |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 41 | |
Jan Kundrát | cf65a20 | 2021-01-19 09:37:14 +0100 | [diff] [blame] | 42 | pkg_check_modules(SYSREPO REQUIRED sysrepo-cpp>=1.4.100 IMPORTED_TARGET sysrepo) |
| 43 | pkg_check_modules(LIBYANG REQUIRED libyang-cpp>=1.0.209 IMPORTED_TARGET libyang) |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 44 | |
Tomáš Pecka | c927d66 | 2020-07-13 11:16:16 +0200 | [diff] [blame] | 45 | include(GNUInstallDirs) |
| 46 | |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 47 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/) |
| 48 | |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 49 | set(YANG_SRCS |
Tomáš Pecka | 9a02c3f | 2021-01-21 15:27:22 +0100 | [diff] [blame] | 50 | yang/czechlight-system@2021-01-13.yang |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 51 | yang/iana-hardware@2018-03-13.yang |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 52 | yang/ietf-hardware@2018-03-13.yang |
Tomáš Pecka | f98ce03 | 2021-01-14 13:35:00 +0100 | [diff] [blame] | 53 | yang/iana-crypt-hash@2014-08-06.yang |
| 54 | yang/ietf-inet-types@2013-07-15.yang |
| 55 | yang/ietf-netconf-acm@2018-02-14.yang |
| 56 | yang/ietf-system@2014-08-06.yang |
| 57 | yang/ietf-yang-types@2013-07-15.yang |
Václav Kubernát | 637fe80 | 2021-01-22 02:43:18 +0100 | [diff] [blame] | 58 | yang/ietf-access-control-list@2019-03-04.yang |
Václav Kubernát | 457d1ad | 2021-01-22 02:43:18 +0100 | [diff] [blame] | 59 | yang/czechlight-firewall@2021-01-25.yang |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 60 | ) |
| 61 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 62 | # Targets |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 63 | # - utils |
Tomáš Pecka | bd82886 | 2020-06-15 15:53:35 +0200 | [diff] [blame] | 64 | add_library(velia-utils STATIC |
Tomáš Pecka | a193c03 | 2020-06-22 17:33:31 +0200 | [diff] [blame] | 65 | src/utils/exceptions.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 66 | src/utils/exceptions.h |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 67 | src/utils/io.cpp |
| 68 | src/utils/io.h |
Tomáš Pecka | a433681 | 2020-07-24 15:32:58 +0200 | [diff] [blame] | 69 | src/utils/journal.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 70 | src/utils/journal.h |
| 71 | src/utils/log.h |
| 72 | src/utils/log-fwd.h |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 73 | src/utils/log-init.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 74 | src/utils/log-init.h |
Tomáš Pecka | ba2dc31 | 2021-01-23 22:29:11 +0100 | [diff] [blame] | 75 | src/utils/sysrepo.cpp |
| 76 | src/utils/sysrepo.h |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 77 | src/utils/time.cpp |
| 78 | src/utils/time.h |
Tomáš Pecka | d033707 | 2021-01-25 19:57:00 +0100 | [diff] [blame] | 79 | src/utils/waitUntilSignalled.cpp |
| 80 | src/utils/waitUntilSignalled.h |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 81 | ) |
Tomáš Pecka | f02671e | 2021-01-13 09:09:48 +0100 | [diff] [blame] | 82 | target_link_libraries(velia-utils PUBLIC spdlog::spdlog PRIVATE PkgConfig::SYSTEMD PkgConfig::SYSREPO) |
Tomáš Pecka | a433681 | 2020-07-24 15:32:58 +0200 | [diff] [blame] | 83 | |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 84 | # - health |
| 85 | add_library(velia-health STATIC |
| 86 | src/health/inputs/AbstractInput.cpp |
| 87 | src/health/inputs/DbusSemaphoreInput.cpp |
| 88 | src/health/inputs/DbusSystemdInput.cpp |
| 89 | src/health/manager/AbstractManager.cpp |
| 90 | src/health/manager/StateManager.cpp |
| 91 | src/health/outputs/LedSysfsDriver.cpp |
| 92 | src/health/outputs/callables.cpp |
| 93 | src/health/State.cpp |
Tomáš Pecka | 74b885f | 2020-06-06 20:02:41 +0200 | [diff] [blame] | 94 | ) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 95 | target_link_libraries(velia-health |
| 96 | PUBLIC |
| 97 | velia-utils |
| 98 | Boost::boost |
| 99 | SDBusCpp::sdbus-c++ |
| 100 | ${STD_FILESYSTEM_LIBRARY} |
| 101 | ) |
Tomáš Pecka | 74b885f | 2020-06-06 20:02:41 +0200 | [diff] [blame] | 102 | |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 103 | # - ietf-hardware |
| 104 | add_library(velia-ietf-hardware STATIC |
| 105 | src/ietf-hardware/sysfs/EMMC.cpp |
| 106 | src/ietf-hardware/sysfs/EMMC.h |
Tomáš Pecka | 9b1c967 | 2020-11-11 15:24:06 +0100 | [diff] [blame] | 107 | src/ietf-hardware/sysfs/HWMon.cpp |
| 108 | src/ietf-hardware/sysfs/HWMon.h |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 109 | src/ietf-hardware/IETFHardware.cpp |
| 110 | src/ietf-hardware/IETFHardware.h |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 111 | ) |
| 112 | target_link_libraries(velia-ietf-hardware |
| 113 | PUBLIC |
| 114 | velia-utils |
| 115 | ${STD_FILESYSTEM_LIBRARY} |
Tomáš Pecka | 9b1c967 | 2020-11-11 15:24:06 +0100 | [diff] [blame] | 116 | Boost::boost |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 117 | ) |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 118 | |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 119 | add_library(velia-ietf-hardware-sysrepo STATIC |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 120 | src/ietf-hardware/sysrepo/Sysrepo.cpp |
| 121 | src/ietf-hardware/sysrepo/Sysrepo.h |
| 122 | ) |
| 123 | target_link_libraries(velia-ietf-hardware-sysrepo |
| 124 | PUBLIC |
| 125 | velia-utils |
| 126 | PkgConfig::SYSREPO |
| 127 | PkgConfig::LIBYANG |
| 128 | ) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 129 | |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 130 | # - ietf-system |
| 131 | add_library(velia-system STATIC |
Tomáš Pecka | 991e4d5 | 2021-01-11 10:03:14 +0100 | [diff] [blame] | 132 | src/system/RAUC.cpp |
| 133 | src/system/RAUC.h |
Tomáš Pecka | cb7a5f8 | 2021-01-20 15:12:00 +0100 | [diff] [blame] | 134 | src/system/CzechlightSystem.cpp |
| 135 | src/system/CzechlightSystem.h |
Tomáš Pecka | f976c5b | 2021-01-23 21:19:52 +0100 | [diff] [blame] | 136 | src/system/IETFSystem.cpp |
| 137 | src/system/IETFSystem.h |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 138 | ) |
| 139 | target_link_libraries(velia-system |
| 140 | PUBLIC |
| 141 | velia-utils |
| 142 | PkgConfig::SYSREPO |
| 143 | PkgConfig::LIBYANG |
Václav Kubernát | 6dd52c8 | 2021-01-21 08:38:42 +0100 | [diff] [blame] | 144 | SDBusCpp::sdbus-c++ |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 145 | ) |
| 146 | |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 147 | # - firewall |
| 148 | add_library(velia-firewall STATIC |
| 149 | src/firewall/Firewall.cpp |
| 150 | ) |
| 151 | target_link_libraries(velia-firewall |
| 152 | PUBLIC |
| 153 | velia-utils |
| 154 | PkgConfig::SYSREPO |
| 155 | PRIVATE |
| 156 | PkgConfig::LIBYANG |
| 157 | ) |
| 158 | |
| 159 | |
Tomáš Pecka | 625b7a1 | 2021-01-23 20:55:51 +0100 | [diff] [blame] | 160 | # - daemons |
Tomáš Pecka | d03044f | 2020-11-12 14:33:10 +0100 | [diff] [blame] | 161 | add_executable(veliad |
Tomáš Pecka | 139e361 | 2021-01-25 19:49:00 +0100 | [diff] [blame^] | 162 | src/main.cpp |
| 163 | src/ietf-hardware/Factory.cpp |
| 164 | src/ietf-hardware/Factory.h |
| 165 | src/health/Factory.cpp |
| 166 | src/health/Factory.h |
| 167 | ) |
Tomáš Pecka | d03044f | 2020-11-12 14:33:10 +0100 | [diff] [blame] | 168 | target_link_libraries(veliad |
| 169 | PUBLIC |
| 170 | velia-health |
| 171 | velia-ietf-hardware |
| 172 | velia-ietf-hardware-sysrepo |
| 173 | docopt |
| 174 | ) |
| 175 | add_dependencies(veliad target-VELIA_VERSION) |
| 176 | target_include_directories(veliad PUBLIC ${CMAKE_BINARY_DIR}) |
| 177 | |
Tomáš Pecka | 625b7a1 | 2021-01-23 20:55:51 +0100 | [diff] [blame] | 178 | add_executable(veliad-system |
| 179 | src/main-system.cpp |
| 180 | ) |
| 181 | target_link_libraries(veliad-system |
| 182 | PUBLIC |
| 183 | velia-system |
| 184 | docopt |
| 185 | ) |
| 186 | add_dependencies(veliad-system target-VELIA_VERSION) |
| 187 | target_include_directories(veliad-system PUBLIC ${CMAKE_BINARY_DIR}) |
| 188 | |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 189 | add_executable(veliad-firewall |
| 190 | src/main-firewall.cpp |
| 191 | ) |
| 192 | target_link_libraries(veliad-firewall |
| 193 | PUBLIC |
| 194 | velia-firewall |
| 195 | velia-utils |
| 196 | Boost::filesystem |
| 197 | docopt |
| 198 | ) |
| 199 | add_dependencies(veliad-firewall target-VELIA_VERSION) |
| 200 | target_include_directories(veliad-firewall PUBLIC ${CMAKE_BINARY_DIR}) |
| 201 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 202 | # Testing |
Tomáš Pecka | a06d74d | 2020-06-14 18:18:13 +0200 | [diff] [blame] | 203 | include(CTest) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 204 | if(BUILD_TESTING) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 205 | find_package(trompeloeil 33 REQUIRED) |
| 206 | find_package(doctest 2.3.1 REQUIRED) |
| 207 | |
Tomáš Pecka | efd8843 | 2020-06-17 15:31:39 +0200 | [diff] [blame] | 208 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/configure.cmake.h.in ${CMAKE_CURRENT_BINARY_DIR}/tests/configure.cmake.h) |
| 209 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 210 | add_library(DoctestIntegration STATIC |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 211 | tests/doctest_integration.cpp |
| 212 | tests/trompeloeil_doctest.h |
| 213 | tests/wait-a-bit-longer.cpp |
| 214 | ) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 215 | target_link_libraries(DoctestIntegration doctest::doctest trompeloeil spdlog::spdlog) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 216 | target_include_directories(DoctestIntegration PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 217 | target_compile_definitions(DoctestIntegration PUBLIC DOCTEST_CONFIG_SUPER_FAST_ASSERTS) |
| 218 | |
Tomáš Pecka | a18702d | 2021-01-25 18:07:23 +0100 | [diff] [blame] | 219 | add_library(SysrepoTesting STATIC |
| 220 | tests/mock/sysrepo/events.cpp |
| 221 | tests/mock/sysrepo/events.h |
| 222 | ) |
| 223 | target_link_libraries(SysrepoTesting DoctestIntegration PkgConfig::SYSREPO) |
| 224 | |
Tomáš Pecka | 0a2e890 | 2020-06-09 21:11:20 +0200 | [diff] [blame] | 225 | add_library(DbusTesting STATIC |
Tomáš Pecka | 991e4d5 | 2021-01-11 10:03:14 +0100 | [diff] [blame] | 226 | tests/dbus-helpers/dbus_rauc_server.cpp |
| 227 | tests/dbus-helpers/dbus_rauc_server.h |
Tomáš Pecka | 0a2e890 | 2020-06-09 21:11:20 +0200 | [diff] [blame] | 228 | tests/dbus-helpers/dbus_semaphore_server.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 229 | tests/dbus-helpers/dbus_semaphore_server.h |
Tomáš Pecka | ccd80c3 | 2020-06-22 14:44:32 +0200 | [diff] [blame] | 230 | tests/dbus-helpers/dbus_systemd_server.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 231 | tests/dbus-helpers/dbus_systemd_server.h |
| 232 | ) |
| 233 | target_link_libraries(DbusTesting |
| 234 | PUBLIC |
| 235 | velia-utils |
| 236 | SDBusCpp::sdbus-c++ |
| 237 | ) |
Tomáš Pecka | 0a2e890 | 2020-06-09 21:11:20 +0200 | [diff] [blame] | 238 | |
Tomáš Pecka | 9b1c967 | 2020-11-11 15:24:06 +0100 | [diff] [blame] | 239 | add_library(FsTestUtils STATIC |
| 240 | tests/fs-helpers/FileInjector.cpp |
| 241 | tests/fs-helpers/FileInjector.h |
| 242 | tests/fs-helpers/utils.cpp |
| 243 | tests/fs-helpers/utils.h |
| 244 | ) |
| 245 | target_link_libraries(FsTestUtils |
| 246 | PUBLIC |
| 247 | ${STD_FILESYSTEM_LIBRARY} |
| 248 | ) |
| 249 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 250 | function(velia_test name) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 251 | add_executable(test-${name} ${CMAKE_SOURCE_DIR}/tests/${name}.cpp) |
| 252 | target_link_libraries(test-${name} DoctestIntegration ${ARGN}) |
| 253 | target_include_directories(test-${name} |
| 254 | PUBLIC |
| 255 | ${CMAKE_CURRENT_SOURCE_DIR} |
| 256 | PRIVATE |
| 257 | ${CMAKE_BINARY_DIR} |
| 258 | ) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 259 | |
| 260 | if(NOT CMAKE_CROSSCOMPILING) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 261 | add_test(test-${name} test-${name}) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 262 | endif() |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 263 | endfunction() |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 264 | |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 265 | find_program(SYSREPOCTL sysrepoctl) |
| 266 | find_program(SYSREPOCFG sysrepocfg) |
| 267 | |
| 268 | set(sysrepo_previous_fixture_name UNDEFINED) |
| 269 | function(sysrepo_fixture_env name) |
| 270 | set(test_name_init sysrepo:prep:${name}) |
| 271 | set(test_name_cleanup sysrepo:clean:${name}) |
| 272 | set(fixture_name sysrepo:env:${name}) |
| 273 | |
| 274 | add_test(NAME ${test_name_init} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepoctl-manage-module.sh ${SYSREPOCTL} ${SYSREPOCFG} prepare ${ARGN}) |
| 275 | set_tests_properties(${test_name_init} PROPERTIES FIXTURES_SETUP ${fixture_name} RESOURCE_LOCK sysrepo) |
| 276 | add_test(NAME ${test_name_cleanup} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepoctl-manage-module.sh ${SYSREPOCTL} ${SYSREPOCFG} uninstall ${ARGN}) |
| 277 | set_tests_properties(${test_name_cleanup} PROPERTIES FIXTURES_CLEANUP ${fixture_name} RESOURCE_LOCK sysrepo) |
| 278 | |
| 279 | if (sysrepo_previous_fixture_name) |
| 280 | set_tests_properties(${test_name_init} PROPERTIES DEPENDS sysrepo:clean:${sysrepo_previous_fixture_name}) |
| 281 | endif () |
| 282 | |
| 283 | set(sysrepo_previous_fixture_name ${name} PARENT_SCOPE) |
| 284 | endfunction() |
| 285 | |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 286 | velia_test(health_state-manager velia-health) |
| 287 | velia_test(health_input-semaphore velia-health DbusTesting) |
| 288 | velia_test(health_input-systemd velia-health DbusTesting) |
| 289 | velia_test(health_output-led velia-health) |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 290 | |
Tomáš Pecka | 991e4d5 | 2021-01-11 10:03:14 +0100 | [diff] [blame] | 291 | velia_test(system_rauc velia-system DbusTesting) |
Tomáš Pecka | cb7a5f8 | 2021-01-20 15:12:00 +0100 | [diff] [blame] | 292 | set_tests_properties( |
| 293 | test-system_rauc |
| 294 | PROPERTIES RESOURCE_LOCK dbus-rauc |
| 295 | ) |
Tomáš Pecka | 991e4d5 | 2021-01-11 10:03:14 +0100 | [diff] [blame] | 296 | |
Tomáš Pecka | 9b1c967 | 2020-11-11 15:24:06 +0100 | [diff] [blame] | 297 | velia_test(hardware_emmc velia-ietf-hardware FsTestUtils) |
| 298 | velia_test(hardware_hwmon velia-ietf-hardware FsTestUtils) |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 299 | |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 300 | sysrepo_fixture_env(sysrepo-ietf-system YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-system@2014-08-06.yang) |
Tomáš Pecka | f976c5b | 2021-01-23 21:19:52 +0100 | [diff] [blame] | 301 | velia_test(sysrepo_system-ietfsystem velia-system DbusTesting) |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 302 | set_tests_properties( |
Tomáš Pecka | f976c5b | 2021-01-23 21:19:52 +0100 | [diff] [blame] | 303 | test-sysrepo_system-ietfsystem |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 304 | PROPERTIES FIXTURES_REQUIRED sysrepo:env:sysrepo-ietf-system |
| 305 | RESOURCE_LOCK sysrepo |
Tomáš Pecka | cb7a5f8 | 2021-01-20 15:12:00 +0100 | [diff] [blame] | 306 | ) |
| 307 | |
| 308 | sysrepo_fixture_env(sysrepo-czechlight-system YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/czechlight-system@2021-01-13.yang) |
| 309 | velia_test(sysrepo_system-czechlightsystem velia-system DbusTesting) |
Tomáš Pecka | 9a6e15b | 2021-01-25 18:57:48 +0100 | [diff] [blame] | 310 | target_link_libraries(test-sysrepo_system-czechlightsystem SysrepoTesting) |
Tomáš Pecka | cb7a5f8 | 2021-01-20 15:12:00 +0100 | [diff] [blame] | 311 | set_tests_properties( |
| 312 | test-sysrepo_system-czechlightsystem |
| 313 | PROPERTIES FIXTURES_REQUIRED sysrepo:env:sysrepo-czechlight-system |
| 314 | RESOURCE_LOCK "sysrepo;dbus-rauc" |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 315 | ) |
| 316 | |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 317 | sysrepo_fixture_env(sysrepo-ietf-hardware YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/iana-hardware@2018-03-13.yang YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-hardware@2018-03-13.yang FEATURE hardware-sensor) |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 318 | velia_test(hardware_ietf-hardware velia-ietf-hardware velia-ietf-hardware-sysrepo) |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 319 | set_tests_properties( |
| 320 | test-hardware_ietf-hardware |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 321 | PROPERTIES FIXTURES_REQUIRED sysrepo:env:sysrepo-ietf-hardware |
Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 322 | RESOURCE_LOCK sysrepo |
| 323 | ) |
| 324 | |
| 325 | velia_test(sysrepo_two-daemons velia-ietf-hardware-sysrepo) |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 326 | # ctest dance for sysrepo_two-daemons: compile daemon, create a fixture for test, add the test into the fixture |
Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 327 | add_executable(test-sysrepo_test_merge-daemon ${CMAKE_SOURCE_DIR}/tests/sysrepo_two-daemons_daemon.cpp) |
| 328 | target_link_libraries(test-sysrepo_test_merge-daemon PkgConfig::SYSREPO PkgConfig::LIBYANG) |
| 329 | |
| 330 | add_test(NAME sysrepo_test_merge-start COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepo_two-daemons_control.sh start) |
| 331 | add_test(NAME sysrepo_test_merge-stop COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepo_two-daemons_control.sh stop) |
| 332 | set_tests_properties(sysrepo_test_merge-start PROPERTIES FIXTURES_SETUP sysrepo:two-daemons RESOURCE_LOCK sysrepo) |
| 333 | set_tests_properties(sysrepo_test_merge-stop PROPERTIES FIXTURES_CLEANUP sysrepo:two-daemons RESOURCE_LOCK sysrepo) |
Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 334 | |
| 335 | set_tests_properties( |
| 336 | test-sysrepo_two-daemons |
| 337 | PROPERTIES |
| 338 | FIXTURES_REQUIRED "sysrepo:two-daemons;sysrepo:env:sysrepo-ietf-hardware" |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 339 | RESOURCE_LOCK sysrepo |
| 340 | ) |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 341 | # ensure we run two-daemons merge test and ietf-hardware test sequentially and don't cleanup before everything ends |
| 342 | set_tests_properties(sysrepo_test_merge-start PROPERTIES DEPENDS test-hardware_ietf-hardware) |
| 343 | set_tests_properties(sysrepo:clean:sysrepo-ietf-hardware PROPERTIES DEPENDS sysrepo_test_merge-stop) |
| 344 | |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 345 | |
| 346 | find_program(YANGLINT_PATH yanglint) |
| 347 | if (NOT YANGLINT_PATH) |
| 348 | message(FATAL_ERROR "Cannot find libyang's yanglint") |
| 349 | endif() |
| 350 | foreach(yang_file ${YANG_SRCS}) |
| 351 | add_test(NAME yang-tree:${yang_file} COMMAND ${YANGLINT_PATH} -f tree ${CMAKE_CURRENT_SOURCE_DIR}/${yang_file}) |
| 352 | endforeach() |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 353 | |
| 354 | sysrepo_fixture_env(sysrepo-firewall |
| 355 | # Installing czechlight-firewall automatically installs ietf-access-control-list as implemented (not just |
| 356 | # imported) but I still need to install it myself to enable the features. |
| 357 | YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-access-control-list@2019-03-04.yang |
| 358 | FEATURE eth |
| 359 | FEATURE match-on-eth |
| 360 | FEATURE match-on-ipv4 |
| 361 | FEATURE ipv4 |
| 362 | FEATURE match-on-ipv6 |
| 363 | FEATURE ipv6 |
| 364 | FEATURE mixed-eth-ipv4-ipv6 |
| 365 | YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/czechlight-firewall@2021-01-25.yang |
| 366 | ) |
| 367 | |
| 368 | velia_test(sysrepo-firewall velia-firewall) |
| 369 | set_tests_properties( |
| 370 | test-sysrepo-firewall |
| 371 | PROPERTIES FIXTURES_REQUIRED sysrepo:env:sysrepo-firewall |
| 372 | RESOURCE_LOCK sysrepo |
| 373 | ) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 374 | endif() |
Tomáš Pecka | c927d66 | 2020-07-13 11:16:16 +0200 | [diff] [blame] | 375 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 376 | if(WITH_DOCS) |
| 377 | set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) |
| 378 | set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) |
| 379 | configure_file(${doxyfile_in} ${doxyfile} @ONLY) |
| 380 | add_custom_target(doc |
| 381 | COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} |
| 382 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 383 | COMMENT "Generating API documentation with Doxygen" |
| 384 | VERBATIM |
| 385 | SOURCES ${doxyfile_in} |
| 386 | ) |
Tomáš Pecka | a06d74d | 2020-06-14 18:18:13 +0200 | [diff] [blame] | 387 | endif() |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 388 | |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 389 | set(YANG_DIR ${CMAKE_INSTALL_PREFIX}/share/velia/yang) |
| 390 | install(FILES ${YANG_SRCS} DESTINATION ${YANG_DIR}) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 391 | install(TARGETS veliad RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/) |
Tomáš Pecka | 625b7a1 | 2021-01-23 20:55:51 +0100 | [diff] [blame] | 392 | install(TARGETS veliad-system RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/) |