| 1 |
# |
| 2 |
# Copyright (c) 2014-2026 Enrico M. Crisostomo |
| 3 |
# |
| 4 |
# This program is free software; you can redistribute it and/or modify it under |
| 5 |
# the terms of the GNU General Public License as published by the Free Software |
| 6 |
# Foundation; either version 3, or (at your option) any later version. |
| 7 |
# |
| 8 |
# This program is distributed in the hope that it will be useful, but WITHOUT |
| 9 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 10 |
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 11 |
# details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU General Public License along with |
| 14 |
# this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
# |
| 16 |
set(SOURCE_FILES |
| 17 |
fswatch_test.cpp |
| 18 |
${PROJECT_BINARY_DIR}/libfswatch/libfswatch_config.h) |
| 19 |
|
| 20 |
add_executable(fswatch_test ${SOURCE_FILES}) |
| 21 |
target_include_directories(fswatch_test BEFORE PRIVATE ${PROJECT_BINARY_DIR}) |
| 22 |
target_include_directories(fswatch_test PRIVATE ../.. .) |
| 23 |
target_link_libraries(fswatch_test PUBLIC libfswatch) |
| 24 |
|
| 25 |
if (BUILD_TESTING) |
| 26 |
find_program(SH_EXECUTABLE sh) |
| 27 |
find_program(GIT_EXECUTABLE git) |
| 28 |
|
| 29 |
add_executable(filter_mode_test filter_mode_test.cpp) |
| 30 |
target_include_directories(filter_mode_test PRIVATE ../.. .) |
| 31 |
target_include_directories(filter_mode_test BEFORE PRIVATE ${PROJECT_BINARY_DIR}) |
| 32 |
target_link_libraries(filter_mode_test PUBLIC libfswatch) |
| 33 |
add_test(NAME filter_mode_test COMMAND filter_mode_test) |
| 34 |
set_tests_properties(filter_mode_test PROPERTIES |
| 35 |
LABELS "unit;filtering") |
| 36 |
|
| 37 |
add_executable(prune_c_api_test prune_c_api_test.cpp) |
| 38 |
target_include_directories(prune_c_api_test PRIVATE ../.. .) |
| 39 |
target_include_directories(prune_c_api_test BEFORE PRIVATE ${PROJECT_BINARY_DIR}) |
| 40 |
target_link_libraries(prune_c_api_test PUBLIC libfswatch) |
| 41 |
add_test(NAME prune_c_api_test COMMAND prune_c_api_test) |
| 42 |
set_tests_properties(prune_c_api_test PROPERTIES |
| 43 |
LABELS "integration;poll;filtering" |
| 44 |
TIMEOUT 15) |
| 45 |
|
| 46 |
if (HAVE_INOTIFY_MONITOR) |
| 47 |
add_executable(inotify_stop_latency_test inotify_stop_latency_test.cpp) |
| 48 |
target_include_directories(inotify_stop_latency_test PRIVATE ../.. .) |
| 49 |
target_include_directories(inotify_stop_latency_test BEFORE PRIVATE ${PROJECT_BINARY_DIR}) |
| 50 |
target_link_libraries(inotify_stop_latency_test PUBLIC libfswatch) |
| 51 |
add_test(NAME inotify_stop_latency_test COMMAND inotify_stop_latency_test) |
| 52 |
set_tests_properties(inotify_stop_latency_test PROPERTIES |
| 53 |
LABELS "integration;inotify" |
| 54 |
TIMEOUT 5) |
| 55 |
|
| 56 |
add_executable(inotify_stop_with_pending_events_test inotify_stop_with_pending_events_test.cpp) |
| 57 |
target_include_directories(inotify_stop_with_pending_events_test PRIVATE ../.. .) |
| 58 |
target_include_directories(inotify_stop_with_pending_events_test BEFORE PRIVATE ${PROJECT_BINARY_DIR}) |
| 59 |
target_link_libraries(inotify_stop_with_pending_events_test PUBLIC libfswatch) |
| 60 |
add_test(NAME inotify_stop_with_pending_events_test COMMAND inotify_stop_with_pending_events_test) |
| 61 |
set_tests_properties(inotify_stop_with_pending_events_test PROPERTIES |
| 62 |
LABELS "integration;inotify" |
| 63 |
TIMEOUT 5) |
| 64 |
|
| 65 |
add_executable(inotify_stop_with_ready_events_test inotify_stop_with_ready_events_test.cpp) |
| 66 |
target_include_directories(inotify_stop_with_ready_events_test PRIVATE ../.. .) |
| 67 |
target_include_directories(inotify_stop_with_ready_events_test BEFORE PRIVATE ${PROJECT_BINARY_DIR}) |
| 68 |
target_link_libraries(inotify_stop_with_ready_events_test PUBLIC libfswatch) |
| 69 |
add_test(NAME inotify_stop_with_ready_events_test COMMAND inotify_stop_with_ready_events_test) |
| 70 |
set_tests_properties(inotify_stop_with_ready_events_test PROPERTIES |
| 71 |
LABELS "integration;inotify" |
| 72 |
TIMEOUT 5) |
| 73 |
|
| 74 |
if (SH_EXECUTABLE) |
| 75 |
add_test(NAME inotify_basic_events |
| 76 |
COMMAND ${SH_EXECUTABLE} |
| 77 |
${PROJECT_SOURCE_DIR}/test/inotify_basic_events.sh |
| 78 |
$<TARGET_FILE:fswatch>) |
| 79 |
set_tests_properties(inotify_basic_events PROPERTIES |
| 80 |
LABELS "integration;inotify" |
| 81 |
TIMEOUT 15) |
| 82 |
|
| 83 |
add_test(NAME inotify_access_events |
| 84 |
COMMAND ${SH_EXECUTABLE} |
| 85 |
${PROJECT_SOURCE_DIR}/test/inotify_access_events.sh |
| 86 |
$<TARGET_FILE:fswatch>) |
| 87 |
set_tests_properties(inotify_access_events PROPERTIES |
| 88 |
LABELS "integration;inotify" |
| 89 |
TIMEOUT 15) |
| 90 |
|
| 91 |
add_test(NAME inotify_missing_root_rescan |
| 92 |
COMMAND ${SH_EXECUTABLE} |
| 93 |
${PROJECT_SOURCE_DIR}/test/inotify_missing_root_rescan.sh |
| 94 |
$<TARGET_FILE:fswatch>) |
| 95 |
set_tests_properties(inotify_missing_root_rescan PROPERTIES |
| 96 |
LABELS "integration;inotify" |
| 97 |
TIMEOUT 20) |
| 98 |
|
| 99 |
add_test(NAME inotify_watched_file_recreate |
| 100 |
COMMAND ${SH_EXECUTABLE} |
| 101 |
${PROJECT_SOURCE_DIR}/test/inotify_watched_file_recreate.sh |
| 102 |
$<TARGET_FILE:fswatch>) |
| 103 |
set_tests_properties(inotify_watched_file_recreate PROPERTIES |
| 104 |
LABELS "integration;inotify" |
| 105 |
TIMEOUT 20) |
| 106 |
|
| 107 |
add_test(NAME inotify_watched_directory_replace |
| 108 |
COMMAND ${SH_EXECUTABLE} |
| 109 |
${PROJECT_SOURCE_DIR}/test/inotify_watched_directory_replace.sh |
| 110 |
$<TARGET_FILE:fswatch>) |
| 111 |
set_tests_properties(inotify_watched_directory_replace PROPERTIES |
| 112 |
LABELS "integration;inotify" |
| 113 |
TIMEOUT 25) |
| 114 |
|
| 115 |
add_test(NAME inotify_burst_create |
| 116 |
COMMAND ${SH_EXECUTABLE} |
| 117 |
${PROJECT_SOURCE_DIR}/test/inotify_burst_create.sh |
| 118 |
$<TARGET_FILE:fswatch>) |
| 119 |
set_tests_properties(inotify_burst_create PROPERTIES |
| 120 |
LABELS "integration;inotify" |
| 121 |
TIMEOUT 20) |
| 122 |
|
| 123 |
add_test(NAME inotify_queue_drain |
| 124 |
COMMAND ${SH_EXECUTABLE} |
| 125 |
${PROJECT_SOURCE_DIR}/test/inotify_queue_drain.sh |
| 126 |
$<TARGET_FILE:fswatch>) |
| 127 |
set_tests_properties(inotify_queue_drain PROPERTIES |
| 128 |
LABELS "integration;inotify" |
| 129 |
TIMEOUT 25) |
| 130 |
|
| 131 |
add_test(NAME inotify_filter_root_path |
| 132 |
COMMAND ${SH_EXECUTABLE} |
| 133 |
${PROJECT_SOURCE_DIR}/test/filter_root_path.sh |
| 134 |
$<TARGET_FILE:fswatch> |
| 135 |
inotify_monitor) |
| 136 |
set_tests_properties(inotify_filter_root_path PROPERTIES |
| 137 |
LABELS "integration;inotify;filtering" |
| 138 |
TIMEOUT 15) |
| 139 |
|
| 140 |
add_test(NAME inotify_filter_root_file |
| 141 |
COMMAND ${SH_EXECUTABLE} |
| 142 |
${PROJECT_SOURCE_DIR}/test/filter_root_file.sh |
| 143 |
$<TARGET_FILE:fswatch> |
| 144 |
inotify_monitor) |
| 145 |
set_tests_properties(inotify_filter_root_file PROPERTIES |
| 146 |
LABELS "integration;inotify;filtering" |
| 147 |
TIMEOUT 15) |
| 148 |
|
| 149 |
add_test(NAME inotify_filter_mode |
| 150 |
COMMAND ${SH_EXECUTABLE} |
| 151 |
${PROJECT_SOURCE_DIR}/test/filter_mode.sh |
| 152 |
$<TARGET_FILE:fswatch> |
| 153 |
inotify_monitor) |
| 154 |
set_tests_properties(inotify_filter_mode PROPERTIES |
| 155 |
LABELS "integration;inotify;filtering" |
| 156 |
TIMEOUT 20) |
| 157 |
|
| 158 |
add_test(NAME inotify_prune |
| 159 |
COMMAND ${SH_EXECUTABLE} |
| 160 |
${PROJECT_SOURCE_DIR}/test/prune.sh |
| 161 |
$<TARGET_FILE:fswatch> |
| 162 |
inotify_monitor) |
| 163 |
set_tests_properties(inotify_prune PROPERTIES |
| 164 |
LABELS "integration;inotify;filtering" |
| 165 |
TIMEOUT 15) |
| 166 |
|
| 167 |
add_test(NAME inotify_prune_root_path |
| 168 |
COMMAND ${SH_EXECUTABLE} |
| 169 |
${PROJECT_SOURCE_DIR}/test/prune_root_path.sh |
| 170 |
$<TARGET_FILE:fswatch> |
| 171 |
inotify_monitor) |
| 172 |
set_tests_properties(inotify_prune_root_path PROPERTIES |
| 173 |
LABELS "integration;inotify;filtering" |
| 174 |
TIMEOUT 15) |
| 175 |
|
| 176 |
if (GIT_EXECUTABLE) |
| 177 |
add_test(NAME inotify_recursive_create |
| 178 |
COMMAND ${SH_EXECUTABLE} |
| 179 |
${PROJECT_SOURCE_DIR}/test/inotify_recursive_create.sh |
| 180 |
$<TARGET_FILE:fswatch> |
| 181 |
${GIT_EXECUTABLE}) |
| 182 |
set_tests_properties(inotify_recursive_create PROPERTIES |
| 183 |
LABELS "integration;inotify" |
| 184 |
TIMEOUT 15) |
| 185 |
endif () |
| 186 |
endif () |
| 187 |
|
| 188 |
endif () |
| 189 |
|
| 190 |
if (SH_EXECUTABLE) |
| 191 |
add_test(NAME poll_filter_root_path |
| 192 |
COMMAND ${SH_EXECUTABLE} |
| 193 |
${PROJECT_SOURCE_DIR}/test/filter_root_path.sh |
| 194 |
$<TARGET_FILE:fswatch> |
| 195 |
poll_monitor) |
| 196 |
set_tests_properties(poll_filter_root_path PROPERTIES |
| 197 |
LABELS "integration;poll;filtering" |
| 198 |
TIMEOUT 20) |
| 199 |
|
| 200 |
add_test(NAME poll_filter_root_file |
| 201 |
COMMAND ${SH_EXECUTABLE} |
| 202 |
${PROJECT_SOURCE_DIR}/test/filter_root_file.sh |
| 203 |
$<TARGET_FILE:fswatch> |
| 204 |
poll_monitor) |
| 205 |
set_tests_properties(poll_filter_root_file PROPERTIES |
| 206 |
LABELS "integration;poll;filtering" |
| 207 |
TIMEOUT 20) |
| 208 |
|
| 209 |
add_test(NAME poll_filter_mode |
| 210 |
COMMAND ${SH_EXECUTABLE} |
| 211 |
${PROJECT_SOURCE_DIR}/test/filter_mode.sh |
| 212 |
$<TARGET_FILE:fswatch> |
| 213 |
poll_monitor) |
| 214 |
set_tests_properties(poll_filter_mode PROPERTIES |
| 215 |
LABELS "integration;poll;filtering" |
| 216 |
TIMEOUT 25) |
| 217 |
|
| 218 |
add_test(NAME poll_prune |
| 219 |
COMMAND ${SH_EXECUTABLE} |
| 220 |
${PROJECT_SOURCE_DIR}/test/prune.sh |
| 221 |
$<TARGET_FILE:fswatch> |
| 222 |
poll_monitor) |
| 223 |
set_tests_properties(poll_prune PROPERTIES |
| 224 |
LABELS "integration;poll;filtering" |
| 225 |
TIMEOUT 20) |
| 226 |
|
| 227 |
add_test(NAME poll_prune_root_path |
| 228 |
COMMAND ${SH_EXECUTABLE} |
| 229 |
${PROJECT_SOURCE_DIR}/test/prune_root_path.sh |
| 230 |
$<TARGET_FILE:fswatch> |
| 231 |
poll_monitor) |
| 232 |
set_tests_properties(poll_prune_root_path PROPERTIES |
| 233 |
LABELS "integration;poll;filtering" |
| 234 |
TIMEOUT 20) |
| 235 |
endif () |
| 236 |
|
| 237 |
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND SH_EXECUTABLE AND HAVE_FANOTIFY) |
| 238 |
add_test(NAME fanotify_basic |
| 239 |
COMMAND ${SH_EXECUTABLE} |
| 240 |
${PROJECT_SOURCE_DIR}/test/fanotify_basic.sh |
| 241 |
$<TARGET_FILE:fswatch>) |
| 242 |
set_tests_properties(fanotify_basic PROPERTIES |
| 243 |
LABELS "integration;fanotify" |
| 244 |
SKIP_RETURN_CODE 77 |
| 245 |
TIMEOUT 20) |
| 246 |
|
| 247 |
add_test(NAME fanotify_access_events |
| 248 |
COMMAND ${SH_EXECUTABLE} |
| 249 |
${PROJECT_SOURCE_DIR}/test/fanotify_access_events.sh |
| 250 |
$<TARGET_FILE:fswatch>) |
| 251 |
set_tests_properties(fanotify_access_events PROPERTIES |
| 252 |
LABELS "integration;fanotify" |
| 253 |
SKIP_RETURN_CODE 77 |
| 254 |
TIMEOUT 20) |
| 255 |
|
| 256 |
add_test(NAME fanotify_unlimited_properties |
| 257 |
COMMAND ${SH_EXECUTABLE} |
| 258 |
${PROJECT_SOURCE_DIR}/test/fanotify_unlimited_properties.sh |
| 259 |
$<TARGET_FILE:fswatch>) |
| 260 |
set_tests_properties(fanotify_unlimited_properties PROPERTIES |
| 261 |
LABELS "integration;fanotify" |
| 262 |
SKIP_RETURN_CODE 77 |
| 263 |
TIMEOUT 20) |
| 264 |
|
| 265 |
add_test(NAME fanotify_filter_root_path |
| 266 |
COMMAND ${SH_EXECUTABLE} |
| 267 |
${PROJECT_SOURCE_DIR}/test/filter_root_path.sh |
| 268 |
$<TARGET_FILE:fswatch> |
| 269 |
fanotify_monitor) |
| 270 |
set_tests_properties(fanotify_filter_root_path PROPERTIES |
| 271 |
LABELS "integration;fanotify;filtering" |
| 272 |
SKIP_RETURN_CODE 77 |
| 273 |
TIMEOUT 20) |
| 274 |
|
| 275 |
add_test(NAME fanotify_filter_mode |
| 276 |
COMMAND ${SH_EXECUTABLE} |
| 277 |
${PROJECT_SOURCE_DIR}/test/filter_mode.sh |
| 278 |
$<TARGET_FILE:fswatch> |
| 279 |
fanotify_monitor) |
| 280 |
set_tests_properties(fanotify_filter_mode PROPERTIES |
| 281 |
LABELS "integration;fanotify;filtering" |
| 282 |
SKIP_RETURN_CODE 77 |
| 283 |
TIMEOUT 25) |
| 284 |
|
| 285 |
add_test(NAME fanotify_prune |
| 286 |
COMMAND ${SH_EXECUTABLE} |
| 287 |
${PROJECT_SOURCE_DIR}/test/prune.sh |
| 288 |
$<TARGET_FILE:fswatch> |
| 289 |
fanotify_monitor) |
| 290 |
set_tests_properties(fanotify_prune PROPERTIES |
| 291 |
LABELS "integration;fanotify;filtering" |
| 292 |
SKIP_RETURN_CODE 77 |
| 293 |
TIMEOUT 20) |
| 294 |
|
| 295 |
add_test(NAME fanotify_prune_root_path |
| 296 |
COMMAND ${SH_EXECUTABLE} |
| 297 |
${PROJECT_SOURCE_DIR}/test/prune_root_path.sh |
| 298 |
$<TARGET_FILE:fswatch> |
| 299 |
fanotify_monitor) |
| 300 |
set_tests_properties(fanotify_prune_root_path PROPERTIES |
| 301 |
LABELS "integration;fanotify;filtering" |
| 302 |
SKIP_RETURN_CODE 77 |
| 303 |
TIMEOUT 20) |
| 304 |
endif () |
| 305 |
|
| 306 |
if (SH_EXECUTABLE AND HAVE_PORT_H) |
| 307 |
add_test(NAME fen_filter_root_file |
| 308 |
COMMAND ${SH_EXECUTABLE} |
| 309 |
${PROJECT_SOURCE_DIR}/test/fen_filter_root_file.sh |
| 310 |
$<TARGET_FILE:fswatch>) |
| 311 |
set_tests_properties(fen_filter_root_file PROPERTIES |
| 312 |
LABELS "integration;fen;filtering" |
| 313 |
SKIP_RETURN_CODE 77 |
| 314 |
TIMEOUT 20) |
| 315 |
endif () |
| 316 |
|
| 317 |
if (SH_EXECUTABLE AND HAVE_SYS_EVENT_H) |
| 318 |
add_test(NAME kqueue_filter_root_file |
| 319 |
COMMAND ${SH_EXECUTABLE} |
| 320 |
${PROJECT_SOURCE_DIR}/test/filter_root_file.sh |
| 321 |
$<TARGET_FILE:fswatch> |
| 322 |
kqueue_monitor) |
| 323 |
set_tests_properties(kqueue_filter_root_file PROPERTIES |
| 324 |
LABELS "integration;kqueue;filtering" |
| 325 |
SKIP_RETURN_CODE 77 |
| 326 |
TIMEOUT 20) |
| 327 |
endif () |
| 328 |
|
| 329 |
if (APPLE) |
| 330 |
add_executable(fsevents_missing_inode_test fsevents_missing_inode_test.cpp) |
| 331 |
target_include_directories(fsevents_missing_inode_test BEFORE PRIVATE ${PROJECT_BINARY_DIR}) |
| 332 |
target_include_directories(fsevents_missing_inode_test PRIVATE ../.. .) |
| 333 |
find_library(CORESERVICES_LIBRARY CoreServices) |
| 334 |
target_link_libraries(fsevents_missing_inode_test PUBLIC libfswatch ${CORESERVICES_LIBRARY}) |
| 335 |
add_test(NAME fsevents_missing_inode_test COMMAND fsevents_missing_inode_test) |
| 336 |
set_tests_properties(fsevents_missing_inode_test PROPERTIES SKIP_RETURN_CODE 77) |
| 337 |
|
| 338 |
add_executable(fsevents_cf_paths_test fsevents_cf_paths_test.cpp) |
| 339 |
target_include_directories(fsevents_cf_paths_test BEFORE PRIVATE ${PROJECT_BINARY_DIR}) |
| 340 |
target_include_directories(fsevents_cf_paths_test PRIVATE ../.. .) |
| 341 |
target_link_libraries(fsevents_cf_paths_test PUBLIC libfswatch ${CORESERVICES_LIBRARY}) |
| 342 |
add_test(NAME fsevents_cf_paths_test COMMAND fsevents_cf_paths_test) |
| 343 |
|
| 344 |
if (SH_EXECUTABLE) |
| 345 |
add_test(NAME fsevents_filter_root_path |
| 346 |
COMMAND ${SH_EXECUTABLE} |
| 347 |
${PROJECT_SOURCE_DIR}/test/filter_root_path.sh |
| 348 |
$<TARGET_FILE:fswatch> |
| 349 |
fsevents_monitor) |
| 350 |
set_tests_properties(fsevents_filter_root_path PROPERTIES |
| 351 |
LABELS "integration;fsevents;filtering" |
| 352 |
SKIP_RETURN_CODE 77 |
| 353 |
TIMEOUT 20) |
| 354 |
|
| 355 |
add_test(NAME fsevents_filter_mode |
| 356 |
COMMAND ${SH_EXECUTABLE} |
| 357 |
${PROJECT_SOURCE_DIR}/test/filter_mode.sh |
| 358 |
$<TARGET_FILE:fswatch> |
| 359 |
fsevents_monitor) |
| 360 |
set_tests_properties(fsevents_filter_mode PROPERTIES |
| 361 |
LABELS "integration;fsevents;filtering" |
| 362 |
SKIP_RETURN_CODE 77 |
| 363 |
TIMEOUT 25) |
| 364 |
endif () |
| 365 |
endif () |
| 366 |
endif () |