diff options
author | Luke Chen <luke.chen@mongodb.com> | 2021-06-02 16:56:12 +1000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-02 07:18:21 +0000 |
commit | 80526485d3a782397c8e2ab8ac1eb0b85546dd97 (patch) | |
tree | 8c1784f32b3a0911b043558b7f7c3391db00c7dd | |
parent | 911e585044f76bb244f425066bfcb838e9dfb258 (diff) | |
download | mongo-80526485d3a782397c8e2ab8ac1eb0b85546dd97.tar.gz |
Import wiredtiger: 5625eb9ce90b3be2c2f8df38187219d5b05c098b from branch mongodb-5.0
ref: 0784f508f9..5625eb9ce9
for: 5.1.0
WT-7535 Complete CMake Windows support
13 files changed, 353 insertions, 77 deletions
diff --git a/src/third_party/wiredtiger/bench/wtperf/wtperf.c b/src/third_party/wiredtiger/bench/wtperf/wtperf.c index b8a36408962..032acd855ac 100644 --- a/src/third_party/wiredtiger/bench/wtperf/wtperf.c +++ b/src/third_party/wiredtiger/bench/wtperf/wtperf.c @@ -2583,14 +2583,10 @@ stop_threads(u_int num, WTPERF_THREAD *threads) static void recreate_dir(const char *name) { - char *buf; - size_t len; - - len = strlen(name) * 2 + 100; - buf = dmalloc(len); - testutil_check(__wt_snprintf(buf, len, "rm -rf %s && mkdir %s", name, name)); - testutil_checkfmt(system(buf), "system: %s", buf); - free(buf); + /* Clean the directory if it already exists. */ + testutil_clean_work_dir(name); + /* Recreate the directory. */ + testutil_make_work_dir(name); } static int diff --git a/src/third_party/wiredtiger/build_cmake/README.md b/src/third_party/wiredtiger/build_cmake/README.md index 42842bbe524..827242f722d 100644 --- a/src/third_party/wiredtiger/build_cmake/README.md +++ b/src/third_party/wiredtiger/build_cmake/README.md @@ -1,5 +1,4 @@ # Building WiredTiger with CMake -> *CMake support for building wiredtiger is an active work-in-progress. As of this time CMake can **only** build the WiredTiger library for POSIX platforms (Linux & Darwin). We suggest you continue using the SCons buildsystem when compiling for Windows.* ### Build Dependencies @@ -38,6 +37,16 @@ brew install python brew install swig ``` +###### Install commands for Windows (using Chocolatey) + +```bash +choco install cmake +choco install ninja +choco install ccache --version=3.7.9 +choco install swig +choco install python --pre +``` + ### Building the WiredTiger Library > *The below commands are written for Linux and Darwin hosts. Windows instructions coming soon!* @@ -105,7 +114,7 @@ $ ccmake . *The configuration options can also be viewed in `build_cmake/configs/base.cmake`*. -###### Switching between GCC and Clang +###### Switching between GCC and Clang (POSIX only) By default CMake will use your default system compiler (`cc`). If you want to use a specific toolchain you can pass a toolchain file! We have provided a toolchain file for both GCC (`build_cmake/toolchains/gcc.cmake`) and Clang (`build_cmake/toolchains/clang.cmake`). To use either toolchain you can pass the `-DCMAKE_TOOLCHAIN_FILE=` to the CMake configuration step. For example: diff --git a/src/third_party/wiredtiger/build_cmake/configs/auto.cmake b/src/third_party/wiredtiger/build_cmake/configs/auto.cmake index 1df2578ed53..01029fd092f 100644 --- a/src/third_party/wiredtiger/build_cmake/configs/auto.cmake +++ b/src/third_party/wiredtiger/build_cmake/configs/auto.cmake @@ -27,10 +27,17 @@ if(${u_intmax_size} STREQUAL "") endif() endif() +set(default_offt_def) +if("${WT_OS}" STREQUAL "windows") + set(default_offt_def "typedef int64_t wt_off_t\\;") +else() + set(default_offt_def "typedef off_t wt_off_t\\;") +endif() + config_string( off_t_decl "off_t type declaration." - DEFAULT "typedef off_t wt_off_t\\;" + DEFAULT "${default_offt_def}" INTERNAL ) @@ -297,7 +304,7 @@ set(wiredtiger_includes_decl) if(HAVE_SYS_TYPES_H) list(APPEND wiredtiger_includes_decl "#include <sys/types.h>") endif() -if(HAVE_INTTYPES_H) +if(HAVE_INTTYPES_H AND (NOT "${WT_OS}" STREQUAL "windows")) list(APPEND wiredtiger_includes_decl "#include <inttypes.h>") endif() if(HAVE_STDARG_H) diff --git a/src/third_party/wiredtiger/build_cmake/configs/base.cmake b/src/third_party/wiredtiger/build_cmake/configs/base.cmake index a572fcb901e..95919f70f5e 100644 --- a/src/third_party/wiredtiger/build_cmake/configs/base.cmake +++ b/src/third_party/wiredtiger/build_cmake/configs/base.cmake @@ -70,7 +70,6 @@ config_bool( ENABLE_PYTHON "Configure the python API" DEFAULT OFF - DEPENDS "NOT ENABLE_STATIC" ) config_bool( @@ -85,6 +84,13 @@ config_bool( DEFAULT OFF ) +config_bool( + DYNAMIC_CRT + "Link with the MSVCRT DLL version" + DEFAULT OFF + DEPENDS "WT_WIN" +) + config_choice( SPINLOCK_TYPE "Set a spinlock type" @@ -145,10 +151,16 @@ config_bool( DEPENDS_ERROR ON "Failed to find tcmalloc library" ) +set(default_optimize_level) +if("${WT_OS}" STREQUAL "windows") + set(default_optimize_level "/O2") +else() + set(default_optimize_level "-O3") +endif() config_string( CC_OPTIMIZE_LEVEL "CC optimization level" - DEFAULT "-O3" + DEFAULT "${default_optimize_level}" ) config_string( @@ -180,7 +192,25 @@ config_string( if(HAVE_DIAGNOSTIC AND (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")) # Avoid setting diagnostic flags if we are building with Debug mode. # CMakes Debug config sets compilation with debug symbols by default. - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + # Produce full symbolic debugging information. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Z7") + # Ensure a PDB file can be generated for debugging symbols. + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG") + else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + endif() +endif() + +if(WT_WIN) + # Check if we a using the dynamic or static run-time library. + if(DYNAMIC_CRT) + # Use the multithread-specific and DLL-specific version of the run-time library (MSVCRT.lib). + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MD") + else() + # Use the multithread, static version of the run-time library. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MT") + endif() endif() if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release") diff --git a/src/third_party/wiredtiger/build_cmake/configs/modes.cmake b/src/third_party/wiredtiger/build_cmake/configs/modes.cmake index 29b5672da6d..74bf5cf8188 100644 --- a/src/third_party/wiredtiger/build_cmake/configs/modes.cmake +++ b/src/third_party/wiredtiger/build_cmake/configs/modes.cmake @@ -8,72 +8,105 @@ # Establishes build configuration modes we can use when compiling. -# Create an ASAN build variant +include(CheckCCompilerFlag) -# Clang and GCC have slightly different linker names for the ASAN library. -set(libasan) -if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") - set(libasan "-static-libsan") +set(build_modes None Debug Release) +if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + set(no_omit_frame_flag "/Oy-") else() - set(libasan "-static-libasan") + set(no_omit_frame_flag "-fno-omit-frame-pointer") endif() -set(CMAKE_C_FLAGS_ASAN - "${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer" CACHE STRING - "Flags used by the C compiler for ASan build type or configuration." FORCE) - -set(CMAKE_CXX_FLAGS_ASAN - "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer" CACHE STRING - "Flags used by the C++ compiler for ASan build type or configuration." FORCE) - -set(CMAKE_EXE_LINKER_FLAGS_ASAN - "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address ${libasan}" CACHE STRING - "Linker flags to be used to create executables for ASan build type." FORCE) - -set(CMAKE_SHARED_LINKER_FLAGS_ASAN - "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address ${libasan}" CACHE STRING - "Linker lags to be used to create shared libraries for ASan build type." FORCE) +# Create an ASAN build variant +if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + set(asan_link_flags "/fsanitize=address") + set(asan_compiler_flag "/fsanitize=address") +elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") + set(asan_link_flags "-fsanitize=address -static-libsan") + set(asan_compiler_flag "-fsanitize=address") +else() + set(asan_link_flags "-fsanitize=address -static-libasan") + set(asan_compiler_flag "-fsanitize=address") +endif() -mark_as_advanced( - CMAKE_CXX_FLAGS_ASAN - CMAKE_C_FLAGS_ASAN - CMAKE_EXE_LINKER_FLAGS_ASAN - CMAKE_SHARED_LINKER_FLAGS_ASAN -) +# Needs to validate linker flags for the test to also pass. +set(CMAKE_REQUIRED_FLAGS "${asan_link_flags}") +# Check if the ASAN compiler flag is available. +check_c_compiler_flag("${asan_compiler_flag}" HAVE_ADDRESS_SANITIZER) +unset(CMAKE_REQUIRED_FLAGS) + +if(HAVE_ADDRESS_SANITIZER) + set(CMAKE_C_FLAGS_ASAN + "${CMAKE_C_FLAGS_DEBUG} ${asan_compiler_flag} ${no_omit_frame_flag}" CACHE STRING + "Flags used by the C compiler for ASan build type or configuration." FORCE) + + set(CMAKE_CXX_FLAGS_ASAN + "${CMAKE_CXX_FLAGS_DEBUG} ${asan_compiler_flag} ${no_omit_frame_flag}" CACHE STRING + "Flags used by the C++ compiler for ASan build type or configuration." FORCE) + + set(CMAKE_EXE_LINKER_FLAGS_ASAN + "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${asan_link_flags}" CACHE STRING + "Linker flags to be used to create executables for ASan build type." FORCE) + + set(CMAKE_SHARED_LINKER_FLAGS_ASAN + "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${asan_link_flags}" CACHE STRING + "Linker lags to be used to create shared libraries for ASan build type." FORCE) + + mark_as_advanced( + CMAKE_CXX_FLAGS_ASAN + CMAKE_C_FLAGS_ASAN + CMAKE_EXE_LINKER_FLAGS_ASAN + CMAKE_SHARED_LINKER_FLAGS_ASAN + ) + list(APPEND build_modes "ASan") +endif() # Create an UBSAN build variant - -# Clang doesn't need to link ubsan, this is only a GCC requirement. -set(libubsan "") -if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") - set(libubsan "-lubsan") +if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + set(ubsan_link_flags "/fsanitize=undefined") + set(ubsan_compiler_flag "/fsanitize=undefined") +elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") + set(ubsan_link_flags "-fsanitize=undefined") + set(ubsan_compiler_flag "-fsanitize=undefined") +else() + set(ubsan_link_flags "-fsanitize=undefined -lubsan") + set(ubsan_compiler_flag "-fsanitize=undefined") endif() -set(CMAKE_C_FLAGS_UBSAN - "${CMAKE_C_FLAGS_DEBUG} -fsanitize=undefined -fno-omit-frame-pointer" CACHE STRING - "Flags used by the C compiler for UBSan build type or configuration." FORCE) - -set(CMAKE_CXX_FLAGS_UBSAN - "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined -fno-omit-frame-pointer" CACHE STRING - "Flags used by the C++ compiler for UBSan build type or configuration." FORCE) - -set(CMAKE_EXE_LINKER_FLAGS_UBSAN - "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=undefined ${libubsan}" CACHE STRING - "Linker flags to be used to create executables for UBSan build type." FORCE) - -set(CMAKE_SHARED_LINKER_FLAGS_UBSAN - "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=undefined ${libubsan}" CACHE STRING - "Linker lags to be used to create shared libraries for UBSan build type." FORCE) - -mark_as_advanced( - CMAKE_CXX_FLAGS_UBSAN - CMAKE_C_FLAGS_UBSAN - CMAKE_EXE_LINKER_FLAGS_UBSAN - CMAKE_SHARED_LINKER_FLAGS_UBSAN -) - +# Needs to validate linker flags for the test to also pass. +set(CMAKE_REQUIRED_FLAGS "${ubsan_link_flags}") +# Check if the UBSAN compiler flag is available. +check_c_compiler_flag("${ubsan_compiler_flag}" HAVE_UB_SANITIZER) +unset(CMAKE_REQUIRED_FLAGS) + +if(HAVE_UB_SANITIZER) + set(CMAKE_C_FLAGS_UBSAN + "${CMAKE_C_FLAGS_DEBUG} ${ubsan_compiler_flag} ${no_omit_frame_flag}" CACHE STRING + "Flags used by the C compiler for UBSan build type or configuration." FORCE) + + set(CMAKE_CXX_FLAGS_UBSAN + "${CMAKE_CXX_FLAGS_DEBUG} ${ubsan_compiler_flag} ${no_omit_frame_flag}" CACHE STRING + "Flags used by the C++ compiler for UBSan build type or configuration." FORCE) + + set(CMAKE_EXE_LINKER_FLAGS_UBSAN + "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${ubsan_link_flags}" CACHE STRING + "Linker flags to be used to create executables for UBSan build type." FORCE) + + set(CMAKE_SHARED_LINKER_FLAGS_UBSAN + "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${ubsan_link_flags}" CACHE STRING + "Linker lags to be used to create shared libraries for UBSan build type." FORCE) + + mark_as_advanced( + CMAKE_CXX_FLAGS_UBSAN + CMAKE_C_FLAGS_UBSAN + CMAKE_EXE_LINKER_FLAGS_UBSAN + CMAKE_SHARED_LINKER_FLAGS_UBSAN + ) + list(APPEND build_modes "UBSan") +endif() if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "None" CACHE STRING "Choose the type of build, options are: None Debug Release ASan UBSan." FORCE) + string(REPLACE ";" " " build_modes_doc "${build_modes}") + set(CMAKE_BUILD_TYPE "None" CACHE STRING "Choose the type of build, options are: ${build_modes_doc}." FORCE) endif() -set(CMAKE_CONFIGURATION_TYPES None Debug Release ASan UBSan) +set(CMAKE_CONFIGURATION_TYPES ${build_modes}) diff --git a/src/third_party/wiredtiger/build_cmake/configs/x86/windows/config.cmake b/src/third_party/wiredtiger/build_cmake/configs/x86/windows/config.cmake new file mode 100644 index 00000000000..842708a1f9d --- /dev/null +++ b/src/third_party/wiredtiger/build_cmake/configs/x86/windows/config.cmake @@ -0,0 +1,40 @@ +# +# Public Domain 2014-present MongoDB, Inc. +# Public Domain 2008-2014 WiredTiger, Inc. +# All rights reserved. +# +# See the file LICENSE for redistribution information +# + +set(WT_ARCH "x86" CACHE STRING "") +set(WT_OS "windows" CACHE STRING "") +set(WT_POSIX OFF CACHE BOOL "") +set(SPINLOCK_TYPE "msvc" CACHE STRING "" FORCE) +# We force a static compilation to generate a ".lib" file. We can then +# additionally generate a dll file using a *DEF file. +set(ENABLE_STATIC ON CACHE BOOL "" FORCE) + +# Compile as C code . +add_compile_options(/TC) +# Inline expansion. +add_compile_options(/Ob1) +# Enable string pooling. +add_compile_options(/GF) +# Extern "C" does not throw. +add_compile_options(/EHsc) +# Separate functions for linker. +add_compile_options(/Gy) +# Conformance: wchar_t is a native type, not a typedef. +add_compile_options(/Zc:wchar_t) +# Use the __cdecl calling convention for all functions. +add_compile_options(/Gd) + +# Disable incremental linking. +string(APPEND win_link_flags " /INCREMENTAL:NO") +# Remove dead code. +string(APPEND win_link_flags " /OPT:REF") +# Allow executables to be randomly rebased at load time (enables virtual address allocation randomization). +string(APPEND win_link_flags " /DYNAMICBASE") +# Executable is compatible with the Windows Data Execution Prevention. +string(APPEND win_link_flags " /NXCOMPAT") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${win_link_flags}") diff --git a/src/third_party/wiredtiger/build_cmake/helpers.cmake b/src/third_party/wiredtiger/build_cmake/helpers.cmake index d353c04aa8a..2b65f537afa 100644 --- a/src/third_party/wiredtiger/build_cmake/helpers.cmake +++ b/src/third_party/wiredtiger/build_cmake/helpers.cmake @@ -251,7 +251,7 @@ function(config_bool config_name description) endif() endif() # Config doesn't meet dependency requirements, set its default state and flag it as disabled. - set(${config_name} ${CONFIG_BOOL_DEFAULT} CACHE STRING "${description}" FORCE) + set(${config_name} OFF CACHE STRING "${description}" FORCE) set(${config_name}_DISABLED ON CACHE INTERNAL "" FORCE) endif() endfunction() diff --git a/src/third_party/wiredtiger/build_cmake/strict/cl_strict.cmake b/src/third_party/wiredtiger/build_cmake/strict/cl_strict.cmake new file mode 100644 index 00000000000..625bf9e88d5 --- /dev/null +++ b/src/third_party/wiredtiger/build_cmake/strict/cl_strict.cmake @@ -0,0 +1,21 @@ +# +# Public Domain 2014-present MongoDB, Inc. +# Public Domain 2008-2014 WiredTiger, Inc. +# All rights reserved. +# +# See the file LICENSE for redistribution information. +# + +# Warning level 3. +list(APPEND win_c_flags "/WX") +# Ignore warning about mismatched const qualifiers. +list(APPEND win_c_flags "/wd4090") +# Ignore deprecated functions. +list(APPEND win_c_flags "/wd4996") +# Complain about unreferenced format parameter. +list(APPEND win_c_flags "/we4100") +# Enable security check. +list(APPEND win_c_flags "/GS") + +# Set our base compiler flags that can be used by the rest of our build. +set(COMPILER_DIAGNOSTIC_FLAGS "${COMPILER_DIAGNOSTIC_FLAGS};${win_c_flags}" CACHE INTERNAL "" FORCE) diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index 2d2fa53ff3f..548bead5fca 100644 --- a/src/third_party/wiredtiger/import.data +++ b/src/third_party/wiredtiger/import.data @@ -2,5 +2,5 @@ "vendor": "wiredtiger", "github": "wiredtiger/wiredtiger.git", "branch": "mongodb-5.0", - "commit": "0784f508f9ea28834c848ec36467fa9ad7a48f15" + "commit": "5625eb9ce90b3be2c2f8df38187219d5b05c098b" } diff --git a/src/third_party/wiredtiger/test/bloom/test_bloom.c b/src/third_party/wiredtiger/test/bloom/test_bloom.c index 76b5bc0a50b..fb964c52a31 100644 --- a/src/third_party/wiredtiger/test/bloom/test_bloom.c +++ b/src/third_party/wiredtiger/test/bloom/test_bloom.c @@ -28,6 +28,8 @@ #include "test_util.h" +#define HOME_SIZE 512 + static struct { WT_CONNECTION *wt_conn; /* WT_CONNECTION handle */ WT_SESSION *wt_session; /* WT_SESSION handle */ @@ -104,8 +106,14 @@ setup(void) WT_CONNECTION *conn; WT_SESSION *session; char config[512]; + static char home[HOME_SIZE]; /* Base home directory */ + + testutil_work_dir_from_path(home, HOME_SIZE, "WT_TEST"); - testutil_check(system("rm -f WiredTiger* *.bf")); + /* Clean the test directory if it already exists. */ + testutil_clean_work_dir(home); + /* Create the home test directory for the test. */ + testutil_make_work_dir(home); /* * This test doesn't test public Wired Tiger functionality, it still needs connection and @@ -120,7 +128,7 @@ setup(void) "create,error_prefix=\"%s\",cache_size=%" PRIu32 "MB,%s", progname, g.c_cache, g.config_open == NULL ? "" : g.config_open)); - testutil_check(wiredtiger_open(NULL, NULL, config, &conn)); + testutil_check(wiredtiger_open(home, NULL, config, &conn)); testutil_check(conn->open_session(conn, NULL, NULL, &session)); diff --git a/src/third_party/wiredtiger/test/ctest_helpers.cmake b/src/third_party/wiredtiger/test/ctest_helpers.cmake index 08584b719ca..d11f494c8ce 100644 --- a/src/third_party/wiredtiger/test/ctest_helpers.cmake +++ b/src/third_party/wiredtiger/test/ctest_helpers.cmake @@ -104,6 +104,15 @@ function(create_test_executable target) target_link_libraries(${target} ${CREATE_TEST_LIBS}) endif() + # If compiling for windows, additionally link in the shim library. + if(WT_WIN) + target_include_directories( + ${target} + PUBLIC ${CMAKE_SOURCE_DIR}/test/windows + ) + target_link_libraries(${target} windows_shim) + endif() + # Install any additional files, scripts, etc in the output test binary # directory. Useful if we need to setup an additional wrappers needed to run the test # executable. @@ -133,3 +142,123 @@ function(create_test_executable target) add_dependencies(${target} copy_dir_${target}_${dir_basename}) endforeach() endfunction() + +function(define_test_variants target) + cmake_parse_arguments( + PARSE_ARGV + 1 + "DEFINE_TEST" + "" + "" + "VARIANTS;LABELS" + ) + if (NOT "${DEFINE_TEST_UNPARSED_ARGUMENTS}" STREQUAL "") + message(FATAL_ERROR "Unknown arguments to define_test_variants: ${DEFINE_TEST_VARIANTS_UNPARSED_ARGUMENTS}") + endif() + if ("${DEFINE_TEST_VARIANTS}" STREQUAL "") + message(FATAL_ERROR "Need at least one variant for define_test_variants") + endif() + + set(defined_tests) + foreach(variant ${DEFINE_TEST_VARIANTS}) + list(LENGTH variant variant_length) + if (NOT variant_length EQUAL 2) + message( + FATAL_ERROR + "Invalid variant format: ${variant} - Expected format 'variant_name;variant args'" + ) + endif() + list(GET variant 0 curr_variant_name) + list(GET variant 1 curr_variant_args) + set(variant_args) + if(WT_WIN) + separate_arguments(variant_args WINDOWS_COMMAND ${curr_variant_args}) + else() + separate_arguments(variant_args UNIX_COMMAND ${curr_variant_args}) + endif() + # Create a variant directory to run the test in. + add_custom_target(${curr_variant_name}_test_dir + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${curr_variant_name}) + # Ensure the variant target is created prior to building the test. + add_dependencies(${target} ${curr_variant_name}_test_dir) + add_test( + NAME ${curr_variant_name} + COMMAND $<TARGET_FILE:${target}> ${variant_args} + # Run each variant in its own subdirectory, allowing us to execute variants in + # parallel. + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${curr_variant_name} + ) + list(APPEND defined_tests ${curr_variant_name}) + endforeach() + if(DEFINE_TEST_LABELS) + set_tests_properties(${defined_tests} PROPERTIES LABELS "${DEFINE_TEST_LABELS}") + endif() +endfunction() + +macro(define_c_test) + cmake_parse_arguments( + "C_TEST" + "SMOKE" + "TARGET;DIR_NAME;DEPENDS" + "SOURCES;FLAGS;ARGUMENTS" + ${ARGN} + ) + if (NOT "${C_TEST_UNPARSED_ARGUMENTS}" STREQUAL "") + message(FATAL_ERROR "Unknown arguments to define_c_test: ${C_TEST_UNPARSED_ARGUMENTS}") + endif() + if ("${C_TEST_TARGET}" STREQUAL "") + message(FATAL_ERROR "No target name given to define_c_test") + endif() + if ("${C_TEST_SOURCES}" STREQUAL "") + message(FATAL_ERROR "No sources given to define_c_test") + endif() + if ("${C_TEST_DIR_NAME}" STREQUAL "") + message(FATAL_ERROR "No directory given to define_c_test") + endif() + + # Check that the csuite dependencies are enabled before compiling and creating the test. + eval_dependency("${C_TEST_DEPENDS}" enabled) + if(enabled) + set(additional_executable_args) + if(NOT "${C_TEST_FLAGS}" STREQUAL "") + list(APPEND additional_executable_args FLAGS ${C_TEST_FLAGS}) + endif() + if (C_TEST_SMOKE) + # csuite test comes with a smoke execution wrapper. + create_test_executable(${C_TEST_TARGET} + SOURCES ${C_TEST_SOURCES} + ADDITIONAL_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${C_TEST_DIR_NAME}/smoke.sh + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${C_TEST_DIR_NAME} + ${additional_executable_args} + ) + add_test(NAME ${C_TEST_TARGET} + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${C_TEST_DIR_NAME}/smoke.sh ${C_TEST_ARGUMENTS} $<TARGET_FILE:${C_TEST_TARGET}> + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${C_TEST_DIR_NAME} + ) + else() + create_test_executable(${C_TEST_TARGET} + SOURCES ${C_TEST_SOURCES} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${C_TEST_DIR_NAME} + ${additional_executable_args} + ) + # Take a CMake-based path and convert it to a platform-specfic path (/ for Unix, \ for Windows). + set(wt_test_home_dir ${CMAKE_CURRENT_BINARY_DIR}/${C_TEST_DIR_NAME}/WT_HOME_${C_TEST_TARGET}) + file(TO_NATIVE_PATH "${wt_test_home_dir}" wt_test_home_dir) + # Ensure each DB home directory is run under the tests working directory. + set(command_args -h ${wt_test_home_dir}) + list(APPEND command_args ${C_TEST_ARGUMENTS}) + set(exec_wrapper) + if(WT_WIN) + # This is a workaround to run our csuite tests under Windows using CTest. When executing a test, + # CTests by-passes the shell and directly executes the test as a child process. In doing so CTest executes the binary with forward-slash paths. + # Which while technically valid breaks assumptions in our testing utilities. Wrap the execution in powershell to avoid this. + set(exec_wrapper "powershell.exe") + endif() + add_test(NAME ${C_TEST_TARGET} + COMMAND ${exec_wrapper} $<TARGET_FILE:${C_TEST_TARGET}> ${command_args} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${C_TEST_DIR_NAME} + ) + endif() + list(APPEND c_tests ${C_TEST_TARGET}) + endif() +endmacro(define_c_test) diff --git a/src/third_party/wiredtiger/test/manydbs/manydbs.c b/src/third_party/wiredtiger/test/manydbs/manydbs.c index 9cb970e04bd..2dc0e5a1f8f 100644 --- a/src/third_party/wiredtiger/test/manydbs/manydbs.c +++ b/src/third_party/wiredtiger/test/manydbs/manydbs.c @@ -164,7 +164,8 @@ main(int argc, char *argv[]) testutil_make_work_dir(home); __wt_random_init(&rnd); for (i = 0; i < dbs; ++i) { - testutil_check(__wt_snprintf(hometmp, HOME_SIZE, "%s/%s.%d", home, HOME_BASE, i)); + testutil_check( + __wt_snprintf(hometmp, HOME_SIZE, "%s%c%s.%d", home, DIR_DELIM, HOME_BASE, i)); testutil_make_work_dir(hometmp); /* * Open each database. Rotate different configurations among them. Open a session and diff --git a/src/third_party/wiredtiger/test/suite/run.py b/src/third_party/wiredtiger/test/suite/run.py index d173fb7c10b..86aafdb261c 100755 --- a/src/third_party/wiredtiger/test/suite/run.py +++ b/src/third_party/wiredtiger/test/suite/run.py @@ -61,6 +61,8 @@ elif os.path.basename(curdir) == '.libs' and \ wt_builddir = os.path.join(curdir, os.pardir) elif os.path.isfile(os.path.join(curdir, 'wt')): wt_builddir = curdir +elif os.path.isfile(os.path.join(curdir, 'wt.exe')): + wt_builddir = curdir elif os.path.isfile(os.path.join(wt_disttop, 'wt')): wt_builddir = wt_disttop elif os.path.isfile(os.path.join(wt_disttop, 'build_posix', 'wt')): |