2014-11-28 11:57:20 +01:00
|
|
|
#include "FuseFsyncTest.h"
|
|
|
|
|
2017-08-25 01:14:16 +02:00
|
|
|
using cpputils::unique_ref;
|
|
|
|
using cpputils::make_unique_ref;
|
|
|
|
|
2014-11-28 11:57:20 +01:00
|
|
|
void FuseFsyncTest::FsyncFile(const char *filename) {
|
2014-12-06 15:33:01 +01:00
|
|
|
int error = FsyncFileReturnError(filename);
|
|
|
|
EXPECT_EQ(0, error);
|
2014-11-28 11:57:20 +01:00
|
|
|
}
|
|
|
|
|
2014-12-06 15:33:01 +01:00
|
|
|
int FuseFsyncTest::FsyncFileReturnError(const char *filename) {
|
2014-11-28 11:57:20 +01:00
|
|
|
auto fs = TestFS();
|
|
|
|
|
2017-08-25 01:14:16 +02:00
|
|
|
auto fd = OpenFile(fs.get(), filename);
|
|
|
|
int retval = ::fsync(fd->fd());
|
2014-12-06 15:33:01 +01:00
|
|
|
if (retval == 0) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return errno;
|
|
|
|
}
|
2014-11-28 11:57:20 +01:00
|
|
|
}
|
|
|
|
|
2017-08-25 01:14:16 +02:00
|
|
|
unique_ref<OpenFileHandle> FuseFsyncTest::OpenFile(const TempTestFS *fs, const char *filename) {
|
2014-11-28 11:57:20 +01:00
|
|
|
auto realpath = fs->mountDir() / filename;
|
2017-08-25 01:14:16 +02:00
|
|
|
auto fd = make_unique_ref<OpenFileHandle>(realpath.c_str(), O_RDWR);
|
|
|
|
EXPECT_GE(fd->fd(), 0) << "Error opening file";
|
2014-11-28 11:57:20 +01:00
|
|
|
return fd;
|
|
|
|
}
|