2014-11-25 16:47:36 +01:00
|
|
|
#include "testutils/FuseCreateAndOpenTest.h"
|
|
|
|
|
|
|
|
using ::testing::_;
|
2019-10-13 17:49:57 +02:00
|
|
|
using ::testing::Eq;
|
2014-11-25 16:47:36 +01:00
|
|
|
using ::testing::Return;
|
|
|
|
|
|
|
|
class FuseCreateAndOpenFilenameTest: public FuseCreateAndOpenTest {
|
|
|
|
public:
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(FuseCreateAndOpenFilenameTest, CreateAndOpenFile) {
|
|
|
|
ReturnDoesntExistOnLstat("/myfile");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, createAndOpenFile(Eq("/myfile"), _, _, _))
|
2014-11-25 16:47:36 +01:00
|
|
|
.Times(1).WillOnce(Return(0));
|
|
|
|
//For the syscall to succeed, we also need to give an fstat implementation.
|
|
|
|
ReturnIsFileOnFstat(0);
|
|
|
|
|
|
|
|
CreateAndOpenFile("/myfile", O_RDONLY);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseCreateAndOpenFilenameTest, CreateAndOpenFileNested) {
|
|
|
|
ReturnIsDirOnLstat("/mydir");
|
|
|
|
ReturnDoesntExistOnLstat("/mydir/myfile");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, createAndOpenFile(Eq("/mydir/myfile"), _, _, _))
|
2014-11-25 16:47:36 +01:00
|
|
|
.Times(1).WillOnce(Return(0));
|
|
|
|
//For the syscall to succeed, we also need to give an fstat implementation.
|
|
|
|
ReturnIsFileOnFstat(0);
|
|
|
|
|
|
|
|
CreateAndOpenFile("/mydir/myfile", O_RDONLY);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseCreateAndOpenFilenameTest, CreateAndOpenFileNested2) {
|
|
|
|
ReturnIsDirOnLstat("/mydir");
|
|
|
|
ReturnIsDirOnLstat("/mydir/mydir2");
|
|
|
|
ReturnDoesntExistOnLstat("/mydir/mydir2/myfile");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, createAndOpenFile(Eq("/mydir/mydir2/myfile"), _, _, _))
|
2014-11-25 16:47:36 +01:00
|
|
|
.Times(1).WillOnce(Return(0));
|
|
|
|
//For the syscall to succeed, we also need to give an fstat implementation.
|
|
|
|
ReturnIsFileOnFstat(0);
|
|
|
|
|
|
|
|
CreateAndOpenFile("/mydir/mydir2/myfile", O_RDONLY);
|
|
|
|
}
|