From 53c3b4496f76b2b70a8531d94777114be060ea83 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 5 Feb 2018 17:12:14 +0800 Subject: [PATCH] test/admin_socket_output: switch to std::experimental::filesystem so we don't need to compile boost::filesystem anymore. Signed-off-by: Kefu Chai --- CMakeLists.txt | 3 +-- src/test/CMakeLists.txt | 11 ++++++++--- src/test/admin_socket_output.cc | 6 +++--- src/test/admin_socket_output.h | 8 +++----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cce8b732717..f748bc6c215 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -560,8 +560,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 thread system regex random program_options date_time iostreams - filesystem) + atomic thread system regex random program_options date_time iostreams) set(BOOST_HEADER_COMPONENTS container) if(WITH_MGR) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 375b8a13f54..3cbfe04fa4d 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -525,9 +525,14 @@ add_executable(ceph_test_admin_socket_output admin_socket_output_tests.cc ) target_link_libraries(ceph_test_admin_socket_output - ceph-common - ${Boost_FILESYSTEM_LIBRARY} - ) + ceph-common) +if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) + target_link_libraries(ceph_test_admin_socket_output + -lstdc++fs) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) + target_link_libraries(ceph_test_admin_socket_output + -lc++experimental) +endif() install(TARGETS ceph_test_admin_socket_output DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/test/admin_socket_output.cc b/src/test/admin_socket_output.cc index a93ab410c1c..7b2f224f264 100644 --- a/src/test/admin_socket_output.cc +++ b/src/test/admin_socket_output.cc @@ -14,7 +14,7 @@ #include #include // For regex, regex_search -#include // For extension +#include // For extension #include "common/admin_socket_client.h" // For AdminSocketClient #include "common/ceph_json.h" // For JSONParser, JSONObjIter @@ -74,9 +74,9 @@ void AdminSocketOutput::postpone(const std::string &target, bool AdminSocketOutput::init_sockets() { std::cout << "Initialising sockets" << std::endl; - for (const auto &x : bfs::directory_iterator(socketdir)) { + for (const auto &x : fs::directory_iterator(socketdir)) { std::cout << x.path() << std::endl; - if (bfs::extension(x.path()) == ".asok") { + if (fs::path(x.path()).extension() == ".asok") { for (auto &target : targets) { if (std::regex_search(x.path().filename().string(), std::regex(prefix + target + R"(\..*\.asok)"))) { diff --git a/src/test/admin_socket_output.h b/src/test/admin_socket_output.h index 28f65767f91..1eda77430c9 100644 --- a/src/test/admin_socket_output.h +++ b/src/test/admin_socket_output.h @@ -19,11 +19,9 @@ #include #include #include +#include // For path -#include // For path -#include // For exists, is_directory - -namespace bfs = boost::filesystem; +namespace fs = std::experimental::filesystem; using socket_results = std::map; using test_functions = @@ -72,7 +70,7 @@ private: std::map tests; std::string prefix = "ceph-"; - bfs::path socketdir = "/var/run/ceph"; + fs::path socketdir = "/var/run/ceph"; }; #endif // CEPH_ADMIN_SOCKET_OUTPUT_H -- 2.47.3