mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 01:55:20 +00:00
Adding large file write/read test for fileops (#2706)
This commit is contained in:
parent
06cbafdeb6
commit
afbde7641a
@ -324,6 +324,30 @@ TEST_F(FileOpsTests, test_seekFile) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(FileOpsTests, test_large_read_write) {
|
||||
TempFile tmp_file;
|
||||
std::string path = tmp_file.path();
|
||||
|
||||
const std::string expected(600000000, 'A');
|
||||
const ssize_t expected_len = expected.size();
|
||||
|
||||
{
|
||||
PlatformFile fd(path, PF_CREATE_ALWAYS | PF_WRITE);
|
||||
EXPECT_TRUE(fd.isValid());
|
||||
auto write_len = fd.write(expected.c_str(), expected_len);
|
||||
EXPECT_EQ(expected_len, write_len);
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<char> buffer(expected_len);
|
||||
PlatformFile fd(path, PF_OPEN_EXISTING | PF_READ);
|
||||
EXPECT_TRUE(fd.isValid());
|
||||
auto read_len = fd.read(buffer.data(), expected_len);
|
||||
EXPECT_EQ(expected_len, read_len);
|
||||
EXPECT_EQ(expected, std::string(buffer.data()));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(FileOpsTests, test_glob) {
|
||||
{
|
||||
std::vector<fs::path> expected{kFakeDirectory + "/door.txt",
|
||||
|
Loading…
Reference in New Issue
Block a user