AU: Extent writer utility classes
These are similar to the FileWriter classes, but focus on writing to
extents within a file (or device) rather than writing a file in order.
Again there is a ExtentWriter interface from which all types of extent
writers interit.
There are also two basic extent writers: a direct extent writer that
writes data directly to the file descriptor, and a zero padding extent
writer that piggy-backs on another extent writer. When the
zero-padding extent writer is End()ed, it fills out the rest of the
extent with zeros.
Also, BzipExtentWriter: an ExtentWriter concrete subclass that writes
to another ExtentWriter. BzipExtentWriter bzip2 decompresses all data
passed through.
Review URL: http://codereview.chromium.org/551132
diff --git a/test_utils.cc b/test_utils.cc
index f83ddf9..6c1e35b 100644
--- a/test_utils.cc
+++ b/test_utils.cc
@@ -165,16 +165,25 @@
return ret;
}
-bool ExpectVectorsEq(const vector<char>& a, const vector<char>& b) {
- EXPECT_EQ(a.size(), b.size());
- if (a.size() != b.size())
+bool ExpectVectorsEq(const vector<char>& expected, const vector<char>& actual) {
+ EXPECT_EQ(expected.size(), actual.size());
+ if (expected.size() != actual.size())
return false;
- for (unsigned int i = 0; i < a.size(); i++) {
- EXPECT_EQ(a[i], b[i]) << "offset: " << i;
+ for (unsigned int i = 0; i < expected.size(); i++) {
+ EXPECT_EQ(expected[i], actual[i]) << "offset: " << i;
}
return true;
}
+void FillWithData(vector<char>* buffer) {
+ size_t input_counter = 0;
+ for (vector<char>::iterator it = buffer->begin(); it != buffer->end(); ++it) {
+ *it = kRandomString[input_counter];
+ input_counter++;
+ input_counter %= sizeof(kRandomString);
+ }
+}
+
void CreateExtImageAtPath(const string& path, vector<string>* out_paths) {
// create 10MiB sparse file
EXPECT_EQ(0, System(StringPrintf("dd if=/dev/zero of=%s"