| 1 |
# |
| 2 |
# Licensed to the Apache Software Foundation (ASF) under one |
| 3 |
# or more contributor license agreements. See the NOTICE file |
| 4 |
# distributed with this work for additional information |
| 5 |
# regarding copyright ownership. The ASF licenses this file |
| 6 |
# to you under the Apache License, Version 2.0 (the |
| 7 |
# "License"); you may not use this file except in compliance |
| 8 |
# with the License. You may obtain a copy of the License at |
| 9 |
# |
| 10 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
# |
| 12 |
# Unless required by applicable law or agreed to in writing, |
| 13 |
# software distributed under the License is distributed on an |
| 14 |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 |
# KIND, either express or implied. See the License for the |
| 16 |
# specific language governing permissions and limitations |
| 17 |
# under the License. |
| 18 |
# |
| 19 |
|
| 20 |
set(testdata "${CMAKE_CURRENT_BINARY_DIR}/testdata") |
| 21 |
set(test_env "") |
| 22 |
|
| 23 |
# SASL configuration for tests |
| 24 |
if(CyrusSASL_Saslpasswd_EXECUTABLE) |
| 25 |
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/testdata/sasl-conf/proton-server.conf.in" |
| 26 |
"${testdata}/sasl-conf/proton-server.conf") |
| 27 |
execute_process( |
| 28 |
COMMAND echo password |
| 29 |
COMMAND ${CyrusSASL_Saslpasswd_EXECUTABLE} -c -p -f "${testdata}/sasl-conf/proton.sasldb" -u proton user |
| 30 |
RESULT_VARIABLE ret) |
| 31 |
if(ret) |
| 32 |
message(WARNING "${CyrusSASL_Saslpasswd_EXECUTABLE}: error ${ret} - some SASL tests will be skipped") |
| 33 |
else() |
| 34 |
set(test_env ${test_env} "PN_SASL_CONFIG_PATH=${testdata}/sasl-conf") |
| 35 |
endif() |
| 36 |
endif() |
| 37 |
|
| 38 |
if (CMAKE_SYSTEM_NAME STREQUAL Windows) |
| 39 |
set(test_env ${test_env} "PATH=$<TARGET_FILE_DIR:qpid-proton>") |
| 40 |
endif() |
| 41 |
|
| 42 |
macro(add_cpp_test test) |
| 43 |
add_executable (${test} src/${test}.cpp) |
| 44 |
target_link_libraries (${test} qpid-proton-cpp ${PLATFORM_LIBS}) |
| 45 |
pn_add_test( |
| 46 |
EXECUTABLE |
| 47 |
NAME cpp-${test} |
| 48 |
APPEND_ENVIRONMENT ${test_env} |
| 49 |
COMMAND $<TARGET_FILE:${test}> |
| 50 |
${ARGN}) |
| 51 |
endmacro(add_cpp_test) |
| 52 |
|
| 53 |
add_cpp_test(codec_test) |
| 54 |
add_cpp_test(connection_driver_test) |
| 55 |
add_cpp_test(interop_test ${CMAKE_SOURCE_DIR}/tests) |
| 56 |
add_cpp_test(message_test) |
| 57 |
add_cpp_test(map_test) |
| 58 |
add_cpp_test(scalar_test) |
| 59 |
add_cpp_test(value_test) |
| 60 |
add_cpp_test(container_test) |
| 61 |
add_cpp_test(reconnect_test) |
| 62 |
add_cpp_test(link_test) |
| 63 |
add_cpp_test(credit_test) |
| 64 |
add_cpp_test(delivery_test) |
| 65 |
if (ENABLE_JSONCPP) |
| 66 |
add_cpp_test(connect_config_test) |
| 67 |
target_link_libraries(connect_config_test qpid-proton-core) # For pn_sasl_enabled |
| 68 |
set_tests_properties(cpp-connect_config_test PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") |
| 69 |
# Test data and output directories for connect_config_test |
| 70 |
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/testdata" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") |
| 71 |
endif() |
| 72 |
|
| 73 |
# TODO aconway 2018-10-31: Catch2 tests |
| 74 |
# This is a simple example of a C++ test using the Catch2 framework. |
| 75 |
# See c/tests/ for more interesting examples. |
| 76 |
# Eventually all the C++ tests will migrate to Catch2. |
| 77 |
|
| 78 |
include_directories(${CMAKE_SOURCE_DIR}/tests/include) |
| 79 |
add_executable(cpp-test src/cpp-test.cpp src/url_test.cpp) |
| 80 |
target_link_libraries(cpp-test qpid-proton-cpp ${PLATFORM_LIBS}) |
| 81 |
# tests that require access to pn_ functions in qpid-proton-core |
| 82 |
add_executable(cpp-core-test src/cpp-test.cpp src/object_test.cpp) |
| 83 |
target_link_libraries(cpp-core-test qpid-proton-cpp qpid-proton-core ${PLATFORM_LIBS}) |
| 84 |
|
| 85 |
macro(add_catch_test tag) |
| 86 |
pn_add_test( |
| 87 |
EXECUTABLE |
| 88 |
NAME cpp-${tag}-test |
| 89 |
APPEND_ENVIRONMENT ${test_env} |
| 90 |
COMMAND $<TARGET_FILE:cpp-test> "[${tag}]") |
| 91 |
set_tests_properties(cpp-${tag}-test PROPERTIES FAIL_REGULAR_EXPRESSION ".*No tests ran.*") |
| 92 |
endmacro(add_catch_test) |
| 93 |
|
| 94 |
macro(add_core_catch_test tag) |
| 95 |
pn_add_test( |
| 96 |
EXECUTABLE |
| 97 |
NAME cpp-${tag}-test |
| 98 |
APPEND_ENVIRONMENT ${test_env} |
| 99 |
COMMAND $<TARGET_FILE:cpp-core-test> "[${tag}]") |
| 100 |
set_tests_properties(cpp-${tag}-test PROPERTIES FAIL_REGULAR_EXPRESSION ".*No tests ran.*") |
| 101 |
endmacro(add_core_catch_test) |
| 102 |
|
| 103 |
add_catch_test(url) |
| 104 |
add_core_catch_test(object) |