Switch to std::filesystem
Change-Id: Idd88815c8971a1dd6a592ac9d3f46d5925afd21b
diff --git a/tests/key-chain-fixture.cpp b/tests/key-chain-fixture.cpp
index f29153f..bae6ca7 100644
--- a/tests/key-chain-fixture.cpp
+++ b/tests/key-chain-fixture.cpp
@@ -27,7 +27,8 @@
#include <ndn-cxx/util/io.hpp>
-#include <boost/filesystem/operations.hpp>
+#include <filesystem>
+#include <system_error>
namespace nlsr::tests {
@@ -40,9 +41,9 @@
KeyChainFixture::~KeyChainFixture()
{
- boost::system::error_code ec;
+ std::error_code ec;
for (const auto& certFile : m_certFiles) {
- boost::filesystem::remove(certFile, ec); // ignore error
+ std::filesystem::remove(certFile, ec); // ignore error
}
}
diff --git a/tests/security/test-certificate-store.cpp b/tests/security/test-certificate-store.cpp
index 484959e..b00744f 100644
--- a/tests/security/test-certificate-store.cpp
+++ b/tests/security/test-certificate-store.cpp
@@ -26,11 +26,11 @@
#include "tests/io-key-chain-fixture.hpp"
#include "tests/test-common.hpp"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/property_tree/info_parser.hpp>
+#include <filesystem>
+
namespace nlsr::tests {
class CertificateStoreFixture : public IoKeyChainFixture
@@ -50,7 +50,7 @@
, nlsr(face, m_keyChain, conf)
, lsdb(nlsr.getLsdb())
, certStore(face, conf, lsdb)
- , ROOT_CERT_PATH(boost::filesystem::current_path() / "root.cert")
+ , ROOT_CERT_PATH(std::filesystem::current_path() / "root.cert")
{
rootId = m_keyChain.createIdentity(rootIdName);
siteIdentity = addSubCertificate(siteIdentityName, rootId);
@@ -112,7 +112,7 @@
ndn::security::Certificate certificate;
ndn::Name certificateKey;
security::CertificateStore certStore;
- const boost::filesystem::path ROOT_CERT_PATH;
+ const std::filesystem::path ROOT_CERT_PATH;
};
BOOST_FIXTURE_TEST_SUITE(TestCertificateStore, CertificateStoreFixture)
diff --git a/tests/test-lsa-rule.cpp b/tests/test-lsa-rule.cpp
index 87f915d..ddd5969 100644
--- a/tests/test-lsa-rule.cpp
+++ b/tests/test-lsa-rule.cpp
@@ -25,12 +25,12 @@
#include "tests/io-key-chain-fixture.hpp"
#include "tests/test-common.hpp"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/property_tree/info_parser.hpp>
#include <boost/property_tree/ptree.hpp>
+#include <filesystem>
+
namespace nlsr::tests {
using namespace ndn;
@@ -48,7 +48,7 @@
, confProcessor(confParam, SyncProtocol::PSYNC, HYPERBOLIC_STATE_OFF,
"/ndn/", "/edu/test-site", "/%C1.Router/router1")
, lsdb(face, m_keyChain, confParam)
- , ROOT_CERT_PATH(boost::filesystem::current_path() / std::string("root.cert"))
+ , ROOT_CERT_PATH(std::filesystem::current_path() / "root.cert")
{
rootId = m_keyChain.createIdentity(rootIdName);
siteIdentity = addSubCertificate(siteIdentityName, rootId);
@@ -92,7 +92,7 @@
DummyConfFileProcessor confProcessor;
Lsdb lsdb;
- const boost::filesystem::path ROOT_CERT_PATH;
+ const std::filesystem::path ROOT_CERT_PATH;
};
BOOST_FIXTURE_TEST_SUITE(TestLsaDataValidation, LsaRuleFixture)
diff --git a/tests/test-sequencing-manager.cpp b/tests/test-sequencing-manager.cpp
index dd098c0..9941d1d 100644
--- a/tests/test-sequencing-manager.cpp
+++ b/tests/test-sequencing-manager.cpp
@@ -23,8 +23,9 @@
#include "tests/boost-test.hpp"
-#include <boost/filesystem/operations.hpp>
+#include <filesystem>
#include <fstream>
+#include <system_error>
namespace nlsr::tests {
@@ -33,22 +34,17 @@
class SequencingManagerFixture
{
public:
- SequencingManagerFixture()
- : m_seqManager("/tmp", HYPERBOLIC_STATE_OFF)
- {
- }
-
~SequencingManagerFixture()
{
- boost::filesystem::remove(seqFile);
+ std::error_code ec;
+ std::filesystem::remove(m_seqFile, ec); // ignore error
}
void
writeToFile(const std::string& testSeq)
{
- std::ofstream outputFile(seqFile, std::ofstream::trunc);
+ std::ofstream outputFile(m_seqFile, std::ofstream::trunc);
outputFile << testSeq;
- outputFile.close();
}
void
@@ -66,8 +62,10 @@
}
public:
- std::string seqFile = "/tmp/nlsrSeqNo.txt";
- SequencingManager m_seqManager;
+ SequencingManager m_seqManager{"/tmp", HYPERBOLIC_STATE_OFF};
+
+private:
+ std::filesystem::path m_seqFile{"/tmp/nlsrSeqNo.txt"};
};
BOOST_FIXTURE_TEST_SUITE(TestSequencingManager, SequencingManagerFixture)
diff --git a/tests/update/test-prefix-update-processor.cpp b/tests/update/test-prefix-update-processor.cpp
index 493d73d..229e2d3 100644
--- a/tests/update/test-prefix-update-processor.cpp
+++ b/tests/update/test-prefix-update-processor.cpp
@@ -29,12 +29,12 @@
#include <ndn-cxx/security/interest-signer.hpp>
#include <ndn-cxx/security/signing-helpers.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/property_tree/info_parser.hpp>
#include <boost/property_tree/ptree.hpp>
+#include <filesystem>
+
namespace nlsr::tests {
using namespace ndn;
@@ -50,7 +50,7 @@
, confProcessor(conf)
, nlsr(face, m_keyChain, conf)
, namePrefixList(conf.getNamePrefixList())
- , SITE_CERT_PATH(boost::filesystem::current_path() / std::string("site.cert"))
+ , SITE_CERT_PATH(std::filesystem::current_path() / "site.cert")
{
// Site cert
siteIdentity = m_keyChain.createIdentity(siteIdentityName);
@@ -139,7 +139,7 @@
Nlsr nlsr;
NamePrefixList& namePrefixList;
- const boost::filesystem::path SITE_CERT_PATH;
+ const std::filesystem::path SITE_CERT_PATH;
};
BOOST_FIXTURE_TEST_SUITE(TestPrefixUpdateProcessor, PrefixUpdateFixture)
diff --git a/tests/update/test-save-delete-prefix.cpp b/tests/update/test-save-delete-prefix.cpp
index ef38cef..5c582cd 100644
--- a/tests/update/test-save-delete-prefix.cpp
+++ b/tests/update/test-save-delete-prefix.cpp
@@ -30,10 +30,10 @@
#include <ndn-cxx/security/interest-signer.hpp>
#include <ndn-cxx/security/signing-helpers.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
#include <boost/property_tree/info_parser.hpp>
+#include <filesystem>
+
namespace nlsr::tests {
namespace bpt = boost::property_tree;
@@ -49,7 +49,7 @@
, conf(face, m_keyChain, testConfFile)
, confProcessor(conf)
, nlsr(face, m_keyChain, conf)
- , SITE_CERT_PATH(boost::filesystem::current_path() / std::string("site.cert"))
+ , SITE_CERT_PATH(std::filesystem::current_path() / "site.cert")
, counter(0)
{
std::ifstream source("nlsr.conf", std::ios::binary);
@@ -69,6 +69,7 @@
std::ifstream inputFile;
inputFile.open(testConfFile);
BOOST_REQUIRE(inputFile.is_open());
+
bpt::ptree pt;
bpt::read_info(inputFile, pt);
// Loads section and file name
@@ -164,7 +165,7 @@
ConfParameter conf;
DummyConfFileProcessor confProcessor;
Nlsr nlsr;
- const boost::filesystem::path SITE_CERT_PATH;
+ const std::filesystem::path SITE_CERT_PATH;
ndn::Name sessionTime;
int counter;
};