From 1121467b31b33bda2f461f0faf11d73b40358b51 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Fri, 11 Dec 2015 00:46:24 +0100 Subject: [PATCH] Fix test cases --- .../createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp | 4 ---- .../createAndOpenFile/testutils/FuseCreateAndOpenTest.cpp | 4 ---- test/fuse/fstat/FuseFstatErrorTest.cpp | 4 ---- test/fuse/fstat/testutils/FuseFstatTest.cpp | 4 ---- test/fuse/read/FuseReadReturnedDataTest.cpp | 2 +- test/fuse/read/testutils/FuseReadTest.h | 4 ++-- test/impl/FuseOpenFileListTest.cpp | 2 +- test/testutils/FuseTest.h | 2 +- 8 files changed, 5 insertions(+), 21 deletions(-) diff --git a/test/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp b/test/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp index 3d970b2c..22a71a8c 100644 --- a/test/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp +++ b/test/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp @@ -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; } diff --git a/test/fuse/createAndOpenFile/testutils/FuseCreateAndOpenTest.cpp b/test/fuse/createAndOpenFile/testutils/FuseCreateAndOpenTest.cpp index cfeaf40a..6b851088 100644 --- a/test/fuse/createAndOpenFile/testutils/FuseCreateAndOpenTest.cpp +++ b/test/fuse/createAndOpenFile/testutils/FuseCreateAndOpenTest.cpp @@ -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 { diff --git a/test/fuse/fstat/FuseFstatErrorTest.cpp b/test/fuse/fstat/FuseFstatErrorTest.cpp index fc4db513..da19139e 100644 --- a/test/fuse/fstat/FuseFstatErrorTest.cpp +++ b/test/fuse/fstat/FuseFstatErrorTest.cpp @@ -21,11 +21,7 @@ class FuseFstatErrorTest: public FuseFstatTest, public WithParamInterface { 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)); diff --git a/test/fuse/fstat/testutils/FuseFstatTest.cpp b/test/fuse/fstat/testutils/FuseFstatTest.cpp index 3ea0f5a2..0b3cfa27 100644 --- a/test/fuse/fstat/testutils/FuseFstatTest.cpp +++ b/test/fuse/fstat/testutils/FuseFstatTest.cpp @@ -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 { diff --git a/test/fuse/read/FuseReadReturnedDataTest.cpp b/test/fuse/read/FuseReadReturnedDataTest.cpp index 0bf509ad..73596cc2 100644 --- a/test/fuse/read/FuseReadReturnedDataTest.cpp +++ b/test/fuse/read/FuseReadReturnedDataTest.cpp @@ -61,7 +61,7 @@ public: } // This read() mock implementation reads from the stored virtual file (testFile). - Action ReadFromFile = Invoke([this](int, void *buf, size_t count, off_t offset) { + Action ReadFromFile = Invoke([this](int, void *buf, size_t count, off_t offset) { return testFile->read(buf, count, offset); }); }; diff --git a/test/fuse/read/testutils/FuseReadTest.h b/test/fuse/read/testutils/FuseReadTest.h index afcb7f00..f74bb474 100644 --- a/test/fuse/read/testutils/FuseReadTest.h +++ b/test/fuse/read/testutils/FuseReadTest.h @@ -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 ReturnSuccessfulRead = + ::testing::Action ReturnSuccessfulRead = ::testing::Invoke([](int, void *, size_t count, off_t) { return count; }); - ::testing::Action ReturnSuccessfulReadRegardingSize(size_t filesize) { + ::testing::Action 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; diff --git a/test/impl/FuseOpenFileListTest.cpp b/test/impl/FuseOpenFileListTest.cpp index 4f3a8ca9..148b7f43 100644 --- a/test/impl/FuseOpenFileListTest.cpp +++ b/test/impl/FuseOpenFileListTest.cpp @@ -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()); diff --git a/test/testutils/FuseTest.h b/test/testutils/FuseTest.h index 6b0832c0..be33629d 100644 --- a/test/testutils/FuseTest.h +++ b/test/testutils/FuseTest.h @@ -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));