summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-07-20 10:53:14 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2019-07-20 10:53:14 +0100
commit4c25da8a7ba7437657c3e2da592145113d3532f4 (patch)
tree40f0468135089ff4f9e967bf8ee74b020bee67f7 /unittests
downloadnetfs-gitfs-4c25da8a7ba7437657c3e2da592145113d3532f4.tar.bz2
netfs-gitfs-4c25da8a7ba7437657c3e2da592145113d3532f4.tar.xz
netfs-gitfs-4c25da8a7ba7437657c3e2da592145113d3532f4.zip
Initial commit
Not a lot of stuff, hard coded paths, tests against /usr/portage
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Jamfile.jam29
-rw-r--r--unittests/core.cpp69
-rw-r--r--unittests/mockDefs.cpp26
-rw-r--r--unittests/mockDefs.h31
4 files changed, 155 insertions, 0 deletions
diff --git a/unittests/Jamfile.jam b/unittests/Jamfile.jam
new file mode 100644
index 0000000..9de6ea6
--- /dev/null
+++ b/unittests/Jamfile.jam
@@ -0,0 +1,29 @@
+import testing ;
+
+lib boost_utf : : <name>boost_unit_test_framework ;
+lib dryice : : : : <library>..//icetray ;
+
+path-constant me : . ;
+
+lib common :
+ mockDefs.cpp
+ :
+ <library>dryice
+ <library>../src//gitfs
+ <library>..//adhocutil
+ <library>boost_utf
+ <define>ROOT=\"$(me)\"
+ : :
+ <library>dryice
+ <library>../src//gitfs
+ <library>boost_utf
+ <define>ROOT=\"$(me)\"
+ <define>BOOST_TEST_DYN_LINK
+ ;
+
+
+run core.cpp : : :
+ <library>../src//gitfs
+ <library>common
+ ;
+
diff --git a/unittests/core.cpp b/unittests/core.cpp
new file mode 100644
index 0000000..9b38dfe
--- /dev/null
+++ b/unittests/core.cpp
@@ -0,0 +1,69 @@
+#define BOOST_TEST_MODULE GitFS_Core
+#include <boost/test/unit_test.hpp>
+
+#include "mockDefs.h"
+#include "sys/stat.h"
+
+using namespace GitFS;
+using namespace GitFS::Test;
+
+BOOST_TEST_GLOBAL_FIXTURE(Service);
+
+BOOST_FIXTURE_TEST_SUITE(client, Client)
+
+ // TODO
+
+BOOST_AUTO_TEST_SUITE_END();
+
+BOOST_FIXTURE_TEST_SUITE(volume, VolumeClient)
+
+BOOST_AUTO_TEST_CASE( access )
+{
+ // Noting is writable
+ // Directories are all readable and executable
+
+ BOOST_CHECK_EQUAL(EINVAL, v->access(env, "", R_OK));
+
+ BOOST_CHECK_EQUAL(0, v->access(env, "/", R_OK));
+ BOOST_CHECK_EQUAL(EACCES, v->access(env, "/", W_OK));
+ BOOST_CHECK_EQUAL(0, v->access(env, "/", X_OK));
+
+ BOOST_CHECK_EQUAL(0, v->access(env, "/metadata", R_OK));
+ BOOST_CHECK_EQUAL(EACCES, v->access(env, "/metadata", W_OK));
+ BOOST_CHECK_EQUAL(0, v->access(env, "/metadata", X_OK));
+
+ BOOST_CHECK_EQUAL(0, v->access(env, "/metadata/timestamp.chk", R_OK));
+ BOOST_CHECK_EQUAL(EACCES, v->access(env, "/metadata/timestamp.chk", W_OK));
+ BOOST_CHECK_EQUAL(EACCES, v->access(env, "/metadata/timestamp.chk", X_OK));
+
+ BOOST_CHECK_EQUAL(0, v->access(env, "/app-antivirus/skyldav/files/skyldav.initd", R_OK));
+ BOOST_CHECK_EQUAL(EACCES, v->access(env, "/app-antivirus/skyldav/files/skyldav.initd", W_OK));
+ BOOST_CHECK_EQUAL(0, v->access(env, "/app-antivirus/skyldav/files/skyldav.initd", X_OK));
+
+ BOOST_CHECK_EQUAL(ENOENT, v->access(env, "/missing", R_OK));
+ BOOST_CHECK_EQUAL(EACCES, v->access(env, "/missing", W_OK));
+ BOOST_CHECK_EQUAL(ENOENT, v->access(env, "/missing", X_OK));
+
+ BOOST_CHECK_EQUAL(ENOENT, v->access(env, "/.", R_OK));
+ BOOST_CHECK_EQUAL(ENOENT, v->access(env, "/../", R_OK));
+ BOOST_CHECK_EQUAL(ENOENT, v->access(env, ".", R_OK));
+ BOOST_CHECK_EQUAL(ENOENT, v->access(env, "..", R_OK));
+ BOOST_CHECK_EQUAL(ENOENT, v->access(env, "../", R_OK));
+}
+
+BOOST_AUTO_TEST_CASE( statRoot )
+{
+ //auto a = v->getattr(env, "/");
+ //BOOST_CHECK_EQUAL(0170555, a.mode);
+ //BOOST_CHECK_EQUAL(1563566842, a.mtime);
+ //BOOST_CHECK_EQUAL(1563566842, a.ctime);
+ //BOOST_CHECK_EQUAL(1563566842, a.atime);
+}
+
+BOOST_AUTO_TEST_CASE(stat_root)
+{
+ auto attr = v->getattr(env, "");
+}
+
+BOOST_AUTO_TEST_SUITE_END();
+
diff --git a/unittests/mockDefs.cpp b/unittests/mockDefs.cpp
new file mode 100644
index 0000000..78ad270
--- /dev/null
+++ b/unittests/mockDefs.cpp
@@ -0,0 +1,26 @@
+#include <boost/test/test_tools.hpp>
+#include "mockDefs.h"
+
+GitFS::Test::Service::Service()
+{
+}
+
+GitFS::Test::Client::Client() :
+ s(getProxy<NetFS::ServicePrx>("Service"))
+{
+ BOOST_TEST_REQUIRE(s);
+ s->ice_ping();
+}
+
+GitFS::Test::VolumeClient::VolumeClient() :
+ v(s->connect("testrepo", "testauth"))
+{
+ BOOST_TEST_REQUIRE(v);
+ v->ice_ping();
+}
+
+GitFS::Test::VolumeClient::~VolumeClient()
+{
+ v->disconnect();
+}
+
diff --git a/unittests/mockDefs.h b/unittests/mockDefs.h
new file mode 100644
index 0000000..f6a6c99
--- /dev/null
+++ b/unittests/mockDefs.h
@@ -0,0 +1,31 @@
+#ifndef GITFS_TEST_MOCKDEFS_H
+#define GITFS_TEST_MOCKDEFS_H
+
+#include <visibility.h>
+#include <dryice.h>
+#include <service.h>
+
+namespace GitFS::Test {
+ class DLL_PUBLIC Service : public IceTray::DryIce {
+ public:
+ Service();
+ };
+
+ class DLL_PUBLIC Client : public IceTray::DryIceClient {
+ public:
+ Client();
+
+ const NetFS::ServicePrxPtr s;
+ };
+ class DLL_PUBLIC VolumeClient : public Client {
+ public:
+ VolumeClient();
+ ~VolumeClient();
+
+ const NetFS::ReqEnv env;
+ const NetFS::VolumePrxPtr v;
+ };
+}
+
+#endif
+