libcryfs/test/fspp/fuse/flush/FuseFlushErrorTest.cpp

38 lines
1.1 KiB
C++
Raw Normal View History

2014-11-21 20:46:39 +01:00
#include "testutils/FuseFlushTest.h"
#include "fspp/fs_interface/FuseErrnoException.h"
2014-11-21 20:46:39 +01:00
using ::testing::WithParamInterface;
using ::testing::Eq;
using ::testing::Return;
using ::testing::Throw;
using ::testing::Values;
using ::testing::_;
using fspp::fuse::FuseErrnoException;
2014-11-21 20:46:39 +01:00
class FuseFlushErrorTest: public FuseFlushTest, public WithParamInterface<int> {
};
2019-10-13 14:16:06 +02:00
INSTANTIATE_TEST_SUITE_P(FuseFlushErrorTest, FuseFlushErrorTest, Values(
2019-04-02 04:39:29 +02:00
EBADF,
#if defined(__GLIBC__) || defined(__APPLE__)
// musl has different handling for EINTR, see https://ewontfix.com/4/
EINTR,
#endif
EIO));
2014-11-21 20:46:39 +01:00
TEST_P(FuseFlushErrorTest, ReturnErrorFromFlush) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, openFile(Eq(FILENAME), _)).WillOnce(Return(GetParam()));
EXPECT_CALL(*fsimpl, flush(Eq(GetParam()))).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
2014-11-21 20:46:39 +01:00
auto fs = TestFS();
auto fd = OpenFile(fs.get(), FILENAME);
2014-11-21 20:46:39 +01:00
int close_result = ::close(fd->fd());
2014-11-21 20:46:39 +01:00
EXPECT_EQ(GetParam(), errno);
EXPECT_EQ(-1, close_result);
fd->release(); // don't close it again
2014-11-21 20:46:39 +01:00
}