2014-11-17 21:13:58 +01:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "gmock/gmock.h"
|
|
|
|
|
|
|
|
#include "fspp/fuse/Fuse.h"
|
2014-11-19 00:25:57 +01:00
|
|
|
#include "test/testutils/FuseTest.h"
|
2014-11-17 21:13:58 +01:00
|
|
|
|
|
|
|
using namespace fspp;
|
|
|
|
using namespace fspp::fuse;
|
2014-11-19 00:40:46 +01:00
|
|
|
|
2014-11-19 00:15:37 +01:00
|
|
|
using ::testing::_;
|
|
|
|
using ::testing::StrEq;
|
2014-11-17 21:13:58 +01:00
|
|
|
|
2014-11-17 21:29:23 +01:00
|
|
|
TEST_F(FuseTest, setupAndTearDown) {
|
|
|
|
//This test case simply checks whether a filesystem can be setup and teardown without crashing.
|
2014-11-19 00:15:37 +01:00
|
|
|
auto fs = TestFS();
|
2014-11-17 21:29:23 +01:00
|
|
|
}
|
|
|
|
|
2014-11-19 00:48:17 +01:00
|
|
|
TEST_F(FuseTest, lstat) {
|
|
|
|
const char *filename = "/myfile";
|
|
|
|
EXPECT_CALL(fsimpl, lstat(StrEq(filename), _)).WillOnce(ReturnIsFileStat);
|
|
|
|
|
|
|
|
auto fs = TestFS();
|
|
|
|
|
|
|
|
auto realpath = fs->mountDir() / filename;
|
|
|
|
struct stat stat;
|
|
|
|
::lstat(realpath.c_str(), &stat);
|
|
|
|
|
|
|
|
EXPECT_TRUE(S_ISREG(stat.st_mode));
|
|
|
|
}
|
|
|
|
|
2014-11-17 21:29:23 +01:00
|
|
|
TEST_F(FuseTest, openFile) {
|
2014-11-19 00:15:37 +01:00
|
|
|
const char *filename = "/myfile";
|
2014-11-19 00:38:41 +01:00
|
|
|
EXPECT_CALL(fsimpl, lstat(StrEq(filename), _)).WillOnce(ReturnIsFileStat);
|
2014-11-19 00:31:47 +01:00
|
|
|
EXPECT_CALL(fsimpl, openFile(StrEq(filename), OpenFlagsEq(O_RDWR)))
|
|
|
|
.Times(1);
|
2014-11-19 00:15:37 +01:00
|
|
|
|
|
|
|
auto fs = TestFS();
|
|
|
|
|
|
|
|
auto realpath = fs->mountDir() / filename;
|
|
|
|
::open(realpath.c_str(), O_RDWR);
|
2014-11-17 21:13:58 +01:00
|
|
|
}
|