From: Lucian Petrut Date: Thu, 19 Dec 2019 13:32:47 +0000 (+0000) Subject: test: Update cmake files, allowing tests to run on Windows X-Git-Tag: v16.1.0~69^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=67a35a582c8c4396535b765453d21f69cd7bb129;p=ceph.git test: Update cmake files, allowing tests to run on Windows We're porting to Windows some of the unit tests, mostly related to rados and rbd. This change filters out the tests that aren't supported on Windows. At the same time, we're defining some missing dependencies since unlike ELFs SOs, all DLL symbols have to be resolved at compile time. Signed-off-by: Lucian Petrut --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b5b5153cf80..dc9b5bd5117f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -578,7 +578,7 @@ option(WITH_SYSTEM_BOOST "require and build with system Boost" OFF) # Boost::thread depends on Boost::atomic, so list it explicitly. set(BOOST_COMPONENTS atomic chrono thread system regex random program_options date_time - iostreams context coroutine) + iostreams context coroutine filesystem) set(BOOST_HEADER_COMPONENTS container) if(WITH_MGR) @@ -586,7 +586,7 @@ if(WITH_MGR) python${MGR_PYTHON_VERSION_MAJOR}${MGR_PYTHON_VERSION_MINOR}) endif() if(WITH_SEASTAR) - list(APPEND BOOST_COMPONENTS filesystem timer) + list(APPEND BOOST_COMPONENTS timer) endif() if(WITH_RADOSGW AND WITH_RADOSGW_LUA_PACKAGES) diff --git a/src/osdc/CMakeLists.txt b/src/osdc/CMakeLists.txt index 551b105f893f..205ad3d4f42e 100644 --- a/src/osdc/CMakeLists.txt +++ b/src/osdc/CMakeLists.txt @@ -5,6 +5,7 @@ set(osdc_files error_code.cc Striper.cc) add_library(osdc STATIC ${osdc_files}) +target_link_libraries(osdc ceph-common) if(WITH_EVENTTRACE) add_dependencies(osdc eventtrace_tp) endif() diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index f66087fb087c..dd2011066f73 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -3,61 +3,76 @@ include(AddCephTest) set(UNITTEST_LIBS GMock::Main GMock::GMock GTest::GTest ${CMAKE_THREAD_LIBS_INIT} ${GSSAPI_LIBRARIES} ${OPENLDAP_LIBRARIES} ${CMAKE_DL_LIBS}) +if(WIN32) + # Needed by Boost. + list(APPEND UNITTEST_LIBS ws2_32) +endif() + add_library(unit-main OBJECT unit.cc) target_include_directories(unit-main PRIVATE $) -add_subdirectory(cls_hello) -add_subdirectory(cls_fifo) -add_subdirectory(cls_lock) -add_subdirectory(cls_cas) -add_subdirectory(cls_log) -add_subdirectory(cls_numops) -add_subdirectory(cls_sdk) -if(WITH_RBD) - add_subdirectory(cls_journal) - add_subdirectory(cls_rbd) -endif(WITH_RBD) -add_subdirectory(cls_refcount) -add_subdirectory(cls_rgw) -add_subdirectory(cls_version) -add_subdirectory(cls_lua) -add_subdirectory(cls_rgw_gc) -add_subdirectory(cls_queue) -add_subdirectory(cls_2pc_queue) -add_subdirectory(cls_cmpomap) add_subdirectory(common) add_subdirectory(compressor) add_subdirectory(crush) add_subdirectory(direct_messenger) add_subdirectory(encoding) -add_subdirectory(erasure-code) -add_subdirectory(filestore) -add_subdirectory(fs) -add_subdirectory(journal) -add_subdirectory(libcephfs) add_subdirectory(librados) -add_subdirectory(neorados) add_subdirectory(librados_test_stub) if(WITH_LIBRADOSSTRIPER) add_subdirectory(libradosstriper) endif() -if(WITH_RBD) +if(WITH_RBD AND NOT WIN32) + # librbd tests require libcls*, which in turn require libos and libosd, which + # haven't been ported to Windows yet. add_subdirectory(librbd) -endif(WITH_RBD) +endif(WITH_RBD AND NOT WIN32) if (WITH_CEPHFS) add_subdirectory(mds) endif() -add_subdirectory(mon) -add_subdirectory(mgr) -add_subdirectory(msgr) -add_subdirectory(ObjectMap) -add_subdirectory(objectstore) -add_subdirectory(os) -add_subdirectory(osd) -add_subdirectory(osdc) add_subdirectory(pybind) -add_subdirectory(immutable_object_cache) + +# Not available on Windows for the time being. +if(NOT WIN32) + # libcls_* dependencies cascade to osd, kv and other libs that are not + # available on Windows yet. + add_subdirectory(cls_hello) + add_subdirectory(cls_fifo) + add_subdirectory(cls_cas) + add_subdirectory(cls_lock) + add_subdirectory(cls_log) + add_subdirectory(cls_numops) + add_subdirectory(cls_sdk) + if(WITH_RBD) + add_subdirectory(cls_journal) + add_subdirectory(cls_rbd) + endif(WITH_RBD) + add_subdirectory(cls_refcount) + add_subdirectory(cls_rgw) + add_subdirectory(cls_version) + add_subdirectory(cls_lua) + add_subdirectory(cls_rgw_gc) + add_subdirectory(cls_queue) + add_subdirectory(cls_2pc_queue) + add_subdirectory(cls_cmpomap) + add_subdirectory(journal) + + add_subdirectory(erasure-code) + add_subdirectory(filestore) + add_subdirectory(fs) + add_subdirectory(libcephfs) + add_subdirectory(mon) + add_subdirectory(mgr) + add_subdirectory(msgr) + add_subdirectory(neorados) + add_subdirectory(objectstore) + add_subdirectory(ObjectMap) + add_subdirectory(os) + add_subdirectory(osd) + add_subdirectory(osdc) + add_subdirectory(immutable_object_cache) +endif() + if(WITH_RADOSGW) set(rgw_libs rgw_a) if(WITH_RADOSGW_AMQP_ENDPOINT) @@ -68,9 +83,9 @@ if(WITH_RADOSGW) endif() add_subdirectory(rgw) endif(WITH_RADOSGW) -if(WITH_RBD) - add_subdirectory(rbd_mirror) -endif(WITH_RBD) +if(WITH_RBD AND NOT WIN32) +add_subdirectory(rbd_mirror) +endif(WITH_RBD AND NOT WIN32) if(WITH_SEASTAR) add_subdirectory(crimson) endif() @@ -119,7 +134,10 @@ if(WITH_LIBCEPHFS) endif(WITH_LIBCEPHFS) add_executable(test_build_librados buildtest_skeleton.cc) -target_link_libraries(test_build_librados librados pthread ${CRYPTO_LIBS} ${EXTRALIBS} osdc osd os ceph-common cls_lock_client ${BLKID_LIBRARIES}) +target_link_libraries(test_build_librados librados pthread ${CRYPTO_LIBS} ${EXTRALIBS} ceph-common ${BLKID_LIBRARIES}) +if(NOT WIN32) + target_link_libraries(test_build_librados os osdc osd cls_lock_client) +endif() # bench_log set(bench_log_srcs @@ -128,7 +146,10 @@ set(bench_log_srcs add_executable(ceph_bench_log ${bench_log_srcs} ) -target_link_libraries(ceph_bench_log global pthread rt ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) +target_link_libraries(ceph_bench_log global pthread ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) +if(NOT WIN32) + target_link_libraries(ceph_bench_log rt) +endif() # ceph_test_mutate add_executable(ceph_test_mutate @@ -137,11 +158,13 @@ add_executable(ceph_test_mutate target_link_libraries(ceph_test_mutate global librados ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) +if(NOT WIN32) # test_trans add_executable(test_trans test_trans.cc ) target_link_libraries(test_trans os global ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) +endif() ## Benchmarks @@ -169,9 +192,11 @@ if(WITH_KVS) install(TARGETS ceph_kvstorebench DESTINATION bin) endif(WITH_KVS) -# ceph_objectstore_bench -add_executable(ceph_objectstore_bench objectstore_bench.cc) -target_link_libraries(ceph_objectstore_bench os global ${BLKID_LIBRARIES}) +if(NOT WIN32) + # ceph_objectstore_bench + add_executable(ceph_objectstore_bench objectstore_bench.cc) + target_link_libraries(ceph_objectstore_bench os global ${BLKID_LIBRARIES}) +endif() if(${WITH_RADOSGW}) # test_cors @@ -364,6 +389,13 @@ add_executable(ceph_multi_stress_watch ) target_link_libraries(ceph_multi_stress_watch librados global radostest-cxx) +install(TARGETS + ceph_bench_log + ceph_multi_stress_watch + ceph_omapbench + DESTINATION bin) + +if(NOT WIN32) #ceph_perf_local add_executable(ceph_perf_local perf_local.cc @@ -381,10 +413,7 @@ endif() target_link_libraries(ceph_perf_local global ${UNITTEST_LIBS}) install(TARGETS - ceph_bench_log - ceph_multi_stress_watch ceph_objectstore_bench - ceph_omapbench ceph_perf_local DESTINATION bin) @@ -418,6 +447,7 @@ add_executable(ceph_test_snap_mapper $ ) target_link_libraries(ceph_test_snap_mapper osd global ${BLKID_LIBRARIES} ${UNITTEST_LIBS}) +endif(NOT WIN32) add_executable(ceph_test_stress_watch test_stress_watch.cc @@ -483,25 +513,30 @@ endif() #following dependencies are run inside make check unit tests add_dependencies(tests - ceph-mon ceph-authtool - get_command_descriptions - crushtool ceph-conf rados - monmaptool - ceph-osd + ceph_snappy) +if(NOT WIN32) + # Not currently supported on Windows + add_dependencies(tests + ceph-mon + get_command_descriptions ceph-dencoder ceph-objectstore-tool ceph-kvstore-tool ceph-monstore-tool + ceph-osd osdmaptool ceph_example ceph_snappy cls_lock ceph_test_objectstore ceph_erasure_code_non_regression - cython_modules) + cython_modules + crushtool + monmaptool) + if (WITH_CEPHFS) add_dependencies(tests ceph-mds) endif() @@ -535,6 +570,9 @@ if(WITH_RBD) add_ceph_test(rbd-ggate.sh ${CMAKE_CURRENT_SOURCE_DIR}/rbd-ggate.sh) endif(FREEBSD) endif(WITH_RBD) + +endif(NOT WIN32) + add_ceph_test(run-cli-tests ${CMAKE_CURRENT_SOURCE_DIR}/run-cli-tests) # flaky, see https://tracker.ceph.com/issues/44243 @@ -604,12 +642,16 @@ add_executable(unittest_str_list add_ceph_unittest(unittest_str_list) target_link_libraries(unittest_str_list global) +# This test's usage of templates generates more sections than a PE file can +# contain. +if(NOT MINGW) # unittest_log add_executable(unittest_log ${CMAKE_SOURCE_DIR}/src/log/test.cc ) add_ceph_unittest(unittest_log) target_link_libraries(unittest_log global) +endif(NOT MINGW) # unittest_base64 add_executable(unittest_base64 @@ -647,6 +689,7 @@ add_executable(unittest_run_cmd add_ceph_unittest(unittest_run_cmd) target_link_libraries(unittest_run_cmd global) +if(NOT WIN32) # signals add_executable(unittest_signals signals.cc @@ -654,6 +697,7 @@ add_executable(unittest_signals ) add_ceph_unittest(unittest_signals) target_link_libraries(unittest_signals global) +endif() # unittest_simple_spin add_executable(unittest_simple_spin @@ -835,6 +879,7 @@ target_link_libraries(unittest_rbd_replay librbd librados global + ceph-common rbd_replay rbd_replay_ios ${BLKID_LIBRARIES} @@ -860,11 +905,13 @@ add_executable(unittest_texttable add_ceph_unittest(unittest_texttable) target_link_libraries(unittest_texttable ceph-common) +if(NOT WIN32) # unittest_on_exit add_executable(unittest_on_exit on_exit.cc) add_ceph_unittest(unittest_on_exit) target_link_libraries(unittest_on_exit ceph-common) +endif() # unittest_subprocess add_executable(unittest_subprocess diff --git a/src/test/common/CMakeLists.txt b/src/test/common/CMakeLists.txt index 57229a1124e5..a625d8fb43bf 100644 --- a/src/test/common/CMakeLists.txt +++ b/src/test/common/CMakeLists.txt @@ -1,4 +1,6 @@ +if(NOT WIN32) # get_command_descriptions +# libmon not currently available on Windows. add_executable(get_command_descriptions get_command_descriptions.cc $ @@ -11,6 +13,7 @@ target_link_libraries(get_command_descriptions ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} ) +endif(NOT WIN32) # Though FreeBSD has blkdev support, the unittests' mocks only work in Linux if(HAVE_BLKID AND LINUX) @@ -64,6 +67,7 @@ add_executable(unittest_prioritized_queue target_link_libraries(unittest_prioritized_queue ceph-common) add_ceph_unittest(unittest_prioritized_queue) +if(NOT WIN32) # unittest_mclock_priority_queue add_executable(unittest_mclock_priority_queue test_mclock_priority_queue.cc @@ -72,6 +76,7 @@ add_ceph_unittest(unittest_mclock_priority_queue) target_link_libraries(unittest_mclock_priority_queue ceph-common dmclock::dmclock) +endif(NOT WIN32) # unittest_str_map add_executable(unittest_str_map @@ -285,28 +290,30 @@ if(WITH_CEPHFS) target_link_libraries(unittest_global_doublefree cephfs librados) endif(WITH_CEPHFS) +if(NOT WIN32) add_executable(unittest_dns_resolve dns_resolve.cc $) target_link_libraries(unittest_dns_resolve global) add_ceph_unittest(unittest_dns_resolve) +endif() add_executable(unittest_back_trace test_back_trace.cc) set_source_files_properties(test_back_trace.cc PROPERTIES COMPILE_FLAGS -fno-inline) -target_link_libraries(unittest_back_trace ceph-common) add_ceph_unittest(unittest_back_trace) +target_link_libraries(unittest_back_trace ceph-common) add_executable(unittest_hostname test_hostname.cc) -target_link_libraries(unittest_hostname ceph-common) add_ceph_unittest(unittest_hostname) +target_link_libraries(unittest_hostname ceph-common) add_executable(unittest_iso_8601 test_iso_8601.cc) -target_link_libraries(unittest_iso_8601 ceph-common) add_ceph_unittest(unittest_iso_8601) +target_link_libraries(unittest_iso_8601 ceph-common) add_executable(unittest_convenience test_convenience.cc) add_ceph_unittest(unittest_convenience) @@ -330,7 +337,7 @@ add_ceph_unittest(unittest_hobject) add_executable(unittest_async_completion test_async_completion.cc) add_ceph_unittest(unittest_async_completion) -target_link_libraries(unittest_async_completion Boost::system) +target_link_libraries(unittest_async_completion ceph-common Boost::system) add_executable(unittest_async_shared_mutex test_async_shared_mutex.cc) add_ceph_unittest(unittest_async_shared_mutex) diff --git a/src/test/compressor/CMakeLists.txt b/src/test/compressor/CMakeLists.txt index 30d37aace054..937694ced602 100644 --- a/src/test/compressor/CMakeLists.txt +++ b/src/test/compressor/CMakeLists.txt @@ -1,4 +1,5 @@ add_library(ceph_example SHARED compressor_plugin_example.cc) +target_link_libraries(ceph_example ceph-common) # unittest_compression add_executable(unittest_compression diff --git a/src/test/lazy-omap-stats/CMakeLists.txt b/src/test/lazy-omap-stats/CMakeLists.txt index fad71f135ce0..636d24c4e82d 100644 --- a/src/test/lazy-omap-stats/CMakeLists.txt +++ b/src/test/lazy-omap-stats/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable(ceph_test_lazy_omap_stats main.cc lazy_omap_stats_test.cc) target_link_libraries(ceph_test_lazy_omap_stats - librados ${UNITTEST_LIBS} Boost::system) + librados Boost::system Boost::filesystem ${UNITTEST_LIBS}) install(TARGETS ceph_test_lazy_omap_stats DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/test/system/CMakeLists.txt b/src/test/system/CMakeLists.txt index 4944bb4462d7..f2b69fb3e432 100644 --- a/src/test/system/CMakeLists.txt +++ b/src/test/system/CMakeLists.txt @@ -9,12 +9,16 @@ set(libsystest_srcs st_rados_list_objects.cc) add_library(systest STATIC ${libsystest_srcs}) +if(NOT WIN32) + set(RT_LIB rt) +endif() + # test_rados_list_parallel add_executable(ceph_test_rados_list_parallel rados_list_parallel.cc ) target_link_libraries(ceph_test_rados_list_parallel librados systest global pthread - rt ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) + ${RT_LIB} ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) # test_rados_open_pools_parallel set(test_rados_open_pools_parallel_srcs @@ -24,7 +28,7 @@ add_executable(ceph_test_rados_open_pools_parallel ) target_link_libraries(ceph_test_rados_open_pools_parallel librados systest global - pthread rt ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) + pthread ${RT_LIB} ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) # test_rados_delete_pools_parallel set(test_rados_delete_pools_parallel_srcs @@ -37,7 +41,7 @@ add_executable(ceph_test_rados_delete_pools_parallel ${test_rados_delete_pools_parallel_srcs} ) target_link_libraries(ceph_test_rados_delete_pools_parallel librados systest global - pthread rt ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) + pthread ${RT_LIB} ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) install(TARGETS ceph_test_rados_delete_pools_parallel diff --git a/win32_build.sh b/win32_build.sh index 4a620f60a8ad..4501f17f1766 100755 --- a/win32_build.sh +++ b/win32_build.sh @@ -119,8 +119,10 @@ if [[ -n $DEV_BUILD ]]; then echo "Dev build enabled." echo "Git versioning will be disabled." ENABLE_GIT_VERSION="OFF" + WITH_CEPH_DEBUG_MUTEX="ON" else ENABLE_GIT_VERSION="ON" + WITH_CEPH_DEBUG_MUTEX="OFF" fi # As opposed to Linux, Windows shared libraries can't have unresolved @@ -132,11 +134,11 @@ cmake -D CMAKE_PREFIX_PATH=$depsDirs \ -D WITH_GSSAPI=OFF -D WITH_FUSE=OFF -D WITH_XFS=OFF \ -D WITH_BLUESTORE=OFF -D WITH_LEVELDB=OFF \ -D WITH_LTTNG=OFF -D WITH_BABELTRACE=OFF \ - -D WITH_SYSTEM_BOOST=ON -D WITH_MGR=OFF \ + -D WITH_SYSTEM_BOOST=ON -D WITH_MGR=OFF -D WITH_KVS=OFF \ -D WITH_LIBCEPHFS=OFF -D WITH_KRBD=OFF -D WITH_RADOSGW=OFF \ - -D ENABLE_SHARED=OFF -D WITH_RBD=ON -D BUILD_GMOCK=OFF \ + -D ENABLE_SHARED=OFF -D WITH_RBD=ON -D BUILD_GMOCK=ON \ -D WITH_CEPHFS=OFF -D WITH_MANPAGE=OFF \ - -D WITH_MGR_DASHBOARD_FRONTEND=OFF -D WITH_SYSTEMD=OFF -D WITH_TESTS=OFF \ + -D WITH_MGR_DASHBOARD_FRONTEND=OFF -D WITH_SYSTEMD=OFF -D WITH_TESTS=ON \ -D LZ4_INCLUDE_DIR=$lz4Include -D LZ4_LIBRARY=$lz4Lib \ -D Backtrace_INCLUDE_DIR="$backtraceDir/include" \ -D Backtrace_LIBRARY="$backtraceDir/lib/libbacktrace.a" \ @@ -144,6 +146,7 @@ cmake -D CMAKE_PREFIX_PATH=$depsDirs \ -D ALLOCATOR="$ALLOCATOR" -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \ -D WNBD_INCLUDE_DIRS="$wnbdSrcDir/include" \ -D WNBD_LIBRARIES="$wnbdLibDir/libwnbd.a" \ + -D WITH_CEPH_DEBUG_MUTEX=$WITH_CEPH_DEBUG_MUTEX \ -G "$generatorUsed" \ $CEPH_DIR 2>&1 | tee "${BUILD_DIR}/cmake.log" fi # [[ -z $SKIP_CMAKE ]] @@ -160,6 +163,7 @@ if [[ -z $SKIP_BUILD ]]; then make_targets["src/tools/rbd"]="all" make_targets["src/tools/rbd_wnbd"]="all" make_targets["src/compressor"]="all" + make_targets["src/test"]="all" for target_subdir in "${!make_targets[@]}"; do echo "Building $target_subdir: ${make_targets[$target_subdir]}" | tee -a "${BUILD_DIR}/build.log"