2016-03-31 17:48:43 +02:00
|
|
|
#pragma once
|
|
|
|
#ifndef MESSMER_FSPP_FSTEST_FSPPNODETEST_STAT_H_
|
|
|
|
#define MESSMER_FSPP_FSTEST_FSPPNODETEST_STAT_H_
|
|
|
|
|
|
|
|
#include "testutils/FsppNodeTest.h"
|
2018-05-21 08:18:34 +02:00
|
|
|
#include "../fs_interface/FuseErrnoException.h"
|
2016-03-31 17:48:43 +02:00
|
|
|
|
|
|
|
template<class ConcreteFileSystemTestFixture>
|
|
|
|
class FsppNodeTest_Stat: public FsppNodeTest<ConcreteFileSystemTestFixture> {
|
|
|
|
public:
|
|
|
|
void Test_Nlink() {
|
2017-01-21 20:16:35 +01:00
|
|
|
this->CreateNode("/mynode");
|
|
|
|
auto node = this->Load("/mynode");
|
2018-09-14 07:38:05 +02:00
|
|
|
this->IN_STAT(node.get(), [] (const fspp::Node::stat_info& st) {
|
|
|
|
EXPECT_EQ(1u, st.nlink);
|
2016-03-31 17:48:43 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Test cases only run for file nodes
|
|
|
|
template<class ConcreteFileSystemTestFixture>
|
2017-01-22 02:11:26 +01:00
|
|
|
class FsppNodeTest_Stat_FileOnly: public FileSystemTest<ConcreteFileSystemTestFixture>, public FsppNodeTestHelper {};
|
2016-03-31 17:48:43 +02:00
|
|
|
|
2019-10-13 14:16:06 +02:00
|
|
|
TYPED_TEST_SUITE_P(FsppNodeTest_Stat_FileOnly);
|
2016-03-31 17:48:43 +02:00
|
|
|
|
|
|
|
TYPED_TEST_P(FsppNodeTest_Stat_FileOnly, CreatedFileIsEmpty) {
|
2017-01-21 20:16:35 +01:00
|
|
|
this->CreateFile("/myfile");
|
|
|
|
auto node = this->Load("/myfile");
|
2018-09-15 23:32:58 +02:00
|
|
|
this->EXPECT_SIZE(fspp::num_bytes_t(0), node.get());
|
2016-03-31 17:48:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TYPED_TEST_P(FsppNodeTest_Stat_FileOnly, FileIsFile) {
|
2017-01-21 20:16:35 +01:00
|
|
|
this->CreateFile("/myfile");
|
|
|
|
auto node = this->Load("/myfile");
|
2018-09-14 07:38:05 +02:00
|
|
|
this->IN_STAT(node.get(), [] (const fspp::Node::stat_info& st) {
|
2018-09-14 11:34:11 +02:00
|
|
|
EXPECT_TRUE(st.mode.hasFileFlag());
|
2016-03-31 17:48:43 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test cases only run for dir nodes
|
|
|
|
template<class ConcreteFileSystemTestFixture>
|
2017-01-22 02:11:26 +01:00
|
|
|
class FsppNodeTest_Stat_DirOnly: public FileSystemTest<ConcreteFileSystemTestFixture>, public FsppNodeTestHelper {};
|
2016-03-31 17:48:43 +02:00
|
|
|
|
2019-10-13 14:16:06 +02:00
|
|
|
TYPED_TEST_SUITE_P(FsppNodeTest_Stat_DirOnly);
|
2016-03-31 17:48:43 +02:00
|
|
|
|
|
|
|
TYPED_TEST_P(FsppNodeTest_Stat_DirOnly, DirIsDir) {
|
2017-01-21 20:16:35 +01:00
|
|
|
this->CreateDir("/mydir");
|
|
|
|
auto node = this->Load("/mydir");
|
2018-09-14 07:38:05 +02:00
|
|
|
this->IN_STAT(node.get(), [] (const fspp::Node::stat_info& st) {
|
2018-09-14 11:34:11 +02:00
|
|
|
EXPECT_TRUE(st.mode.hasDirFlag());
|
2016-03-31 17:48:43 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test cases only run for symlink nodes
|
|
|
|
template<class ConcreteFileSystemTestFixture>
|
2017-01-22 02:11:26 +01:00
|
|
|
class FsppNodeTest_Stat_SymlinkOnly: public FileSystemTest<ConcreteFileSystemTestFixture>, public FsppNodeTestHelper {};
|
2016-03-31 17:48:43 +02:00
|
|
|
|
2019-10-13 14:16:06 +02:00
|
|
|
TYPED_TEST_SUITE_P(FsppNodeTest_Stat_SymlinkOnly);
|
2016-03-31 17:48:43 +02:00
|
|
|
|
|
|
|
TYPED_TEST_P(FsppNodeTest_Stat_SymlinkOnly, SymlinkIsSymlink) {
|
2017-01-21 20:16:35 +01:00
|
|
|
this->CreateSymlink("/mysymlink");
|
|
|
|
auto node = this->Load("/mysymlink");
|
2018-09-14 07:38:05 +02:00
|
|
|
this->IN_STAT(node.get(), [] (const fspp::Node::stat_info& st) {
|
2018-09-14 11:34:11 +02:00
|
|
|
EXPECT_TRUE(st.mode.hasSymlinkFlag());
|
2016-03-31 17:48:43 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-10-13 14:16:06 +02:00
|
|
|
REGISTER_NODE_TEST_SUITE(FsppNodeTest_Stat,
|
2016-03-31 17:48:43 +02:00
|
|
|
Nlink
|
|
|
|
);
|
|
|
|
|
2019-10-13 14:16:06 +02:00
|
|
|
REGISTER_TYPED_TEST_SUITE_P(FsppNodeTest_Stat_FileOnly,
|
2016-03-31 17:48:43 +02:00
|
|
|
CreatedFileIsEmpty,
|
|
|
|
FileIsFile
|
|
|
|
);
|
|
|
|
|
2019-10-13 14:16:06 +02:00
|
|
|
REGISTER_TYPED_TEST_SUITE_P(FsppNodeTest_Stat_DirOnly,
|
2016-03-31 17:48:43 +02:00
|
|
|
DirIsDir
|
|
|
|
);
|
|
|
|
|
2019-10-13 14:16:06 +02:00
|
|
|
REGISTER_TYPED_TEST_SUITE_P(FsppNodeTest_Stat_SymlinkOnly,
|
2016-03-31 17:48:43 +02:00
|
|
|
SymlinkIsSymlink
|
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//TODO More test cases
|