libcryfs/fstest/FsppDeviceTest.h

117 lines
3.3 KiB
C
Raw Normal View History

2015-03-16 02:56:40 +01:00
#ifndef MESSMER_FSPP_FSTEST_FSPPDEVICETEST_H_
#define MESSMER_FSPP_FSTEST_FSPPDEVICETEST_H_
template<class ConcreteFileSystemTestFixture>
class FsppDeviceTest: public FileSystemTest<ConcreteFileSystemTestFixture> {
2015-03-17 12:43:27 +01:00
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);
}
2015-03-16 02:56:40 +01:00
};
TYPED_TEST_CASE_P(FsppDeviceTest);
TYPED_TEST_P(FsppDeviceTest, InitFilesystem) {
//fixture->createDevice() is called in the FileSystemTest constructor
}
TYPED_TEST_P(FsppDeviceTest, LoadRootDir) {
this->LoadDir("/");
}
TYPED_TEST_P(FsppDeviceTest, LoadFileFromRootDir) {
2015-03-17 12:43:27 +01:00
this->InitDirStructure();
2015-03-16 02:56:40 +01:00
this->LoadFile("/myfile");
}
TYPED_TEST_P(FsppDeviceTest, LoadDirFromRootDir) {
2015-03-17 12:43:27 +01:00
this->InitDirStructure();
2015-03-16 02:56:40 +01:00
this->LoadDir("/mydir");
}
2015-03-17 12:43:27 +01:00
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")
);
}
2015-03-16 04:02:45 +01:00
TYPED_TEST_P(FsppDeviceTest, LoadNonexistingFromRootDir) {
2015-03-17 12:43:27 +01:00
this->InitDirStructure();
2015-03-16 04:02:45 +01:00
//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, LoadNonexistingFromNonexistingDir) {
2015-03-17 12:43:27 +01:00
this->InitDirStructure();
2015-03-16 04:02:45 +01:00
//TODO Change, as soon as it's clear how we want to handle fs errors
EXPECT_ANY_THROW(
this->device->Load("/nonexisting/nonexisting2")
);
}
TYPED_TEST_P(FsppDeviceTest, LoadNonexistingFromExistingDir) {
2015-03-17 12:43:27 +01:00
this->InitDirStructure();
2015-03-16 04:02:45 +01:00
//TODO Change, as soon as it's clear how we want to handle fs errors
EXPECT_ANY_THROW(
this->device->Load("/mydir/nonexisting")
);
}
2015-03-17 12:43:27 +01:00
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")
);
}
2015-03-16 04:37:12 +01:00
TYPED_TEST_P(FsppDeviceTest, LoadFileFromDir_Nesting1) {
2015-03-17 12:43:27 +01:00
this->InitDirStructure();
2015-03-16 04:37:12 +01:00
this->LoadFile("/mydir/myfile");
}
TYPED_TEST_P(FsppDeviceTest, LoadDirFromDir_Nesting1) {
2015-03-17 12:43:27 +01:00
this->InitDirStructure();
2015-03-16 04:37:12 +01:00
this->LoadDir("/mydir/mysubdir");
}
TYPED_TEST_P(FsppDeviceTest, LoadFileFromDir_Nesting2) {
2015-03-17 12:43:27 +01:00
this->InitDirStructure();
2015-03-16 04:37:12 +01:00
this->LoadFile("/mydir/mysubdir/myfile");
}
TYPED_TEST_P(FsppDeviceTest, LoadDirFromDir_Nesting2) {
2015-03-17 12:43:27 +01:00
this->InitDirStructure();
2015-03-16 04:37:12 +01:00
this->LoadDir("/mydir/mysubdir/mysubsubdir");
}
2015-03-17 12:43:27 +01:00
//TODO Test statfs
2015-03-16 02:56:40 +01:00
REGISTER_TYPED_TEST_CASE_P(FsppDeviceTest,
InitFilesystem,
LoadRootDir,
LoadFileFromRootDir,
2015-03-16 04:02:45 +01:00
LoadDirFromRootDir,
2015-03-17 12:43:27 +01:00
LoadNonexistingFromEmptyRootDir,
2015-03-16 04:02:45 +01:00
LoadNonexistingFromRootDir,
LoadNonexistingFromNonexistingDir,
2015-03-16 04:37:12 +01:00
LoadNonexistingFromExistingDir,
2015-03-17 12:43:27 +01:00
LoadNonexistingFromExistingEmptyDir,
2015-03-16 04:37:12 +01:00
LoadFileFromDir_Nesting1,
LoadDirFromDir_Nesting1,
LoadFileFromDir_Nesting2,
LoadDirFromDir_Nesting2
2015-03-16 02:56:40 +01:00
);
#endif