fuse unit tests and fixes
This commit is contained in:
parent
0d5ac30e49
commit
77299455f9
@ -251,6 +251,12 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static auto create_file_path(std::string &file_name) {
|
||||
file_name += std::to_string(++idx);
|
||||
auto file_path = utils::path::combine(mount_location, {file_name});
|
||||
return file_path;
|
||||
}
|
||||
|
||||
static auto create_file_and_test(std::string &file_name,
|
||||
mode_t perms) -> std::string {
|
||||
file_name += std::to_string(++idx);
|
||||
|
@ -59,6 +59,36 @@ TYPED_TEST(fuse_test, create_can_create_file_with_specific_perms) {
|
||||
|
||||
this->unlink_file_and_test(file_path);
|
||||
}
|
||||
|
||||
TYPED_TEST(fuse_test, create_can_create_file) {
|
||||
auto file_path = this->create_file_path("create_test");
|
||||
|
||||
auto handle = open(file_path.c_str(), O_CREAT, ACCESSPERMS);
|
||||
EXPECT_LE(1, handle);
|
||||
close(handle);
|
||||
|
||||
this->unlink_file_and_test(file_path);
|
||||
}
|
||||
|
||||
TYPED_TEST(fuse_test, create_can_create_and_truncate_file) {
|
||||
std::string file_name{"create_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
EXPECT_EQ(0, truncate(file_path.c_str(), 24U));
|
||||
|
||||
auto size = utils::file::file{file_path}.size();
|
||||
EXPECT_TRUE(size.has_value());
|
||||
EXPECT_EQ(24U, *size);
|
||||
|
||||
auto handle = open(file_path.c_str(), O_TRUNC, ACCESSPERMS);
|
||||
EXPECT_LE(1, handle);
|
||||
close(handle);
|
||||
|
||||
size = utils::file::file{file_path}.size();
|
||||
EXPECT_TRUE(size.has_value());
|
||||
EXPECT_EQ(0U, *size);
|
||||
|
||||
this->unlink_file_and_test(file_path);
|
||||
}
|
||||
} // namespace repertory
|
||||
|
||||
#endif // !defined(_WIN32)
|
||||
|
Loading…
x
Reference in New Issue
Block a user