2014-11-21 20:46:39 +01:00
|
|
|
#include "testutils/FuseFlushTest.h"
|
|
|
|
|
2018-05-21 08:18:34 +02:00
|
|
|
#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::_;
|
|
|
|
|
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> {
|
|
|
|
};
|
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);
|
|
|
|
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, openFile(Eq(FILENAME), _)).WillOnce(Return(GetParam()));
|
2018-12-03 07:57:21 +01:00
|
|
|
EXPECT_CALL(*fsimpl, flush(Eq(GetParam()))).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
|
2014-11-21 20:46:39 +01:00
|
|
|
|
|
|
|
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
|
|
|
}
|