Add integration test for XOR ops
Test: th
Bug: 201099341
Change-Id: I36f4c2da25f23b3dcdfa0852a9dc01f896a292f1
diff --git a/common/utils.h b/common/utils.h
index 50b6cb1..4ff4050 100644
--- a/common/utils.h
+++ b/common/utils.h
@@ -38,6 +38,7 @@
#include <brillo/secure_blob.h>
#include "android-base/mapped_file.h"
+#include "google/protobuf/repeated_field.h"
#include "update_engine/common/action.h"
#include "update_engine/common/action_processor.h"
#include "update_engine/common/constants.h"
@@ -137,6 +138,8 @@
off_t FileSize(const std::string& path);
off_t FileSize(int fd);
+bool SendFile(int out_fd, int in_fd, size_t count);
+
std::string ErrnoNumberAsString(int err);
// Returns true if the file exists for sure. Returns false if it doesn't exist,
@@ -308,6 +311,27 @@
ssize_t out_data_size,
size_t block_size);
+bool WriteExtents(const std::string& path,
+ const google::protobuf::RepeatedPtrField<Extent>& extents,
+ const brillo::Blob& data,
+ size_t block_size);
+
+constexpr bool ReadExtents(const std::string& path,
+ const std::vector<Extent>& extents,
+ brillo::Blob* out_data,
+ size_t block_size) {
+ return ReadExtents(path,
+ extents,
+ out_data,
+ utils::BlocksInExtents(extents) * block_size,
+ block_size);
+}
+
+bool ReadExtents(const std::string& path,
+ const google::protobuf::RepeatedPtrField<Extent>& extents,
+ brillo::Blob* out_data,
+ size_t block_size);
+
// Read the current boot identifier and store it in |boot_id|. This identifier
// is constants during the same boot of the kernel and is regenerated after
// reboot. Returns whether it succeeded getting the boot_id.
@@ -485,6 +509,11 @@
std::string HexEncode(const brillo::Blob& blob) noexcept;
std::string HexEncode(const std::string_view blob) noexcept;
+template <size_t kSize>
+std::string HexEncode(const std::array<uint8_t, kSize> blob) noexcept {
+ return base::HexEncode(blob.data(), blob.size());
+}
+
} // namespace chromeos_update_engine
#define TEST_AND_RETURN_FALSE_ERRNO(_x) \