xref: /aosp_15_r20/external/curl/tests/CMakeLists.txt (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker#***************************************************************************
2*6236dae4SAndroid Build Coastguard Worker#                                  _   _ ____  _
3*6236dae4SAndroid Build Coastguard Worker#  Project                     ___| | | |  _ \| |
4*6236dae4SAndroid Build Coastguard Worker#                             / __| | | | |_) | |
5*6236dae4SAndroid Build Coastguard Worker#                            | (__| |_| |  _ <| |___
6*6236dae4SAndroid Build Coastguard Worker#                             \___|\___/|_| \_\_____|
7*6236dae4SAndroid Build Coastguard Worker#
8*6236dae4SAndroid Build Coastguard Worker# Copyright (C) Daniel Stenberg, <[email protected]>, et al.
9*6236dae4SAndroid Build Coastguard Worker#
10*6236dae4SAndroid Build Coastguard Worker# This software is licensed as described in the file COPYING, which
11*6236dae4SAndroid Build Coastguard Worker# you should have received as part of this distribution. The terms
12*6236dae4SAndroid Build Coastguard Worker# are also available at https://curl.se/docs/copyright.html.
13*6236dae4SAndroid Build Coastguard Worker#
14*6236dae4SAndroid Build Coastguard Worker# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15*6236dae4SAndroid Build Coastguard Worker# copies of the Software, and permit persons to whom the Software is
16*6236dae4SAndroid Build Coastguard Worker# furnished to do so, under the terms of the COPYING file.
17*6236dae4SAndroid Build Coastguard Worker#
18*6236dae4SAndroid Build Coastguard Worker# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19*6236dae4SAndroid Build Coastguard Worker# KIND, either express or implied.
20*6236dae4SAndroid Build Coastguard Worker#
21*6236dae4SAndroid Build Coastguard Worker# SPDX-License-Identifier: curl
22*6236dae4SAndroid Build Coastguard Worker#
23*6236dae4SAndroid Build Coastguard Worker###########################################################################
24*6236dae4SAndroid Build Coastguard Workeroption(CURL_TEST_BUNDLES "Bundle libtest and unittest tests into single binaries" OFF)
25*6236dae4SAndroid Build Coastguard Worker
26*6236dae4SAndroid Build Coastguard Workerfind_program(TEST_NGHTTPX "nghttpx")
27*6236dae4SAndroid Build Coastguard Workerif(NOT TEST_NGHTTPX)
28*6236dae4SAndroid Build Coastguard Worker  set(TEST_NGHTTPX "nghttpx")
29*6236dae4SAndroid Build Coastguard Workerendif()
30*6236dae4SAndroid Build Coastguard Workermark_as_advanced(TEST_NGHTTPX)
31*6236dae4SAndroid Build Coastguard Worker# Consumed variables: TEST_NGHTTPX
32*6236dae4SAndroid Build Coastguard Workerconfigure_file("config.in" "${CMAKE_CURRENT_BINARY_DIR}/config" @ONLY)
33*6236dae4SAndroid Build Coastguard Worker
34*6236dae4SAndroid Build Coastguard Workeradd_custom_target(testdeps)
35*6236dae4SAndroid Build Coastguard Workeradd_subdirectory(http)
36*6236dae4SAndroid Build Coastguard Workeradd_subdirectory(http/clients)
37*6236dae4SAndroid Build Coastguard Workeradd_subdirectory(server)
38*6236dae4SAndroid Build Coastguard Workeradd_subdirectory(libtest)
39*6236dae4SAndroid Build Coastguard Workeradd_subdirectory(unit)
40*6236dae4SAndroid Build Coastguard Workeradd_subdirectory(certs EXCLUDE_FROM_ALL)
41*6236dae4SAndroid Build Coastguard Worker
42*6236dae4SAndroid Build Coastguard Workerfunction(add_runtests _targetname _test_flags)
43*6236dae4SAndroid Build Coastguard Worker  if(CURL_TEST_BUNDLES)
44*6236dae4SAndroid Build Coastguard Worker    set(_test_flags "${_test_flags} -bundle")
45*6236dae4SAndroid Build Coastguard Worker  endif()
46*6236dae4SAndroid Build Coastguard Worker  # Skip walking through dependent targets before running tests in CI.
47*6236dae4SAndroid Build Coastguard Worker  # This avoids: GNU Make doing a slow re-evaluation of all targets and
48*6236dae4SAndroid Build Coastguard Worker  # skipping them, MSBuild doing a re-evaluation, and actually rebuilding them.
49*6236dae4SAndroid Build Coastguard Worker  unset(_depends)
50*6236dae4SAndroid Build Coastguard Worker  if(NOT _targetname STREQUAL "test-ci")
51*6236dae4SAndroid Build Coastguard Worker    set(_depends "testdeps")
52*6236dae4SAndroid Build Coastguard Worker  endif()
53*6236dae4SAndroid Build Coastguard Worker  # Use a special '$TFLAGS' placeholder as last argument which will be
54*6236dae4SAndroid Build Coastguard Worker  # replaced by the contents of the environment variable in runtests.pl.
55*6236dae4SAndroid Build Coastguard Worker  # This is a workaround for CMake's limitation where commands executed by
56*6236dae4SAndroid Build Coastguard Worker  # 'make' or 'ninja' cannot portably reference environment variables.
57*6236dae4SAndroid Build Coastguard Worker  string(REPLACE " " ";" _test_flags_list "${_test_flags}")
58*6236dae4SAndroid Build Coastguard Worker  add_custom_target(${_targetname}
59*6236dae4SAndroid Build Coastguard Worker    COMMAND
60*6236dae4SAndroid Build Coastguard Worker      "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runtests.pl"
61*6236dae4SAndroid Build Coastguard Worker      ${_test_flags_list}
62*6236dae4SAndroid Build Coastguard Worker      "\$TFLAGS"
63*6236dae4SAndroid Build Coastguard Worker    DEPENDS "${_depends}"
64*6236dae4SAndroid Build Coastguard Worker    VERBATIM USES_TERMINAL
65*6236dae4SAndroid Build Coastguard Worker  )
66*6236dae4SAndroid Build Coastguard Workerendfunction()
67*6236dae4SAndroid Build Coastguard Worker
68*6236dae4SAndroid Build Coastguard Workerfunction(add_pytest _targetname _test_flags)
69*6236dae4SAndroid Build Coastguard Worker  unset(_depends)
70*6236dae4SAndroid Build Coastguard Worker  if(NOT _targetname STREQUAL "pytest-ci")
71*6236dae4SAndroid Build Coastguard Worker    set(_depends "test-http-clients")
72*6236dae4SAndroid Build Coastguard Worker  endif()
73*6236dae4SAndroid Build Coastguard Worker  string(REPLACE " " ";" _test_flags_list "${_test_flags}")
74*6236dae4SAndroid Build Coastguard Worker  add_custom_target(${_targetname}
75*6236dae4SAndroid Build Coastguard Worker    COMMAND pytest ${_test_flags_list} "${CMAKE_CURRENT_SOURCE_DIR}/http"
76*6236dae4SAndroid Build Coastguard Worker    DEPENDS "${_depends}"
77*6236dae4SAndroid Build Coastguard Worker    VERBATIM USES_TERMINAL
78*6236dae4SAndroid Build Coastguard Worker  )
79*6236dae4SAndroid Build Coastguard Workerendfunction()
80*6236dae4SAndroid Build Coastguard Worker
81*6236dae4SAndroid Build Coastguard Worker# Create configurehelp.pm, used by tests needing to run the C preprocessor.
82*6236dae4SAndroid Build Coastguard Workerif(MSVC OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
83*6236dae4SAndroid Build Coastguard Worker  set(CURL_CPP "\"${CMAKE_C_COMPILER}\" -E")
84*6236dae4SAndroid Build Coastguard Worker  if(APPLE AND CMAKE_OSX_SYSROOT)
85*6236dae4SAndroid Build Coastguard Worker    set(CURL_CPP "${CURL_CPP} -isysroot ${CMAKE_OSX_SYSROOT}")
86*6236dae4SAndroid Build Coastguard Worker  endif()
87*6236dae4SAndroid Build Coastguard Worker  # Add header directories, like autotools builds do.
88*6236dae4SAndroid Build Coastguard Worker  get_property(_include_dirs TARGET ${LIB_SELECTED} PROPERTY INCLUDE_DIRECTORIES)
89*6236dae4SAndroid Build Coastguard Worker  foreach(_include_dir IN LISTS _include_dirs)
90*6236dae4SAndroid Build Coastguard Worker    set(CURL_CPP "${CURL_CPP} -I${_include_dir}")
91*6236dae4SAndroid Build Coastguard Worker  endforeach()
92*6236dae4SAndroid Build Coastguard Workerelse()
93*6236dae4SAndroid Build Coastguard Worker  set(CURL_CPP "cpp")
94*6236dae4SAndroid Build Coastguard Workerendif()
95*6236dae4SAndroid Build Coastguard Worker# Generate version script for the linker, for versioned symbols.
96*6236dae4SAndroid Build Coastguard Worker# Consumed variable:
97*6236dae4SAndroid Build Coastguard Worker#   CURL_CPP
98*6236dae4SAndroid Build Coastguard Workerconfigure_file(
99*6236dae4SAndroid Build Coastguard Worker  "${CMAKE_CURRENT_SOURCE_DIR}/configurehelp.pm.in"
100*6236dae4SAndroid Build Coastguard Worker  "${CMAKE_CURRENT_BINARY_DIR}/configurehelp.pm" @ONLY)
101*6236dae4SAndroid Build Coastguard Worker
102*6236dae4SAndroid Build Coastguard Workeradd_runtests(test-quiet     "-a -s")
103*6236dae4SAndroid Build Coastguard Workeradd_runtests(test-am        "-a -am")
104*6236dae4SAndroid Build Coastguard Workeradd_runtests(test-full      "-a -p -r")
105*6236dae4SAndroid Build Coastguard Worker# ~flaky means that it ignores results of tests using the flaky keyword
106*6236dae4SAndroid Build Coastguard Workeradd_runtests(test-nonflaky  "-a -p ~flaky ~timing-dependent")
107*6236dae4SAndroid Build Coastguard Workeradd_runtests(test-ci        "-a -p ~flaky ~timing-dependent -r -rm -j20")
108*6236dae4SAndroid Build Coastguard Workeradd_runtests(test-torture   "-a -t -j20")
109*6236dae4SAndroid Build Coastguard Workeradd_runtests(test-event     "-a -e")
110*6236dae4SAndroid Build Coastguard Worker
111*6236dae4SAndroid Build Coastguard Workeradd_pytest(curl-pytest      "")
112*6236dae4SAndroid Build Coastguard Workeradd_pytest(curl-pytest-ci   "-v")
113