FsTest tests set access permissions correctly

This commit is contained in:
Sebastian Meßmer 2015-03-16 04:53:35 +01:00
parent afd4c90e21
commit 990d2a7011
3 changed files with 28 additions and 26 deletions

View File

@ -16,12 +16,12 @@ TYPED_TEST_P(FsppDeviceTest, LoadRootDir) {
}
TYPED_TEST_P(FsppDeviceTest, LoadFileFromRootDir) {
this->LoadDir("/")->createAndOpenFile("myfile", 0);
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC);
this->LoadFile("/myfile");
}
TYPED_TEST_P(FsppDeviceTest, LoadDirFromRootDir) {
this->LoadDir("/")->createDir("mydir", 0);
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
this->LoadDir("/mydir");
}
@ -40,7 +40,7 @@ TYPED_TEST_P(FsppDeviceTest, LoadNonexistingFromNonexistingDir) {
}
TYPED_TEST_P(FsppDeviceTest, LoadNonexistingFromExistingDir) {
this->LoadDir("/")->createDir("mydir", 0);
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
//TODO Change, as soon as it's clear how we want to handle fs errors
EXPECT_ANY_THROW(
this->device->Load("/mydir/nonexisting")
@ -48,28 +48,28 @@ TYPED_TEST_P(FsppDeviceTest, LoadNonexistingFromExistingDir) {
}
TYPED_TEST_P(FsppDeviceTest, LoadFileFromDir_Nesting1) {
this->LoadDir("/")->createDir("mydir", 0);
this->LoadDir("/mydir")->createAndOpenFile("myfile", 0);
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC);
this->LoadFile("/mydir/myfile");
}
TYPED_TEST_P(FsppDeviceTest, LoadDirFromDir_Nesting1) {
this->LoadDir("/")->createDir("mydir", 0);
this->LoadDir("/mydir")->createDir("mysubdir", 0);
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC);
this->LoadDir("/mydir/mysubdir");
}
TYPED_TEST_P(FsppDeviceTest, LoadFileFromDir_Nesting2) {
this->LoadDir("/")->createDir("mydir", 0);
this->LoadDir("/mydir")->createDir("mysubdir", 0);
this->LoadDir("/mydir/mysubdir")->createAndOpenFile("myfile", 0);
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC);
this->LoadDir("/mydir/mysubdir")->createAndOpenFile("myfile", this->MODE_PUBLIC);
this->LoadFile("/mydir/mysubdir/myfile");
}
TYPED_TEST_P(FsppDeviceTest, LoadDirFromDir_Nesting2) {
this->LoadDir("/")->createDir("mydir", 0);
this->LoadDir("/mydir")->createDir("mysubdir", 0);
this->LoadDir("/mydir/mysubdir")->createDir("mysubsubdir", 0);
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC);
this->LoadDir("/mydir/mysubdir")->createDir("mysubsubdir", this->MODE_PUBLIC);
this->LoadDir("/mydir/mysubdir/mysubsubdir");
}

View File

@ -14,7 +14,7 @@ TYPED_TEST_P(FsppDirTest, Children_EmptyRootDir) {
TYPED_TEST_P(FsppDirTest, Children_OneFileInRootDir) {
auto rootdir = this->LoadDir("/");
rootdir->createAndOpenFile("myfile", 0);
rootdir->createAndOpenFile("myfile", this->MODE_PUBLIC);
auto children = rootdir->children();
EXPECT_EQ(1, children->size());
EXPECT_EQ(fspp::Dir::EntryType::FILE, (*children)[0].type);
@ -23,7 +23,7 @@ TYPED_TEST_P(FsppDirTest, Children_OneFileInRootDir) {
TYPED_TEST_P(FsppDirTest, Children_OneDirInRootDir) {
auto rootdir = this->LoadDir("/");
rootdir->createDir("mydir", 0);
rootdir->createDir("mydir", this->MODE_PUBLIC);
auto children = rootdir->children();
EXPECT_EQ(1, children->size());
EXPECT_EQ(fspp::Dir::EntryType::DIR, (*children)[0].type);
@ -31,9 +31,9 @@ TYPED_TEST_P(FsppDirTest, Children_OneDirInRootDir) {
}
TYPED_TEST_P(FsppDirTest, Children_OneFileInNestedDir_Directly) {
this->LoadDir("/")->createDir("mydir", 0);
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
auto dir = this->LoadDir("/mydir");
dir->createAndOpenFile("myfile", 0);
dir->createAndOpenFile("myfile", this->MODE_PUBLIC);
auto children = dir->children();
EXPECT_EQ(1, children->size());
EXPECT_EQ(fspp::Dir::EntryType::FILE, (*children)[0].type);
@ -41,8 +41,8 @@ TYPED_TEST_P(FsppDirTest, Children_OneFileInNestedDir_Directly) {
}
TYPED_TEST_P(FsppDirTest, Children_OneFileInNestedDir_AfterReloadingDir) {
this->LoadDir("/")->createDir("mydir", 0);
this->LoadDir("/mydir")->createAndOpenFile("myfile", 0);
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC);
auto dir = this->LoadDir("/mydir");
auto children = dir->children();
EXPECT_EQ(1, children->size());
@ -51,9 +51,9 @@ TYPED_TEST_P(FsppDirTest, Children_OneFileInNestedDir_AfterReloadingDir) {
}
TYPED_TEST_P(FsppDirTest, Children_OneDirInNestedDir_Directly) {
this->LoadDir("/")->createDir("mydir", 0);
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
auto dir = this->LoadDir("/mydir");
dir->createDir("mysubdir", 0);
dir->createDir("mysubdir", this->MODE_PUBLIC);
auto children = dir->children();
EXPECT_EQ(1, children->size());
EXPECT_EQ(fspp::Dir::EntryType::DIR, (*children)[0].type);
@ -61,8 +61,8 @@ TYPED_TEST_P(FsppDirTest, Children_OneDirInNestedDir_Directly) {
}
TYPED_TEST_P(FsppDirTest, Children_OneDirInNestedDir_AfterReloadingDir) {
this->LoadDir("/")->createDir("mydir", 0);
this->LoadDir("/mydir")->createDir("mysubdir", 0);
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC);
auto dir = this->LoadDir("/mydir");
auto children = dir->children();
EXPECT_EQ(1, children->size());
@ -71,12 +71,12 @@ TYPED_TEST_P(FsppDirTest, Children_OneDirInNestedDir_AfterReloadingDir) {
}
TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_LoadAfterwards) {
this->LoadDir("/")->createAndOpenFile("myfile", 0);
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC);
this->LoadFile("/myfile");
}
TYPED_TEST_P(FsppDirTest, CreateDir_LoadAfterwards) {
this->LoadDir("/")->createDir("mydir", 0);
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
this->LoadDir("/mydir");
}
@ -93,6 +93,7 @@ REGISTER_TYPED_TEST_CASE_P(FsppDirTest,
);
//TODO Build dir structure with more than one entry
//TODO createDir/createAndOpenFile for already existing
//TODO rmdir

View File

@ -30,6 +30,8 @@ public:
ConcreteFileSystemTestFixture fixture;
std::unique_ptr<fspp::Device> device;
static constexpr mode_t MODE_PUBLIC = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH;
std::unique_ptr<fspp::Dir> LoadDir(const boost::filesystem::path &path) {
auto loaded = device->Load(path);
auto dir = cpputils::dynamic_pointer_move<fspp::Dir>(loaded);
@ -46,5 +48,4 @@ public:
};
#endif