From 7dc6c3eb7377735be3d48074d0a78d341b6d6e72 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 19 Jul 2015 20:47:30 +0100 Subject: Start mock clients with a real configuration file that has specific parts replaced at run-time --- netfs/unittests/Jamfile.jam | 6 +++--- netfs/unittests/defaultFuse.xml | 15 +++++++++++++++ netfs/unittests/mockFuse.cpp | 13 ++++++++----- netfs/unittests/testCore.cpp | 2 +- netfs/unittests/testEdgeCases.cpp | 2 +- netfs/unittests/testGlacier.cpp | 2 +- 6 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 netfs/unittests/defaultFuse.xml diff --git a/netfs/unittests/Jamfile.jam b/netfs/unittests/Jamfile.jam index 8811d27..316491e 100644 --- a/netfs/unittests/Jamfile.jam +++ b/netfs/unittests/Jamfile.jam @@ -27,21 +27,21 @@ lib testMocks : run testCore.cpp - : : defaultDaemon.xml : + : : defaultDaemon.xml defaultFuse.xml : BOOST_TEST_DYN_LINK boost_utf testMocks : testCore ; run testGlacier.cpp - : : defaultDaemon.xml : + : : defaultDaemon.xml defaultFuse.xml : BOOST_TEST_DYN_LINK boost_utf testMocks : testGlacier ; run testEdgeCases.cpp - : : defaultDaemon.xml : + : : defaultDaemon.xml defaultFuse.xml : BOOST_TEST_DYN_LINK boost_utf testMocks diff --git a/netfs/unittests/defaultFuse.xml b/netfs/unittests/defaultFuse.xml new file mode 100644 index 0000000..37f55a3 --- /dev/null +++ b/netfs/unittests/defaultFuse.xml @@ -0,0 +1,15 @@ + + + + + testvol + + testvol + + overridden + + + + + + diff --git a/netfs/unittests/mockFuse.cpp b/netfs/unittests/mockFuse.cpp index 345dd4c..2b9edad 100644 --- a/netfs/unittests/mockFuse.cpp +++ b/netfs/unittests/mockFuse.cpp @@ -34,12 +34,15 @@ FuseMock::main(int &, char **, const struct fuse_operations * o) } NetFS::Client::ConfigurationPtr -FuseMock::ReadConfiguration(const std::string &) const +FuseMock::ReadConfiguration(const std::string & path) const { - return new NetFS::Client::Configuration( - { - { "testvol", new NetFS::Client::Resource("testvol", "Service", { testEndpoint }) } - }); + auto c = FuseApp::ReadConfiguration(path); + for(auto r : c->Resources) { + for(auto & e : r.second->Endpoints) { + e = testEndpoint; + } + } + return c; } FuseMockHost::FuseMockHost(const std::string & ep, int c, char ** v) : diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp index af03ed3..d13708c 100644 --- a/netfs/unittests/testCore.cpp +++ b/netfs/unittests/testCore.cpp @@ -14,7 +14,7 @@ const boost::filesystem::path RootDir(XSTR(ROOT)); const std::string testEndpoint("tcp -h localhost -p 12012"); char * defaultFuseArgv[] = { - strdup((RootDir / ":testvol").string().c_str()), + strdup((RootDir / "defaultFuse.xml:testvol").string().c_str()), strdup((RootDir / "test").string().c_str()) }; diff --git a/netfs/unittests/testEdgeCases.cpp b/netfs/unittests/testEdgeCases.cpp index 3955e73..5c5f671 100644 --- a/netfs/unittests/testEdgeCases.cpp +++ b/netfs/unittests/testEdgeCases.cpp @@ -14,7 +14,7 @@ const boost::filesystem::path RootDir(XSTR(ROOT)); const std::string testEndpoint("tcp -h localhost -p 12014"); char * defaultFuseArgv[] = { - strdup((RootDir / ":testvol").string().c_str()), + strdup((RootDir / "defaultFuse.xml:testvol").string().c_str()), strdup((RootDir / "test").string().c_str()) }; diff --git a/netfs/unittests/testGlacier.cpp b/netfs/unittests/testGlacier.cpp index abe8a1e..8ee055d 100644 --- a/netfs/unittests/testGlacier.cpp +++ b/netfs/unittests/testGlacier.cpp @@ -26,7 +26,7 @@ BOOST_AUTO_TEST_CASE ( withRouter ) { char * glacierFuseArgv[] = { - strdup((RootDir / ":testvol").string().c_str()), + strdup((RootDir / "defaultFuse.xml:testvol").string().c_str()), strdup((RootDir / "test").string().c_str()), strdup("--Ice.Default.Router=Glacier2/router:tcp -h localhost -p 4063") }; -- cgit v1.2.3