1# Copyright (c) 2018-2022 Yubico AB. All rights reserved. 2# Use of this source code is governed by a BSD-style 3# license that can be found in the LICENSE file. 4# SPDX-License-Identifier: BSD-2-Clause 5 6add_custom_target(regress) 7 8macro(add_regress_test NAME SOURCES LIB) 9 add_executable(${NAME} ${SOURCES}) 10 add_test(${NAME} ${NAME}) 11 add_dependencies(regress ${NAME}) 12 target_link_libraries(${NAME} ${LIB}) 13endmacro() 14 15if(MSVC AND BUILD_SHARED_LIBS) 16 add_custom_command(TARGET regress POST_BUILD 17 COMMAND "${CMAKE_COMMAND}" -E copy 18 "${CBOR_BIN_DIRS}/${CBOR_LIBRARIES}.dll" 19 "${CRYPTO_BIN_DIRS}/${CRYPTO_LIBRARIES}.dll" 20 "${ZLIB_BIN_DIRS}/${ZLIB_LIBRARIES}.dll" 21 "$<TARGET_FILE:${_FIDO2_LIBRARY}>" 22 "${CMAKE_CURRENT_BINARY_DIR}") 23endif() 24 25if(CYGWIN AND BUILD_SHARED_LIBS) 26 add_custom_command(TARGET regress POST_BUILD 27 COMMAND "${CMAKE_COMMAND}" -E copy 28 "$<TARGET_FILE:${_FIDO2_LIBRARY}>" 29 "${CMAKE_CURRENT_BINARY_DIR}") 30endif() 31 32if(CMAKE_CROSSCOMPILING OR (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64" AND 33 CMAKE_GENERATOR_PLATFORM MATCHES "^ARM.*$")) 34 add_custom_command(TARGET regress POST_BUILD 35 COMMAND "${CMAKE_COMMAND}" -E echo 36 "Cross-compilation detected. Skipping regress tests.") 37else() 38 add_custom_command(TARGET regress POST_BUILD 39 COMMAND "${CMAKE_CTEST_COMMAND}" --output-on-failure 40 WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) 41endif() 42 43add_regress_test(regress_assert assert.c ${_FIDO2_LIBRARY}) 44add_regress_test(regress_cred cred.c ${_FIDO2_LIBRARY}) 45add_regress_test(regress_dev dev.c ${_FIDO2_LIBRARY}) 46add_regress_test(regress_eddsa eddsa.c ${_FIDO2_LIBRARY}) 47add_regress_test(regress_es256 es256.c ${_FIDO2_LIBRARY}) 48add_regress_test(regress_es384 es384.c ${_FIDO2_LIBRARY}) 49add_regress_test(regress_rs256 rs256.c ${_FIDO2_LIBRARY}) 50if(BUILD_STATIC_LIBS) 51 add_regress_test(regress_compress compress.c fido2) 52endif() 53 54if(MINGW) 55 # needed for nanosleep() in mingw 56 target_link_libraries(regress_dev winpthread) 57endif() 58