2014-12-06 15:33:01 +01:00
|
|
|
#include "FuseFlushTest.h"
|
|
|
|
|
2017-08-25 01:14:16 +02:00
|
|
|
using cpputils::unique_ref;
|
|
|
|
using cpputils::make_unique_ref;
|
|
|
|
|
2014-12-06 15:33:01 +01:00
|
|
|
void FuseFlushTest::OpenAndCloseFile(const std::string &filename) {
|
|
|
|
auto fs = TestFS();
|
2017-08-25 01:14:16 +02:00
|
|
|
auto fd = OpenFile(fs.get(), filename);
|
|
|
|
CloseFile(fd->fd());
|
|
|
|
fd->release(); // don't try to close it again
|
2014-12-06 15:33:01 +01:00
|
|
|
}
|
|
|
|
|
2017-08-25 01:14:16 +02:00
|
|
|
unique_ref<OpenFileHandle> FuseFlushTest::OpenFile(const TempTestFS *fs, const std::string &filename) {
|
2014-12-06 15:33:01 +01:00
|
|
|
auto real_path = fs->mountDir() / filename;
|
2018-05-21 01:20:38 +02:00
|
|
|
auto fd = make_unique_ref<OpenFileHandle>(real_path.string().c_str(), O_RDONLY);
|
2017-08-25 01:14:16 +02:00
|
|
|
EXPECT_GE(fd->fd(), 0) << "Opening file failed";
|
2014-12-06 15:33:01 +01:00
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FuseFlushTest::CloseFile(int fd) {
|
|
|
|
int retval = ::close(fd);
|
|
|
|
EXPECT_EQ(0, retval);
|
|
|
|
}
|