2014-11-21 20:46:39 +01:00
|
|
|
#include "testutils/FuseFlushTest.h"
|
|
|
|
|
2016-02-11 12:53:42 +01:00
|
|
|
#include "fspp/fuse/FuseErrnoException.h"
|
2014-11-21 20:46:39 +01:00
|
|
|
|
|
|
|
using ::testing::WithParamInterface;
|
|
|
|
using ::testing::StrEq;
|
|
|
|
using ::testing::Eq;
|
|
|
|
using ::testing::Return;
|
|
|
|
using ::testing::Throw;
|
|
|
|
using ::testing::AtLeast;
|
|
|
|
using ::testing::Values;
|
|
|
|
using ::testing::_;
|
|
|
|
|
2014-11-28 14:46:45 +01:00
|
|
|
using fspp::fuse::FuseErrnoException;
|
2014-11-21 20:46:39 +01:00
|
|
|
|
|
|
|
class FuseFlushErrorTest: public FuseFlushTest, public WithParamInterface<int> {
|
|
|
|
};
|
|
|
|
INSTANTIATE_TEST_CASE_P(FuseFlushErrorTest, FuseFlushErrorTest, Values(EBADF, EINTR, EIO));
|
|
|
|
|
|
|
|
TEST_P(FuseFlushErrorTest, ReturnErrorFromFlush) {
|
|
|
|
ReturnIsFileOnLstat(FILENAME);
|
|
|
|
|
|
|
|
EXPECT_CALL(fsimpl, openFile(StrEq(FILENAME), _)).WillOnce(Return(GetParam()));
|
|
|
|
EXPECT_CALL(fsimpl, flush(Eq(GetParam()))).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
|
|
|
|
|
|
|
|
auto fs = TestFS();
|
2017-08-25 01:14:16 +02:00
|
|
|
auto fd = OpenFile(fs.get(), FILENAME);
|
2014-11-21 20:46:39 +01:00
|
|
|
|
2017-08-25 01:14:16 +02:00
|
|
|
int close_result = ::close(fd->fd());
|
2014-11-21 20:46:39 +01:00
|
|
|
EXPECT_EQ(GetParam(), errno);
|
2014-12-06 15:33:01 +01:00
|
|
|
EXPECT_EQ(-1, close_result);
|
2017-08-25 01:14:16 +02:00
|
|
|
fd->release(); // don't close it again
|
2014-11-21 20:46:39 +01:00
|
|
|
}
|