Last active
January 11, 2024 02:29
-
-
Save scivision/463a44a496357dd6de73d58302ba3d4f to your computer and use it in GitHub Desktop.
CTest checking that internet works before tests requiring internet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.19) | |
project(Connect LANGUAGES NONE) | |
enable_testing() | |
add_test(NAME InternetConnection COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_LIST_DIR}/connection.cmake) | |
set_property(TEST InternetConnection PROPERTY FIXTURES_SETUP InternetOK) | |
add_test(NAME NeedsInternet COMMAND ...) | |
set_property(TEST NeedsInternet PROPERTY FIXTURES_REQUIRED InternetOK) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file(DOWNLOAD https://connectivitycheck.gstatic.com/generate_204 | |
STATUS ret | |
TLS_VERIFY ON | |
) | |
list(GET ret 0 status) | |
if(NOT status EQUAL 0) | |
list(GET ret 1 msg) | |
message(FATAL_ERROR "Internet connectivity test failed. | |
Return code: ${status} | |
Error: ${msg}" | |
) | |
endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment