Comments
This commit is contained in:
parent
862cb1b26c
commit
e7181c3c8b
@ -11,7 +11,7 @@ using ::testing::StrEq;
|
|||||||
|
|
||||||
typedef FuseTest BasicFuseTest;
|
typedef FuseTest BasicFuseTest;
|
||||||
|
|
||||||
|
//This test case simply checks whether a filesystem can be setup and teardown without crashing.
|
||||||
TEST_F(BasicFuseTest, setupAndTearDown) {
|
TEST_F(BasicFuseTest, setupAndTearDown) {
|
||||||
//This test case simply checks whether a filesystem can be setup and teardown without crashing.
|
|
||||||
auto fs = TestFS();
|
auto fs = TestFS();
|
||||||
}
|
}
|
@ -17,7 +17,9 @@ INSTANTIATE_TEST_CASE_P(LstatErrorCodes, FuseLstatErrorTest, Values(EACCES, EBAD
|
|||||||
|
|
||||||
TEST_F(FuseLstatErrorTest, ReturnNoError) {
|
TEST_F(FuseLstatErrorTest, ReturnNoError) {
|
||||||
EXPECT_CALL(fsimpl, lstat(StrEq(FILENAME), _)).Times(1).WillOnce(ReturnIsFile);
|
EXPECT_CALL(fsimpl, lstat(StrEq(FILENAME), _)).Times(1).WillOnce(ReturnIsFile);
|
||||||
|
errno = 0;
|
||||||
int retval = LstatPathAllowErrors(FILENAME);
|
int retval = LstatPathAllowErrors(FILENAME);
|
||||||
|
EXPECT_EQ(errno, 0);
|
||||||
EXPECT_EQ(retval, 0);
|
EXPECT_EQ(retval, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,15 +4,21 @@
|
|||||||
|
|
||||||
#include "FuseLstatTest.h"
|
#include "FuseLstatTest.h"
|
||||||
|
|
||||||
|
// This class offers test helpers for testing (struct stat) entries. We return them from
|
||||||
|
// our mock filesystem, set up a temporary filesystem, call lstat syscall on it, and
|
||||||
|
// then check the return value.
|
||||||
template<typename Property>
|
template<typename Property>
|
||||||
class FuseLstatReturnTest: public FuseLstatTest {
|
class FuseLstatReturnTest: public FuseLstatTest {
|
||||||
public:
|
public:
|
||||||
|
// Set the specified (struct stat) entry to the given value, and test whether it is correctly returned from the syscall.
|
||||||
|
// The CallFile[...] version tests it on a file node of the filesystem, the CallDir[...] version on a dir node.
|
||||||
struct stat CallFileLstatWithValue(Property value);
|
struct stat CallFileLstatWithValue(Property value);
|
||||||
struct stat CallDirLstatWithValue(Property value);
|
struct stat CallDirLstatWithValue(Property value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::function<void(struct stat*)> SetPropertyImpl(Property value);
|
std::function<void(struct stat*)> SetPropertyImpl(Property value);
|
||||||
|
|
||||||
|
// Override this function to specify, how to set the specified (struct stat) entry on the passed (struct stat *) object.
|
||||||
virtual void set(struct stat *stat, Property value) = 0;
|
virtual void set(struct stat *stat, Property value) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,19 +10,32 @@
|
|||||||
|
|
||||||
#include "test/testutils/FuseTest.h"
|
#include "test/testutils/FuseTest.h"
|
||||||
|
|
||||||
|
// This class offers some utility functions for testing lstat().
|
||||||
class FuseLstatTest: public FuseTest {
|
class FuseLstatTest: public FuseTest {
|
||||||
public:
|
protected:
|
||||||
const char *FILENAME = "/myfile";
|
const char *FILENAME = "/myfile";
|
||||||
|
|
||||||
|
// Set up a temporary filesystem (using the fsimpl mock in FuseTest as filesystem implementation)
|
||||||
|
// and call the lstat syscall on the given (filesystem-relative) path.
|
||||||
void LstatPath(const std::string &path);
|
void LstatPath(const std::string &path);
|
||||||
|
// Same as LstatPath above, but also return the result of the lstat syscall.
|
||||||
void LstatPath(const std::string &path, struct stat *result);
|
void LstatPath(const std::string &path, struct stat *result);
|
||||||
|
|
||||||
|
// These two functions are the same as LstatPath above, but they don't fail the test when the lstat syscall
|
||||||
|
// crashes. Instead, they return the result value of the lstat syscall.
|
||||||
int LstatPathAllowErrors(const std::string &path);
|
int LstatPathAllowErrors(const std::string &path);
|
||||||
int LstatPathAllowErrors(const std::string &path, struct stat *result);
|
int LstatPathAllowErrors(const std::string &path, struct stat *result);
|
||||||
|
|
||||||
protected:
|
// You can specify an implementation, which can modify the (struct stat *) result,
|
||||||
|
// our fuse mock filesystem implementation will then return this to fuse on an lstat call.
|
||||||
|
// This functions then set up a temporary filesystem with this mock, call lstat on a filesystem node
|
||||||
|
// and return the (struct stat) returned from an lstat syscall to this filesystem.
|
||||||
|
struct stat CallLstatWithImpl(std::function<void(struct stat*)> implementation);
|
||||||
|
|
||||||
|
// These two functions are like CallLstatWithImpl, but they also modify the (struct stat).st_mode
|
||||||
|
// field, so the node accessed is specified to be a file/directory.
|
||||||
struct stat CallFileLstatWithImpl(std::function<void(struct stat*)> implementation);
|
struct stat CallFileLstatWithImpl(std::function<void(struct stat*)> implementation);
|
||||||
struct stat CallDirLstatWithImpl(std::function<void(struct stat*)> implementation);
|
struct stat CallDirLstatWithImpl(std::function<void(struct stat*)> implementation);
|
||||||
struct stat CallLstatWithImpl(std::function<void(struct stat*)> implementation);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user