summaryrefslogtreecommitdiff
path: root/test_utils.cc
diff options
context:
space:
mode:
authorAlex Vakulenko <avakulenko@chromium.org>2015-02-09 12:53:18 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-02-11 06:00:18 +0000
commitf68bbbc952aa9a71898e4939b5f36187fa564a50 (patch)
tree3927ffc053db9275a052ba2a370cbae62b5c236a /test_utils.cc
parent981a9fb68ec5fe56f57b3ecb117a0dc681bf5e83 (diff)
update_engine: replace std::vector<char> with chromeos::Blob
To make update engine consistent with the rest of platform2 code replaced std::vector<char> as the container of binary data with chromeos::Blob. BUG=None TEST=`FEATURES=test emerge-link update_engine` Change-Id: I6385fd2257d15aa24bfa74ac35512c2a06c33012 Reviewed-on: https://chromium-review.googlesource.com/247793 Reviewed-by: Gilad Arnold <garnold@chromium.org> Reviewed-by: Alex Deymo <deymo@chromium.org> Tested-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Diffstat (limited to 'test_utils.cc')
-rw-r--r--test_utils.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/test_utils.cc b/test_utils.cc
index bd55ccb6..beda7986 100644
--- a/test_utils.cc
+++ b/test_utils.cc
@@ -35,7 +35,7 @@ namespace test_utils {
const char* const kMountPathTemplate = "UpdateEngineTests_mnt-XXXXXX";
-const unsigned char kRandomString[] = {
+const uint8_t kRandomString[] = {
0xf2, 0xb7, 0x55, 0x92, 0xea, 0xa6, 0xc9, 0x57,
0xe0, 0xf8, 0xeb, 0x34, 0x93, 0xd9, 0xc4, 0x8f,
0xcb, 0x20, 0xfa, 0x37, 0x4b, 0x40, 0xcf, 0xdc,
@@ -106,8 +106,8 @@ bool IsXAttrSupported(const base::FilePath& dir_path) {
return xattr_res == 0;
}
-bool WriteFileVector(const string& path, const vector<char>& data) {
- return utils::WriteFile(path.c_str(), &data[0], data.size());
+bool WriteFileVector(const string& path, const chromeos::Blob& data) {
+ return utils::WriteFile(path.c_str(), data.data(), data.size());
}
bool WriteFileString(const string& path, const string& data) {
@@ -137,7 +137,8 @@ bool BindToUnusedLoopDevice(const string& filename, string* lo_dev_name_p) {
return true;
}
-bool ExpectVectorsEq(const vector<char>& expected, const vector<char>& actual) {
+bool ExpectVectorsEq(const chromeos::Blob& expected,
+ const chromeos::Blob& actual) {
EXPECT_EQ(expected.size(), actual.size());
if (expected.size() != actual.size())
return false;
@@ -149,10 +150,10 @@ bool ExpectVectorsEq(const vector<char>& expected, const vector<char>& actual) {
return is_all_eq;
}
-void FillWithData(vector<char>* buffer) {
+void FillWithData(chromeos::Blob* buffer) {
size_t input_counter = 0;
- for (vector<char>::iterator it = buffer->begin(); it != buffer->end(); ++it) {
- *it = kRandomString[input_counter];
+ for (uint8_t& b : *buffer) {
+ b = kRandomString[input_counter];
input_counter++;
input_counter %= sizeof(kRandomString);
}