CCF/CMakeLists.txt

1445 строки
43 KiB
CMake

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache 2.0 License.
cmake_minimum_required(VERSION 3.16)
set(ALLOWED_TARGETS "snp;virtual")
set(COMPILE_TARGET
"snp"
CACHE STRING
"Target compilation platforms, Choose from: ${ALLOWED_TARGETS}"
)
set(CCF_DIR ${CMAKE_CURRENT_SOURCE_DIR})
include(${CCF_DIR}/cmake/preproject.cmake)
include(${CCF_DIR}/cmake/version.cmake)
project(
${CCF_PROJECT}
VERSION ${CCF_RELEASE_VERSION}
LANGUAGES C CXX
)
message(STATUS "CCF version = ${CCF_VERSION}")
message(STATUS "CCF release version = ${CCF_RELEASE_VERSION}")
message(STATUS "CCF version suffix = ${CCF_VERSION_SUFFIX}")
# Set the default install prefix for CCF. Users may override this value with the
# cmake command. For example:
#
# $ cmake -DCMAKE_INSTALL_PREFIX=/opt/myplace ..
#
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX
"/opt/${CCF_PROJECT}"
CACHE PATH "Default install prefix" FORCE
)
endif()
include(${CCF_DIR}/cmake/cpack_settings.cmake)
message(STATUS "CMAKE_INSTALL_PREFIX is '${CMAKE_INSTALL_PREFIX}'")
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/preproject.cmake
DESTINATION cmake
)
include(GNUInstallDirs)
set(CMAKE_MODULE_PATH "${CCF_DIR}/cmake;${CMAKE_MODULE_PATH}")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(Threads REQUIRED)
function(message)
if(NOT MESSAGE_QUIET)
_message(${ARGN})
endif()
endfunction()
option(PROFILE_TESTS "Profile tests" OFF)
set(PYTHON python3)
set(DISTRIBUTE_PERF_TESTS
""
CACHE
STRING
"Hosts to which performance tests should be distributed, for example -n ssh://x.x.x.x -n ssh://x.x.x.x -n ssh://x.x.x.x"
)
if(DISTRIBUTE_PERF_TESTS)
separate_arguments(NODES UNIX_COMMAND ${DISTRIBUTE_PERF_TESTS})
else()
unset(NODES)
endif()
option(
VERBOSE_LOGGING
"Enable verbose, potentially unsafe logging of enclave code. Affects logging level passed at run-time to end-to-end-tests."
OFF
)
set(TEST_LOGGING_LEVEL "info")
if(VERBOSE_LOGGING)
set(TEST_LOGGING_LEVEL "trace")
endif()
option(USE_NULL_ENCRYPTOR "Turn off encryption of ledger updates - debug only"
OFF
)
if(USE_NULL_ENCRYPTOR)
add_compile_definitions(USE_NULL_ENCRYPTOR)
endif()
option(SAN "Enable Address and Undefined Behavior Sanitizers" OFF)
option(BUILD_END_TO_END_TESTS "Build end to end tests" ON)
option(COVERAGE "Enable coverage mapping" OFF)
option(SHUFFLE_SUITE "Shuffle end to end test suite" OFF)
option(LONG_TESTS "Enable long end-to-end tests" OFF)
option(KV_STATE_RB "Enable RBMap as underlying KV state implementation" OFF)
if(KV_STATE_RB)
add_compile_definitions(KV_STATE_RB)
endif()
# This option controls whether to link virtual builds against snmalloc rather
# than use the system allocator. In builds using Open Enclave, enclave
# allocation is managed separately and enabling snmalloc is done by linking
# openenclave::oesnmalloc
option(USE_SNMALLOC "Link virtual build against snmalloc" ON)
# Default inherited from Open Enclave usage
option(USE_LIBCXX "Use libc++ instead of libstdc++" ON)
enable_language(ASM)
set(CCF_GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated)
include_directories(${CCF_DIR}/include)
include_directories(${CCF_DIR}/src)
set(CCF_3RD_PARTY_EXPORTED_DIR "${CCF_DIR}/3rdparty/exported")
set(CCF_3RD_PARTY_INTERNAL_DIR "${CCF_DIR}/3rdparty/internal")
include_directories(SYSTEM ${CCF_3RD_PARTY_EXPORTED_DIR})
include_directories(SYSTEM ${CCF_3RD_PARTY_INTERNAL_DIR})
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/tools.cmake)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/tools.cmake DESTINATION cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ccf_app.cmake)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ccf_app.cmake DESTINATION cmake)
if(SAN AND LVI_MITIGATIONS)
message(
FATAL_ERROR
"Building with both SAN and LVI mitigations is unsafe and deadlocks - choose one"
)
endif()
if(TSAN AND LVI_MITIGATIONS)
message(
FATAL_ERROR
"Building with both TSAN and LVI mitigations is unsafe and deadlocks - choose one"
)
endif()
# Copy and install CCF utilities
set(CCF_UTILITIES keygenerator.sh submit_recovery_share.sh verify_quote.sh)
foreach(UTILITY ${CCF_UTILITIES})
configure_file(
${CCF_DIR}/python/utils/${UTILITY} ${CMAKE_CURRENT_BINARY_DIR} COPYONLY
)
install(PROGRAMS ${CCF_DIR}/python/utils/${UTILITY} DESTINATION bin)
endforeach()
# Copy utilities from tests directory
set(CCF_TEST_UTILITIES tests.sh convert_pico_to_bencher.py test_install.sh
docker_wrap.sh config.jinja recovery_benchmark.sh
)
foreach(UTILITY ${CCF_TEST_UTILITIES})
configure_file(
${CCF_DIR}/tests/${UTILITY} ${CMAKE_CURRENT_BINARY_DIR} COPYONLY
)
endforeach()
# Install additional utilities
install(PROGRAMS ${CCF_DIR}/samples/scripts/snpinfo.sh DESTINATION bin)
install(FILES ${CCF_DIR}/tests/config.jinja DESTINATION bin)
if(SAN)
install(FILES ${CCF_DIR}/src/san_common.suppressions DESTINATION bin)
endif()
# Install getting_started scripts for VM creation and setup
install(
DIRECTORY ${CCF_DIR}/getting_started/
DESTINATION getting_started
USE_SOURCE_PERMISSIONS
)
if(COMPILE_TARGET STREQUAL "snp")
set(INSTALL_VIRTUAL_LIBRARIES OFF)
else()
set(INSTALL_VIRTUAL_LIBRARIES ON)
endif()
set(HTTP_PARSER_SOURCES
${CCF_3RD_PARTY_EXPORTED_DIR}/llhttp/api.c
${CCF_3RD_PARTY_EXPORTED_DIR}/llhttp/http.c
${CCF_3RD_PARTY_EXPORTED_DIR}/llhttp/llhttp.c
)
set(CCF_ENDPOINTS_SOURCES
${CCF_DIR}/src/endpoints/endpoint.cpp
${CCF_DIR}/src/endpoints/endpoint_registry.cpp
${CCF_DIR}/src/endpoints/base_endpoint_registry.cpp
${CCF_DIR}/src/endpoints/common_endpoint_registry.cpp
${CCF_DIR}/src/endpoints/user_endpoint_registry.cpp
${CCF_DIR}/src/endpoints/json_handler.cpp
${CCF_DIR}/src/endpoints/authentication/cose_auth.cpp
${CCF_DIR}/src/endpoints/authentication/cert_auth.cpp
${CCF_DIR}/src/endpoints/authentication/empty_auth.cpp
${CCF_DIR}/src/endpoints/authentication/jwt_auth.cpp
${CCF_DIR}/src/endpoints/authentication/all_of_auth.cpp
${CCF_DIR}/src/endpoints/endpoint_utils.cpp
${CCF_DIR}/src/enclave/enclave_time.cpp
${CCF_DIR}/src/indexing/strategies/seqnos_by_key_bucketed.cpp
${CCF_DIR}/src/indexing/strategies/seqnos_by_key_in_memory.cpp
${CCF_DIR}/src/indexing/strategies/visit_each_entry_in_map.cpp
${CCF_DIR}/src/node/historical_queries_adapter.cpp
${CCF_DIR}/src/node/historical_queries_utils.cpp
${CCF_DIR}/src/node/receipt.cpp
)
include(${CCF_DIR}/cmake/crypto.cmake)
include(${CCF_DIR}/cmake/quickjs.cmake)
include(${CCF_DIR}/cmake/sss.cmake)
include(${CCF_DIR}/cmake/nghttp2.cmake)
include(${CCF_DIR}/cmake/qcbor.cmake)
include(${CCF_DIR}/cmake/t_cose.cmake)
# Host Executable
if(SAN
OR TSAN
OR NOT USE_SNMALLOC
)
set(SNMALLOC_COMPILE_OPTIONS "")
else()
set(SNMALLOC_HEADER_ONLY_LIBRARY ON)
add_subdirectory(3rdparty/exported/snmalloc EXCLUDE_FROM_ALL)
set(SNMALLOC_COMPILE_OPTIONS "-mcx16")
list(APPEND CCHOST_SOURCES src/host/snmalloc.cpp)
endif()
list(APPEND CCHOST_SOURCES ${CCF_DIR}/src/host/main.cpp
${CCF_DIR}/src/host/env.cpp
)
add_executable(cchost ${CCHOST_SOURCES})
add_warning_checks(cchost)
add_san(cchost)
target_compile_options(
cchost PRIVATE ${COMPILE_LIBCXX} ${SNMALLOC_COMPILE_OPTIONS}
)
target_include_directories(cchost PRIVATE ${CCF_GENERATED_DIR})
if(COMPILE_TARGET STREQUAL "snp")
target_compile_definitions(cchost PUBLIC PLATFORM_SNP)
elseif(COMPILE_TARGET STREQUAL "virtual")
target_compile_definitions(cchost PUBLIC PLATFORM_VIRTUAL)
endif()
target_link_libraries(
cchost PRIVATE uv ${TLS_LIBRARY} ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT}
${LINK_LIBCXX} ccfcrypto.host
)
install(TARGETS cchost DESTINATION bin)
# HTTP parser
if(COMPILE_TARGET STREQUAL "snp")
add_library(http_parser.snp "${HTTP_PARSER_SOURCES}")
set_property(TARGET http_parser.snp PROPERTY POSITION_INDEPENDENT_CODE ON)
install(
TARGETS http_parser.snp
EXPORT ccf
DESTINATION lib
)
endif()
add_library(http_parser.host "${HTTP_PARSER_SOURCES}")
set_property(TARGET http_parser.host PROPERTY POSITION_INDEPENDENT_CODE ON)
if(INSTALL_VIRTUAL_LIBRARIES)
install(
TARGETS http_parser.host
EXPORT ccf
DESTINATION lib
)
endif()
# CCF js libs
set(CCF_JS_SOURCES
${CCF_DIR}/src/js/global_class_ids.cpp
${CCF_DIR}/src/js/core/wrapped_value.cpp
${CCF_DIR}/src/js/core/runtime.cpp
${CCF_DIR}/src/js/core/context.cpp
${CCF_DIR}/src/js/no_plugins.cpp
${CCF_DIR}/src/js/ffi_plugins.cpp
${CCF_DIR}/src/js/extensions/console.cpp
${CCF_DIR}/src/js/extensions/math/random.cpp
${CCF_DIR}/src/js/extensions/snp_attestation.cpp
${CCF_DIR}/src/js/extensions/ccf/consensus.cpp
${CCF_DIR}/src/js/extensions/ccf/converters.cpp
${CCF_DIR}/src/js/extensions/ccf/crypto.cpp
${CCF_DIR}/src/js/extensions/ccf/gov_effects.cpp
${CCF_DIR}/src/js/extensions/ccf/historical.cpp
${CCF_DIR}/src/js/extensions/ccf/host.cpp
${CCF_DIR}/src/js/extensions/ccf/kv.cpp
${CCF_DIR}/src/js/extensions/ccf/network.cpp
${CCF_DIR}/src/js/extensions/ccf/node.cpp
${CCF_DIR}/src/js/extensions/ccf/rpc.cpp
${CCF_DIR}/src/js/extensions/ccf/request.cpp
${CCF_DIR}/src/js/registry.cpp
)
set(OE_BINDIR "")
if(COMPILE_TARGET STREQUAL "snp")
add_host_library(ccf_js.snp "${CCF_JS_SOURCES}")
add_san(ccf_js.snp)
target_link_libraries(ccf_js.snp PUBLIC ccfcrypto.snp quickjs.snp)
add_warning_checks(ccf_js.snp)
install(
TARGETS ccf_js.snp
EXPORT ccf
DESTINATION lib
)
endif()
add_host_library(ccf_js.host "${CCF_JS_SOURCES}")
add_san(ccf_js.host)
target_link_libraries(ccf_js.host PUBLIC ccfcrypto.host quickjs.host)
add_warning_checks(ccf_js.host)
if(INSTALL_VIRTUAL_LIBRARIES)
install(
TARGETS ccf_js.host
EXPORT ccf
DESTINATION lib
)
endif()
# CCF kv libs
set(CCF_KV_SOURCES
${CCF_DIR}/src/kv/tx.cpp ${CCF_DIR}/src/kv/untyped_map_handle.cpp
${CCF_DIR}/src/kv/untyped_map_diff.cpp
)
if(COMPILE_TARGET STREQUAL "snp")
add_host_library(ccf_kv.snp "${CCF_KV_SOURCES}")
add_san(ccf_kv.snp)
add_warning_checks(ccf_kv.snp)
install(
TARGETS ccf_kv.snp
EXPORT ccf
DESTINATION lib
)
endif()
add_host_library(ccf_kv.host "${CCF_KV_SOURCES}")
add_san(ccf_kv.host)
add_warning_checks(ccf_kv.host)
if(INSTALL_VIRTUAL_LIBRARIES)
install(
TARGETS ccf_kv.host
EXPORT ccf
DESTINATION lib
)
endif()
# CCF endpoints libs
if(COMPILE_TARGET STREQUAL "snp")
add_host_library(ccf_endpoints.snp "${CCF_ENDPOINTS_SOURCES}")
target_include_directories(ccf_endpoints.snp PRIVATE ${CCF_DIR}/src/endpoints)
target_link_libraries(
ccf_endpoints.snp PUBLIC qcbor.snp t_cose.snp http_parser.snp ccfcrypto.snp
ccf_kv.snp
)
add_san(ccf_endpoints.snp)
add_warning_checks(ccf_endpoints.snp)
install(
TARGETS ccf_endpoints.snp
EXPORT ccf
DESTINATION lib
)
endif()
add_host_library(ccf_endpoints.host "${CCF_ENDPOINTS_SOURCES}")
target_include_directories(ccf_endpoints.host PRIVATE ${CCF_DIR}/src/endpoints)
target_link_libraries(
ccf_endpoints.host PUBLIC qcbor.host t_cose.host http_parser.host
ccfcrypto.host ccf_kv.host
)
add_san(ccf_endpoints.host)
add_warning_checks(ccf_endpoints.host)
if(INSTALL_VIRTUAL_LIBRARIES)
install(
TARGETS ccf_endpoints.host
EXPORT ccf
DESTINATION lib
)
endif()
# Common test args for Python scripts starting up CCF networks
set(WORKER_THREADS
0
CACHE STRING "Number of worker threads to start on each CCF node"
)
set(CCF_NETWORK_TEST_DEFAULT_CONSTITUTION
--constitution
${CCF_DIR}/samples/constitutions/default/actions.js
--constitution
${CCF_DIR}/samples/constitutions/default/validate.js
--constitution
${CCF_DIR}/samples/constitutions/default/resolve.js
--constitution
${CCF_DIR}/samples/constitutions/default/apply.js
)
set(CCF_NETWORK_TEST_ARGS
--host-log-level ${TEST_LOGGING_LEVEL} --enclave-log-level
${TEST_LOGGING_LEVEL} --worker-threads ${WORKER_THREADS}
)
set(JS_GENERIC_SOURCES ${CCF_DIR}/src/apps/js_generic/js_generic_base.cpp)
if(COMPILE_TARGET STREQUAL "snp")
add_library(js_generic_base.snp STATIC ${JS_GENERIC_SOURCES})
add_san(js_generic_base.snp)
add_warning_checks(js_generic_base.snp)
target_link_libraries(js_generic_base.snp PUBLIC ccf.snp)
target_compile_options(js_generic_base.snp PRIVATE ${COMPILE_LIBCXX})
target_compile_definitions(
js_generic_base.snp PUBLIC INSIDE_ENCLAVE VIRTUAL_ENCLAVE
_LIBCPP_HAS_THREAD_API_PTHREAD PLATFORM_SNP
)
set_property(TARGET js_generic_base.snp PROPERTY POSITION_INDEPENDENT_CODE ON)
install(
TARGETS js_generic_base.snp
EXPORT ccf
DESTINATION lib
)
elseif(COMPILE_TARGET STREQUAL "virtual")
add_library(js_generic_base.virtual STATIC ${JS_GENERIC_SOURCES})
add_san(js_generic_base.virtual)
add_warning_checks(js_generic_base.virtual)
target_link_libraries(js_generic_base.virtual PUBLIC ccf.virtual)
target_compile_options(js_generic_base.virtual PRIVATE ${COMPILE_LIBCXX})
set_property(
TARGET js_generic_base.virtual PROPERTY POSITION_INDEPENDENT_CODE ON
)
install(
TARGETS js_generic_base.virtual
EXPORT ccf
DESTINATION lib
)
endif()
# SNIPPET_START: JS generic application
add_ccf_app(
js_generic
SRCS ${CCF_DIR}/src/apps/js_generic/js_generic.cpp
LINK_LIBS_ENCLAVE js_generic_base.enclave
LINK_LIBS_VIRTUAL js_generic_base.virtual
LINK_LIBS_SNP js_generic_base.snp INSTALL_LIBS ON
)
# SNIPPET_END: JS generic application
install(DIRECTORY ${CCF_DIR}/samples/apps/logging/js
DESTINATION samples/logging
)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common.cmake)
file(WRITE ${CMAKE_BINARY_DIR}/PLATFORM "${COMPILE_TARGET}")
install(FILES ${CMAKE_BINARY_DIR}/PLATFORM DESTINATION share)
set(CMAKE_GENERATED_COMMENT
"This file was auto-generated by CMake from a corresponding *.in file. DO NOT EDIT"
)
configure_file(
${CCF_DIR}/src/common/version.h.in ${CCF_DIR}/include/ccf/version.h @ONLY
)
install(FILES ${CCF_DIR}/include/ccf/version.h DESTINATION include/ccf)
file(READ ${CCF_DIR}/doc/host_config_schema/cchost_config.json
HOST_CONFIG_SCHEMA
)
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS
${CCF_DIR}/doc/host_config_schema/cchost_config.json
)
configure_file(
${CCF_DIR}/src/host/config_schema.h.in ${CCF_DIR}/src/host/config_schema.h
@ONLY
)
file(READ ${CCF_DIR}/doc/schemas/gov/2023-06-01-preview/gov.json
GOV_API_SCHEMA_2023_06_01_PREVIEW
)
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS
${CCF_DIR}/doc/schemas/gov/2023-06-01-preview/gov.json
)
file(READ ${CCF_DIR}/doc/schemas/gov/2024-07-01/gov.json
GOV_API_SCHEMA_2024_07_01
)
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS
${CCF_DIR}/doc/schemas/gov/2024-07-01/gov.json
)
configure_file(
${CCF_DIR}/src/node/gov/api_schema.h.in ${CCF_DIR}/src/node/gov/api_schema.h
@ONLY
)
option(BUILD_TESTS "Build tests" ON)
option(BUILD_UNIT_TESTS "Build unit tests" ON)
option(CLIENT_PROTOCOLS_TEST "Test client protocols (TLS, HTTP/2)" OFF)
option(BUILD_TPCC "Build TPPC sample app and clients" OFF)
option(
FORCE_ENABLE_XAPIC_MITIGATION
"Always enable aligned reads from host-memory to mitigate xAPIC stale data read vulnerability. When this setting is off, the mitigation is enabled at run-time when vulnerable hardware is detected"
OFF
)
# Allow framework code to use LOG_*_FMT macros. These will be removed from
# public headers in future
add_compile_definitions(CCF_LOGGER_NO_DEPRECATE)
option(CCF_RAFT_TRACING "Enable tracing of Raft consensus" OFF)
if(CCF_RAFT_TRACING)
add_compile_definitions(CCF_RAFT_TRACING)
endif()
# Build common library for CCF enclaves
add_custom_target(ccf ALL)
set(CCF_IMPL_SOURCE
${CCF_DIR}/src/enclave/main.cpp ${CCF_DIR}/src/enclave/enclave_time.cpp
${CCF_DIR}/src/enclave/thread_local.cpp ${CCF_DIR}/src/node/quote.cpp
)
# Same as virtual for the time being but will diverge soon
if(COMPILE_TARGET STREQUAL "snp")
# SNP version
add_library(ccf.snp STATIC ${CCF_IMPL_SOURCE})
target_compile_definitions(
ccf.snp PUBLIC INSIDE_ENCLAVE VIRTUAL_ENCLAVE
_LIBCPP_HAS_THREAD_API_PTHREAD PLATFORM_SNP
)
target_compile_options(ccf.snp PUBLIC ${COMPILE_LIBCXX})
add_warning_checks(ccf.snp)
target_include_directories(
ccf.snp SYSTEM
PUBLIC
$<BUILD_INTERFACE:${CCF_GENERATED_DIR}>
$<INSTALL_INTERFACE:include/ccf/> #< This contains the private headers
#< which are currently under src, and
#< should be removed or renamed
$<INSTALL_INTERFACE:include/>
$<INSTALL_INTERFACE:include/3rdparty/>
)
target_link_libraries(
ccf.snp
PUBLIC ${LINK_LIBCXX}
-lgcc
http_parser.snp
sss.snp
ccf_js.snp
ccf_endpoints.snp
ccfcrypto.snp
ccf_kv.snp
nghttp2.snp
${CMAKE_THREAD_LIBS_INIT}
)
set_property(TARGET ccf.snp PROPERTY POSITION_INDEPENDENT_CODE ON)
add_san(ccf.snp)
install(
TARGETS ccf.snp
EXPORT ccf
DESTINATION lib
)
add_dependencies(ccf ccf.snp)
elseif(COMPILE_TARGET STREQUAL "virtual")
# virtual version
add_library(ccf.virtual STATIC ${CCF_IMPL_SOURCE})
target_compile_definitions(
ccf.virtual PUBLIC INSIDE_ENCLAVE VIRTUAL_ENCLAVE
_LIBCPP_HAS_THREAD_API_PTHREAD PLATFORM_VIRTUAL
)
target_compile_options(ccf.virtual PUBLIC ${COMPILE_LIBCXX})
add_warning_checks(ccf.virtual)
target_include_directories(
ccf.virtual SYSTEM
PUBLIC
$<BUILD_INTERFACE:${CCF_GENERATED_DIR}>
$<INSTALL_INTERFACE:include/ccf/> #< This contains the private headers
#< which are currently under src, and
#< should be removed or renamed
$<INSTALL_INTERFACE:include/>
$<INSTALL_INTERFACE:include/3rdparty/>
)
target_link_libraries(
ccf.virtual
PUBLIC ${LINK_LIBCXX}
-lgcc
http_parser.host
sss.host
ccf_js.host
ccf_endpoints.host
ccfcrypto.host
ccf_kv.host
nghttp2.host
${CMAKE_THREAD_LIBS_INIT}
)
set_property(TARGET ccf.virtual PROPERTY POSITION_INDEPENDENT_CODE ON)
add_san(ccf.virtual)
install(
TARGETS ccf.virtual
EXPORT ccf
DESTINATION lib
)
add_dependencies(ccf ccf.virtual)
endif()
install(
EXPORT ccf
DESTINATION cmake
FILE ccf-targets.cmake
)
# Install exported 3rd-party library includes
install(
DIRECTORY 3rdparty/exported/
DESTINATION include/3rdparty
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
PATTERN "*.inc"
)
# Install all private CCF headers, which may still be needed
install(
DIRECTORY src/
DESTINATION include/ccf/_private
FILES_MATCHING
PATTERN "*.h"
PATTERN "*/test*" EXCLUDE
)
# Install all public CCF headers
install(
DIRECTORY include/
DESTINATION include
FILES_MATCHING
PATTERN "*.h"
)
# Install CCF Python infrastructure
install(
DIRECTORY tests/infra/
DESTINATION bin/infra
FILES_MATCHING
PATTERN "*.py"
PATTERN "*/__pycache__*" EXCLUDE
)
install(PROGRAMS tests/sandbox/sandbox.sh DESTINATION bin)
install(PROGRAMS tests/docker_wrap.sh DESTINATION bin)
install(FILES samples/constitutions/default/actions.js DESTINATION bin)
install(FILES samples/constitutions/default/validate.js DESTINATION bin)
install(FILES samples/constitutions/sandbox/resolve.js DESTINATION bin)
install(FILES samples/constitutions/default/apply.js DESTINATION bin)
install(FILES tests/start_network.py DESTINATION bin)
install(FILES tests/requirements.txt DESTINATION bin)
# Add sample apps
add_subdirectory(${CCF_DIR}/samples)
if(BUILD_TESTS)
enable_testing()
# Unit tests
if(BUILD_UNIT_TESTS)
add_unit_test(map_test ${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/map_test.cpp)
add_unit_test(
json_schema ${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/json_schema.cpp
)
add_unit_test(
logger_test ${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/logger.cpp
)
add_unit_test(
openapi_test ${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/openapi.cpp
)
target_link_libraries(openapi_test PRIVATE http_parser.host)
add_unit_test(
logger_json_test
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/logger_json_test.cpp
)
add_unit_test(
kv_test
${CMAKE_CURRENT_SOURCE_DIR}/src/kv/test/kv_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/kv/test/kv_contention.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/kv/test/kv_serialisation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/kv/test/kv_snapshot.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/kv/test/kv_dynamic_tables.cpp
)
target_link_libraries(
kv_test PRIVATE ${CMAKE_THREAD_LIBS_INIT} http_parser.host ccf_kv.host
)
add_unit_test(
ds_test
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/ring_buffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/messaging.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/oversized.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/typed_messages.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/serialized.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/serializer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/hash.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/thread_messaging.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/lru.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/hex.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/contiguous_set.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/unit_strings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/dl_list.cpp
)
target_link_libraries(ds_test PRIVATE ${CMAKE_THREAD_LIBS_INIT})
add_unit_test(
ledger_test ${CMAKE_CURRENT_SOURCE_DIR}/src/host/test/ledger.cpp
)
add_unit_test(
raft_test ${CMAKE_CURRENT_SOURCE_DIR}/src/consensus/aft/test/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/consensus/aft/test/view_history.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/consensus/aft/test/committable_suffix.cpp
)
target_link_libraries(raft_test PRIVATE ccfcrypto.host)
add_unit_test(
raft_enclave_test
${CMAKE_CURRENT_SOURCE_DIR}/src/consensus/aft/test/enclave.cpp
)
target_include_directories(raft_enclave_test PRIVATE ${CCFCRYPTO_INC})
target_link_libraries(raft_enclave_test PRIVATE ccfcrypto.host)
add_unit_test(
crypto_test ${CMAKE_CURRENT_SOURCE_DIR}/src/crypto/test/crypto.cpp
)
target_include_directories(crypto_test PRIVATE ${CCFCRYPTO_INC})
target_link_libraries(crypto_test PRIVATE ccfcrypto.host)
add_unit_test(
sharing_test
${CMAKE_CURRENT_SOURCE_DIR}/src/crypto/test/secret_sharing.cpp
)
target_include_directories(sharing_test PRIVATE ${CCFCRYPTO_INC})
target_link_libraries(sharing_test PRIVATE ccfcrypto.host)
add_unit_test(
key_exchange_test
${CMAKE_CURRENT_SOURCE_DIR}/src/crypto/test/key_exchange.cpp
)
target_link_libraries(key_exchange_test PRIVATE)
add_unit_test(
history_test ${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/history.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/enclave/enclave_time.cpp
)
target_link_libraries(
history_test PRIVATE ccfcrypto.host http_parser.host ccf_kv.host
)
add_unit_test(
secret_sharing_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/secret_share.cpp
)
target_link_libraries(secret_sharing_test PRIVATE sss.host)
add_unit_test(
encryptor_test ${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/encryptor.cpp
)
target_link_libraries(encryptor_test PRIVATE ccfcrypto.host ccf_kv.host)
add_unit_test(js_test ${CMAKE_CURRENT_SOURCE_DIR}/src/js/test/js.cpp)
target_link_libraries(
js_test PRIVATE ccf_js.host ccf_kv.host ccf_endpoints.host ccfcrypto.host
http_parser.host
)
add_unit_test(
endorsements_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/endorsements.cpp
)
set_property(
TEST endorsements_test
APPEND
PROPERTY
ENVIRONMENT
"TEST_ENDORSEMENTS_PATH=${CMAKE_CURRENT_SOURCE_DIR}/tests/uvm_endorsements"
)
add_unit_test(
historical_queries_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/historical_queries.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/receipt.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/node/receipt.cpp
)
target_link_libraries(
historical_queries_test PRIVATE http_parser.host sss.host ccf_kv.host
ccf_endpoints.host
)
# Temporarily disabled flaky test
# https://github.com/microsoft/CCF/issues/4403 add_unit_test( indexing_test
# ${CMAKE_CURRENT_SOURCE_DIR}/src/indexing/test/indexing.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/src/indexing/test/lfs.cpp )
# target_link_libraries( indexing_test PRIVATE ccf_endpoints.host sss.host
# ccf_kv.host ) target_link_libraries( indexing_test PRIVATE
# ccf_endpoints.host sss.host ccf_kv.host )
add_unit_test(
snapshot_test ${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/snapshot.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/enclave/enclave_time.cpp
)
target_link_libraries(snapshot_test PRIVATE ccf_kv.host)
add_unit_test(
snapshotter_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/snapshotter.cpp
)
target_link_libraries(
snapshotter_test PRIVATE ccf_kv.host ccf_endpoints.host
)
add_unit_test(
node_info_json_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/node_info_json.cpp
)
add_unit_test(tls_test ${CMAKE_CURRENT_SOURCE_DIR}/src/tls/test/main.cpp)
target_link_libraries(tls_test PRIVATE ${CMAKE_THREAD_LIBS_INIT})
add_unit_test(
base64_test ${CMAKE_CURRENT_SOURCE_DIR}/src/crypto/test/base64.cpp
)
target_link_libraries(base64_test PRIVATE ${CMAKE_THREAD_LIBS_INIT})
add_unit_test(
cose_test ${CMAKE_CURRENT_SOURCE_DIR}/src/crypto/test/cose.cpp
)
target_link_libraries(
cose_test PRIVATE ${CMAKE_THREAD_LIBS_INIT} ccfcrypto.host qcbor.host
)
add_unit_test(pem_test ${CMAKE_CURRENT_SOURCE_DIR}/src/crypto/test/pem.cpp)
target_link_libraries(pem_test PRIVATE ${CMAKE_THREAD_LIBS_INIT})
add_test_bin(
kp_cert_test ${CMAKE_CURRENT_SOURCE_DIR}/src/crypto/test/kp_cert.cpp
)
target_link_libraries(kp_cert_test PRIVATE ${CMAKE_THREAD_LIBS_INIT})
add_unit_test(
channels_test ${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/channels.cpp
)
target_link_libraries(channels_test PRIVATE)
add_unit_test(
http_test ${CMAKE_CURRENT_SOURCE_DIR}/src/http/test/http_test.cpp
)
target_link_libraries(http_test PRIVATE http_parser.host)
add_unit_test(
http_etag_test
${CMAKE_CURRENT_SOURCE_DIR}/src/http/test/http_etag_test.cpp
)
add_unit_test(
frontend_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/rpc/test/frontend_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/enclave/enclave_time.cpp
${CCF_DIR}/src/node/quote.cpp
)
target_link_libraries(
frontend_test
PRIVATE ${CMAKE_THREAD_LIBS_INIT}
http_parser.host
sss.host
ccf_js.host
ccf_endpoints.host
ccfcrypto.host
ccf_kv.host
)
add_unit_test(
endpoint_registry_test
${CMAKE_CURRENT_SOURCE_DIR}/src/endpoints/test/endpoint_registry.cpp
)
target_include_directories(
endpoint_registry_test PRIVATE ${CCF_DIR}/src/endpoints
)
target_link_libraries(endpoint_registry_test PRIVATE ccf_endpoints.host)
add_unit_test(
jwt_auth_test
${CMAKE_CURRENT_SOURCE_DIR}/src/endpoints/test/test_jwt_auth.cpp
)
target_link_libraries(jwt_auth_test PRIVATE ccf_endpoints.host)
add_unit_test(
tx_status_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/rpc/test/tx_status_test.cpp
)
add_unit_test(
node_frontend_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/rpc/test/node_frontend_test.cpp
${CCF_DIR}/src/node/quote.cpp
)
target_link_libraries(
node_frontend_test
PRIVATE ${CMAKE_THREAD_LIBS_INIT}
http_parser.host
sss.host
ccf_js.host
ccf_endpoints.host
ccfcrypto.host
ccf_kv.host
)
add_unit_test(
merkle_test ${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/merkle_test.cpp
)
# Merkle Tree memory test
add_executable(merkle_mem src/node/test/merkle_mem.cpp)
target_compile_options(merkle_mem PRIVATE ${COMPILE_LIBCXX})
target_link_libraries(
merkle_mem PRIVATE ${CMAKE_THREAD_LIBS_INIT} ${LINK_LIBCXX}
ccfcrypto.host
)
# Raft driver and scenario test
add_executable(
raft_driver ${CMAKE_CURRENT_SOURCE_DIR}/src/consensus/aft/test/driver.cpp
src/enclave/thread_local.cpp
)
target_link_libraries(raft_driver PRIVATE ccfcrypto.host)
target_include_directories(raft_driver PRIVATE src/aft)
add_test(
NAME raft_scenario_test
COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/tests/raft_scenarios_runner.py
./raft_driver ${CMAKE_SOURCE_DIR}/tests/raft_scenarios/
)
set_property(TEST raft_scenario_test PROPERTY LABELS raft_scenario)
add_test(NAME csr_test COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/tests/certs.py
./kp_cert_test
)
set_property(
TEST csr_test
APPEND
PROPERTY LABELS unit_test
)
# https://github.com/microsoft/CCF/issues/5198
set_property(
TEST csr_test
APPEND
PROPERTY ENVIRONMENT "ASAN_OPTIONS=alloc_dealloc_mismatch=0"
)
add_test(NAME versionifier_test
COMMAND ${PYTHON}
${CMAKE_SOURCE_DIR}/python/src/ccf/_versionifier.py
)
add_test(NAME github_version_lts_test
COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/tests/infra/github.py
)
endif()
if(NOT TSAN)
# Picobench benchmarks
add_picobench(map_bench SRCS src/ds/test/map_bench.cpp)
add_picobench(logger_bench SRCS src/ds/test/logger_bench.cpp)
add_picobench(json_bench SRCS src/ds/test/json_bench.cpp)
add_picobench(ring_buffer_bench SRCS src/ds/test/ring_buffer_bench.cpp)
add_picobench(
crypto_bench
SRCS src/crypto/test/bench.cpp
LINK_LIBS
)
add_picobench(
history_bench
SRCS src/node/test/history_bench.cpp src/enclave/thread_local.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/enclave/enclave_time.cpp
LINK_LIBS ccf_kv.host
)
add_picobench(
kv_bench
SRCS src/kv/test/kv_bench.cpp src/enclave/thread_local.cpp
LINK_LIBS ccf_kv.host
)
add_picobench(merkle_bench SRCS src/node/test/merkle_bench.cpp)
add_picobench(hash_bench SRCS src/ds/test/hash_bench.cpp)
if(LONG_TESTS)
set(ADDITIONAL_RECOVERY_ARGS --with-load)
add_e2e_test(
NAME recovery_test_cft_api_0
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/recovery.py
ADDITIONAL_ARGS ${ADDITIONAL_RECOVERY_ARGS} --gov-api-version "classic"
)
endif()
add_e2e_test(
NAME recovery_test_cft_api_1
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/recovery.py
ADDITIONAL_ARGS ${ADDITIONAL_RECOVERY_ARGS} --gov-api-version
"2024-07-01"
)
add_e2e_test(
NAME recovery_test_suite
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/e2e_suite.py
LABEL suite
ADDITIONAL_ARGS
--test-duration
150
--test-suite
rekey_recovery
--test-suite
membership_recovery
--jinja-templates-path
${CMAKE_SOURCE_DIR}/samples/templates
)
add_e2e_test(
NAME reconfiguration_test_suite
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/e2e_suite.py
LABEL suite
ADDITIONAL_ARGS
--test-duration 200 --test-suite reconfiguration --jinja-templates-path
${CMAKE_SOURCE_DIR}/samples/templates
)
if(LONG_TESTS)
add_e2e_test(
NAME regression_test_suite
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/e2e_suite.py
LABEL suite
ADDITIONAL_ARGS --test-duration 200 --test-suite regression_5236
)
endif()
add_e2e_test(
NAME full_test_suite
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/e2e_suite.py
LABEL suite
ADDITIONAL_ARGS
--oe-binary
${OE_BINDIR}
--ledger-recovery-timeout
20
--test-duration
200
--test-suite
all
--jinja-templates-path
${CMAKE_SOURCE_DIR}/samples/templates
)
add_e2e_test(
NAME committable_suffix_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/committable.py
ADDITIONAL_ARGS --sig-ms-interval 100
)
add_e2e_test(
NAME commit_latency
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/commit_latency.py
LABEL perf
)
add_e2e_test(
NAME js_batched_stress_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/e2e_batched.py
ADDITIONAL_ARGS
--js-app-bundle
${CMAKE_SOURCE_DIR}/src/apps/batched
--election-timeout-ms
10000 # Larger election timeout as recording large JS applications may
# trigger leadership changes
)
add_e2e_test(
NAME modules_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/js-modules/modules.py
ADDITIONAL_ARGS
--package
libjs_generic
--election-timeout-ms
10000 # Larger election timeout as recording
# large JS applications may trigger leadership changes
)
add_e2e_test(
NAME auth
PYTHON_SCRIPT
${CMAKE_SOURCE_DIR}/tests/js-custom-authorization/custom_authorization.py
ADDITIONAL_ARGS --package libjs_generic --js-app-bundle
${CMAKE_SOURCE_DIR}/tests
)
add_e2e_test(
NAME launch_host_process_test
PYTHON_SCRIPT
${CMAKE_SOURCE_DIR}/tests/js-launch-host-process/host_process.py
ADDITIONAL_ARGS --js-app-bundle
${CMAKE_SOURCE_DIR}/tests/js-launch-host-process
)
set(CONSTITUTION_ARGS
--constitution
${CCF_DIR}/samples/constitutions/default/actions.js
--constitution
${CCF_DIR}/samples/constitutions/test/test_actions.js
--constitution
${CCF_DIR}/samples/constitutions/default/validate.js
--constitution
${CCF_DIR}/samples/constitutions/test/resolve.js
--constitution
${CCF_DIR}/samples/constitutions/default/apply.js
)
add_e2e_test(
NAME governance_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/governance.py
CONSTITUTION ${CONSTITUTION_ARGS}
ADDITIONAL_ARGS
--oe-binary ${OE_BINDIR} --initial-operator-count 1
--jinja-templates-path ${CMAKE_SOURCE_DIR}/samples/templates
)
add_e2e_test(
NAME jwt_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/jwt_test.py
LABEL snp_flaky
)
add_e2e_test(
NAME code_update_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/code_update.py
ADDITIONAL_ARGS --oe-binary ${OE_BINDIR} --js-app-bundle
${CMAKE_SOURCE_DIR}/samples/apps/logging/js
)
if(BUILD_TPCC)
include(${CMAKE_CURRENT_SOURCE_DIR}/src/apps/tpcc/tpcc.cmake)
endif()
if(CLIENT_PROTOCOLS_TEST)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/testssl/testssl.sh
COMMAND
rm -rf ${CMAKE_CURRENT_BINARY_DIR}/testssl && git clone --depth 1
--branch v3.0.7 --single-branch
https://github.com/drwetter/testssl.sh
${CMAKE_CURRENT_BINARY_DIR}/testssl
)
add_custom_target(
testssl ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/testssl/testssl.sh
)
endif()
add_e2e_test(
NAME e2e_logging_cft
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/e2e_logging.py
ADDITIONAL_ARGS --js-app-bundle
${CMAKE_SOURCE_DIR}/samples/apps/logging/js
)
set(RBAC_CONSTITUTION_ARGS
--constitution
${CCF_DIR}/samples/constitutions/default/actions.js
--constitution
${CCF_DIR}/samples/constitutions/roles/set_role_definition.js
--constitution
${CCF_DIR}/samples/constitutions/default/validate.js
--constitution
${CCF_DIR}/samples/constitutions/default/resolve.js
--constitution
${CCF_DIR}/samples/constitutions/default/apply.js
)
add_e2e_test(
NAME programmability
CONSTITUTION ${RBAC_CONSTITUTION_ARGS}
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/programmability.py
)
# This test uses large requests (so too slow for SAN)
if(NOT SAN)
add_e2e_test(
NAME e2e_limits PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/limits.py
)
endif()
add_e2e_test(
NAME e2e_redirects
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/redirects.py
ADDITIONAL_ARGS --js-app-bundle
${CMAKE_SOURCE_DIR}/samples/apps/logging/js
)
add_e2e_test(
NAME e2e_logging_http2
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/e2e_logging.py
ADDITIONAL_ARGS --js-app-bundle
${CMAKE_SOURCE_DIR}/samples/apps/logging/js --http2
)
if(LONG_TESTS)
add_e2e_test(
NAME membership_api_0
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/membership.py
ADDITIONAL_ARGS --gov-api-version "classic"
)
endif()
add_e2e_test(
NAME membership_api_1
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/membership.py
ADDITIONAL_ARGS --gov-api-version "2024-07-01"
)
set(PARTITIONS_TEST_ARGS
# Higher snapshot interval as the test currently assumes that no
# transactions
# are emitted while partitions are up. To be removed when
# https://github.com/microsoft/CCF/issues/2577 is implemented
--snapshot-tx-interval 10000
)
add_e2e_test(
NAME partitions_cft
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/partitions_test.py
LABEL partitions
CONFIGURATIONS partitions
ADDITIONAL_ARGS ${PARTITIONS_TEST_ARGS}
)
add_e2e_test(
NAME connections_cft
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/connections.py
)
add_e2e_test(
NAME consistency_trace_validation
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/consistency_trace_validation.py
LABEL snp_flaky
)
add_e2e_test(
NAME fuzz_test PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/fuzzing.py
)
if(CLIENT_PROTOCOLS_TEST)
add_e2e_test(
NAME client_protocols
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/client_protocols.py
LABEL protocolstest
)
endif()
add_e2e_test(
NAME schema_test_cft
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/schema.py
ADDITIONAL_ARGS
--schema-dir
${CMAKE_SOURCE_DIR}/doc/schemas
--ledger-tutorial
${CMAKE_SOURCE_DIR}/python/ledger_tutorial.py
--config-samples-dir
${CMAKE_SOURCE_DIR}/samples/config
--config-file-1x
${CMAKE_SOURCE_DIR}/python/config_1_x.ini
)
list(APPEND LTS_TEST_ARGS --oe-binary ${OE_BINDIR} --ccf-version
${CCF_VERSION}
)
if(LONG_TESTS)
list(APPEND LTS_TEST_ARGS --check-ledger-compatibility)
endif()
if(NOT SAN)
add_e2e_test(
NAME lts_compatibility
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/lts_compatibility.py
LABEL e2e
ADDITIONAL_ARGS ${LTS_TEST_ARGS}
)
set_property(
TEST lts_compatibility
APPEND
PROPERTY ENVIRONMENT "LTS_COMPAT_GOV_CLIENT=1"
)
endif()
if(LONG_TESTS)
set(ROTATION_TEST_ARGS --rotation-retirements 10)
endif()
add_e2e_test(
NAME rotation_test_cft
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/rotation.py
LABEL rotation
ADDITIONAL_ARGS ${ROTATION_TEST_ARGS}
)
set(RECONFIG_TEST_ARGS --ccf-version ${CCF_VERSION})
add_e2e_test(
NAME reconfiguration_test_cft
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/reconfiguration.py
ADDITIONAL_ARGS ${RECONFIG_TEST_ARGS}
)
add_e2e_test(
NAME election_test PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/election.py
)
if(LONG_TESTS)
add_e2e_test(
NAME acme_endorsement_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/acme_endorsement.py
LABEL ACME
)
endif()
add_piccolo_test(
NAME pi_ls
PYTHON_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/tests/infra/piccolo_driver.py
CLIENT_BIN ./submit PERF_LABEL "Logging"
ADDITIONAL_ARGS --package "samples/apps/logging/liblogging"
--max-writes-ahead 1000 --repetitions 10000
)
add_piccolo_test(
NAME pi_basic
PYTHON_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/tests/infra/basicperf.py
CLIENT_BIN ./submit PERF_LABEL "Basic"
ADDITIONAL_ARGS --package "samples/apps/basic/libbasic" --client-def
"1,write,100000,primary"
)
add_piccolo_test(
NAME pi_basic_js
PYTHON_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/tests/infra/basicperf.py
CLIENT_BIN ./submit PERF_LABEL "Basic JS"
ADDITIONAL_ARGS --js-app-bundle ${CMAKE_SOURCE_DIR}/samples/apps/basic/js
--client-def "1,write,100000,primary"
)
if(WORKER_THREADS)
add_piccolo_test(
NAME pi_basic_mt
PYTHON_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/tests/infra/basicperf.py
CLIENT_BIN ./submit PERF_LABEL "Basic Multi-Threaded"
ADDITIONAL_ARGS --package "samples/apps/basic/libbasic" --client-def
"${WORKER_THREADS},write,100000,primary"
)
endif()
add_piccolo_test(
NAME pi_ls_jwt
PYTHON_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/tests/infra/piccolo_driver.py
CLIENT_BIN ./submit PERF_LABEL "Logging JWT"
ADDITIONAL_ARGS
--package
"samples/apps/logging/liblogging"
--max-writes-ahead
1000
--repetitions
1000
--use-jwt
)
add_e2e_test(
NAME historical_query_perf_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/historical_query_perf.py
LABEL perf PERF_LABEL "Historical Queries"
CONFIGURATIONS perf
)
add_e2e_test(
NAME historical_query_cache_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/historical_query_cache.py
)
endif()
endif()
# Generate and install CMake export file for consumers using CMake
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CCF_PROJECT}-config.cmake.in
${CMAKE_BINARY_DIR}/cmake/${CCF_PROJECT}-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake
PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_BINDIR CMAKE_INSTALL_INCLUDEDIR
)
write_basic_package_version_file(
${CMAKE_BINARY_DIR}/cmake/${CCF_PROJECT}-config-version.cmake
COMPATIBILITY SameMajorVersion
)
install(FILES ${CMAKE_BINARY_DIR}/cmake/${CCF_PROJECT}-config.cmake
${CMAKE_BINARY_DIR}/cmake/${CCF_PROJECT}-config-version.cmake
DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake
)
# Perf tool executable
include(${CCF_DIR}/tests/perf-system/submitter/CMakeLists.txt)