summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--netfs/unittests/Jamfile.jam33
-rw-r--r--netfs/unittests/testCore.cpp70
-rw-r--r--netfs/unittests/testEdgeCases.cpp60
-rw-r--r--netfs/unittests/testGlacier.cpp41
4 files changed, 129 insertions, 75 deletions
diff --git a/netfs/unittests/Jamfile.jam b/netfs/unittests/Jamfile.jam
index 3b4694b..79f77e3 100644
--- a/netfs/unittests/Jamfile.jam
+++ b/netfs/unittests/Jamfile.jam
@@ -8,19 +8,42 @@ lib Ice ;
path-constant me : . ;
-run
- testCore.cpp mockDaemon.cpp mockFuse.cpp
+lib testMocks :
+ [ glob mock*.cpp ]
: :
- :
- <define>BOOST_TEST_DYN_LINK
<library>IceUtil
<library>Ice
<library>boost_system
<library>boost_filesystem
- <library>boost_utf
<library>../daemon//netfsd
<library>../fuse//netfsClient
<library>../ice//netfsComms
<define>ROOT=\"$(me)\"
+ :
+ <library>boost_system
+ <library>boost_filesystem
+ <define>ROOT=\"$(me)\"
+ ;
+
+
+run testCore.cpp
+ : : :
+ <define>BOOST_TEST_DYN_LINK
+ <library>boost_utf
+ <library>testMocks
: testCore ;
+run testGlacier.cpp
+ : : :
+ <define>BOOST_TEST_DYN_LINK
+ <library>boost_utf
+ <library>testMocks
+ : testGlacier ;
+
+run testEdgeCases.cpp
+ : : :
+ <define>BOOST_TEST_DYN_LINK
+ <library>boost_utf
+ <library>testMocks
+ : testEdgeCases ;
+
diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp
index 6589838..75d55a4 100644
--- a/netfs/unittests/testCore.cpp
+++ b/netfs/unittests/testCore.cpp
@@ -1,10 +1,5 @@
#define BOOST_TEST_MODULE TestNetFSCore
#include <boost/test/unit_test.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/scope_exit.hpp>
-#include <Ice/ObjectAdapter.h>
-#include <Ice/Service.h>
#include "mockDaemon.h"
#include "mockFuse.h"
#include <boost/filesystem/path.hpp>
@@ -58,68 +53,3 @@ BOOST_AUTO_TEST_CASE ( clientInitialised )
BOOST_AUTO_TEST_SUITE_END();
-BOOST_AUTO_TEST_CASE ( createAndDaemonRestart )
-{
- MockDaemonHost daemon(testEndpoint);
- FuseMockHost fuse(testEndpoint, 2, defaultFuseArgv);
-
- struct statvfs s;
- BOOST_REQUIRE_EQUAL(0, fuse.fuse->statfs("/", &s));
-
- const char * fileName = "/createMe";
- BOOST_CHECKPOINT("Create a new file");
- struct fuse_file_info fh;
- memset(&fh, 0, sizeof(fh));
- fh.flags = O_WRONLY | O_CREAT | O_APPEND;
- BOOST_REQUIRE_EQUAL(0, fuse.fuse->create(fileName, 0100644, &fh));
- BOOST_REQUIRE(fh.fh);
-
- BOOST_CHECKPOINT("Fetch file attributes");
- struct stat st;
- BOOST_REQUIRE_EQUAL(0, fuse.fuse->fgetattr(fileName, &st, &fh));
- BOOST_REQUIRE_EQUAL(st.st_size, 0);
- BOOST_REQUIRE_EQUAL(st.st_uid, getuid());
- BOOST_REQUIRE_EQUAL(st.st_gid, getgid());
-
- BOOST_CHECKPOINT("Write some data");
- char someData[890];
- BOOST_REQUIRE_EQUAL(sizeof(someData), fuse.fuse->write(fileName, someData, sizeof(someData), 0, &fh));
-
- BOOST_REQUIRE_EQUAL(0, fuse.fuse->fgetattr(fileName, &st, &fh));
- BOOST_REQUIRE_EQUAL(st.st_size, sizeof(someData));
-
- BOOST_CHECKPOINT("Restart daemon object");
- daemon.restart();
-
- BOOST_CHECKPOINT("Fetch file attributes again");
- BOOST_REQUIRE_EQUAL(0, fuse.fuse->fgetattr(fileName, &st, &fh));
-
- BOOST_CHECKPOINT("Close file");
- BOOST_REQUIRE_EQUAL(0, fuse.fuse->release(fileName, &fh));
-}
-
-BOOST_AUTO_TEST_CASE ( withRouter )
-{
- BOOST_REQUIRE_EQUAL(0,
- system("/usr/bin/glacier2router --Glacier2.Client.Endpoints='tcp -p 4063' --Glacier2.PermissionsVerifier=Glacier2/NullPermissionsVerifier --daemon --pidfile /tmp/glacier.pid"));
- sleep(1);
-
- BOOST_SCOPE_EXIT(void) {
- system("kill $(cat /tmp/glacier.pid)");
- } BOOST_SCOPE_EXIT_END;
-
- {
- char * glacierFuseArgv[] = {
- strdup((RootDir / ":testvol").string().c_str()),
- strdup((RootDir / "test").string().c_str()),
- strdup("--Ice.Default.Router=Glacier2/router:tcp -h localhost -p 4063")
- };
-
- MockDaemonHost daemon(testEndpoint);
- FuseMockHost fuse(testEndpoint, 3, glacierFuseArgv);
-
- struct statvfs s;
- BOOST_REQUIRE_EQUAL(0, fuse.fuse->statfs("/", &s));
- }
-}
-
diff --git a/netfs/unittests/testEdgeCases.cpp b/netfs/unittests/testEdgeCases.cpp
new file mode 100644
index 0000000..afa2338
--- /dev/null
+++ b/netfs/unittests/testEdgeCases.cpp
@@ -0,0 +1,60 @@
+#define BOOST_TEST_MODULE TestNetFSEdgeCases
+#include <boost/test/unit_test.hpp>
+#include "mockDaemon.h"
+#include "mockFuse.h"
+#include <boost/filesystem/path.hpp>
+
+#ifndef ROOT
+#error "ROOT needs to be defined at compilation time"
+#endif
+
+#define XSTR(s) STR(s)
+#define STR(s) #s
+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 / "test").string().c_str())
+};
+
+BOOST_AUTO_TEST_CASE ( createAndDaemonRestart )
+{
+ MockDaemonHost daemon(testEndpoint);
+ FuseMockHost fuse(testEndpoint, 2, defaultFuseArgv);
+
+ struct statvfs s;
+ BOOST_REQUIRE_EQUAL(0, fuse.fuse->statfs("/", &s));
+
+ const char * fileName = "/createMe";
+ BOOST_CHECKPOINT("Create a new file");
+ struct fuse_file_info fh;
+ memset(&fh, 0, sizeof(fh));
+ fh.flags = O_WRONLY | O_CREAT | O_APPEND;
+ BOOST_REQUIRE_EQUAL(0, fuse.fuse->create(fileName, 0100644, &fh));
+ BOOST_REQUIRE(fh.fh);
+
+ BOOST_CHECKPOINT("Fetch file attributes");
+ struct stat st;
+ BOOST_REQUIRE_EQUAL(0, fuse.fuse->fgetattr(fileName, &st, &fh));
+ BOOST_REQUIRE_EQUAL(st.st_size, 0);
+ BOOST_REQUIRE_EQUAL(st.st_uid, getuid());
+ BOOST_REQUIRE_EQUAL(st.st_gid, getgid());
+
+ BOOST_CHECKPOINT("Write some data");
+ char someData[890];
+ BOOST_REQUIRE_EQUAL(sizeof(someData), fuse.fuse->write(fileName, someData, sizeof(someData), 0, &fh));
+
+ BOOST_REQUIRE_EQUAL(0, fuse.fuse->fgetattr(fileName, &st, &fh));
+ BOOST_REQUIRE_EQUAL(st.st_size, sizeof(someData));
+
+ BOOST_CHECKPOINT("Restart daemon object");
+ daemon.restart();
+
+ BOOST_CHECKPOINT("Fetch file attributes again");
+ BOOST_REQUIRE_EQUAL(0, fuse.fuse->fgetattr(fileName, &st, &fh));
+
+ BOOST_CHECKPOINT("Close file");
+ BOOST_REQUIRE_EQUAL(0, fuse.fuse->release(fileName, &fh));
+}
+
diff --git a/netfs/unittests/testGlacier.cpp b/netfs/unittests/testGlacier.cpp
new file mode 100644
index 0000000..17f892a
--- /dev/null
+++ b/netfs/unittests/testGlacier.cpp
@@ -0,0 +1,41 @@
+#define BOOST_TEST_MODULE TestNetFSGlacier
+#include <boost/test/unit_test.hpp>
+#include "mockDaemon.h"
+#include "mockFuse.h"
+#include <boost/filesystem/path.hpp>
+#include <boost/scope_exit.hpp>
+
+#ifndef ROOT
+#error "ROOT needs to be defined at compilation time"
+#endif
+
+#define XSTR(s) STR(s)
+#define STR(s) #s
+const boost::filesystem::path RootDir(XSTR(ROOT));
+const std::string testEndpoint("tcp -h localhost -p 12013");
+
+BOOST_AUTO_TEST_CASE ( withRouter )
+{
+ BOOST_REQUIRE_EQUAL(0,
+ system("/usr/bin/glacier2router --Glacier2.Client.Endpoints='tcp -p 4063' --Glacier2.PermissionsVerifier=Glacier2/NullPermissionsVerifier --daemon --pidfile /tmp/glacier.pid"));
+ sleep(1);
+
+ BOOST_SCOPE_EXIT(void) {
+ system("kill $(cat /tmp/glacier.pid)");
+ } BOOST_SCOPE_EXIT_END;
+
+ {
+ char * glacierFuseArgv[] = {
+ strdup((RootDir / ":testvol").string().c_str()),
+ strdup((RootDir / "test").string().c_str()),
+ strdup("--Ice.Default.Router=Glacier2/router:tcp -h localhost -p 4063")
+ };
+
+ MockDaemonHost daemon(testEndpoint);
+ FuseMockHost fuse(testEndpoint, 3, glacierFuseArgv);
+
+ struct statvfs s;
+ BOOST_REQUIRE_EQUAL(0, fuse.fuse->statfs("/", &s));
+ }
+}
+