[Unit Test] Complete FUSE unit tests #22
This commit is contained in:
parent
3c2c783683
commit
9eb3e7a22d
@ -171,6 +171,34 @@ TYPED_TEST(fuse_test, rdrw_can_not_read_or_write_to_directory) {
|
|||||||
|
|
||||||
this->rmdir_and_test(dir_path);
|
this->rmdir_and_test(dir_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TYPED_TEST(fuse_test, rdrw_can_append_to_file) {
|
||||||
|
std::string file_name{"append_test"};
|
||||||
|
auto file_path = this->create_file_and_test(file_name);
|
||||||
|
|
||||||
|
auto handle = open(file_path.c_str(), O_WRONLY);
|
||||||
|
ASSERT_GT(handle, -1);
|
||||||
|
auto bytes_written = pwrite64(handle, "test_", 5U, 0);
|
||||||
|
EXPECT_EQ(5U, bytes_written);
|
||||||
|
close(handle);
|
||||||
|
|
||||||
|
handle = open(file_path.c_str(), O_WRONLY | O_APPEND);
|
||||||
|
ASSERT_GT(handle, -1);
|
||||||
|
bytes_written = write(handle, "cow", 3U);
|
||||||
|
EXPECT_EQ(3U, bytes_written);
|
||||||
|
close(handle);
|
||||||
|
|
||||||
|
handle = open(file_path.c_str(), O_RDONLY);
|
||||||
|
ASSERT_GT(handle, -1);
|
||||||
|
std::string read_buffer;
|
||||||
|
read_buffer.resize(8U);
|
||||||
|
auto bytes_read = pread64(handle, read_buffer.data(), read_buffer.size(), 0);
|
||||||
|
EXPECT_EQ(8U, bytes_read);
|
||||||
|
EXPECT_STREQ("test_cow", read_buffer.c_str());
|
||||||
|
close(handle);
|
||||||
|
|
||||||
|
this->unlink_file_and_test(file_path);
|
||||||
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
|
||||||
#endif // !defined(_WIN32)
|
#endif // !defined(_WIN32)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user