Extended FsppDeviceTest

This commit is contained in:
Sebastian Messmer 2015-03-17 12:43:27 +01:00
parent 990d2a7011
commit 7fdbc9f629

View File

@ -3,6 +3,17 @@
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);
}
};
TYPED_TEST_CASE_P(FsppDeviceTest);
@ -16,16 +27,24 @@ TYPED_TEST_P(FsppDeviceTest, LoadRootDir) {
}
TYPED_TEST_P(FsppDeviceTest, LoadFileFromRootDir) {
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC);
this->InitDirStructure();
this->LoadFile("/myfile");
}
TYPED_TEST_P(FsppDeviceTest, LoadDirFromRootDir) {
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
this->InitDirStructure();
this->LoadDir("/mydir");
}
TYPED_TEST_P(FsppDeviceTest, LoadNonexistingFromEmptyRootDir) {
//TODO Change, as soon as it's clear how we want to handle fs errors
EXPECT_ANY_THROW(
this->device->Load("/nonexisting")
);
}
TYPED_TEST_P(FsppDeviceTest, LoadNonexistingFromRootDir) {
this->InitDirStructure();
//TODO Change, as soon as it's clear how we want to handle fs errors
EXPECT_ANY_THROW(
this->device->Load("/nonexisting")
@ -33,6 +52,7 @@ TYPED_TEST_P(FsppDeviceTest, LoadNonexistingFromRootDir) {
}
TYPED_TEST_P(FsppDeviceTest, LoadNonexistingFromNonexistingDir) {
this->InitDirStructure();
//TODO Change, as soon as it's clear how we want to handle fs errors
EXPECT_ANY_THROW(
this->device->Load("/nonexisting/nonexisting2")
@ -40,50 +60,53 @@ TYPED_TEST_P(FsppDeviceTest, LoadNonexistingFromNonexistingDir) {
}
TYPED_TEST_P(FsppDeviceTest, LoadNonexistingFromExistingDir) {
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
this->InitDirStructure();
//TODO Change, as soon as it's clear how we want to handle fs errors
EXPECT_ANY_THROW(
this->device->Load("/mydir/nonexisting")
);
}
TYPED_TEST_P(FsppDeviceTest, LoadNonexistingFromExistingEmptyDir) {
this->InitDirStructure();
//TODO Change, as soon as it's clear how we want to handle fs errors
EXPECT_ANY_THROW(
this->device->Load("/myemptydir/nonexisting")
);
}
TYPED_TEST_P(FsppDeviceTest, LoadFileFromDir_Nesting1) {
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC);
this->InitDirStructure();
this->LoadFile("/mydir/myfile");
}
TYPED_TEST_P(FsppDeviceTest, LoadDirFromDir_Nesting1) {
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC);
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC);
this->InitDirStructure();
this->LoadDir("/mydir/mysubdir");
}
TYPED_TEST_P(FsppDeviceTest, LoadFileFromDir_Nesting2) {
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->InitDirStructure();
this->LoadFile("/mydir/mysubdir/myfile");
}
TYPED_TEST_P(FsppDeviceTest, LoadDirFromDir_Nesting2) {
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->InitDirStructure();
this->LoadDir("/mydir/mysubdir/mysubsubdir");
}
//TODO Load from dir structure with more than one entry per dir
//TODO statfs
//TODO Test statfs
REGISTER_TYPED_TEST_CASE_P(FsppDeviceTest,
InitFilesystem,
LoadRootDir,
LoadFileFromRootDir,
LoadDirFromRootDir,
LoadNonexistingFromEmptyRootDir,
LoadNonexistingFromRootDir,
LoadNonexistingFromNonexistingDir,
LoadNonexistingFromExistingDir,
LoadNonexistingFromExistingEmptyDir,
LoadFileFromDir_Nesting1,
LoadDirFromDir_Nesting1,
LoadFileFromDir_Nesting2,