Fix filesystem tests
This commit is contained in:
parent
9de2d9d04a
commit
2f2ba7756b
@ -5,14 +5,14 @@ template<class ConcreteFileSystemTestFixture>
|
||||
class FsppDeviceTest: public FileSystemTest<ConcreteFileSystemTestFixture> {
|
||||
public:
|
||||
void InitDirStructure() {
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("myemptydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile2", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir/mysubdir")->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir/mysubdir")->createDir("mysubsubdir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("myemptydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile2", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir/mysubdir")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir/mysubdir")->createDir("mysubsubdir", this->MODE_PUBLIC, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
@ -97,6 +97,8 @@ TYPED_TEST_P(FsppDeviceTest, LoadDirFromDir_Nesting2) {
|
||||
|
||||
//TODO Test statfs
|
||||
|
||||
//TODO Test class for symlink tests (like FsppDirTest, FsppFileTest, ...)
|
||||
|
||||
REGISTER_TYPED_TEST_CASE_P(FsppDeviceTest,
|
||||
InitFilesystem,
|
||||
LoadRootDir,
|
||||
|
@ -5,14 +5,14 @@ template<class ConcreteFileSystemTestFixture>
|
||||
class FsppDirTest: public FileSystemTest<ConcreteFileSystemTestFixture> {
|
||||
public:
|
||||
void InitDirStructure() {
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("myemptydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile2", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir/mysubdir")->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir/mysubdir")->createDir("mysubsubdir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("myemptydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile2", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir/mysubdir")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir/mysubdir")->createDir("mysubsubdir", this->MODE_PUBLIC, 0, 0);
|
||||
}
|
||||
|
||||
void EXPECT_CHILDREN_ARE(const boost::filesystem::path &path, const std::initializer_list<fspp::Dir::Entry> expected) {
|
||||
@ -61,14 +61,14 @@ TYPED_TEST_P(FsppDirTest, Children_RootDir_Empty) {
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_RootDir_OneFile_Directly) {
|
||||
auto rootdir = this->LoadDir("/");
|
||||
rootdir->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
rootdir->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE(*rootdir, {
|
||||
FileEntry("myfile")
|
||||
});
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_RootDir_OneFile_AfterReloadingDir) {
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE("/", {
|
||||
FileEntry("myfile")
|
||||
});
|
||||
@ -76,14 +76,14 @@ TYPED_TEST_P(FsppDirTest, Children_RootDir_OneFile_AfterReloadingDir) {
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_RootDir_OneDir_Directly) {
|
||||
auto rootdir = this->LoadDir("/");
|
||||
rootdir->createDir("mydir", this->MODE_PUBLIC);
|
||||
rootdir->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE(*rootdir, {
|
||||
DirEntry("mydir")
|
||||
});
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_RootDir_OneDir_AfterReloadingDir) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE("/", {
|
||||
DirEntry("mydir")
|
||||
});
|
||||
@ -99,39 +99,39 @@ TYPED_TEST_P(FsppDirTest, Children_RootDir_LargerStructure) {
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_Nested_Empty) {
|
||||
this->LoadDir("/")->createDir("myemptydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("myemptydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE("/myemptydir", {});
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_Nested_OneFile_Directly) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
auto dir = this->LoadDir("/mydir");
|
||||
dir->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
dir->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE(*dir, {
|
||||
FileEntry("myfile")
|
||||
});
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_Nested_OneFile_AfterReloadingDir) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE("/mydir", {
|
||||
FileEntry("myfile")
|
||||
});
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_Nested_OneDir_Directly) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
auto dir = this->LoadDir("/mydir");
|
||||
dir->createDir("mysubdir", this->MODE_PUBLIC);
|
||||
dir->createDir("mysubdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE(*dir, {
|
||||
DirEntry("mysubdir")
|
||||
});
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_Nested_OneDir_AfterReloadingDir) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE("/mydir", {
|
||||
DirEntry("mysubdir")
|
||||
});
|
||||
@ -160,13 +160,13 @@ TYPED_TEST_P(FsppDirTest, Children_Nested2_LargerStructure) {
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InEmptyRoot) {
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadFile("/myfile");
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InNonemptyRoot) {
|
||||
this->InitDirStructure();
|
||||
this->LoadDir("/")->createAndOpenFile("mynewfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createAndOpenFile("mynewfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE("/", {
|
||||
FileEntry("myfile"),
|
||||
DirEntry("mydir"),
|
||||
@ -177,7 +177,7 @@ TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InNonemptyRoot) {
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InEmptyNestedDir) {
|
||||
this->InitDirStructure();
|
||||
this->LoadDir("/myemptydir")->createAndOpenFile("mynewfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/myemptydir")->createAndOpenFile("mynewfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE("/myemptydir", {
|
||||
FileEntry("mynewfile")
|
||||
});
|
||||
@ -185,7 +185,7 @@ TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InEmptyNestedDir) {
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InNonemptyNestedDir) {
|
||||
this->InitDirStructure();
|
||||
this->LoadDir("/mydir")->createAndOpenFile("mynewfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("mynewfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE("/mydir", {
|
||||
FileEntry("myfile"),
|
||||
FileEntry("myfile2"),
|
||||
@ -195,21 +195,21 @@ TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InNonemptyNestedDir) {
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_AlreadyExisting) {
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
//TODO Change, once we know which way of error reporting we want for such errors
|
||||
EXPECT_ANY_THROW(
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
);
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateDir_InEmptyRoot) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir");
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateDir_InNonemptyRoot) {
|
||||
this->InitDirStructure();
|
||||
this->LoadDir("/")->createDir("mynewdir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("mynewdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE("/", {
|
||||
FileEntry("myfile"),
|
||||
DirEntry("mydir"),
|
||||
@ -220,7 +220,7 @@ TYPED_TEST_P(FsppDirTest, CreateDir_InNonemptyRoot) {
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateDir_InEmptyNestedDir) {
|
||||
this->InitDirStructure();
|
||||
this->LoadDir("/myemptydir")->createDir("mynewdir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/myemptydir")->createDir("mynewdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE("/myemptydir", {
|
||||
DirEntry("mynewdir")
|
||||
});
|
||||
@ -228,7 +228,7 @@ TYPED_TEST_P(FsppDirTest, CreateDir_InEmptyNestedDir) {
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateDir_InNonemptyNestedDir) {
|
||||
this->InitDirStructure();
|
||||
this->LoadDir("/mydir")->createDir("mynewdir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir")->createDir("mynewdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->EXPECT_CHILDREN_ARE("/mydir", {
|
||||
FileEntry("myfile"),
|
||||
FileEntry("myfile2"),
|
||||
@ -238,10 +238,10 @@ TYPED_TEST_P(FsppDirTest, CreateDir_InNonemptyNestedDir) {
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateDir_AlreadyExisting) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
//TODO Change, once we know which way of error reporting we want for such errors
|
||||
EXPECT_ANY_THROW(
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
);
|
||||
}
|
||||
|
||||
@ -279,6 +279,9 @@ REGISTER_TYPED_TEST_CASE_P(FsppDirTest,
|
||||
//TODO rename
|
||||
//TODO utimens
|
||||
//TODO rmdir
|
||||
//TODO chmod
|
||||
//TODO chown
|
||||
//TODO mkdir with uid/gid
|
||||
|
||||
//TODO Test permission flags
|
||||
|
||||
|
@ -169,6 +169,9 @@ REGISTER_TYPED_TEST_CASE_P(FsppFileTest,
|
||||
//TODO rename
|
||||
//TODO utimens
|
||||
//TODO unlink
|
||||
//TODO chmod
|
||||
//TODO chown
|
||||
//TODO createAndOpenFile with uid/gid
|
||||
|
||||
//TODO Test permission flags
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define MESSMER_FSPP_FSTEST_TESTUTILS_FILETEST_H_
|
||||
|
||||
#include "FileSystemTest.h"
|
||||
#include <messmer/cpp-utils/data/Data.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -9,11 +10,11 @@ template<class ConcreteFileSystemTestFixture>
|
||||
class FileTest: public FileSystemTest<ConcreteFileSystemTestFixture> {
|
||||
public:
|
||||
FileTest() {
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
file_root = this->LoadFile("/myfile");
|
||||
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("mynestedfile", this->MODE_PUBLIC);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("mynestedfile", this->MODE_PUBLIC, 0, 0);
|
||||
file_nested = this->LoadFile("/mydir/mynestedfile");
|
||||
}
|
||||
std::unique_ptr<fspp::File> file_root;
|
||||
|
Loading…
Reference in New Issue
Block a user