2014-11-28 12:27:39 +01:00
|
|
|
#include "FuseFdatasyncTest.h"
|
|
|
|
|
|
|
|
void FuseFdatasyncTest::FdatasyncFile(const char *filename) {
|
2014-12-06 15:33:01 +01:00
|
|
|
int error = FdatasyncFileReturnError(filename);
|
|
|
|
EXPECT_EQ(0, error);
|
2014-11-28 12:27:39 +01:00
|
|
|
}
|
|
|
|
|
2014-12-06 15:33:01 +01:00
|
|
|
int FuseFdatasyncTest::FdatasyncFileReturnError(const char *filename) {
|
2014-11-28 12:27:39 +01:00
|
|
|
auto fs = TestFS();
|
|
|
|
|
|
|
|
int fd = OpenFile(fs.get(), filename);
|
2014-12-06 15:33:01 +01:00
|
|
|
int retval = ::fdatasync(fd);
|
|
|
|
if (retval == 0) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return errno;
|
|
|
|
}
|
2014-11-28 12:27:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int FuseFdatasyncTest::OpenFile(const TempTestFS *fs, const char *filename) {
|
|
|
|
auto realpath = fs->mountDir() / filename;
|
|
|
|
int fd = ::open(realpath.c_str(), O_RDWR);
|
|
|
|
EXPECT_GE(fd, 0) << "Error opening file";
|
|
|
|
return fd;
|
|
|
|
}
|