Fix test cases
This commit is contained in:
parent
3943862f0e
commit
1121467b31
@ -18,11 +18,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
int CreateAndOpenFile(const TempTestFS *fs, const char *filename) {
|
int CreateAndOpenFile(const TempTestFS *fs, const char *filename) {
|
||||||
auto realpath = fs->mountDir() / 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);
|
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";
|
EXPECT_GE(fd, 0) << "Creating file failed";
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,7 @@ int FuseCreateAndOpenTest::CreateAndOpenFileAllowError(const char *filename, int
|
|||||||
auto fs = TestFS();
|
auto fs = TestFS();
|
||||||
|
|
||||||
auto realpath = fs->mountDir() / filename;
|
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);
|
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) {
|
if (fd >= 0) {
|
||||||
return fd;
|
return fd;
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,11 +21,7 @@ class FuseFstatErrorTest: public FuseFstatTest, public WithParamInterface<int> {
|
|||||||
public:
|
public:
|
||||||
int CreateFileAllowErrors(const TempTestFS *fs, const std::string &filename) {
|
int CreateFileAllowErrors(const TempTestFS *fs, const std::string &filename) {
|
||||||
auto real_path = fs->mountDir() / 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);
|
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));
|
INSTANTIATE_TEST_CASE_P(FuseFstatErrorTest, FuseFstatErrorTest, Values(EACCES, EBADF, EFAULT, ELOOP, ENAMETOOLONG, ENOENT, ENOMEM, ENOTDIR, EOVERFLOW));
|
||||||
|
@ -21,11 +21,7 @@ int FuseFstatTest::CreateFileReturnError(const TempTestFS *fs, const std::string
|
|||||||
|
|
||||||
int FuseFstatTest::CreateFileAllowErrors(const TempTestFS *fs, const std::string &filename) {
|
int FuseFstatTest::CreateFileAllowErrors(const TempTestFS *fs, const std::string &filename) {
|
||||||
auto real_path = fs->mountDir() / 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);
|
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) {
|
if (fd >= 0) {
|
||||||
return fd;
|
return fd;
|
||||||
} else {
|
} else {
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This read() mock implementation reads from the stored virtual file (testFile).
|
// 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);
|
return testFile->read(buf, count, offset);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -16,12 +16,12 @@ public:
|
|||||||
void ReadFile(const char *filename, void *buf, size_t count, off_t offset);
|
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);
|
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) {
|
::testing::Invoke([](int, void *, size_t count, off_t) {
|
||||||
return count;
|
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) {
|
return ::testing::Invoke([filesize](int, void *, size_t count, off_t offset) {
|
||||||
size_t ableToReadCount = std::min(count, (size_t)(filesize - offset));
|
size_t ableToReadCount = std::min(count, (size_t)(filesize - offset));
|
||||||
return ableToReadCount;
|
return ableToReadCount;
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
|
|
||||||
MOCK_CONST_METHOD1(stat, void(struct ::stat*));
|
MOCK_CONST_METHOD1(stat, void(struct ::stat*));
|
||||||
MOCK_CONST_METHOD1(truncate, void(off_t));
|
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_METHOD3(write, void(const void*, size_t, off_t));
|
||||||
MOCK_METHOD0(flush, void());
|
MOCK_METHOD0(flush, void());
|
||||||
MOCK_METHOD0(fsync, void());
|
MOCK_METHOD0(fsync, void());
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
MOCK_METHOD2(fstat, void(int, struct ::stat*));
|
MOCK_METHOD2(fstat, void(int, struct ::stat*));
|
||||||
MOCK_PATH_METHOD2(truncate, void, off_t);
|
MOCK_PATH_METHOD2(truncate, void, off_t);
|
||||||
MOCK_METHOD2(ftruncate, void(int, 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_METHOD4(write, void(int, const void*, size_t, off_t));
|
||||||
MOCK_METHOD1(flush, void(int));
|
MOCK_METHOD1(flush, void(int));
|
||||||
MOCK_METHOD1(fsync, void(int));
|
MOCK_METHOD1(fsync, void(int));
|
||||||
|
Loading…
Reference in New Issue
Block a user