2019-01-23 06:25:20 +08:00
|
|
|
# This configures the fdb testing system in cmake. Currently this simply means
|
|
|
|
# that it will get a list of all test files and store this list in a parent scope
|
|
|
|
# so that we can later verify that all of them were assigned to a test.
|
|
|
|
#
|
|
|
|
# - TEST_DIRECTORY The directory where all the tests are
|
|
|
|
# - ERROR_ON_ADDITIONAL_FILES if this is passed verify_fdb_tests will print
|
|
|
|
# an error if there are any .txt files in the test directory that do not
|
|
|
|
# correspond to a test or are not ignore by a pattern
|
|
|
|
# - IGNORE_PATTERNS regular expressions. All files that match any of those
|
|
|
|
# experessions don't need to be associated with a test
|
|
|
|
function(configure_testing)
|
|
|
|
set(options ERROR_ON_ADDITIONAL_FILES)
|
|
|
|
set(oneValueArgs TEST_DIRECTORY)
|
|
|
|
set(multiValueArgs IGNORE_PATTERNS)
|
|
|
|
cmake_parse_arguments(CONFIGURE_TESTING "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
|
|
|
set(no_tests YES)
|
|
|
|
if(CONFIGURE_TESTING_ERROR_ON_ADDITIONAL_FILES)
|
|
|
|
file(GLOB_RECURSE candidates "${CONFIGURE_TESTING_TEST_DIRECTORY}/*.txt")
|
2020-07-13 05:41:12 +08:00
|
|
|
file(GLOB_RECURSE toml_candidates "${CONFIGURE_TESTING_TEST_DIRECTORY}/*.toml")
|
|
|
|
list(APPEND candidates ${toml_candidates})
|
2019-01-23 06:25:20 +08:00
|
|
|
foreach(candidate IN LISTS candidates)
|
|
|
|
set(candidate_is_test YES)
|
|
|
|
foreach(pattern IN LISTS CONFIGURE_TESTING_IGNORE_PATTERNS)
|
|
|
|
if("${candidate}" MATCHES "${pattern}")
|
|
|
|
set(candidate_is_test NO)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if(candidate_is_test)
|
|
|
|
if(no_tests)
|
|
|
|
set(no_tests NO)
|
|
|
|
set(fdb_test_files "${candidate}")
|
|
|
|
else()
|
|
|
|
set(fdb_test_files "${fdb_test_files};${candidate}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
set(fdb_test_files "${fdb_test_files}" PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(verify_testing)
|
2021-07-28 01:17:55 +08:00
|
|
|
if(NOT ENABLE_SIMULATION_TESTS)
|
|
|
|
return()
|
|
|
|
endif()
|
2019-01-23 06:25:20 +08:00
|
|
|
foreach(test_file IN LISTS fdb_test_files)
|
|
|
|
message(SEND_ERROR "${test_file} found but it is not associated with a test")
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# This will add a test that can be run by ctest. This macro can be called
|
|
|
|
# with the following arguments:
|
|
|
|
#
|
|
|
|
# - UNIT will run the test as a unit test (it won't bring up a whole simulated system)
|
|
|
|
# - TEST_NAME followed the name of the test
|
|
|
|
# - TIMEOUT followed by a timeout - reaching the timeout makes the test fail (default is
|
|
|
|
# 3600 seconds). The timeout will be reached whenever it ran either too long in simulated
|
|
|
|
# time or in real time - whatever is smaller.
|
|
|
|
# - TEST_FILES followed by typically one test file. The test runner will run
|
|
|
|
# all these tests in serialized order and within the same directory. This is
|
|
|
|
# useful for restart tests
|
|
|
|
function(add_fdb_test)
|
2019-04-05 02:33:00 +08:00
|
|
|
set(options UNIT IGNORE)
|
2019-01-23 06:25:20 +08:00
|
|
|
set(oneValueArgs TEST_NAME TIMEOUT)
|
|
|
|
set(multiValueArgs TEST_FILES)
|
|
|
|
cmake_parse_arguments(ADD_FDB_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
|
|
|
set(this_test_timeout ${ADD_FDB_TEST_TIMEOUT})
|
|
|
|
if(NOT this_test_timeout)
|
|
|
|
set(this_test_timeout 3600)
|
2019-08-16 02:48:37 +08:00
|
|
|
if(USE_VALGRIND_FOR_CTEST)
|
|
|
|
set(this_test_timeout 36000)
|
|
|
|
endif()
|
2019-01-23 06:25:20 +08:00
|
|
|
endif()
|
|
|
|
set(test_type "simulation")
|
|
|
|
set(fdb_test_files_ "${fdb_test_files}")
|
|
|
|
foreach(test_file IN LISTS ADD_FDB_TEST_TEST_FILES)
|
|
|
|
list(REMOVE_ITEM fdb_test_files_ "${CMAKE_CURRENT_SOURCE_DIR}/${test_file}")
|
|
|
|
endforeach()
|
|
|
|
set(fdb_test_files "${fdb_test_files_}" PARENT_SCOPE)
|
|
|
|
list(LENGTH ADD_FDB_TEST_TEST_FILES NUM_TEST_FILES)
|
|
|
|
if(ADD_FDB_TEST_IGNORE AND NOT RUN_IGNORED_TESTS)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
if(ADD_FDB_TEST_UNIT)
|
|
|
|
set(test_type "test")
|
|
|
|
endif()
|
|
|
|
list(GET ADD_FDB_TEST_TEST_FILES 0 first_file)
|
2020-07-13 10:53:44 +08:00
|
|
|
string(REGEX REPLACE "^(.*)\\.(txt|toml)$" "\\1" test_name ${first_file})
|
2019-01-23 06:25:20 +08:00
|
|
|
if("${test_name}" MATCHES "(-\\d)$")
|
|
|
|
string(REGEX REPLACE "(.*)(-\\d)$" "\\1" test_name_1 ${test_name})
|
|
|
|
message(STATUS "new testname ${test_name_1}")
|
|
|
|
endif()
|
|
|
|
if (NOT "${ADD_FDB_TEST_TEST_NAME}" STREQUAL "")
|
|
|
|
set(test_name ${ADD_FDB_TEST_TEST_NAME})
|
|
|
|
endif()
|
2020-04-29 00:19:04 +08:00
|
|
|
if((NOT test_name MATCHES "${TEST_INCLUDE}") OR (test_name MATCHES "${TEST_EXCLUDE}"))
|
|
|
|
return()
|
|
|
|
endif()
|
2019-07-16 05:52:24 +08:00
|
|
|
math(EXPR test_idx "${CURRENT_TEST_INDEX} + ${NUM_TEST_FILES}")
|
2019-02-17 02:27:13 +08:00
|
|
|
set(CURRENT_TEST_INDEX "${test_idx}" PARENT_SCOPE)
|
|
|
|
# set(<var> <value> PARENT_SCOPE) doesn't set the
|
|
|
|
# value in this scope (only in the parent scope). So
|
|
|
|
# if the value was undefined before, it will still be
|
|
|
|
# undefined.
|
2019-07-16 05:52:24 +08:00
|
|
|
math(EXPR assigned_id "${test_idx} - ${NUM_TEST_FILES}")
|
2019-01-23 06:25:20 +08:00
|
|
|
if(ADD_FDB_TEST_UNIT)
|
|
|
|
message(STATUS
|
2019-02-17 02:27:13 +08:00
|
|
|
"ADDING UNIT TEST ${assigned_id} ${test_name}")
|
2019-01-23 06:25:20 +08:00
|
|
|
else()
|
|
|
|
message(STATUS
|
2019-02-17 02:27:13 +08:00
|
|
|
"ADDING SIMULATOR TEST ${assigned_id} ${test_name}")
|
2019-01-23 06:25:20 +08:00
|
|
|
endif()
|
|
|
|
set(test_files "")
|
|
|
|
foreach(curr_test_file ${ADD_FDB_TEST_TEST_FILES})
|
|
|
|
set(test_files "${test_files} ${curr_test_file}")
|
|
|
|
endforeach()
|
|
|
|
set(BUGGIFY_OPTION "")
|
|
|
|
if (ENABLE_BUGGIFY)
|
|
|
|
set(BUGGIFY_OPTION "-B")
|
|
|
|
endif()
|
2019-07-03 00:15:05 +08:00
|
|
|
set(VALGRIND_OPTION "")
|
2019-08-16 02:48:37 +08:00
|
|
|
if (USE_VALGRIND_FOR_CTEST)
|
2019-07-03 00:15:05 +08:00
|
|
|
set(VALGRIND_OPTION "--use-valgrind")
|
|
|
|
endif()
|
2019-01-23 06:25:20 +08:00
|
|
|
list(TRANSFORM ADD_FDB_TEST_TEST_FILES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
|
2021-07-28 01:38:25 +08:00
|
|
|
if (ENABLE_SIMULATION_TESTS)
|
|
|
|
add_test(NAME ${test_name}
|
|
|
|
COMMAND $<TARGET_FILE:Python::Interpreter> ${TestRunner}
|
|
|
|
-n ${test_name}
|
|
|
|
-b ${PROJECT_BINARY_DIR}
|
|
|
|
-t ${test_type}
|
2021-08-24 03:52:58 +08:00
|
|
|
-O ${OLD_FDBSERVER_BINARY}
|
|
|
|
--config "@CTEST_CONFIGURATION_TYPE@"
|
2021-07-28 01:38:25 +08:00
|
|
|
--crash
|
|
|
|
--aggregate-traces ${TEST_AGGREGATE_TRACES}
|
|
|
|
--log-format ${TEST_LOG_FORMAT}
|
|
|
|
--keep-logs ${TEST_KEEP_LOGS}
|
|
|
|
--keep-simdirs ${TEST_KEEP_SIMDIR}
|
|
|
|
--seed ${SEED}
|
|
|
|
--test-number ${assigned_id}
|
|
|
|
${BUGGIFY_OPTION}
|
|
|
|
${VALGRIND_OPTION}
|
|
|
|
${ADD_FDB_TEST_TEST_FILES}
|
|
|
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
|
|
|
|
set_tests_properties("${test_name}" PROPERTIES ENVIRONMENT UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1)
|
|
|
|
get_filename_component(test_dir_full ${first_file} DIRECTORY)
|
|
|
|
if(NOT ${test_dir_full} STREQUAL "")
|
|
|
|
get_filename_component(test_dir ${test_dir_full} NAME)
|
|
|
|
set_tests_properties(${test_name} PROPERTIES TIMEOUT ${this_test_timeout} LABELS "${test_dir}")
|
|
|
|
endif()
|
2019-11-09 05:39:21 +08:00
|
|
|
endif()
|
|
|
|
# set variables used for generating test packages
|
|
|
|
set(TEST_NAMES ${TEST_NAMES} ${test_name} PARENT_SCOPE)
|
|
|
|
set(TEST_FILES_${test_name} ${ADD_FDB_TEST_TEST_FILES} PARENT_SCOPE)
|
|
|
|
set(TEST_TYPE_${test_name} ${test_type} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2019-11-09 06:21:47 +08:00
|
|
|
if(NOT WIN32)
|
|
|
|
set(TEST_PACKAGE_INCLUDE ".*" CACHE STRING "A regex of all tests that should be included in the test package")
|
|
|
|
set(TEST_PACKAGE_EXCLUDE ".^" CACHE STRING "A regex of all tests that shouldn't be added to the test package")
|
|
|
|
set(TEST_PACKAGE_ADD_DIRECTORIES "" CACHE STRING "A ;-separated list of directories. All files within each directory will be added to the test package")
|
|
|
|
endif()
|
2019-11-09 05:39:21 +08:00
|
|
|
|
2020-05-22 04:35:54 +08:00
|
|
|
# This sets up a directory with the correctness files common to all correctness packages.
|
|
|
|
# This function should be called with the following arguments:
|
|
|
|
#
|
|
|
|
# - OUT_DIR the directory where files will be staged
|
|
|
|
# - CONTEXT the type of correctness package being built (e.g. 'valgrind correctness')
|
|
|
|
function(stage_correctness_package)
|
2020-10-23 03:53:03 +08:00
|
|
|
set(oneValueArgs OUT_DIR CONTEXT OUT_FILES)
|
2020-05-28 01:25:13 +08:00
|
|
|
cmake_parse_arguments(STAGE "" "${oneValueArgs}" "" "${ARGN}")
|
2020-05-23 01:10:34 +08:00
|
|
|
file(MAKE_DIRECTORY ${STAGE_OUT_DIR}/bin)
|
2019-11-09 05:39:21 +08:00
|
|
|
string(LENGTH "${CMAKE_SOURCE_DIR}/tests/" base_length)
|
|
|
|
foreach(test IN LISTS TEST_NAMES)
|
|
|
|
if(("${TEST_TYPE_${test}}" STREQUAL "simulation") AND
|
|
|
|
(${test} MATCHES ${TEST_PACKAGE_INCLUDE}) AND
|
|
|
|
(NOT ${test} MATCHES ${TEST_PACKAGE_EXCLUDE}))
|
|
|
|
foreach(file IN LISTS TEST_FILES_${test})
|
|
|
|
string(SUBSTRING ${file} ${base_length} -1 rel_out_file)
|
2020-05-22 04:35:54 +08:00
|
|
|
set(out_file ${STAGE_OUT_DIR}/tests/${rel_out_file})
|
|
|
|
list(APPEND test_files ${out_file})
|
2019-11-09 05:39:21 +08:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${out_file}
|
|
|
|
DEPENDS ${file}
|
2020-05-22 04:35:54 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${file} ${out_file}
|
|
|
|
COMMENT "Copying ${STAGE_CONTEXT} test file ${rel_out_file}"
|
|
|
|
)
|
2019-11-09 05:39:21 +08:00
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2019-11-09 06:15:38 +08:00
|
|
|
foreach(dir IN LISTS TEST_PACKAGE_ADD_DIRECTORIES)
|
|
|
|
file(GLOB_RECURSE files ${dir}/*)
|
|
|
|
string(LENGTH ${dir} dir_len)
|
|
|
|
foreach(file IN LISTS files)
|
|
|
|
get_filename_component(src_dir ${file} DIRECTORY)
|
2019-11-09 07:13:32 +08:00
|
|
|
# We need to make sure that ${src_dir} is at least
|
|
|
|
# as long as ${dir}. Otherwise the later call to
|
|
|
|
# SUBSTRING will fail
|
|
|
|
set(src_dir "${src_dir}/")
|
2019-11-09 06:15:38 +08:00
|
|
|
string(SUBSTRING ${src_dir} ${dir_len} -1 dest_dir)
|
2020-05-28 02:34:15 +08:00
|
|
|
string(SUBSTRING ${file} ${dir_len} -1 rel_out_file)
|
|
|
|
set(out_file ${STAGE_OUT_DIR}/${rel_out_file})
|
|
|
|
list(APPEND external_files ${out_file})
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${out_file}
|
|
|
|
DEPENDS ${file}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${file} ${out_file}
|
|
|
|
COMMENT "Copying ${STAGE_CONTEXT} external file ${file}"
|
|
|
|
)
|
2019-11-09 06:15:38 +08:00
|
|
|
endforeach()
|
|
|
|
endforeach()
|
2020-05-22 04:35:54 +08:00
|
|
|
list(APPEND package_files ${STAGE_OUT_DIR}/bin/fdbserver
|
2020-10-23 03:49:53 +08:00
|
|
|
${STAGE_OUT_DIR}/bin/coverage.fdbserver.xml
|
2020-10-23 04:51:10 +08:00
|
|
|
${STAGE_OUT_DIR}/bin/coverage.fdbclient.xml
|
|
|
|
${STAGE_OUT_DIR}/bin/coverage.fdbrpc.xml
|
|
|
|
${STAGE_OUT_DIR}/bin/coverage.flow.xml
|
2020-05-22 04:35:54 +08:00
|
|
|
${STAGE_OUT_DIR}/bin/TestHarness.exe
|
|
|
|
${STAGE_OUT_DIR}/bin/TraceLogHelper.dll
|
|
|
|
${STAGE_OUT_DIR}/CMakeCache.txt
|
|
|
|
)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${package_files}
|
|
|
|
DEPENDS ${CMAKE_BINARY_DIR}/CMakeCache.txt
|
|
|
|
${CMAKE_BINARY_DIR}/packages/bin/fdbserver
|
2020-10-23 03:49:53 +08:00
|
|
|
${CMAKE_BINARY_DIR}/bin/coverage.fdbserver.xml
|
2020-10-23 04:51:10 +08:00
|
|
|
${CMAKE_BINARY_DIR}/lib/coverage.fdbclient.xml
|
|
|
|
${CMAKE_BINARY_DIR}/lib/coverage.fdbrpc.xml
|
|
|
|
${CMAKE_BINARY_DIR}/lib/coverage.flow.xml
|
2020-05-22 04:35:54 +08:00
|
|
|
${CMAKE_BINARY_DIR}/packages/bin/TestHarness.exe
|
|
|
|
${CMAKE_BINARY_DIR}/packages/bin/TraceLogHelper.dll
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/CMakeCache.txt ${STAGE_OUT_DIR}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/packages/bin/fdbserver
|
2020-10-23 03:49:53 +08:00
|
|
|
${CMAKE_BINARY_DIR}/bin/coverage.fdbserver.xml
|
2020-10-23 04:51:10 +08:00
|
|
|
${CMAKE_BINARY_DIR}/lib/coverage.fdbclient.xml
|
|
|
|
${CMAKE_BINARY_DIR}/lib/coverage.fdbrpc.xml
|
|
|
|
${CMAKE_BINARY_DIR}/lib/coverage.flow.xml
|
2020-05-22 04:35:54 +08:00
|
|
|
${CMAKE_BINARY_DIR}/packages/bin/TestHarness.exe
|
|
|
|
${CMAKE_BINARY_DIR}/packages/bin/TraceLogHelper.dll
|
|
|
|
${STAGE_OUT_DIR}/bin
|
|
|
|
COMMENT "Copying files for ${STAGE_CONTEXT} package"
|
|
|
|
)
|
|
|
|
list(APPEND package_files ${test_files} ${external_files})
|
2020-10-23 03:53:03 +08:00
|
|
|
if(STAGE_OUT_FILES)
|
|
|
|
set(${STAGE_OUT_FILES} ${package_files} PARENT_SCOPE)
|
|
|
|
endif()
|
2020-05-22 04:35:54 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(create_correctness_package)
|
|
|
|
if(WIN32)
|
|
|
|
return()
|
2020-03-28 00:36:57 +08:00
|
|
|
endif()
|
2020-05-22 04:35:54 +08:00
|
|
|
set(out_dir "${CMAKE_BINARY_DIR}/correctness")
|
2020-10-23 03:53:03 +08:00
|
|
|
stage_correctness_package(OUT_DIR ${out_dir} CONTEXT "correctness" OUT_FILES package_files)
|
2020-05-22 04:35:54 +08:00
|
|
|
set(tar_file ${CMAKE_BINARY_DIR}/packages/correctness-${CMAKE_PROJECT_VERSION}.tar.gz)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${tar_file}
|
|
|
|
DEPENDS ${package_files}
|
|
|
|
${CMAKE_SOURCE_DIR}/contrib/Joshua/scripts/correctnessTest.sh
|
|
|
|
${CMAKE_SOURCE_DIR}/contrib/Joshua/scripts/correctnessTimeout.sh
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/contrib/Joshua/scripts/correctnessTest.sh
|
|
|
|
${out_dir}/joshua_test
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/contrib/Joshua/scripts/correctnessTimeout.sh
|
|
|
|
${out_dir}/joshua_timeout
|
2020-06-19 06:59:08 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E tar cfz ${tar_file} ${package_files}
|
|
|
|
${out_dir}/joshua_test
|
|
|
|
${out_dir}/joshua_timeout
|
2020-05-22 04:35:54 +08:00
|
|
|
WORKING_DIRECTORY ${out_dir}
|
|
|
|
COMMENT "Package correctness archive"
|
|
|
|
)
|
|
|
|
add_custom_target(package_tests ALL DEPENDS ${tar_file})
|
|
|
|
add_dependencies(package_tests strip_only_fdbserver TestHarness)
|
2021-06-30 05:40:59 +08:00
|
|
|
set(unversioned_tar_file "${CMAKE_BINARY_DIR}/packages/correctness.tar.gz")
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${unversioned_tar_file}"
|
|
|
|
DEPENDS "${tar_file}"
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy "${tar_file}" "${unversioned_tar_file}"
|
|
|
|
COMMENT "Copy correctness package to ${unversioned_tar_file}")
|
|
|
|
add_custom_target(package_tests_u DEPENDS "${unversioned_tar_file}")
|
|
|
|
add_dependencies(package_tests_u package_tests)
|
2020-05-22 04:35:54 +08:00
|
|
|
endfunction()
|
2020-03-27 05:02:21 +08:00
|
|
|
|
2020-05-22 04:35:54 +08:00
|
|
|
function(create_valgrind_correctness_package)
|
|
|
|
if(WIN32)
|
|
|
|
return()
|
|
|
|
endif()
|
2020-03-28 00:38:20 +08:00
|
|
|
if(USE_VALGRIND)
|
2020-05-22 04:35:54 +08:00
|
|
|
set(out_dir "${CMAKE_BINARY_DIR}/valgrind_correctness")
|
2020-10-23 03:53:03 +08:00
|
|
|
stage_correctness_package(OUT_DIR ${out_dir} CONTEXT "valgrind correctness" OUT_FILES package_files)
|
2020-03-28 00:47:37 +08:00
|
|
|
set(tar_file ${CMAKE_BINARY_DIR}/packages/valgrind-${CMAKE_PROJECT_VERSION}.tar.gz)
|
2020-03-28 00:38:20 +08:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${tar_file}
|
2020-05-22 04:35:54 +08:00
|
|
|
DEPENDS ${package_files}
|
2020-04-11 09:23:29 +08:00
|
|
|
${CMAKE_SOURCE_DIR}/contrib/Joshua/scripts/valgrindTest.sh
|
|
|
|
${CMAKE_SOURCE_DIR}/contrib/Joshua/scripts/valgrindTimeout.sh
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/contrib/Joshua/scripts/valgrindTest.sh
|
2020-05-22 04:35:54 +08:00
|
|
|
${out_dir}/joshua_test
|
2020-04-11 09:23:29 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/contrib/Joshua/scripts/valgrindTimeout.sh
|
2020-05-22 04:35:54 +08:00
|
|
|
${out_dir}/joshua_timeout
|
2020-06-19 06:59:08 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E tar cfz ${tar_file} ${package_files}
|
|
|
|
${out_dir}/joshua_test
|
|
|
|
${out_dir}/joshua_timeout
|
2020-05-22 04:35:54 +08:00
|
|
|
WORKING_DIRECTORY ${out_dir}
|
|
|
|
COMMENT "Package valgrind correctness archive"
|
2020-03-28 00:38:20 +08:00
|
|
|
)
|
|
|
|
add_custom_target(package_valgrind_tests ALL DEPENDS ${tar_file})
|
|
|
|
add_dependencies(package_valgrind_tests strip_only_fdbserver TestHarness)
|
2021-06-30 05:40:59 +08:00
|
|
|
set(unversioned_tar_file "${CMAKE_BINARY_DIR}/packages/valgrind.tar.gz")
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${unversioned_tar_file}"
|
|
|
|
DEPENDS "${tar_file}"
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy "${tar_file}" "${unversioned_tar_file}"
|
|
|
|
COMMENT "Copy valgrind package to ${unversioned_tar_file}")
|
|
|
|
add_custom_target(package_valgrind_tests_u DEPENDS "${unversioned_tar_file}")
|
|
|
|
add_dependencies(package_valgrind_tests_u package_valgrind_tests)
|
2020-03-28 00:36:38 +08:00
|
|
|
endif()
|
2020-03-27 07:01:58 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(package_bindingtester)
|
|
|
|
if(WIN32 OR OPEN_FOR_IDE)
|
|
|
|
return()
|
|
|
|
elseif(APPLE)
|
|
|
|
set(fdbcName "libfdb_c.dylib")
|
|
|
|
else()
|
|
|
|
set(fdbcName "libfdb_c.so")
|
|
|
|
endif()
|
|
|
|
set(bdir ${CMAKE_BINARY_DIR}/bindingtester)
|
|
|
|
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bindingtester)
|
|
|
|
set(outfiles ${bdir}/fdbcli ${bdir}/fdbserver ${bdir}/${fdbcName} ${bdir}/joshua_test ${bdir}/joshua_timeout)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${outfiles}
|
2020-05-22 04:35:54 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/CMakeCache.txt
|
|
|
|
${CMAKE_BINARY_DIR}/packages/bin/fdbcli
|
2020-03-27 07:01:58 +08:00
|
|
|
${CMAKE_BINARY_DIR}/packages/bin/fdbserver
|
|
|
|
${CMAKE_BINARY_DIR}/packages/lib/${fdbcName}
|
|
|
|
${bdir}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/contrib/Joshua/scripts/bindingTest.sh ${bdir}/joshua_test
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/contrib/Joshua/scripts/bindingTimeout.sh ${bdir}/joshua_timeout
|
2020-03-28 00:36:08 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/contrib/Joshua/scripts/localClusterStart.sh ${bdir}/localClusterStart.sh
|
2020-04-01 09:40:25 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/contrib/Joshua/scripts/bindingTestScript.sh ${bdir}/bindingTestScript.sh
|
2020-05-22 04:35:54 +08:00
|
|
|
COMMENT "Copy executables and scripts to bindingtester dir")
|
2020-03-27 07:01:58 +08:00
|
|
|
file(GLOB_RECURSE test_files ${CMAKE_SOURCE_DIR}/bindings/*)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${CMAKE_BINARY_DIR}/bindingtester.touch"
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bindingtester/tests
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bindingtester/tests
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/bindings ${CMAKE_BINARY_DIR}/bindingtester/tests
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_BINARY_DIR}/bindingtester.touch"
|
|
|
|
COMMENT "Copy test files for bindingtester")
|
2020-04-28 09:17:20 +08:00
|
|
|
|
2020-04-29 07:24:27 +08:00
|
|
|
add_custom_target(copy_binding_output_files DEPENDS ${CMAKE_BINARY_DIR}/bindingtester.touch python_binding fdb_flow_tester)
|
|
|
|
add_custom_command(
|
|
|
|
TARGET copy_binding_output_files
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:fdb_flow_tester> ${bdir}/tests/flow/bin/fdb_flow_tester
|
|
|
|
COMMENT "Copy Flow tester for bindingtester")
|
|
|
|
|
2020-04-28 09:17:20 +08:00
|
|
|
set(generated_binding_files python/fdb/fdboptions.py)
|
2021-08-05 21:31:15 +08:00
|
|
|
if(WITH_JAVA_BINDING)
|
2020-04-29 07:24:27 +08:00
|
|
|
if(NOT FDB_RELEASE)
|
|
|
|
set(prerelease_string "-PRERELEASE")
|
|
|
|
else()
|
|
|
|
set(prerelease_string "")
|
|
|
|
endif()
|
2020-04-28 09:17:20 +08:00
|
|
|
add_custom_command(
|
2020-04-29 07:24:27 +08:00
|
|
|
TARGET copy_binding_output_files
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
|
|
${CMAKE_BINARY_DIR}/packages/fdb-java-${CMAKE_PROJECT_VERSION}${prerelease_string}.jar
|
|
|
|
${bdir}/tests/java/foundationdb-client.jar
|
|
|
|
COMMENT "Copy Java bindings for bindingtester")
|
|
|
|
add_dependencies(copy_binding_output_files fat-jar)
|
|
|
|
add_dependencies(copy_binding_output_files foundationdb-tests)
|
|
|
|
set(generated_binding_files ${generated_binding_files} java/foundationdb-tests.jar)
|
|
|
|
endif()
|
2020-04-28 09:17:20 +08:00
|
|
|
|
2021-08-05 21:31:15 +08:00
|
|
|
if(WITH_GO_BINDING AND NOT OPEN_FOR_IDE)
|
2020-04-29 07:24:27 +08:00
|
|
|
add_dependencies(copy_binding_output_files fdb_go_tester fdb_go)
|
2020-04-28 09:17:20 +08:00
|
|
|
add_custom_command(
|
2020-04-29 07:24:27 +08:00
|
|
|
TARGET copy_binding_output_files
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bindings/go/bin/_stacktester ${bdir}/tests/go/build/bin/_stacktester
|
2020-04-28 09:17:20 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
|
|
${CMAKE_BINARY_DIR}/bindings/go/src/github.com/apple/foundationdb/bindings/go/src/fdb/generated.go # SRC
|
|
|
|
${bdir}/tests/go/src/fdb/ # DEST
|
|
|
|
COMMENT "Copy generated.go for bindingtester")
|
|
|
|
endif()
|
|
|
|
|
2020-04-29 07:24:27 +08:00
|
|
|
foreach(generated IN LISTS generated_binding_files)
|
|
|
|
add_custom_command(
|
|
|
|
TARGET copy_binding_output_files
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bindings/${generated} ${bdir}/tests/${generated}
|
|
|
|
COMMENT "Copy ${generated} to bindingtester")
|
|
|
|
endforeach()
|
|
|
|
|
2020-04-28 09:17:20 +08:00
|
|
|
add_custom_target(copy_bindingtester_binaries
|
2020-04-29 07:24:27 +08:00
|
|
|
DEPENDS ${outfiles} "${CMAKE_BINARY_DIR}/bindingtester.touch" copy_binding_output_files)
|
2020-03-27 07:01:58 +08:00
|
|
|
add_dependencies(copy_bindingtester_binaries strip_only_fdbserver strip_only_fdbcli strip_only_fdb_c)
|
2020-03-28 00:47:37 +08:00
|
|
|
set(tar_file ${CMAKE_BINARY_DIR}/packages/bindingtester-${CMAKE_PROJECT_VERSION}.tar.gz)
|
2020-03-27 07:01:58 +08:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${tar_file}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E tar czf ${tar_file} *
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bindingtester
|
|
|
|
COMMENT "Pack bindingtester")
|
|
|
|
add_custom_target(bindingtester ALL DEPENDS ${tar_file})
|
|
|
|
add_dependencies(bindingtester copy_bindingtester_binaries)
|
2019-01-23 06:25:20 +08:00
|
|
|
endfunction()
|
2020-09-25 05:43:05 +08:00
|
|
|
|
2021-03-10 04:14:54 +08:00
|
|
|
# Creates a single cluster before running the specified command (usually a ctest test)
|
2020-09-25 05:43:05 +08:00
|
|
|
function(add_fdbclient_test)
|
|
|
|
set(options DISABLED ENABLED)
|
2021-07-15 14:55:54 +08:00
|
|
|
set(oneValueArgs NAME PROCESS_NUMBER TEST_TIMEOUT)
|
2020-09-25 05:43:05 +08:00
|
|
|
set(multiValueArgs COMMAND)
|
|
|
|
cmake_parse_arguments(T "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
2021-01-26 08:09:32 +08:00
|
|
|
if(OPEN_FOR_IDE)
|
|
|
|
return()
|
|
|
|
endif()
|
2020-09-25 05:43:05 +08:00
|
|
|
if(NOT T_ENABLED AND T_DISABLED)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
if(NOT T_NAME)
|
|
|
|
message(FATAL_ERROR "NAME is a required argument for add_fdbclient_test")
|
|
|
|
endif()
|
|
|
|
if(NOT T_COMMAND)
|
|
|
|
message(FATAL_ERROR "COMMAND is a required argument for add_fdbclient_test")
|
|
|
|
endif()
|
|
|
|
message(STATUS "Adding Client test ${T_NAME}")
|
2021-07-15 04:17:12 +08:00
|
|
|
if (T_PROCESS_NUMBER)
|
|
|
|
add_test(NAME "${T_NAME}"
|
2021-07-22 03:46:39 +08:00
|
|
|
COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/TestRunner/tmp_cluster.py
|
2020-09-25 05:43:05 +08:00
|
|
|
--build-dir ${CMAKE_BINARY_DIR}
|
2021-07-15 04:17:12 +08:00
|
|
|
--process-number ${T_PROCESS_NUMBER}
|
2020-09-25 05:43:05 +08:00
|
|
|
--
|
|
|
|
${T_COMMAND})
|
2021-07-15 04:17:12 +08:00
|
|
|
else()
|
|
|
|
add_test(NAME "${T_NAME}"
|
2021-07-22 03:46:39 +08:00
|
|
|
COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/TestRunner/tmp_cluster.py
|
2021-07-15 04:17:12 +08:00
|
|
|
--build-dir ${CMAKE_BINARY_DIR}
|
|
|
|
--
|
|
|
|
${T_COMMAND})
|
|
|
|
endif()
|
2021-07-15 14:55:54 +08:00
|
|
|
if (T_TEST_TIMEOUT)
|
|
|
|
set_tests_properties("${T_NAME}" PROPERTIES TIMEOUT ${T_TEST_TIMEOUT})
|
|
|
|
else()
|
|
|
|
# default timeout
|
|
|
|
set_tests_properties("${T_NAME}" PROPERTIES TIMEOUT 60)
|
|
|
|
endif()
|
2021-06-24 00:25:51 +08:00
|
|
|
set_tests_properties("${T_NAME}" PROPERTIES ENVIRONMENT UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1)
|
2021-09-29 12:59:43 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Creates a cluster file for a nonexistent cluster before running the specified command
|
|
|
|
# (usually a ctest test)
|
|
|
|
function(add_unavailable_fdbclient_test)
|
|
|
|
set(options DISABLED ENABLED)
|
|
|
|
set(oneValueArgs NAME TEST_TIMEOUT)
|
|
|
|
set(multiValueArgs COMMAND)
|
|
|
|
cmake_parse_arguments(T "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
|
|
|
if(OPEN_FOR_IDE)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
if(NOT T_ENABLED AND T_DISABLED)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
if(NOT T_NAME)
|
|
|
|
message(FATAL_ERROR "NAME is a required argument for add_unavailable_fdbclient_test")
|
|
|
|
endif()
|
|
|
|
if(NOT T_COMMAND)
|
|
|
|
message(FATAL_ERROR "COMMAND is a required argument for add_unavailable_fdbclient_test")
|
|
|
|
endif()
|
|
|
|
message(STATUS "Adding unavailable client test ${T_NAME}")
|
|
|
|
add_test(NAME "${T_NAME}"
|
|
|
|
COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/TestRunner/fake_cluster.py
|
|
|
|
--output-dir ${CMAKE_BINARY_DIR}
|
|
|
|
--
|
|
|
|
${T_COMMAND})
|
|
|
|
if (T_TEST_TIMEOUT)
|
|
|
|
set_tests_properties("${T_NAME}" PROPERTIES TIMEOUT ${T_TEST_TIMEOUT})
|
|
|
|
else()
|
|
|
|
# default timeout
|
|
|
|
set_tests_properties("${T_NAME}" PROPERTIES TIMEOUT 60)
|
|
|
|
endif()
|
|
|
|
set_tests_properties("${T_NAME}" PROPERTIES ENVIRONMENT UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1)
|
2020-09-25 05:43:05 +08:00
|
|
|
endfunction()
|
|
|
|
|
2021-03-10 04:14:54 +08:00
|
|
|
# Creates 3 distinct clusters before running the specified command.
|
|
|
|
# This is useful for testing features that require multiple clusters (like the
|
|
|
|
# multi-cluster FDB client)
|
|
|
|
function(add_multi_fdbclient_test)
|
|
|
|
set(options DISABLED ENABLED)
|
|
|
|
set(oneValueArgs NAME)
|
|
|
|
set(multiValueArgs COMMAND)
|
|
|
|
cmake_parse_arguments(T "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
|
|
|
if(OPEN_FOR_IDE)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
if(NOT T_ENABLED AND T_DISABLED)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
if(NOT T_NAME)
|
|
|
|
message(FATAL_ERROR "NAME is a required argument for add_multi_fdbclient_test")
|
|
|
|
endif()
|
|
|
|
if(NOT T_COMMAND)
|
|
|
|
message(FATAL_ERROR "COMMAND is a required argument for add_multi_fdbclient_test")
|
|
|
|
endif()
|
|
|
|
message(STATUS "Adding Client test ${T_NAME}")
|
|
|
|
add_test(NAME "${T_NAME}"
|
2021-07-22 03:46:39 +08:00
|
|
|
COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/TestRunner/tmp_multi_cluster.py
|
2021-03-10 04:14:54 +08:00
|
|
|
--build-dir ${CMAKE_BINARY_DIR}
|
|
|
|
--clusters 3
|
|
|
|
--
|
|
|
|
${T_COMMAND})
|
|
|
|
set_tests_properties("${T_NAME}" PROPERTIES TIMEOUT 60)
|
2020-09-25 05:43:05 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(add_java_test)
|
|
|
|
set(options DISABLED ENABLED)
|
|
|
|
set(oneValueArgs NAME CLASS)
|
|
|
|
set(multiValueArgs CLASS_PATH)
|
|
|
|
cmake_parse_arguments(T "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
|
|
|
if(NOT T_ENABLED AND T_DISABLED)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
if(NOT T_NAME)
|
2021-02-05 09:24:45 +08:00
|
|
|
message(FATAL_ERROR "NAME is a required argument for add_java_test")
|
2020-09-25 05:43:05 +08:00
|
|
|
endif()
|
|
|
|
if(NOT T_CLASS)
|
2021-02-05 09:24:45 +08:00
|
|
|
message(FATAL_ERROR "CLASS is a required argument for add_java_test")
|
2020-09-25 05:43:05 +08:00
|
|
|
endif()
|
|
|
|
set(cp "")
|
|
|
|
set(separator ":")
|
|
|
|
if (WIN32)
|
|
|
|
set(separator ";")
|
|
|
|
endif()
|
2020-09-25 05:58:41 +08:00
|
|
|
message(STATUS "CLASSPATH ${T_CLASS_PATH}")
|
|
|
|
foreach(path ${T_CLASS_PATH})
|
2020-09-25 05:43:05 +08:00
|
|
|
if(cp)
|
|
|
|
set(cp "${cp}${separator}${path}")
|
|
|
|
else()
|
|
|
|
set(cp "${path}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
add_fdbclient_test(
|
|
|
|
NAME ${T_NAME}
|
2020-09-25 23:38:33 +08:00
|
|
|
COMMAND ${Java_JAVA_EXECUTABLE}
|
|
|
|
-cp "${cp}"
|
|
|
|
-Djava.library.path=${CMAKE_BINARY_DIR}/lib
|
|
|
|
${T_CLASS} "@CLUSTER_FILE@")
|
2020-09-25 05:43:05 +08:00
|
|
|
endfunction()
|