summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-07-19 20:47:30 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-07-19 20:47:30 +0100
commit7dc6c3eb7377735be3d48074d0a78d341b6d6e72 (patch)
treee4e1efd8517989e4ec116829c2871d2e19582c5c
parentTidy up a little (diff)
downloadnetfs-7dc6c3eb7377735be3d48074d0a78d341b6d6e72.tar.bz2
netfs-7dc6c3eb7377735be3d48074d0a78d341b6d6e72.tar.xz
netfs-7dc6c3eb7377735be3d48074d0a78d341b6d6e72.zip
Start mock clients with a real configuration file that has specific parts replaced at run-time
-rw-r--r--netfs/unittests/Jamfile.jam6
-rw-r--r--netfs/unittests/defaultFuse.xml15
-rw-r--r--netfs/unittests/mockFuse.cpp13
-rw-r--r--netfs/unittests/testCore.cpp2
-rw-r--r--netfs/unittests/testEdgeCases.cpp2
-rw-r--r--netfs/unittests/testGlacier.cpp2
6 files changed, 29 insertions, 11 deletions
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 :
<define>BOOST_TEST_DYN_LINK
<library>boost_utf
<library>testMocks
: testCore ;
run testGlacier.cpp
- : : defaultDaemon.xml :
+ : : defaultDaemon.xml defaultFuse.xml :
<define>BOOST_TEST_DYN_LINK
<library>boost_utf
<library>testMocks
: testGlacier ;
run testEdgeCases.cpp
- : : defaultDaemon.xml :
+ : : defaultDaemon.xml defaultFuse.xml :
<define>BOOST_TEST_DYN_LINK
<library>boost_utf
<library>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 @@
+<?xml version="1.0" encoding="ascii"?>
+<config>
+ <resources>
+ <resource>
+ <name>testvol</name>
+ <resource>
+ <export>testvol</export>
+ <endpoints>
+ <endpoint>overridden</endpoint>
+ </endpoints>
+ </resource>
+ </resource>
+ </resources>
+</config>
+
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")
};