Fix test cases

This commit is contained in:
Sebastian Messmer 2015-12-11 00:46:24 +01:00
parent 3943862f0e
commit 1121467b31
8 changed files with 5 additions and 21 deletions

View File

@ -18,11 +18,7 @@ public:
private:
int CreateAndOpenFile(const TempTestFS *fs, const char *filename) {
auto realpath = fs->mountDir() / filename;
#if __GNUC__ == 4 && __GNUC_MINOR__ == 8
int fd = ::open(realpath.c_str(), O_RDONLY | O_CREAT, S_IRUSR | S_IRGRP | S_IROTH);
#else
int fd = ::open(realpath.c_str(), O_RDONLY | O_CREAT);
#endif
EXPECT_GE(fd, 0) << "Creating file failed";
return fd;
}

View File

@ -21,11 +21,7 @@ int FuseCreateAndOpenTest::CreateAndOpenFileAllowError(const char *filename, int
auto fs = TestFS();
auto realpath = fs->mountDir() / filename;
#if __GNUC__ == 4 && __GNUC_MINOR__ == 8
int fd = ::open(realpath.c_str(), flags | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
#else
int fd = ::open(realpath.c_str(), flags | O_CREAT);
#endif
if (fd >= 0) {
return fd;
} else {

View File

@ -21,11 +21,7 @@ class FuseFstatErrorTest: public FuseFstatTest, public WithParamInterface<int> {
public:
int CreateFileAllowErrors(const TempTestFS *fs, const std::string &filename) {
auto real_path = fs->mountDir() / filename;
#if __GNUC__ == 4 && __GNUC_MINOR__ == 8
return ::open(real_path.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
#else
return ::open(real_path.c_str(), O_RDWR | O_CREAT);
#endif
}
};
INSTANTIATE_TEST_CASE_P(FuseFstatErrorTest, FuseFstatErrorTest, Values(EACCES, EBADF, EFAULT, ELOOP, ENAMETOOLONG, ENOENT, ENOMEM, ENOTDIR, EOVERFLOW));

View File

@ -21,11 +21,7 @@ int FuseFstatTest::CreateFileReturnError(const TempTestFS *fs, const std::string
int FuseFstatTest::CreateFileAllowErrors(const TempTestFS *fs, const std::string &filename) {
auto real_path = fs->mountDir() / filename;
#if __GNUC__ == 4 && __GNUC_MINOR__ == 8
int fd = ::open(real_path.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
#else
int fd = ::open(real_path.c_str(), O_RDWR | O_CREAT);
#endif
if (fd >= 0) {
return fd;
} else {

View File

@ -61,7 +61,7 @@ public:
}
// This read() mock implementation reads from the stored virtual file (testFile).
Action<int(int, void*, size_t, off_t)> ReadFromFile = Invoke([this](int, void *buf, size_t count, off_t offset) {
Action<size_t(int, void*, size_t, off_t)> ReadFromFile = Invoke([this](int, void *buf, size_t count, off_t offset) {
return testFile->read(buf, count, offset);
});
};

View File

@ -16,12 +16,12 @@ public:
void ReadFile(const char *filename, void *buf, size_t count, off_t offset);
ReadError ReadFileReturnError(const char *filename, void *buf, size_t count, off_t offset);
::testing::Action<int(int, void*, size_t, off_t)> ReturnSuccessfulRead =
::testing::Action<size_t(int, void*, size_t, off_t)> ReturnSuccessfulRead =
::testing::Invoke([](int, void *, size_t count, off_t) {
return count;
});
::testing::Action<int(int, void*, size_t, off_t)> ReturnSuccessfulReadRegardingSize(size_t filesize) {
::testing::Action<size_t(int, void*, size_t, off_t)> ReturnSuccessfulReadRegardingSize(size_t filesize) {
return ::testing::Invoke([filesize](int, void *, size_t count, off_t offset) {
size_t ableToReadCount = std::min(count, (size_t)(filesize - offset));
return ableToReadCount;

View File

@ -19,7 +19,7 @@ public:
MOCK_CONST_METHOD1(stat, void(struct ::stat*));
MOCK_CONST_METHOD1(truncate, void(off_t));
MOCK_CONST_METHOD3(read, ssize_t(void*, size_t, off_t));
MOCK_CONST_METHOD3(read, size_t(void*, size_t, off_t));
MOCK_METHOD3(write, void(const void*, size_t, off_t));
MOCK_METHOD0(flush, void());
MOCK_METHOD0(fsync, void());

View File

@ -50,7 +50,7 @@ public:
MOCK_METHOD2(fstat, void(int, struct ::stat*));
MOCK_PATH_METHOD2(truncate, void, off_t);
MOCK_METHOD2(ftruncate, void(int, off_t));
MOCK_METHOD4(read, int(int, void*, size_t, off_t));
MOCK_METHOD4(read, size_t(int, void*, size_t, off_t));
MOCK_METHOD4(write, void(int, const void*, size_t, off_t));
MOCK_METHOD1(flush, void(int));
MOCK_METHOD1(fsync, void(int));