diff options
author | Scott Lobdell <slobdell@google.com> | 2021-04-08 04:26:25 +0000 |
---|---|---|
committer | Scott Lobdell <slobdell@google.com> | 2021-04-08 04:26:25 +0000 |
commit | 3a4cdf5b5bee8d156df159f79b3effb36704a9c2 (patch) | |
tree | 8c26ca98b9e4e5bd1535df8a66df3371ec646080 /payload_consumer/filesystem_verifier_action_unittest.cc | |
parent | b7d8bd23484260376b7c038f5f4d759d9430fe3a (diff) | |
parent | ea9d6ec577e940a73cf77d7c3d4a2372a058aa57 (diff) |
Merge SP1A.210407.002
Change-Id: I26458e9a17a92f9d5c5f741ed5d3ee3a7c32cc3f
Diffstat (limited to 'payload_consumer/filesystem_verifier_action_unittest.cc')
-rw-r--r-- | payload_consumer/filesystem_verifier_action_unittest.cc | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/payload_consumer/filesystem_verifier_action_unittest.cc b/payload_consumer/filesystem_verifier_action_unittest.cc index 2cad5232..c1006842 100644 --- a/payload_consumer/filesystem_verifier_action_unittest.cc +++ b/payload_consumer/filesystem_verifier_action_unittest.cc @@ -26,8 +26,8 @@ #include <brillo/message_loops/message_loop_utils.h> #include <brillo/secure_blob.h> #include <gtest/gtest.h> +#include <libsnapshot/snapshot_writer.h> -#include "gmock/gmock-actions.h" #include "update_engine/common/dynamic_partition_control_stub.h" #include "update_engine/common/hash_calculator.h" #include "update_engine/common/mock_dynamic_partition_control.h" @@ -463,4 +463,26 @@ TEST_F(FilesystemVerifierActionTest, RunWithVABCNoVerity) { ASSERT_EQ(actual_read_size, part.target_size); } +TEST_F(FilesystemVerifierActionTest, ReadAfterWrite) { + constexpr auto BLOCK_SIZE = 4096; + ScopedTempFile cow_device_file("cow_device.XXXXXX", true); + android::snapshot::CompressedSnapshotWriter snapshot_writer{ + {.block_size = BLOCK_SIZE}}; + snapshot_writer.SetCowDevice(android::base::unique_fd{cow_device_file.fd()}); + snapshot_writer.Initialize(); + std::vector<unsigned char> buffer; + buffer.resize(BLOCK_SIZE); + std::fill(buffer.begin(), buffer.end(), 123); + + ASSERT_TRUE(snapshot_writer.AddRawBlocks(0, buffer.data(), buffer.size())); + ASSERT_TRUE(snapshot_writer.Finalize()); + auto cow_reader = snapshot_writer.OpenReader(); + ASSERT_NE(cow_reader, nullptr); + ASSERT_TRUE(snapshot_writer.AddRawBlocks(1, buffer.data(), buffer.size())); + ASSERT_TRUE(snapshot_writer.AddRawBlocks(2, buffer.data(), buffer.size())); + ASSERT_TRUE(snapshot_writer.Finalize()); + cow_reader = snapshot_writer.OpenReader(); + ASSERT_NE(cow_reader, nullptr); +} + } // namespace chromeos_update_engine |