Switch to std::filesystem

Change-Id: I3b8e8adfae9b063f97396d35a5f2296df56a3eb9
diff --git a/tests/daemon/face/unix-stream-channel.t.cpp b/tests/daemon/face/unix-stream-channel.t.cpp
index 605597d..f149b95 100644
--- a/tests/daemon/face/unix-stream-channel.t.cpp
+++ b/tests/daemon/face/unix-stream-channel.t.cpp
@@ -27,12 +27,16 @@
 
 #include "channel-fixture.hpp"
 
-#include <boost/filesystem.hpp>
+#include <filesystem>
 #include <fstream>
+#include <system_error>
+
+BOOST_TEST_DONT_PRINT_LOG_VALUE(::std::filesystem::file_type)
+BOOST_TEST_DONT_PRINT_LOG_VALUE(::std::filesystem::perms)
 
 namespace nfd::tests {
 
-namespace fs = boost::filesystem;
+namespace fs = std::filesystem;
 namespace local = boost::asio::local;
 using face::UnixStreamChannel;
 
@@ -41,12 +45,12 @@
 protected:
   UnixStreamChannelFixture()
   {
-    listenerEp = unix_stream::Endpoint(socketPath.string());
+    listenerEp = unix_stream::Endpoint(socketPath);
   }
 
   ~UnixStreamChannelFixture() override
   {
-    boost::system::error_code ec;
+    std::error_code ec;
     fs::remove_all(testDir, ec); // ignore error
   }
 
@@ -141,16 +145,17 @@
 BOOST_AUTO_TEST_CASE(CreateAndRemove)
 {
   auto channel = makeChannel();
-  BOOST_CHECK_EQUAL(fs::symlink_status(socketPath).type(), fs::file_not_found);
+  BOOST_TEST(fs::symlink_status(socketPath).type() == fs::file_type::not_found);
 
   channel->listen(nullptr, nullptr);
   auto status = fs::symlink_status(socketPath);
-  BOOST_CHECK_EQUAL(status.type(), fs::socket_file);
-  BOOST_CHECK_EQUAL(status.permissions(), fs::owner_read | fs::group_read | fs::others_read |
-                                          fs::owner_write | fs::group_write | fs::others_write);
+  BOOST_TEST(status.type() == fs::file_type::socket);
+  BOOST_TEST(status.permissions() ==
+             (fs::perms::owner_read | fs::perms::group_read | fs::perms::others_read |
+              fs::perms::owner_write | fs::perms::group_write | fs::perms::others_write));
 
   channel.reset();
-  BOOST_CHECK_EQUAL(fs::symlink_status(socketPath).type(), fs::file_not_found);
+  BOOST_TEST(fs::symlink_status(socketPath).type() == fs::file_type::not_found);
 }
 
 BOOST_AUTO_TEST_CASE(InUse)
@@ -159,10 +164,10 @@
   fs::create_directories(socketPath.parent_path());
 
   local::stream_protocol::acceptor acceptor(g_io, listenerEp);
-  BOOST_CHECK_EQUAL(fs::symlink_status(socketPath).type(), fs::socket_file);
+  BOOST_TEST(fs::symlink_status(socketPath).type() == fs::file_type::socket);
 
   BOOST_CHECK_EXCEPTION(channel->listen(nullptr, nullptr), fs::filesystem_error, [&] (const auto& e) {
-    return e.code() == boost::system::errc::address_in_use &&
+    return e.code() == std::errc::address_in_use &&
            e.path1() == socketPath &&
            std::string_view(e.what()).find("UnixStreamChannel::listen") != std::string_view::npos;
   });
@@ -176,23 +181,23 @@
   local::stream_protocol::acceptor acceptor(g_io, listenerEp);
   acceptor.close();
   // the socket file is not removed when the acceptor is closed
-  BOOST_CHECK_EQUAL(fs::symlink_status(socketPath).type(), fs::socket_file);
+  BOOST_TEST(fs::symlink_status(socketPath).type() == fs::file_type::socket);
 
   // drop write permission from the parent directory
-  fs::permissions(socketPath.parent_path(), fs::owner_all & ~fs::owner_write);
+  fs::permissions(socketPath.parent_path(), fs::perms::owner_all & ~fs::perms::owner_write);
   // removal of the "stale" socket fails due to insufficient permissions
   BOOST_CHECK_EXCEPTION(channel->listen(nullptr, nullptr), fs::filesystem_error, [&] (const auto& e) {
-    return e.code() == boost::system::errc::permission_denied &&
+    return e.code() == std::errc::permission_denied &&
            e.path1() == socketPath &&
            std::string_view(e.what()).find("remove") != std::string_view::npos;
   });
-  BOOST_CHECK_EQUAL(fs::symlink_status(socketPath).type(), fs::socket_file);
+  BOOST_TEST(fs::symlink_status(socketPath).type() == fs::file_type::socket);
 
   // restore all permissions
-  fs::permissions(socketPath.parent_path(), fs::owner_all);
+  fs::permissions(socketPath.parent_path(), fs::perms::owner_all);
   // the socket file should be considered "stale" and overwritten
   channel->listen(nullptr, nullptr);
-  BOOST_CHECK_EQUAL(fs::symlink_status(socketPath).type(), fs::socket_file);
+  BOOST_TEST(fs::symlink_status(socketPath).type() == fs::file_type::socket);
 }
 
 BOOST_AUTO_TEST_CASE(NotASocket)
