2014-11-25 18:43:50 +01:00
|
|
|
#include "FuseFstatTest.h"
|
|
|
|
|
|
|
|
using ::testing::StrEq;
|
|
|
|
using ::testing::_;
|
|
|
|
using ::testing::Return;
|
2017-08-25 01:14:16 +02:00
|
|
|
using cpputils::unique_ref;
|
|
|
|
using cpputils::make_unique_ref;
|
2014-11-25 18:43:50 +01:00
|
|
|
|
2017-08-25 01:14:16 +02:00
|
|
|
|
|
|
|
unique_ref<OpenFileHandle> FuseFstatTest::CreateFile(const TempTestFS *fs, const std::string &filename) {
|
|
|
|
auto fd = CreateFileAllowErrors(fs, filename);
|
|
|
|
EXPECT_GE(fd->fd(), 0) << "Opening file failed";
|
2014-11-25 18:43:50 +01:00
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
2014-12-06 15:33:01 +01:00
|
|
|
int FuseFstatTest::CreateFileReturnError(const TempTestFS *fs, const std::string &filename) {
|
2017-08-25 01:14:16 +02:00
|
|
|
auto fd = CreateFileAllowErrors(fs, filename);
|
|
|
|
return fd->errorcode();
|
2014-12-06 15:33:01 +01:00
|
|
|
}
|
|
|
|
|
2017-08-25 01:14:16 +02:00
|
|
|
unique_ref<OpenFileHandle> FuseFstatTest::CreateFileAllowErrors(const TempTestFS *fs, const std::string &filename) {
|
2014-11-25 18:43:50 +01:00
|
|
|
auto real_path = fs->mountDir() / filename;
|
2017-08-25 01:14:16 +02:00
|
|
|
auto fd = make_unique_ref<OpenFileHandle>(real_path.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
|
|
|
return fd;
|
2014-11-25 18:43:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FuseFstatTest::OnCreateAndOpenReturnFileDescriptor(const char *filename, int descriptor) {
|
2015-04-25 03:26:59 +02:00
|
|
|
EXPECT_CALL(fsimpl, createAndOpenFile(StrEq(filename), _, _, _)).Times(1).WillOnce(Return(descriptor));
|
2014-11-25 18:43:50 +01:00
|
|
|
}
|