2014-11-25 16:47:36 +01:00
|
|
|
#include "FuseCreateAndOpenTest.h"
|
|
|
|
|
|
|
|
using ::testing::_;
|
|
|
|
|
|
|
|
int FuseCreateAndOpenTest::CreateAndOpenFile(const char *filename, int flags) {
|
|
|
|
int fd = CreateAndOpenFileAllowError(filename, flags);
|
|
|
|
EXPECT_GE(fd, 0);
|
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
2014-12-06 15:33:01 +01:00
|
|
|
int FuseCreateAndOpenTest::CreateAndOpenFileReturnError(const char *filename, int flags) {
|
|
|
|
int fd = CreateAndOpenFileAllowError(filename, flags);
|
|
|
|
if (fd >= 0) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return -fd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-25 16:47:36 +01:00
|
|
|
int FuseCreateAndOpenTest::CreateAndOpenFileAllowError(const char *filename, int flags) {
|
|
|
|
auto fs = TestFS();
|
|
|
|
|
|
|
|
auto realpath = fs->mountDir() / filename;
|
2014-12-06 15:33:01 +01:00
|
|
|
int fd = ::open(realpath.c_str(), flags | O_CREAT);
|
|
|
|
if (fd >= 0) {
|
|
|
|
return fd;
|
|
|
|
} else {
|
|
|
|
return -errno;
|
|
|
|
}
|
2014-11-25 16:47:36 +01:00
|
|
|
}
|