Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/external/curl/tests/CMakeLists.txt
2654 views
1
#***************************************************************************
2
# _ _ ____ _
3
# Project ___| | | | _ \| |
4
# / __| | | | |_) | |
5
# | (__| |_| | _ <| |___
6
# \___|\___/|_| \_\_____|
7
#
8
# Copyright (C) Daniel Stenberg, <[email protected]>, et al.
9
#
10
# This software is licensed as described in the file COPYING, which
11
# you should have received as part of this distribution. The terms
12
# are also available at https://curl.se/docs/copyright.html.
13
#
14
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15
# copies of the Software, and permit persons to whom the Software is
16
# furnished to do so, under the terms of the COPYING file.
17
#
18
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
# KIND, either express or implied.
20
#
21
# SPDX-License-Identifier: curl
22
#
23
###########################################################################
24
find_program(TEST_NGHTTPX "nghttpx")
25
if(NOT TEST_NGHTTPX)
26
set(TEST_NGHTTPX "")
27
endif()
28
mark_as_advanced(TEST_NGHTTPX)
29
# Consumed variables: TEST_NGHTTPX
30
configure_file("config.in" "${CMAKE_CURRENT_BINARY_DIR}/config" @ONLY)
31
32
add_custom_target(testdeps)
33
if(BUILD_CURL_EXE)
34
add_dependencies(testdeps "curlinfo")
35
endif()
36
37
if(CURL_CLANG_TIDY)
38
add_custom_target(tests-clang-tidy)
39
add_dependencies(testdeps tests-clang-tidy)
40
endif()
41
42
add_subdirectory(http)
43
add_subdirectory(server)
44
add_subdirectory(libtest)
45
add_subdirectory(tunit)
46
add_subdirectory(unit)
47
add_subdirectory(certs)
48
49
# Add a runtests target with customized flags
50
function(curl_add_runtests _targetname _test_flags)
51
if(NOT BUILD_LIBCURL_DOCS)
52
string(APPEND _test_flags " !documentation")
53
endif()
54
set(_depends "")
55
# Skip walking through dependent targets before running tests in CI.
56
# This avoids: GNU Make doing a slow re-evaluation of all targets and
57
# skipping them, MSBuild doing a re-evaluation, and actually rebuilding them.
58
if(NOT _targetname STREQUAL "test-ci")
59
if(BUILD_CURL_EXE)
60
list(APPEND _depends "${EXE_NAME}")
61
endif()
62
list(APPEND _depends "testdeps")
63
endif()
64
set(_setenv "")
65
if(CMAKE_CONFIGURATION_TYPES)
66
set(_setenv "${CMAKE_COMMAND}" -E env "CURL_DIRSUFFIX=$<CONFIG>")
67
endif()
68
# Use a special '$TFLAGS' placeholder as last argument which will be
69
# replaced by the contents of the environment variable in runtests.pl.
70
# This is a workaround for CMake's limitation where commands executed by
71
# 'make' or 'ninja' cannot portably reference environment variables.
72
string(REPLACE " " ";" _test_flags_list "${_test_flags}")
73
add_custom_target(${_targetname}
74
COMMAND
75
${_setenv}
76
"${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runtests.pl"
77
${_test_flags_list}
78
"\$TFLAGS"
79
DEPENDS "${_depends}"
80
VERBATIM USES_TERMINAL
81
)
82
endfunction()
83
84
# Add a pytests target with customized flags
85
function(curl_add_pytests _targetname _test_flags)
86
set(_depends "")
87
if(NOT _targetname STREQUAL "pytest-ci")
88
if(BUILD_CURL_EXE)
89
list(APPEND _depends "${EXE_NAME}" "curlinfo")
90
endif()
91
list(APPEND _depends "libtests")
92
endif()
93
string(REPLACE " " ";" _test_flags_list "${_test_flags}")
94
add_custom_target(${_targetname}
95
COMMAND pytest ${_test_flags_list} "${CMAKE_CURRENT_SOURCE_DIR}/http"
96
DEPENDS "${_depends}"
97
VERBATIM USES_TERMINAL
98
)
99
endfunction()
100
101
# Create configurehelp.pm, used by tests needing to run the C preprocessor.
102
if(MSVC OR CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
103
set(CURL_CPP "\"${CMAKE_C_COMPILER}\" -E")
104
if(APPLE AND CMAKE_OSX_SYSROOT)
105
string(APPEND CURL_CPP " -isysroot ${CMAKE_OSX_SYSROOT}")
106
endif()
107
string(APPEND CURL_CPP " ${CMAKE_C_FLAGS}")
108
# Add header directories, like autotools builds do.
109
get_property(_include_dirs TARGET ${LIB_SELECTED} PROPERTY INCLUDE_DIRECTORIES)
110
foreach(_include_dir IN LISTS _include_dirs)
111
string(APPEND CURL_CPP " -I${_include_dir}")
112
endforeach()
113
else()
114
set(CURL_CPP "cpp")
115
endif()
116
# Generate version script for the linker, for versioned symbols.
117
# Consumed variable:
118
# CURL_CPP
119
configure_file(
120
"${CMAKE_CURRENT_SOURCE_DIR}/configurehelp.pm.in"
121
"${CMAKE_CURRENT_BINARY_DIR}/configurehelp.pm" @ONLY)
122
123
curl_add_runtests(tests "") # Avoid 'test', which is a reserved target name in CMake
124
curl_add_runtests(test-quiet "-a -s")
125
curl_add_runtests(test-am "-a -am")
126
curl_add_runtests(test-full "-a -p -r")
127
# ~flaky means that it ignores results of tests using the flaky keyword
128
curl_add_runtests(test-nonflaky "-a -p ~flaky ~timing-dependent")
129
curl_add_runtests(test-ci "-a -p ~flaky ~timing-dependent -r --retry=5 -j20 --buildinfo")
130
curl_add_runtests(test-torture "-a -t -j20")
131
curl_add_runtests(test-event "-a -e")
132
133
curl_add_pytests(curl-pytest "-n auto")
134
curl_add_pytests(curl-pytest-ci "-n auto -v")
135
136