Tomáš Pecka | 9fa5f6a | 2021-04-13 11:36:11 +0200 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.19) |
Tomáš Pecka | 698fabc | 2023-04-07 10:14:07 +0200 | [diff] [blame] | 2 | project(velia LANGUAGES CXX) |
Tomáš Pecka | 9fa5f6a | 2021-04-13 11:36:11 +0200 | [diff] [blame] | 3 | cmake_policy(SET CMP0109 NEW) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 4 | |
| 5 | # Build options |
Václav Kubernát | b332d98 | 2021-04-16 01:40:11 +0200 | [diff] [blame] | 6 | set(CMAKE_CXX_STANDARD 20) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 7 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 8 | |
| 9 | set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}") |
Václav Kubernát | d4b8a69 | 2021-04-16 01:21:44 +0200 | [diff] [blame] | 10 | set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Woverloaded-virtual -Wimplicit-fallthrough ${CMAKE_CXX_FLAGS}") |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 11 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
| 12 | set(CMAKE_CXX_FLAGS "-Wsuggest-override ${CMAKE_CXX_FLAGS}") |
| 13 | endif() |
| 14 | |
Tomáš Pecka | 5d4cf2a | 2020-07-13 13:19:41 +0200 | [diff] [blame] | 15 | if(CMAKE_CXX_FLAGS MATCHES "-stdlib=libc\\+\\+" AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) |
| 16 | set(STD_FILESYSTEM_LIBRARY c++fs) |
| 17 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.1) |
| 18 | set(STD_FILESYSTEM_LIBRARY stdc++fs) |
| 19 | endif() |
| 20 | |
| 21 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 22 | add_custom_target(velia-version-cmake-ide |
| 23 | cmake/ProjectGitVersion.cmake |
| 24 | cmake/ProjectGitVersionRunner.cmake |
| 25 | ) |
| 26 | include(cmake/ProjectGitVersion.cmake) |
Jan Kundrát | e44fe29 | 2024-09-17 17:05:18 +0200 | [diff] [blame] | 27 | prepare_git_version(VELIA_VERSION "1") |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 28 | |
| 29 | find_package(Doxygen) |
| 30 | option(WITH_DOCS "Create and install internal documentation (needs Doxygen)" ${DOXYGEN_FOUND}) |
| 31 | |
Tomáš Pecka | 72f540e | 2024-07-08 13:45:22 +0200 | [diff] [blame] | 32 | find_package(date REQUIRED) # FIXME: Remove when we have STL with __cpp_lib_chrono >= 201907 (gcc 14) |
Václav Kubernát | de0e4e6 | 2021-02-08 17:46:14 +0100 | [diff] [blame] | 33 | find_package(Boost REQUIRED) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 34 | find_package(spdlog REQUIRED) |
Tomáš Pecka | 6a266d8 | 2021-11-19 11:35:39 +0100 | [diff] [blame] | 35 | find_package(sdbus-c++ "1.0.0" REQUIRED) |
Tomáš Pecka | a433681 | 2020-07-24 15:32:58 +0200 | [diff] [blame] | 36 | find_package(PkgConfig) |
Jan Kundrát | 242e6e1 | 2024-10-15 17:16:00 +0200 | [diff] [blame] | 37 | find_package(fmt "9.0.0" REQUIRED) |
Jan Kundrát | fee3bea | 2022-02-15 20:36:08 +0100 | [diff] [blame] | 38 | find_package(nlohmann_json REQUIRED) |
Jan Kundrát | 9e8752a | 2023-02-02 20:55:39 +0100 | [diff] [blame] | 39 | pkg_check_modules(DOCOPT REQUIRED IMPORTED_TARGET docopt) |
Tomáš Pecka | a433681 | 2020-07-24 15:32:58 +0200 | [diff] [blame] | 40 | |
| 41 | pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd) |
Tomáš Pecka | 1f42cfe | 2020-10-21 18:38:27 +0200 | [diff] [blame] | 42 | if(${SYSTEMD_VERSION} VERSION_EQUAL 245) |
| 43 | 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.") |
| 44 | endif() |
Tomáš Pecka | 070f60d | 2021-10-13 21:48:14 +0200 | [diff] [blame] | 45 | #TODO: Check patch 20333 active |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 46 | |
Jan Kundrát | 7935e81 | 2024-09-17 17:02:01 +0200 | [diff] [blame] | 47 | pkg_check_modules(SYSREPO REQUIRED IMPORTED_TARGET sysrepo sysrepo-cpp>=3) |
| 48 | pkg_check_modules(LIBYANG REQUIRED IMPORTED_TARGET libyang libyang-cpp>=3) |
Tomáš Pecka | 2d578c8 | 2021-02-23 19:01:35 +0100 | [diff] [blame] | 49 | pkg_check_modules(LIBNL REQUIRED IMPORTED_TARGET libnl-route-3.0) |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 50 | |
Tomáš Pecka | c927d66 | 2020-07-13 11:16:16 +0200 | [diff] [blame] | 51 | include(GNUInstallDirs) |
| 52 | |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 53 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/) |
| 54 | |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 55 | set(YANG_SRCS |
Jan Kundrát | 7a30cf4 | 2022-07-12 22:24:09 +0200 | [diff] [blame] | 56 | yang/czechlight-system@2022-07-08.yang |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 57 | yang/iana-hardware@2018-03-13.yang |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 58 | yang/ietf-hardware@2018-03-13.yang |
Tomáš Pecka | f98ce03 | 2021-01-14 13:35:00 +0100 | [diff] [blame] | 59 | yang/iana-crypt-hash@2014-08-06.yang |
| 60 | yang/ietf-inet-types@2013-07-15.yang |
| 61 | yang/ietf-netconf-acm@2018-02-14.yang |
| 62 | yang/ietf-system@2014-08-06.yang |
| 63 | yang/ietf-yang-types@2013-07-15.yang |
Tomáš Pecka | 435ca2a | 2021-01-27 10:53:48 +0100 | [diff] [blame] | 64 | yang/ietf-ethertypes@2019-03-04.yang |
| 65 | yang/ietf-interfaces@2018-02-20.yang |
| 66 | yang/ietf-packet-fields@2019-03-04.yang |
Václav Kubernát | 637fe80 | 2021-01-22 02:43:18 +0100 | [diff] [blame] | 67 | yang/ietf-access-control-list@2019-03-04.yang |
Václav Kubernát | 457d1ad | 2021-01-22 02:43:18 +0100 | [diff] [blame] | 68 | yang/czechlight-firewall@2021-01-25.yang |
Tomáš Pecka | dac27d4 | 2021-02-22 13:20:05 +0100 | [diff] [blame] | 69 | yang/czechlight-network@2021-02-22.yang |
| 70 | yang/iana-if-type@2017-01-19.yang |
| 71 | yang/ietf-ip@2018-02-22.yang |
Tomáš Pecka | 2a4ea7b | 2021-03-30 17:01:37 +0200 | [diff] [blame] | 72 | yang/ietf-routing@2018-03-13.yang |
| 73 | yang/ietf-ipv4-unicast-routing@2018-03-13.yang |
| 74 | yang/ietf-ipv6-unicast-routing@2018-03-13.yang |
Tomáš Pecka | 7acf392 | 2021-08-10 11:16:57 +0200 | [diff] [blame] | 75 | yang/czechlight-lldp@2020-11-04.yang |
| 76 | yang/iana-afn-safi@2013-07-04.yang |
Tomáš Pecka | 6a2334b | 2022-07-12 13:57:54 +0200 | [diff] [blame] | 77 | yang/ietf-alarms@2019-09-11.yang |
| 78 | yang/velia-alarms@2022-07-12.yang |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 79 | ) |
| 80 | |
Jan Kundrát | 086de99 | 2024-08-31 08:49:55 +0200 | [diff] [blame] | 81 | set(YANG_SUBMODULES |
| 82 | yang/ietf-ipv6-router-advertisements@2018-03-13.yang |
| 83 | ) |
| 84 | |
Tomáš Pecka | 59a148f | 2023-01-16 19:14:15 +0100 | [diff] [blame] | 85 | # temporary until our CI switches to fmt>=9 |
| 86 | add_compile_definitions(FMT_DEPRECATED_OSTREAM) |
| 87 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 88 | # Targets |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 89 | # - utils |
Tomáš Pecka | bd82886 | 2020-06-15 15:53:35 +0200 | [diff] [blame] | 90 | add_library(velia-utils STATIC |
Tomáš Pecka | ad3247f | 2023-05-11 15:56:26 +0200 | [diff] [blame] | 91 | src/utils/alarms.cpp |
| 92 | src/utils/alarms.h |
Jan Kundrát | b98b4f9 | 2024-10-17 17:39:24 +0200 | [diff] [blame] | 93 | src/utils/benchmark.cpp |
| 94 | src/utils/benchmark.h |
Tomáš Pecka | a193c03 | 2020-06-22 17:33:31 +0200 | [diff] [blame] | 95 | src/utils/exceptions.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 96 | src/utils/exceptions.h |
Václav Kubernát | 6d9357e | 2021-01-28 15:38:24 +0100 | [diff] [blame] | 97 | src/utils/exec.cpp |
| 98 | src/utils/exec.h |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 99 | src/utils/io.cpp |
| 100 | src/utils/io.h |
Tomáš Pecka | a433681 | 2020-07-24 15:32:58 +0200 | [diff] [blame] | 101 | src/utils/journal.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 102 | src/utils/journal.h |
Václav Kubernát | cbdc98a | 2021-01-28 13:24:37 +0100 | [diff] [blame] | 103 | src/utils/libyang.cpp |
| 104 | src/utils/libyang.h |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 105 | src/utils/log.h |
Václav Kubernát | 6018f08 | 2021-02-11 01:32:18 +0100 | [diff] [blame] | 106 | src/utils/log.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 107 | src/utils/log-fwd.h |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 108 | src/utils/log-init.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 109 | src/utils/log-init.h |
Tomáš Pecka | ba2dc31 | 2021-01-23 22:29:11 +0100 | [diff] [blame] | 110 | src/utils/sysrepo.cpp |
| 111 | src/utils/sysrepo.h |
Tomáš Pecka | d033707 | 2021-01-25 19:57:00 +0100 | [diff] [blame] | 112 | src/utils/waitUntilSignalled.cpp |
| 113 | src/utils/waitUntilSignalled.h |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 114 | ) |
Tomáš Pecka | 1eb1f35 | 2023-04-14 10:39:56 +0200 | [diff] [blame] | 115 | target_link_libraries(velia-utils PUBLIC spdlog::spdlog PRIVATE PkgConfig::SYSTEMD PkgConfig::LIBYANG PkgConfig::SYSREPO fmt::fmt PkgConfig::DOCOPT) |
Tomáš Pecka | a433681 | 2020-07-24 15:32:58 +0200 | [diff] [blame] | 116 | |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 117 | # - health |
| 118 | add_library(velia-health STATIC |
Tomáš Pecka | e1f0abd | 2022-07-13 19:31:13 +0200 | [diff] [blame] | 119 | src/health/outputs/AlarmsOutputs.cpp |
| 120 | src/health/outputs/AlarmsOutputs.h |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 121 | src/health/outputs/LedSysfsDriver.cpp |
| 122 | src/health/outputs/callables.cpp |
| 123 | src/health/State.cpp |
Tomáš Pecka | 1d2b95c | 2023-05-11 16:01:46 +0200 | [diff] [blame] | 124 | src/health/SystemdUnits.cpp |
| 125 | src/health/SystemdUnits.h |
Tomáš Pecka | 74b885f | 2020-06-06 20:02:41 +0200 | [diff] [blame] | 126 | ) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 127 | target_link_libraries(velia-health |
| 128 | PUBLIC |
| 129 | velia-utils |
| 130 | Boost::boost |
| 131 | SDBusCpp::sdbus-c++ |
| 132 | ${STD_FILESYSTEM_LIBRARY} |
Tomáš Pecka | 6a2334b | 2022-07-12 13:57:54 +0200 | [diff] [blame] | 133 | PRIVATE |
| 134 | PkgConfig::LIBYANG |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 135 | ) |
Tomáš Pecka | 74b885f | 2020-06-06 20:02:41 +0200 | [diff] [blame] | 136 | |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 137 | # - ietf-hardware |
| 138 | add_library(velia-ietf-hardware STATIC |
| 139 | src/ietf-hardware/sysfs/EMMC.cpp |
| 140 | src/ietf-hardware/sysfs/EMMC.h |
Tomáš Pecka | 9b1c967 | 2020-11-11 15:24:06 +0100 | [diff] [blame] | 141 | src/ietf-hardware/sysfs/HWMon.cpp |
| 142 | src/ietf-hardware/sysfs/HWMon.h |
Tomáš Pecka | fd09bbf | 2024-10-15 13:50:37 +0200 | [diff] [blame] | 143 | src/ietf-hardware/sysfs/IpmiFruEEPROM.cpp |
| 144 | src/ietf-hardware/sysfs/IpmiFruEEPROM.h |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 145 | src/ietf-hardware/IETFHardware.cpp |
| 146 | src/ietf-hardware/IETFHardware.h |
Tomáš Pecka | 45b67f9 | 2024-01-11 14:13:05 +0100 | [diff] [blame] | 147 | src/ietf-hardware/FspYh.cpp |
| 148 | src/ietf-hardware/FspYh.h |
Tomáš Pecka | 50584c5 | 2023-04-19 10:17:01 +0200 | [diff] [blame] | 149 | src/ietf-hardware/thresholds.h |
Tomáš Pecka | dad552b8 | 2023-05-04 20:18:18 +0200 | [diff] [blame] | 150 | src/ietf-hardware/thresholds.cpp |
Tomáš Pecka | 50584c5 | 2023-04-19 10:17:01 +0200 | [diff] [blame] | 151 | src/ietf-hardware/thresholds_fwd.h |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 152 | ) |
| 153 | target_link_libraries(velia-ietf-hardware |
| 154 | PUBLIC |
| 155 | velia-utils |
| 156 | ${STD_FILESYSTEM_LIBRARY} |
Tomáš Pecka | 9b1c967 | 2020-11-11 15:24:06 +0100 | [diff] [blame] | 157 | Boost::boost |
Tomáš Pecka | 72f540e | 2024-07-08 13:45:22 +0200 | [diff] [blame] | 158 | PRIVATE |
| 159 | PkgConfig::LIBYANG |
| 160 | date::date |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 161 | ) |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 162 | |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 163 | add_library(velia-ietf-hardware-sysrepo STATIC |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 164 | src/ietf-hardware/sysrepo/Sysrepo.cpp |
| 165 | src/ietf-hardware/sysrepo/Sysrepo.h |
| 166 | ) |
| 167 | target_link_libraries(velia-ietf-hardware-sysrepo |
| 168 | PUBLIC |
| 169 | velia-utils |
| 170 | PkgConfig::SYSREPO |
| 171 | PkgConfig::LIBYANG |
| 172 | ) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 173 | |
Václav Kubernát | 6d9357e | 2021-01-28 15:38:24 +0100 | [diff] [blame] | 174 | set(NOBODY_UID 65534 CACHE STRING "UID which refers to 'nobody'. Used for dropping root privileges.") |
| 175 | set(NOBODY_GID 65534 CACHE STRING "GID which refers to 'nobody'. Used for dropping root privileges.") |
| 176 | |
Václav Kubernát | de0e4e6 | 2021-02-08 17:46:14 +0100 | [diff] [blame] | 177 | if(NOT NFT_EXECUTABLE) |
| 178 | find_program(NFT_EXECUTABLE nft) |
| 179 | endif() |
Václav Kubernát | babbab9 | 2021-01-27 09:25:05 +0100 | [diff] [blame] | 180 | if(NOT SSH_KEYGEN_EXECUTABLE) |
| 181 | find_program(SSH_KEYGEN_EXECUTABLE ssh-keygen) |
| 182 | endif() |
| 183 | if(NOT CHPASSWD_EXECUTABLE) |
| 184 | find_program(CHPASSWD_EXECUTABLE chpasswd) |
| 185 | endif() |
Tomáš Pecka | 879a603 | 2021-02-03 17:21:48 +0100 | [diff] [blame] | 186 | if(NOT SYSTEMCTL_EXECUTABLE) |
| 187 | find_program(SYSTEMCTL_EXECUTABLE systemctl) |
| 188 | endif() |
Tomáš Pecka | 5c19e72 | 2021-02-15 20:41:29 +0100 | [diff] [blame] | 189 | if(NOT NETWORKCTL_EXECUTABLE) |
| 190 | find_program(NETWORKCTL_EXECUTABLE networkctl) |
| 191 | endif() |
Václav Kubernát | 566c940 | 2021-02-10 08:33:54 +0100 | [diff] [blame] | 192 | if(NOT HOSTNAMECTL_EXECUTABLE) |
| 193 | find_program(HOSTNAMECTL_EXECUTABLE hostnamectl) |
| 194 | endif() |
Václav Kubernát | babbab9 | 2021-01-27 09:25:05 +0100 | [diff] [blame] | 195 | |
| 196 | set(VELIA_AUTHORIZED_KEYS_FORMAT "{HOME}/.ssh/authorized_keys" CACHE STRING "pattern for determining path to users' SSH authorized_keys file. Must at least one of '{USER}' or '{HOME}' which will get replaced by the name of the user and the home directory of the user respectively.") |
| 197 | if(NOT VELIA_AUTHORIZED_KEYS_FORMAT) |
| 198 | message(FATAL_ERROR "VELIA_AUTHORIZED_KEYS_FORMAT not set.") |
| 199 | endif() |
| 200 | |
| 201 | if(NOT VELIA_AUTHORIZED_KEYS_FORMAT MATCHES "{USER}" AND NOT VELIA_AUTHORIZED_KEYS_FORMAT MATCHES "{HOME}") |
| 202 | message(FATAL_ERROR "Wrong format string given for VELIA_AUTHORIZED_KEYS_FORMAT: at least one of {USER} or {HOME} expected.") |
| 203 | endif() |
| 204 | |
| 205 | set(VELIA_REAL_ETC_PASSWD "/etc/passwd" CACHE STRING "Path to passwd file") |
| 206 | if(NOT VELIA_REAL_ETC_PASSWD) |
| 207 | message(FATAL_ERROR "VELIA_REAL_ETC_PASSWD not set") |
| 208 | endif() |
| 209 | |
| 210 | set(VELIA_REAL_ETC_SHADOW "/etc/shadow" CACHE STRING "Path to shadow file") |
| 211 | if(NOT VELIA_REAL_ETC_SHADOW) |
| 212 | message(FATAL_ERROR "VELIA_REAL_ETC_SHADOW not set") |
| 213 | endif() |
| 214 | |
| 215 | set(VELIA_BACKUP_ETC_SHADOW "/etc/shadow" CACHE STRING "Path to where /etc/shadow gets copied to upon each change") |
| 216 | if(NOT VELIA_BACKUP_ETC_SHADOW) |
| 217 | message(FATAL_ERROR "VELIA_BACKUP_ETC_SHADOW not set") |
| 218 | endif() |
Václav Kubernát | de0e4e6 | 2021-02-08 17:46:14 +0100 | [diff] [blame] | 219 | |
Václav Kubernát | 566c940 | 2021-02-10 08:33:54 +0100 | [diff] [blame] | 220 | set(VELIA_BACKUP_ETC_HOSTNAME "/etc/hostname" CACHE STRING "Path to hostname file") |
| 221 | if(NOT VELIA_BACKUP_ETC_HOSTNAME ) |
| 222 | message(FATAL_ERROR "VELIA_BACKUP_ETC_HOSTNAME not set") |
| 223 | endif() |
| 224 | |
Václav Kubernát | 6d9357e | 2021-01-28 15:38:24 +0100 | [diff] [blame] | 225 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/system/system_vars.h.in ${CMAKE_CURRENT_BINARY_DIR}/system_vars.h @ONLY) |
| 226 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
| 227 | |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 228 | # - ietf-system |
| 229 | add_library(velia-system STATIC |
Tomáš Pecka | 991e4d5 | 2021-01-11 10:03:14 +0100 | [diff] [blame] | 230 | src/system/RAUC.cpp |
| 231 | src/system/RAUC.h |
Tomáš Pecka | 594a676 | 2021-01-29 11:06:08 +0100 | [diff] [blame] | 232 | src/system/Firmware.cpp |
| 233 | src/system/Firmware.h |
Tomáš Pecka | f976c5b | 2021-01-23 21:19:52 +0100 | [diff] [blame] | 234 | src/system/IETFSystem.cpp |
| 235 | src/system/IETFSystem.h |
Václav Kubernát | babbab9 | 2021-01-27 09:25:05 +0100 | [diff] [blame] | 236 | src/system/Authentication.cpp |
| 237 | src/system/Authentication.h |
Tomáš Pecka | 2d578c8 | 2021-02-23 19:01:35 +0100 | [diff] [blame] | 238 | src/system/Rtnetlink.cpp |
| 239 | src/system/Rtnetlink.h |
Tomáš Pecka | f10b930 | 2021-02-23 19:02:02 +0100 | [diff] [blame] | 240 | src/system/IETFInterfaces.cpp |
| 241 | src/system/IETFInterfaces.h |
Tomáš Pecka | 39bbb51 | 2021-05-23 22:07:22 +0200 | [diff] [blame] | 242 | src/system/IETFInterfacesConfig.cpp |
| 243 | src/system/IETFInterfacesConfig.h |
Tomáš Pecka | e566fd4 | 2024-01-02 17:00:10 +0100 | [diff] [blame] | 244 | src/system/JournalUpload.cpp |
| 245 | src/system/JournalUpload.h |
Tomáš Pecka | af7b704 | 2021-04-20 20:14:13 +0200 | [diff] [blame] | 246 | src/system/LED.cpp |
| 247 | src/system/LED.h |
Tomáš Pecka | 7acf392 | 2021-08-10 11:16:57 +0200 | [diff] [blame] | 248 | src/system/LLDP.cpp |
| 249 | src/system/LLDP.h |
| 250 | src/system/LLDPCallback.cpp |
| 251 | src/system/LLDPCallback.h |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 252 | ) |
| 253 | target_link_libraries(velia-system |
| 254 | PUBLIC |
| 255 | velia-utils |
| 256 | PkgConfig::SYSREPO |
| 257 | PkgConfig::LIBYANG |
Tomáš Pecka | 2d578c8 | 2021-02-23 19:01:35 +0100 | [diff] [blame] | 258 | PkgConfig::LIBNL |
Václav Kubernát | 6dd52c8 | 2021-01-21 08:38:42 +0100 | [diff] [blame] | 259 | SDBusCpp::sdbus-c++ |
Jan Kundrát | fee3bea | 2022-02-15 20:36:08 +0100 | [diff] [blame] | 260 | nlohmann_json::nlohmann_json |
Tomáš Pecka | 72f540e | 2024-07-08 13:45:22 +0200 | [diff] [blame] | 261 | PRIVATE |
| 262 | date::date-tz |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 263 | ) |
| 264 | |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 265 | # - firewall |
| 266 | add_library(velia-firewall STATIC |
| 267 | src/firewall/Firewall.cpp |
| 268 | ) |
| 269 | target_link_libraries(velia-firewall |
| 270 | PUBLIC |
| 271 | velia-utils |
| 272 | PkgConfig::SYSREPO |
| 273 | PRIVATE |
| 274 | PkgConfig::LIBYANG |
| 275 | ) |
| 276 | |
| 277 | |
Tomáš Pecka | 625b7a1 | 2021-01-23 20:55:51 +0100 | [diff] [blame] | 278 | # - daemons |
Tomáš Pecka | cd19e62 | 2021-01-27 09:18:11 +0100 | [diff] [blame] | 279 | add_executable(veliad-health |
| 280 | src/main-health.cpp |
Tomáš Pecka | 139e361 | 2021-01-25 19:49:00 +0100 | [diff] [blame] | 281 | src/health/Factory.cpp |
| 282 | src/health/Factory.h |
| 283 | ) |
Tomáš Pecka | cd19e62 | 2021-01-27 09:18:11 +0100 | [diff] [blame] | 284 | target_link_libraries(veliad-health |
Tomáš Pecka | aae9fe3 | 2021-01-25 19:57:22 +0100 | [diff] [blame] | 285 | PUBLIC |
Tomáš Pecka | d03044f | 2020-11-12 14:33:10 +0100 | [diff] [blame] | 286 | velia-health |
Jan Kundrát | 9e8752a | 2023-02-02 20:55:39 +0100 | [diff] [blame] | 287 | PkgConfig::DOCOPT |
Tomáš Pecka | aae9fe3 | 2021-01-25 19:57:22 +0100 | [diff] [blame] | 288 | ) |
Tomáš Pecka | cd19e62 | 2021-01-27 09:18:11 +0100 | [diff] [blame] | 289 | add_dependencies(veliad-health target-VELIA_VERSION) |
| 290 | target_include_directories(veliad-health PUBLIC ${CMAKE_BINARY_DIR}) |
Tomáš Pecka | d03044f | 2020-11-12 14:33:10 +0100 | [diff] [blame] | 291 | |
Tomáš Pecka | 625b7a1 | 2021-01-23 20:55:51 +0100 | [diff] [blame] | 292 | add_executable(veliad-system |
| 293 | src/main-system.cpp |
| 294 | ) |
| 295 | target_link_libraries(veliad-system |
| 296 | PUBLIC |
| 297 | velia-system |
Jan Kundrát | 9e8752a | 2023-02-02 20:55:39 +0100 | [diff] [blame] | 298 | PkgConfig::DOCOPT |
Tomáš Pecka | 625b7a1 | 2021-01-23 20:55:51 +0100 | [diff] [blame] | 299 | ) |
| 300 | add_dependencies(veliad-system target-VELIA_VERSION) |
| 301 | target_include_directories(veliad-system PUBLIC ${CMAKE_BINARY_DIR}) |
| 302 | |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 303 | add_executable(veliad-firewall |
| 304 | src/main-firewall.cpp |
| 305 | ) |
| 306 | target_link_libraries(veliad-firewall |
| 307 | PUBLIC |
| 308 | velia-firewall |
| 309 | velia-utils |
Jan Kundrát | 9e8752a | 2023-02-02 20:55:39 +0100 | [diff] [blame] | 310 | PkgConfig::DOCOPT |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 311 | ) |
| 312 | add_dependencies(veliad-firewall target-VELIA_VERSION) |
| 313 | target_include_directories(veliad-firewall PUBLIC ${CMAKE_BINARY_DIR}) |
| 314 | |
Tomáš Pecka | aae9fe3 | 2021-01-25 19:57:22 +0100 | [diff] [blame] | 315 | add_executable(veliad-hardware |
| 316 | src/main-hardware.cpp |
| 317 | src/ietf-hardware/Factory.cpp |
| 318 | src/ietf-hardware/Factory.h |
| 319 | ) |
| 320 | target_link_libraries(veliad-hardware |
| 321 | PUBLIC |
| 322 | velia-ietf-hardware |
| 323 | velia-ietf-hardware-sysrepo |
Jan Kundrát | 9e8752a | 2023-02-02 20:55:39 +0100 | [diff] [blame] | 324 | PkgConfig::DOCOPT |
Tomáš Pecka | aae9fe3 | 2021-01-25 19:57:22 +0100 | [diff] [blame] | 325 | ) |
| 326 | add_dependencies(veliad-hardware target-VELIA_VERSION) |
| 327 | target_include_directories(veliad-hardware PUBLIC ${CMAKE_BINARY_DIR}) |
| 328 | |
Tomáš Pecka | fd09bbf | 2024-10-15 13:50:37 +0200 | [diff] [blame] | 329 | add_executable(velia-ipmi-fru-eeprom |
| 330 | src/main-ipmi-fru-eeprom.cpp |
| 331 | ) |
| 332 | add_dependencies(velia-ipmi-fru-eeprom target-VELIA_VERSION) |
| 333 | target_link_libraries(velia-ipmi-fru-eeprom |
| 334 | PUBLIC |
| 335 | velia-ietf-hardware |
| 336 | PkgConfig::DOCOPT |
| 337 | fmt::fmt |
| 338 | ) |
| 339 | add_dependencies(veliad-hardware target-VELIA_VERSION) |
| 340 | target_include_directories(veliad-hardware PUBLIC ${CMAKE_BINARY_DIR}) |
| 341 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 342 | # Testing |
Tomáš Pecka | a06d74d | 2020-06-14 18:18:13 +0200 | [diff] [blame] | 343 | include(CTest) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 344 | if(BUILD_TESTING) |
Jan Kundrát | 613f07f | 2023-11-03 13:28:51 +0100 | [diff] [blame] | 345 | find_package(trompeloeil 45 REQUIRED) |
| 346 | find_package(doctest 2.4.11 REQUIRED) |
Jan Kundrát | d012b32 | 2024-01-12 18:37:05 +0100 | [diff] [blame] | 347 | include(cmake/SysrepoTest.cmake) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 348 | |
Tomáš Pecka | efd8843 | 2020-06-17 15:31:39 +0200 | [diff] [blame] | 349 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/configure.cmake.h.in ${CMAKE_CURRENT_BINARY_DIR}/tests/configure.cmake.h) |
| 350 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 351 | add_library(DoctestIntegration STATIC |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 352 | tests/doctest_integration.cpp |
| 353 | tests/trompeloeil_doctest.h |
| 354 | tests/wait-a-bit-longer.cpp |
| 355 | ) |
Václav Kubernát | 7efd6d5 | 2021-11-09 01:31:11 +0100 | [diff] [blame] | 356 | target_link_libraries(DoctestIntegration doctest::doctest spdlog::spdlog) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 357 | target_include_directories(DoctestIntegration PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 358 | target_compile_definitions(DoctestIntegration PUBLIC DOCTEST_CONFIG_SUPER_FAST_ASSERTS) |
| 359 | |
Tomáš Pecka | a18702d | 2021-01-25 18:07:23 +0100 | [diff] [blame] | 360 | add_library(SysrepoTesting STATIC |
Tomáš Pecka | 0ed5f4f | 2023-05-17 12:20:23 +0200 | [diff] [blame] | 361 | tests/mock/ietf_hardware.h |
| 362 | tests/mock/system.h |
Tomáš Pecka | c164ca6 | 2024-01-24 13:38:03 +0100 | [diff] [blame] | 363 | tests/sysrepo-helpers/common.cpp |
| 364 | tests/sysrepo-helpers/common.h |
Tomáš Pecka | 7eb6459 | 2024-01-24 14:10:47 +0100 | [diff] [blame] | 365 | tests/sysrepo-helpers/datastore.cpp |
| 366 | tests/sysrepo-helpers/datastore.h |
Tomáš Pecka | 9f7b13e | 2024-01-24 13:47:04 +0100 | [diff] [blame] | 367 | tests/sysrepo-helpers/notifications.cpp |
| 368 | tests/sysrepo-helpers/notifications.h |
Tomáš Pecka | 6fcb759 | 2024-01-24 14:42:14 +0100 | [diff] [blame] | 369 | tests/sysrepo-helpers/rpc.cpp |
| 370 | tests/sysrepo-helpers/rpc.h |
Tomáš Pecka | baf289c | 2024-01-24 15:12:44 +0100 | [diff] [blame] | 371 | tests/sysrepo-helpers/alarms.cpp |
| 372 | tests/sysrepo-helpers/alarms.h |
Tomáš Pecka | a18702d | 2021-01-25 18:07:23 +0100 | [diff] [blame] | 373 | ) |
| 374 | target_link_libraries(SysrepoTesting DoctestIntegration PkgConfig::SYSREPO) |
| 375 | |
Tomáš Pecka | 0a2e890 | 2020-06-09 21:11:20 +0200 | [diff] [blame] | 376 | add_library(DbusTesting STATIC |
Tomáš Pecka | 991e4d5 | 2021-01-11 10:03:14 +0100 | [diff] [blame] | 377 | tests/dbus-helpers/dbus_rauc_server.cpp |
| 378 | tests/dbus-helpers/dbus_rauc_server.h |
Tomáš Pecka | 79344c8 | 2021-09-16 18:25:59 +0200 | [diff] [blame] | 379 | tests/dbus-helpers/dbus_resolve1_server.cpp |
| 380 | tests/dbus-helpers/dbus_resolve1_server.h |
Tomáš Pecka | 0a2e890 | 2020-06-09 21:11:20 +0200 | [diff] [blame] | 381 | tests/dbus-helpers/dbus_semaphore_server.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 382 | tests/dbus-helpers/dbus_semaphore_server.h |
Tomáš Pecka | ccd80c3 | 2020-06-22 14:44:32 +0200 | [diff] [blame] | 383 | tests/dbus-helpers/dbus_systemd_server.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 384 | tests/dbus-helpers/dbus_systemd_server.h |
| 385 | ) |
| 386 | target_link_libraries(DbusTesting |
| 387 | PUBLIC |
| 388 | velia-utils |
| 389 | SDBusCpp::sdbus-c++ |
| 390 | ) |
Tomáš Pecka | 0a2e890 | 2020-06-09 21:11:20 +0200 | [diff] [blame] | 391 | |
Tomáš Pecka | 9b1c967 | 2020-11-11 15:24:06 +0100 | [diff] [blame] | 392 | add_library(FsTestUtils STATIC |
| 393 | tests/fs-helpers/FileInjector.cpp |
| 394 | tests/fs-helpers/FileInjector.h |
| 395 | tests/fs-helpers/utils.cpp |
| 396 | tests/fs-helpers/utils.h |
| 397 | ) |
| 398 | target_link_libraries(FsTestUtils |
| 399 | PUBLIC |
| 400 | ${STD_FILESYSTEM_LIBRARY} |
| 401 | ) |
| 402 | |
Tomáš Pecka | 174cc84 | 2023-02-02 14:52:12 +0100 | [diff] [blame] | 403 | find_program(IPROUTE2_EXECUTABLE ip REQUIRED) |
Tomáš Pecka | 174cc84 | 2023-02-02 14:52:12 +0100 | [diff] [blame] | 404 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/test_vars.h.in ${CMAKE_CURRENT_BINARY_DIR}/test_vars.h @ONLY) |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 405 | |
Tomáš Pecka | 174cc84 | 2023-02-02 14:52:12 +0100 | [diff] [blame] | 406 | function(velia_test) |
Jan Kundrát | d012b32 | 2024-01-12 18:37:05 +0100 | [diff] [blame] | 407 | cmake_parse_arguments(TEST "" "NAME" "" ${ARGN}) |
| 408 | sysrepo_test(NAME ${TEST_NAME} ${TEST_UNPARSED_ARGUMENTS}) |
Tomáš Pecka | c164ca6 | 2024-01-24 13:38:03 +0100 | [diff] [blame] | 409 | target_link_libraries(test-${TEST_NAME} DoctestIntegration SysrepoTesting) |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 410 | endfunction() |
| 411 | |
Tomáš Pecka | 0f85ab6 | 2023-02-02 14:53:14 +0100 | [diff] [blame] | 412 | find_program(YANGLINT_PATH yanglint) |
| 413 | if (NOT YANGLINT_PATH) |
| 414 | message(FATAL_ERROR "Cannot find libyang's yanglint") |
| 415 | endif() |
| 416 | foreach(yang_file ${YANG_SRCS}) |
| 417 | add_test(NAME yang-tree:${yang_file} COMMAND ${YANGLINT_PATH} -f tree ${CMAKE_CURRENT_SOURCE_DIR}/${yang_file}) |
| 418 | endforeach() |
| 419 | |
Tomáš Pecka | 174cc84 | 2023-02-02 14:52:12 +0100 | [diff] [blame] | 420 | velia_test(NAME system_rauc LIBRARIES velia-system DbusTesting RESOURCE_LOCK dbus-rauc) |
| 421 | velia_test(NAME system_lldp LIBRARIES velia-system DbusTesting) |
Tomáš Pecka | 991e4d5 | 2021-01-11 10:03:14 +0100 | [diff] [blame] | 422 | |
Tomáš Pecka | 50584c5 | 2023-04-19 10:17:01 +0200 | [diff] [blame] | 423 | velia_test(NAME hardware_thresholds LIBRARIES velia-ietf-hardware) |
Jan Kundrát | c98da38 | 2024-10-08 16:47:04 +0200 | [diff] [blame] | 424 | velia_test(NAME hardware_eeprom LIBRARIES velia-ietf-hardware) |
Tomáš Pecka | 174cc84 | 2023-02-02 14:52:12 +0100 | [diff] [blame] | 425 | velia_test(NAME hardware_emmc LIBRARIES velia-ietf-hardware FsTestUtils) |
| 426 | velia_test(NAME hardware_hwmon LIBRARIES velia-ietf-hardware FsTestUtils) |
Tomáš Pecka | 45b67f9 | 2024-01-11 14:13:05 +0100 | [diff] [blame] | 427 | velia_test(NAME hardware_fspyh LIBRARIES velia-ietf-hardware FsTestUtils) |
Tomáš Pecka | 3f81196 | 2023-04-14 10:54:32 +0200 | [diff] [blame] | 428 | velia_test(NAME hardware_ietf-hardware LIBRARIES velia-ietf-hardware) |
Tomáš Pecka | 7acf392 | 2021-08-10 11:16:57 +0200 | [diff] [blame] | 429 | |
Jan Kundrát | d012b32 | 2024-01-12 18:37:05 +0100 | [diff] [blame] | 430 | set(fixture_sysrepo-czechlight-lldp --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/czechlight-lldp@2020-11-04.yang) |
Tomáš Pecka | 174cc84 | 2023-02-02 14:52:12 +0100 | [diff] [blame] | 431 | velia_test(NAME sysrepo_system-lldp LIBRARIES velia-system DbusTesting FIXTURE fixture_sysrepo-czechlight-lldp) |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 432 | |
Jan Kundrát | d012b32 | 2024-01-12 18:37:05 +0100 | [diff] [blame] | 433 | set(fixture_sysrepo-ietf-system --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-system@2014-08-06.yang) |
Tomáš Pecka | 174cc84 | 2023-02-02 14:52:12 +0100 | [diff] [blame] | 434 | velia_test(NAME sysrepo_system-ietfsystem LIBRARIES velia-system DbusTesting FIXTURE fixture_sysrepo-ietf-system) |
Tomáš Pecka | cb7a5f8 | 2021-01-20 15:12:00 +0100 | [diff] [blame] | 435 | |
Tomáš Pecka | 24b5483 | 2024-01-17 18:10:44 +0100 | [diff] [blame] | 436 | set(fixture_sysrepo-czechlight-system --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/czechlight-system@2022-07-08.yang --init-data ${CMAKE_CURRENT_SOURCE_DIR}/yang/czechlight-authentication.json) |
Tomáš Pecka | c164ca6 | 2024-01-24 13:38:03 +0100 | [diff] [blame] | 437 | velia_test(NAME sysrepo_system-firmware LIBRARIES velia-system DbusTesting FIXTURE fixture_sysrepo-czechlight-system RESOURCE_LOCK dbus-rauc) |
Tomáš Pecka | 72f540e | 2024-07-08 13:45:22 +0200 | [diff] [blame] | 438 | velia_test(NAME sysrepo_authentication LIBRARIES velia-system FsTestUtils date::date-tz FIXTURE fixture_sysrepo-czechlight-system) |
Tomáš Pecka | 174cc84 | 2023-02-02 14:52:12 +0100 | [diff] [blame] | 439 | velia_test(NAME sysrepo_system-leds LIBRARIES velia-system FsTestUtils FIXTURE fixture_sysrepo-czechlight-system) |
Tomáš Pecka | e566fd4 | 2024-01-02 17:00:10 +0100 | [diff] [blame] | 440 | velia_test(NAME sysrepo_system-journalupload LIBRARIES velia-system FIXTURE fixture_sysrepo-czechlight-system) |
Tomáš Pecka | af7b704 | 2021-04-20 20:14:13 +0200 | [diff] [blame] | 441 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 442 | set(fixture_sysrepo-czechlight-network |
Jan Kundrát | d012b32 | 2024-01-12 18:37:05 +0100 | [diff] [blame] | 443 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/iana-if-type@2017-01-19.yang |
| 444 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-interfaces@2018-02-20.yang |
| 445 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-ip@2018-02-22.yang |
| 446 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-routing@2018-03-13.yang |
| 447 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-ipv4-unicast-routing@2018-03-13.yang |
| 448 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-ipv6-unicast-routing@2018-03-13.yang |
| 449 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/czechlight-network@2021-02-22.yang) |
Jan Kundrát | f1af318 | 2023-02-08 21:55:15 +0100 | [diff] [blame] | 450 | velia_test(NAME sysrepo_interfaces-systemd-networkd LIBRARIES velia-system FIXTURE fixture_sysrepo-czechlight-network) |
Tomáš Pecka | f10b930 | 2021-02-23 19:02:02 +0100 | [diff] [blame] | 451 | |
Tomáš Pecka | fd5ec7b | 2023-02-02 18:48:37 +0100 | [diff] [blame] | 452 | find_program(UNSHARE_EXECUTABLE unshare REQUIRED) |
Jan Kundrát | cb93e66 | 2023-02-08 17:39:06 +0100 | [diff] [blame] | 453 | find_program(MOUNT_EXECUTABLE mount REQUIRED) |
Tomáš Pecka | fd5ec7b | 2023-02-02 18:48:37 +0100 | [diff] [blame] | 454 | pkg_get_variable(SR_GROUP sysrepo SR_GROUP) |
| 455 | if (SR_GROUP) |
| 456 | set(UNSHARE_MAP_GROUP_ARG "--map-group=${SR_GROUP}") |
| 457 | else() |
| 458 | set(UNSHARE_MAP_GROUP_ARG "") |
Tomáš Pecka | 9fa5f6a | 2021-04-13 11:36:11 +0200 | [diff] [blame] | 459 | endif() |
Jan Kundrát | d16357d | 2023-02-08 21:57:57 +0100 | [diff] [blame] | 460 | velia_test(NAME sysrepo_interfaces-libnl LIBRARIES velia-system FIXTURE fixture_sysrepo-czechlight-network |
| 461 | COMMAND ${UNSHARE_EXECUTABLE} --net --mount --map-root-user ${UNSHARE_MAP_GROUP_ARG} sh -c "set -ex $<SEMICOLON> ${MOUNT_EXECUTABLE} -t sysfs none /sys $<SEMICOLON> $<TARGET_FILE:test-sysrepo_interfaces-libnl>") |
Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 462 | |
Tomáš Pecka | 2117ce5 | 2023-05-12 11:28:34 +0200 | [diff] [blame] | 463 | set(fixture_sysrepo-ietf-hardware |
Jan Kundrát | d012b32 | 2024-01-12 18:37:05 +0100 | [diff] [blame] | 464 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/iana-hardware@2018-03-13.yang |
| 465 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-hardware@2018-03-13.yang |
| 466 | --enable-feature hardware-sensor |
| 467 | --enable-feature hardware-state |
| 468 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-alarms@2019-09-11.yang |
| 469 | --enable-feature alarm-shelving |
| 470 | --enable-feature alarm-summary |
| 471 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/velia-alarms@2022-07-12.yang |
| 472 | --install ${CMAKE_CURRENT_SOURCE_DIR}/tests/yang/sysrepo-ietf-alarms@2022-02-17.yang) |
Tomáš Pecka | 3f81196 | 2023-04-14 10:54:32 +0200 | [diff] [blame] | 473 | velia_test(NAME sysrepo_ietf-hardware LIBRARIES velia-ietf-hardware velia-ietf-hardware-sysrepo FsTestUtils FIXTURE fixture_sysrepo-ietf-hardware) |
Tomáš Pecka | 174cc84 | 2023-02-02 14:52:12 +0100 | [diff] [blame] | 474 | |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 475 | # 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] | 476 | add_executable(test-sysrepo_test_merge-daemon ${CMAKE_SOURCE_DIR}/tests/sysrepo_two-daemons_daemon.cpp) |
| 477 | target_link_libraries(test-sysrepo_test_merge-daemon PkgConfig::SYSREPO PkgConfig::LIBYANG) |
Tomáš Pecka | 174cc84 | 2023-02-02 14:52:12 +0100 | [diff] [blame] | 478 | velia_test(NAME sysrepo_two-daemons LIBRARIES velia-ietf-hardware-sysrepo FIXTURE fixture_sysrepo-ietf-hardware) |
Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 479 | |
| 480 | add_test(NAME sysrepo_test_merge-start COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepo_two-daemons_control.sh start) |
| 481 | add_test(NAME sysrepo_test_merge-stop COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepo_two-daemons_control.sh stop) |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 482 | set_tests_properties(sysrepo_test_merge-start PROPERTIES FIXTURES_SETUP sysrepo:two-daemons) |
| 483 | set_tests_properties(sysrepo_test_merge-stop PROPERTIES FIXTURES_CLEANUP sysrepo:two-daemons) |
Jan Kundrát | d012b32 | 2024-01-12 18:37:05 +0100 | [diff] [blame] | 484 | get_property(TWO_DAEMONS_ENV TEST test-sysrepo_two-daemons PROPERTY ENVIRONMENT) |
| 485 | set_property(TEST sysrepo_test_merge-start sysrepo_test_merge-stop PROPERTY ENVIRONMENT ${TWO_DAEMONS_ENV}) |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 486 | set_property(TEST test-sysrepo_two-daemons APPEND PROPERTY FIXTURES_REQUIRED sysrepo:two-daemons) |
| 487 | |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 488 | # ensure we run two-daemons merge test and ietf-hardware test sequentially and don't cleanup before everything ends |
Tomáš Pecka | 3f81196 | 2023-04-14 10:54:32 +0200 | [diff] [blame] | 489 | set_tests_properties(sysrepo_test_merge-start PROPERTIES DEPENDS test-sysrepo_ietf-hardware) |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 490 | set_tests_properties(sysrepo:clean:sysrepo_two-daemons PROPERTIES DEPENDS sysrepo_test_merge-stop) |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 491 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 492 | set(fixture_sysrepo-firewall |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 493 | # Installing czechlight-firewall automatically installs ietf-access-control-list as implemented (not just |
| 494 | # imported) but I still need to install it myself to enable the features. |
Jan Kundrát | d012b32 | 2024-01-12 18:37:05 +0100 | [diff] [blame] | 495 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-access-control-list@2019-03-04.yang |
| 496 | --enable-feature match-on-eth |
| 497 | --enable-feature eth |
| 498 | --enable-feature match-on-ipv4 |
| 499 | --enable-feature ipv4 |
| 500 | --enable-feature match-on-ipv6 |
| 501 | --enable-feature ipv6 |
| 502 | --enable-feature mixed-eth-ipv4-ipv6 |
| 503 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/czechlight-firewall@2021-01-25.yang |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 504 | ) |
| 505 | |
Tomáš Pecka | 174cc84 | 2023-02-02 14:52:12 +0100 | [diff] [blame] | 506 | velia_test(NAME sysrepo-firewall LIBRARIES velia-firewall FIXTURE fixture_sysrepo-firewall) |
Tomáš Pecka | 6a2334b | 2022-07-12 13:57:54 +0200 | [diff] [blame] | 507 | |
| 508 | set(fixture_sysrepo-alarms |
Jan Kundrát | d012b32 | 2024-01-12 18:37:05 +0100 | [diff] [blame] | 509 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-alarms@2019-09-11.yang |
| 510 | --enable-feature alarm-shelving |
| 511 | --enable-feature alarm-summary |
| 512 | --install ${CMAKE_CURRENT_SOURCE_DIR}/yang/velia-alarms@2022-07-12.yang |
| 513 | --install ${CMAKE_CURRENT_SOURCE_DIR}/tests/yang/sysrepo-ietf-alarms@2022-02-17.yang |
Tomáš Pecka | 6a2334b | 2022-07-12 13:57:54 +0200 | [diff] [blame] | 514 | ) |
Tomáš Pecka | 3906c89 | 2022-07-26 13:51:17 +0200 | [diff] [blame] | 515 | velia_test(NAME health_systemd-units LIBRARIES velia-health DbusTesting FIXTURE fixture_sysrepo-alarms) |
| 516 | velia_test(NAME sysrepo_health-led-alarms LIBRARIES velia-health DbusTesting FIXTURE fixture_sysrepo-alarms) |
Tomáš Pecka | be79707 | 2022-07-15 20:45:52 +0200 | [diff] [blame] | 517 | |
| 518 | find_program(SYSREPO_IETF_ALARMSD_EXECUTABLE sysrepo-ietf-alarmsd) |
| 519 | if(SYSREPO_IETF_ALARMSD_EXECUTABLE) |
| 520 | velia_test(NAME sysrepo_ietf-alarms LIBRARIES velia-health DbusTesting FIXTURE fixture_sysrepo-alarms) |
| 521 | |
| 522 | add_test(NAME sysrepo_ietf-alarms-start COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepo_sysrepo-ietf-alarms_control.sh start ${SYSREPO_IETF_ALARMSD_EXECUTABLE} ${CMAKE_BINARY_DIR}/sysrepo-ietf-alarmsd.log) |
| 523 | add_test(NAME sysrepo_ietf-alarms-stop COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepo_sysrepo-ietf-alarms_control.sh stop) |
Jan Kundrát | d012b32 | 2024-01-12 18:37:05 +0100 | [diff] [blame] | 524 | get_property(IETF_ALARMS_ENV TEST test-sysrepo_ietf-alarms PROPERTY ENVIRONMENT) |
| 525 | set_property(TEST sysrepo_ietf-alarms-start sysrepo_ietf-alarms-stop PROPERTY ENVIRONMENT ${IETF_ALARMS_ENV}) |
Tomáš Pecka | be79707 | 2022-07-15 20:45:52 +0200 | [diff] [blame] | 526 | set_tests_properties(sysrepo_ietf-alarms-start PROPERTIES FIXTURES_SETUP sysrepo-ietf-alarmsd) |
| 527 | set_tests_properties(sysrepo_ietf-alarms-stop PROPERTIES FIXTURES_CLEANUP sysrepo-ietf-alarmsd) |
| 528 | set_property(TEST test-sysrepo_ietf-alarms APPEND PROPERTY FIXTURES_REQUIRED sysrepo-ietf-alarmsd) |
| 529 | |
| 530 | set_tests_properties(sysrepo_ietf-alarms-start PROPERTIES DEPENDS sysrepo:prep:sysrepo_ietf-alarms) |
| 531 | set_tests_properties(sysrepo:clean:sysrepo_ietf-alarms PROPERTIES DEPENDS sysrepo_ietf-alarms-stop) |
| 532 | endif() |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 533 | endif() |
Tomáš Pecka | c927d66 | 2020-07-13 11:16:16 +0200 | [diff] [blame] | 534 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 535 | if(WITH_DOCS) |
| 536 | set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) |
| 537 | set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) |
| 538 | configure_file(${doxyfile_in} ${doxyfile} @ONLY) |
| 539 | add_custom_target(doc |
| 540 | COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} |
| 541 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 542 | COMMENT "Generating API documentation with Doxygen" |
| 543 | VERBATIM |
| 544 | SOURCES ${doxyfile_in} |
| 545 | ) |
Tomáš Pecka | a06d74d | 2020-06-14 18:18:13 +0200 | [diff] [blame] | 546 | endif() |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 547 | |
Jan Kundrát | 9efb73c | 2024-08-31 08:52:19 +0200 | [diff] [blame] | 548 | set(YANG_DIR ${CMAKE_INSTALL_PREFIX}/share/yang/modules/velia) |
Jan Kundrát | 086de99 | 2024-08-31 08:49:55 +0200 | [diff] [blame] | 549 | install(FILES ${YANG_SRCS} ${YANG_SUBMODULES} DESTINATION ${YANG_DIR}) |
Jan Kundrát | 9efb73c | 2024-08-31 08:52:19 +0200 | [diff] [blame] | 550 | set(YANG_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/yang/static-data/velia) |
| 551 | install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/yang/czechlight-authentication.json DESTINATION ${YANG_DATA_DIR}) |
Jan Kundrát | c8a0866 | 2024-10-16 17:34:23 +0200 | [diff] [blame] | 552 | install(TARGETS |
| 553 | veliad-health |
| 554 | veliad-system |
| 555 | veliad-hardware |
| 556 | veliad-firewall |
| 557 | velia-ipmi-fru-eeprom |
| 558 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}) |
Tomáš Pecka | 848207c | 2024-09-24 15:22:41 +0200 | [diff] [blame] | 559 | |
Jan Kundrát | 276f59b | 2024-10-16 17:35:18 +0200 | [diff] [blame] | 560 | set(JQ_SRCS) |
| 561 | function(add_jq_utility NAME) |
| 562 | set(JQ_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cli/${NAME}.jq) |
| 563 | set(JQ_WRAPPER ${CMAKE_CURRENT_SOURCE_DIR}/cli/${NAME}.in) |
| 564 | list(APPEND JQ_SRCS ${JQ_FILE} ${JQ_WRAPPER}) |
| 565 | configure_file(${JQ_WRAPPER} ${CMAKE_CURRENT_BINARY_DIR}/${NAME} @ONLY) |
| 566 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME} |
| 567 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE |
| 568 | DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}) |
| 569 | install(FILES ${JQ_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}/velia) |
| 570 | endfunction() |
| 571 | add_custom_target(jq_utils SOURCES ${JQ_SRCS}) |
| 572 | |
Jan Kundrát | 6d34167 | 2024-10-17 01:30:35 +0200 | [diff] [blame] | 573 | find_program(JQ_EXECUTABLE jq) |
| 574 | function(add_jq_test UTILITY_NAME TESTCASE_NAME) |
| 575 | set(test_name jq-${UTILITY_NAME}-${TESTCASE_NAME}) |
| 576 | if(JQ_EXECUTABLE STREQUAL "JQ_EXECUTABLE-NOTFOUND") |
| 577 | message(WARNING "Cannot find the `jq` program, skipping test \"${test_name}\"") |
| 578 | return() |
| 579 | endif() |
| 580 | set(test_input_prefix ${CMAKE_CURRENT_SOURCE_DIR}/tests/jq/${UTILITY_NAME}/${TESTCASE_NAME}) |
| 581 | if(EXISTS ${test_input_prefix}.config.json) |
| 582 | set(jq_extra_config "--argjson config \"$(< ${test_input_prefix}.config.json)\"") |
| 583 | else() |
| 584 | set(jq_extra_config "") |
| 585 | endif() |
| 586 | add_test(NAME ${test_name} |
| 587 | COMMAND sh -c |
| 588 | "${JQ_EXECUTABLE} -f ${CMAKE_CURRENT_SOURCE_DIR}/cli/${UTILITY_NAME}.jq ${jq_extra_config} \ |
| 589 | < ${test_input_prefix}.json \ |
| 590 | | diff -u ${test_input_prefix}.expected -") |
| 591 | endfunction() |
| 592 | |
Jan Kundrát | 276f59b | 2024-10-16 17:35:18 +0200 | [diff] [blame] | 593 | add_jq_utility(velia-list-alarms) |
Jan Kundrát | 6d34167 | 2024-10-17 01:30:35 +0200 | [diff] [blame] | 594 | add_jq_test(velia-list-alarms EDFA-LINE-SDN-ID210512) |
| 595 | add_jq_test(velia-list-alarms active-since) |
| 596 | add_jq_test(velia-list-alarms cleared-before) |
Jan Kundrát | e255241 | 2024-10-16 17:40:07 +0200 | [diff] [blame] | 597 | add_jq_utility(velia-list-hardware) |
Jan Kundrát | 6d34167 | 2024-10-17 01:30:35 +0200 | [diff] [blame] | 598 | add_jq_test(velia-list-hardware EDFA-LINE-SDN-ID210512) |