@@ -200,19 +205,19 @@
   auto channel = makeChannel();
 
   fs::create_directories(socketPath);
-  BOOST_CHECK_EQUAL(fs::symlink_status(socketPath).type(), fs::directory_file);
+  BOOST_TEST(fs::symlink_status(socketPath).type() == fs::file_type::directory);
   BOOST_CHECK_EXCEPTION(channel->listen(nullptr, nullptr), fs::filesystem_error, [&] (const auto& e) {
-    return e.code() == boost::system::errc::not_a_socket &&
+    return e.code() == std::errc::not_a_socket &&
            e.path1() == socketPath &&
            std::string_view(e.what()).find("UnixStreamChannel::listen") != std::string_view::npos;
   });
 
   fs::remove(socketPath);
-  std::ofstream f(socketPath.string());
+  std::ofstream f(socketPath);
   f.close();
-  BOOST_CHECK_EQUAL(fs::symlink_status(socketPath).type(), fs::regular_file);
+  BOOST_TEST(fs::symlink_status(socketPath).type() == fs::file_type::regular);
   BOOST_CHECK_EXCEPTION(channel->listen(nullptr, nullptr), fs::filesystem_error, [&] (const auto& e) {
-    return e.code() == boost::system::errc::not_a_socket &&
+    return e.code() == std::errc::not_a_socket &&
            e.path1() == socketPath &&
            std::string_view(e.what()).find("UnixStreamChannel::listen") != std::string_view::npos;
   });
@@ -224,13 +229,14 @@
   fs::create_directories(testDir);
 
   auto parent = socketPath.parent_path();
-  std::ofstream f(parent.string());
+  std::ofstream f(parent);
   f.close();
-  BOOST_CHECK_EQUAL(fs::symlink_status(parent).type(), fs::regular_file);
+  BOOST_TEST(fs::symlink_status(parent).type() == fs::file_type::regular);
   BOOST_CHECK_EXCEPTION(channel->listen(nullptr, nullptr), fs::filesystem_error, [&] (const auto& e) {
-    return e.code() == boost::system::errc::file_exists &&
+    return (e.code() == std::errc::not_a_directory || // libstdc++
+            e.code() == std::errc::file_exists) &&    // libc++
            e.path1() == parent &&
-           std::string_view(e.what()).find("create_dir") != std::string_view::npos;
+           std::string_view(e.what()).find("create") != std::string_view::npos;
   });
 }
 
@@ -239,38 +245,40 @@
   auto channel = makeChannel();
   fs::create_directories(testDir);
 
-  fs::permissions(testDir, fs::no_perms);
+  fs::permissions(testDir, fs::perms::none);
   BOOST_CHECK_EXCEPTION(channel->listen(nullptr, nullptr), fs::filesystem_error, [&] (const auto& e) {
-    return e.code() == boost::system::errc::permission_denied &&
+    return e.code() == std::errc::permission_denied &&
            e.path1() == socketPath.parent_path() &&
-           std::string_view(e.what()).find("create_dir") != std::string_view::npos;
+           std::string_view(e.what()).find("create") != std::string_view::npos;
   });
 
-  fs::permissions(testDir, fs::owner_read | fs::owner_exe);
+  fs::permissions(testDir, fs::perms::owner_read | fs::perms::owner_exec);
   BOOST_CHECK_EXCEPTION(channel->listen(nullptr, nullptr), fs::filesystem_error, [&] (const auto& e) {
-    return e.code() == boost::system::errc::permission_denied &&
+    return e.code() == std::errc::permission_denied &&
            e.path1() == socketPath.parent_path() &&
-           std::string_view(e.what()).find("create_dir") != std::string_view::npos;
+           std::string_view(e.what()).find("create") != std::string_view::npos;
   });
 
-  fs::permissions(testDir, fs::owner_all);
+  fs::permissions(testDir, fs::perms::owner_all);
   fs::create_directories(socketPath.parent_path());
 
-  fs::permissions(socketPath.parent_path(), fs::no_perms);
+  fs::permissions(socketPath.parent_path(), fs::perms::none);
   BOOST_CHECK_EXCEPTION(channel->listen(nullptr, nullptr), fs::filesystem_error, [&] (const auto& e) {
-    return e.code() == boost::system::errc::permission_denied &&
+    std::string_view what(e.what());
+    return e.code() == std::errc::permission_denied &&
            e.path1() == socketPath &&
-           std::string_view(e.what()).find("status") != std::string_view::npos;
+           (what.find("symlink_status") != std::string_view::npos ||  // libstdc++
+            what.find("posix_stat") != std::string_view::npos);       // libc++
   });
 
-  fs::permissions(socketPath.parent_path(), fs::owner_read | fs::owner_exe);
+  fs::permissions(socketPath.parent_path(), fs::perms::owner_read | fs::perms::owner_exec);
   BOOST_CHECK_EXCEPTION(channel->listen(nullptr, nullptr), fs::filesystem_error, [&] (const auto& e) {
-    return e.code() == boost::system::errc::permission_denied &&
+    return e.code() == std::errc::permission_denied &&
            e.path1() == socketPath &&
            std::string_view(e.what()).find("bind") != std::string_view::npos;
   });
 
-  fs::permissions(socketPath.parent_path(), fs::owner_all);
+  fs::permissions(socketPath.parent_path(), fs::perms::owner_all);
 }
 
 BOOST_AUTO_TEST_SUITE_END() // SocketFile