summaryrefslogtreecommitdiff
path: root/payload_generator/zip_unittest.cc
diff options
context:
space:
mode:
authorKelvin Zhang <zhangkelvin@google.com>2021-02-09 14:06:25 -0500
committerTreehugger Robot <treehugger-gerrit@google.com>2021-04-20 06:08:38 +0000
commit4d22ca2ab60f99f25d613f1ede3e1f16d9cc76cf (patch)
treebc2c54262cc3d4a777a667fe3089c00cafbf6fd8 /payload_generator/zip_unittest.cc
parent0c71550bf36a8d1590486e480fe2deb7253664cb (diff)
Refactor extent writer to take filedescriptor in constructor
Functions which receive an instance of extent writer need to manually pass fd to ExtentWriter via Init() call, which breaks separation of concerns. It makes it hard for us to decouple InstallOp execution from writing of data, as the execution unit must be aware of which fd to pass to extent writer. In addition, many extents writer, such as snapshot extent writer, simply ignores the fd parameter, which is a indication of poor code structure. To address the above issue, we pass FileDescriptorPtr via constructor if needed. This way, whoever is "executing" InstallOps don't need to care about where the output data is going, and whoever's writing the data would be responsible for initializing an ExtentWriter. Test: th Change-Id: I6d1eabde085eefd55da9ecc0352d4a16ae458698
Diffstat (limited to 'payload_generator/zip_unittest.cc')
-rw-r--r--payload_generator/zip_unittest.cc6
1 files changed, 2 insertions, 4 deletions
diff --git a/payload_generator/zip_unittest.cc b/payload_generator/zip_unittest.cc
index e357b156..10e899b0 100644
--- a/payload_generator/zip_unittest.cc
+++ b/payload_generator/zip_unittest.cc
@@ -33,7 +33,6 @@
using chromeos_update_engine::test_utils::kRandomString;
using google::protobuf::RepeatedPtrField;
using std::string;
-using std::vector;
namespace chromeos_update_engine {
@@ -50,8 +49,7 @@ class MemoryExtentWriter : public ExtentWriter {
}
~MemoryExtentWriter() override = default;
- bool Init(FileDescriptorPtr fd,
- const RepeatedPtrField<Extent>& extents,
+ bool Init(const RepeatedPtrField<Extent>& extents,
uint32_t block_size) override {
return true;
}
@@ -72,7 +70,7 @@ bool DecompressWithWriter(const brillo::Blob& in, brillo::Blob* out) {
std::unique_ptr<ExtentWriter> writer(
new W(std::make_unique<MemoryExtentWriter>(out)));
// Init() parameters are ignored by the testing MemoryExtentWriter.
- bool ok = writer->Init(nullptr, {}, 1);
+ bool ok = writer->Init({}, 1);
ok = writer->Write(in.data(), in.size()) && ok;
return ok;
}