update_engine: Run clang-format on common/
BUG=none
TEST=unittest
Change-Id: Icdaf5017e03a197bc576f08f4b8dcdd00cff217c
Reviewed-on: https://chromium-review.googlesource.com/1407541
Commit-Ready: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Sen Jiang <senj@chromium.org>
diff --git a/common/action.h b/common/action.h
index 6c88216..9e2f5ff 100644
--- a/common/action.h
+++ b/common/action.h
@@ -145,12 +145,12 @@
};
// Forward declare a couple classes we use.
-template<typename T>
+template <typename T>
class ActionPipe;
-template<typename T>
+template <typename T>
class ActionTraits;
-template<typename SubClass>
+template <typename SubClass>
class Action : public AbstractAction {
public:
~Action() override {}
@@ -162,8 +162,9 @@
void set_in_pipe(
// this type is a fancy way of saying: a shared_ptr to an
// ActionPipe<InputObjectType>.
- const std::shared_ptr<ActionPipe<
- typename ActionTraits<SubClass>::InputObjectType>>& in_pipe) {
+ const std::shared_ptr<
+ ActionPipe<typename ActionTraits<SubClass>::InputObjectType>>&
+ in_pipe) {
in_pipe_ = in_pipe;
}
@@ -174,8 +175,9 @@
void set_out_pipe(
// this type is a fancy way of saying: a shared_ptr to an
// ActionPipe<OutputObjectType>.
- const std::shared_ptr<ActionPipe<
- typename ActionTraits<SubClass>::OutputObjectType>>& out_pipe) {
+ const std::shared_ptr<
+ ActionPipe<typename ActionTraits<SubClass>::OutputObjectType>>&
+ out_pipe) {
out_pipe_ = out_pipe;
}
@@ -192,9 +194,7 @@
}
// Returns true iff there's an output pipe.
- bool HasOutputPipe() const {
- return out_pipe_.get();
- }
+ bool HasOutputPipe() const { return out_pipe_.get(); }
// Copies the object passed into the output pipe. It will be accessible to
// the next Action via that action's input pipe (which is the same as this
diff --git a/common/action_pipe.h b/common/action_pipe.h
index 376c2f1..0c98ee1 100644
--- a/common/action_pipe.h
+++ b/common/action_pipe.h
@@ -48,10 +48,10 @@
// for that type, no object is taken/given.
class NoneType {};
-template<typename T>
+template <typename T>
class Action;
-template<typename ObjectType>
+template <typename ObjectType>
class ActionPipe {
public:
virtual ~ActionPipe() {}
@@ -67,7 +67,7 @@
// Bonds two Actions together with a new ActionPipe. The ActionPipe is
// jointly owned by the two Actions and will be automatically destroyed
// when the last Action is destroyed.
- template<typename FromAction, typename ToAction>
+ template <typename FromAction, typename ToAction>
static void Bond(FromAction* from, ToAction* to) {
std::shared_ptr<ActionPipe<ObjectType>> pipe(new ActionPipe<ObjectType>);
from->set_out_pipe(pipe);
@@ -87,7 +87,7 @@
};
// Utility function
-template<typename FromAction, typename ToAction>
+template <typename FromAction, typename ToAction>
void BondActions(FromAction* from, ToAction* to) {
static_assert(
std::is_same<typename FromAction::OutputObjectType,
diff --git a/common/action_pipe_unittest.cc b/common/action_pipe_unittest.cc
index 9bfbc83..233561d 100644
--- a/common/action_pipe_unittest.cc
+++ b/common/action_pipe_unittest.cc
@@ -28,7 +28,7 @@
class ActionPipeTestAction;
-template<>
+template <>
class ActionTraits<ActionPipeTestAction> {
public:
typedef string OutputObjectType;
@@ -46,7 +46,7 @@
string Type() const { return "ActionPipeTestAction"; }
};
-class ActionPipeTest : public ::testing::Test { };
+class ActionPipeTest : public ::testing::Test {};
// This test creates two simple Actions and sends a message via an ActionPipe
// from one to the other.
diff --git a/common/action_processor.cc b/common/action_processor.cc
index ead99c4..6e555dd 100644
--- a/common/action_processor.cc
+++ b/common/action_processor.cc
@@ -115,8 +115,8 @@
current_action_.reset();
LOG(INFO) << "ActionProcessor: finished "
<< (actions_.empty() ? "last action " : "") << old_type
- << (suspended_ ? " while suspended" : "")
- << " with code " << utils::ErrorCodeToString(code);
+ << (suspended_ ? " while suspended" : "") << " with code "
+ << utils::ErrorCodeToString(code);
if (!actions_.empty() && code != ErrorCode::kSuccess) {
LOG(INFO) << "ActionProcessor: Aborting processing due to failure.";
actions_.clear();
diff --git a/common/action_processor.h b/common/action_processor.h
index 1a67c99..735a106 100644
--- a/common/action_processor.h
+++ b/common/action_processor.h
@@ -80,9 +80,7 @@
// Sets/gets the current delegate. Set to null to remove a delegate.
ActionProcessorDelegate* delegate() const { return delegate_; }
- void set_delegate(ActionProcessorDelegate *delegate) {
- delegate_ = delegate;
- }
+ void set_delegate(ActionProcessorDelegate* delegate) { delegate_ = delegate; }
// Returns a pointer to the current Action that's processing.
AbstractAction* current_action() const { return current_action_.get(); }
diff --git a/common/action_processor_unittest.cc b/common/action_processor_unittest.cc
index eb646ef..4057abd 100644
--- a/common/action_processor_unittest.cc
+++ b/common/action_processor_unittest.cc
@@ -32,7 +32,7 @@
class ActionProcessorTestAction;
-template<>
+template <>
class ActionTraits<ActionProcessorTestAction> {
public:
typedef string OutputObjectType;
@@ -104,9 +104,7 @@
EXPECT_CALL(*mock_action_, Type()).Times(testing::AnyNumber());
}
- void TearDown() override {
- action_processor_.set_delegate(nullptr);
- }
+ void TearDown() override { action_processor_.set_delegate(nullptr); }
protected:
// The ActionProcessor under test.
diff --git a/common/action_unittest.cc b/common/action_unittest.cc
index b2f9ba4..ca48bee 100644
--- a/common/action_unittest.cc
+++ b/common/action_unittest.cc
@@ -31,7 +31,7 @@
class ActionTestAction;
-template<>
+template <>
class ActionTraits<ActionTestAction> {
public:
typedef string OutputObjectType;
@@ -54,7 +54,7 @@
string Type() const { return "ActionTestAction"; }
};
-class ActionTest : public ::testing::Test { };
+class ActionTest : public ::testing::Test {};
// This test creates two simple Actions and sends a message via an ActionPipe
// from one to the other.
diff --git a/common/clock.cc b/common/clock.cc
index f0eff44..05c495c 100644
--- a/common/clock.cc
+++ b/common/clock.cc
@@ -36,7 +36,7 @@
}
struct timeval now_tv;
now_tv.tv_sec = now_ts.tv_sec;
- now_tv.tv_usec = now_ts.tv_nsec/base::Time::kNanosecondsPerMicrosecond;
+ now_tv.tv_usec = now_ts.tv_nsec / base::Time::kNanosecondsPerMicrosecond;
return base::Time::FromTimeVal(now_tv);
}
@@ -51,7 +51,7 @@
}
struct timeval now_tv;
now_tv.tv_sec = now_ts.tv_sec;
- now_tv.tv_usec = now_ts.tv_nsec/base::Time::kNanosecondsPerMicrosecond;
+ now_tv.tv_usec = now_ts.tv_nsec / base::Time::kNanosecondsPerMicrosecond;
return base::Time::FromTimeVal(now_tv);
}
diff --git a/common/error_code_utils.cc b/common/error_code_utils.cc
index a1607f5..b0bbbd4 100644
--- a/common/error_code_utils.cc
+++ b/common/error_code_utils.cc
@@ -30,12 +30,15 @@
// doesn't support any combinations of those.
if ((static_cast<int>(code) & static_cast<int>(ErrorCode::kSpecialFlags)) &&
(static_cast<int>(code) & ~static_cast<int>(ErrorCode::kSpecialFlags)))
- code = static_cast<ErrorCode>(
- static_cast<int>(code) & ~static_cast<int>(ErrorCode::kSpecialFlags));
+ code = static_cast<ErrorCode>(static_cast<int>(code) &
+ ~static_cast<int>(ErrorCode::kSpecialFlags));
switch (code) {
- case ErrorCode::kSuccess: return "ErrorCode::kSuccess";
- case ErrorCode::kError: return "ErrorCode::kError";
- case ErrorCode::kOmahaRequestError: return "ErrorCode::kOmahaRequestError";
+ case ErrorCode::kSuccess:
+ return "ErrorCode::kSuccess";
+ case ErrorCode::kError:
+ return "ErrorCode::kError";
+ case ErrorCode::kOmahaRequestError:
+ return "ErrorCode::kOmahaRequestError";
case ErrorCode::kOmahaResponseHandlerError:
return "ErrorCode::kOmahaResponseHandlerError";
case ErrorCode::kFilesystemCopierError:
diff --git a/common/fake_boot_control.h b/common/fake_boot_control.h
index ba975a2..3d65075 100644
--- a/common/fake_boot_control.h
+++ b/common/fake_boot_control.h
@@ -89,9 +89,7 @@
devices_.resize(num_slots_);
}
- void SetCurrentSlot(BootControlInterface::Slot slot) {
- current_slot_ = slot;
- }
+ void SetCurrentSlot(BootControlInterface::Slot slot) { current_slot_ = slot; }
void SetPartitionDevice(const std::string& partition_name,
BootControlInterface::Slot slot,
diff --git a/common/fake_clock.h b/common/fake_clock.h
index 3d3bad8..165ec4d 100644
--- a/common/fake_clock.h
+++ b/common/fake_clock.h
@@ -26,29 +26,17 @@
public:
FakeClock() {}
- base::Time GetWallclockTime() override {
- return wallclock_time_;
- }
+ base::Time GetWallclockTime() override { return wallclock_time_; }
- base::Time GetMonotonicTime() override {
- return monotonic_time_;
- }
+ base::Time GetMonotonicTime() override { return monotonic_time_; }
- base::Time GetBootTime() override {
- return boot_time_;
- }
+ base::Time GetBootTime() override { return boot_time_; }
- void SetWallclockTime(const base::Time &time) {
- wallclock_time_ = time;
- }
+ void SetWallclockTime(const base::Time& time) { wallclock_time_ = time; }
- void SetMonotonicTime(const base::Time &time) {
- monotonic_time_ = time;
- }
+ void SetMonotonicTime(const base::Time& time) { monotonic_time_ = time; }
- void SetBootTime(const base::Time &time) {
- boot_time_ = time;
- }
+ void SetBootTime(const base::Time& time) { boot_time_ = time; }
private:
base::Time wallclock_time_;
diff --git a/common/fake_hardware.h b/common/fake_hardware.h
index 55ef32d..63346ce 100644
--- a/common/fake_hardware.h
+++ b/common/fake_hardware.h
@@ -159,9 +159,7 @@
oobe_timestamp_ = oobe_timestamp;
}
- void UnsetIsOOBEComplete() {
- is_oobe_complete_ = false;
- }
+ void UnsetIsOOBEComplete() { is_oobe_complete_ = false; }
void SetHardwareClass(const std::string& hardware_class) {
hardware_class_ = hardware_class;
@@ -171,9 +169,7 @@
firmware_version_ = firmware_version;
}
- void SetECVersion(const std::string& ec_version) {
- ec_version_ = ec_version;
- }
+ void SetECVersion(const std::string& ec_version) { ec_version_ = ec_version; }
void SetMinKernelKeyVersion(int min_kernel_key_version) {
min_kernel_key_version_ = min_kernel_key_version;
diff --git a/common/fake_prefs.cc b/common/fake_prefs.cc
index 5a0a3af..c446e06 100644
--- a/common/fake_prefs.cc
+++ b/common/fake_prefs.cc
@@ -27,8 +27,8 @@
namespace {
void CheckNotNull(const string& key, void* ptr) {
- EXPECT_NE(nullptr, ptr)
- << "Called Get*() for key \"" << key << "\" with a null parameter.";
+ EXPECT_NE(nullptr, ptr) << "Called Get*() for key \"" << key
+ << "\" with a null parameter.";
}
} // namespace
@@ -40,25 +40,25 @@
}
// Compile-time type-dependent constants definitions.
-template<>
+template <>
FakePrefs::PrefType const FakePrefs::PrefConsts<string>::type =
FakePrefs::PrefType::kString;
-template<>
-string FakePrefs::PrefValue::* const // NOLINT(runtime/string), not static str.
+template <>
+string FakePrefs::PrefValue::*const // NOLINT(runtime/string), not static str.
FakePrefs::PrefConsts<string>::member = &FakePrefs::PrefValue::as_str;
-template<>
+template <>
FakePrefs::PrefType const FakePrefs::PrefConsts<int64_t>::type =
FakePrefs::PrefType::kInt64;
-template<>
-int64_t FakePrefs::PrefValue::* const FakePrefs::PrefConsts<int64_t>::member =
+template <>
+int64_t FakePrefs::PrefValue::*const FakePrefs::PrefConsts<int64_t>::member =
&FakePrefs::PrefValue::as_int64;
-template<>
+template <>
FakePrefs::PrefType const FakePrefs::PrefConsts<bool>::type =
FakePrefs::PrefType::kBool;
-template<>
-bool FakePrefs::PrefValue::* const FakePrefs::PrefConsts<bool>::member =
+template <>
+bool FakePrefs::PrefValue::*const FakePrefs::PrefConsts<bool>::member =
&FakePrefs::PrefValue::as_bool;
bool FakePrefs::GetString(const string& key, string* value) const {
@@ -124,7 +124,7 @@
<< " but is accessed as a " << GetTypeName(type);
}
-template<typename T>
+template <typename T>
void FakePrefs::SetValue(const string& key, const T& value) {
CheckKeyType(key, PrefConsts<T>::type);
values_[key].type = PrefConsts<T>::type;
@@ -137,7 +137,7 @@
}
}
-template<typename T>
+template <typename T>
bool FakePrefs::GetValue(const string& key, T* value) const {
CheckKeyType(key, PrefConsts<T>::type);
auto it = values_.find(key);
@@ -157,8 +157,7 @@
auto observer_it =
std::find(observers_for_key.begin(), observers_for_key.end(), observer);
EXPECT_NE(observer_it, observers_for_key.end())
- << "Trying to remove an observer instance not watching the key "
- << key;
+ << "Trying to remove an observer instance not watching the key " << key;
if (observer_it != observers_for_key.end())
observers_for_key.erase(observer_it);
if (observers_for_key.empty())
diff --git a/common/fake_prefs.h b/common/fake_prefs.h
index d194060..b1c5b71 100644
--- a/common/fake_prefs.h
+++ b/common/fake_prefs.h
@@ -72,14 +72,14 @@
};
// Class to store compile-time type-dependent constants.
- template<typename T>
+ template <typename T>
class PrefConsts {
public:
// The PrefType associated with T.
static FakePrefs::PrefType const type;
// The data member pointer to PrefValue associated with T.
- static T FakePrefs::PrefValue::* const member;
+ static T FakePrefs::PrefValue::*const member;
};
// Returns a string representation of the PrefType useful for logging.
@@ -90,13 +90,13 @@
// Helper function to set a value of the passed |key|. It sets the type based
// on the template parameter T.
- template<typename T>
+ template <typename T>
void SetValue(const std::string& key, const T& value);
// Helper function to get a value from the map checking for invalid calls.
// The function fails the test if you attempt to read a value defined as a
// different type. Returns whether the get succeeded.
- template<typename T>
+ template <typename T>
bool GetValue(const std::string& key, T* value) const;
// Container for all the key/value pairs.
diff --git a/common/file_fetcher.h b/common/file_fetcher.h
index 2368b1d..fbdfc32 100644
--- a/common/file_fetcher.h
+++ b/common/file_fetcher.h
@@ -57,7 +57,7 @@
// Ignore all extra headers for files.
void SetHeader(const std::string& header_name,
- const std::string& header_value) override {};
+ const std::string& header_value) override {}
// Suspend the asynchronous file read.
void Pause() override;
diff --git a/common/hash_calculator.cc b/common/hash_calculator.cc
index ebfdb6e..d010a53 100644
--- a/common/hash_calculator.cc
+++ b/common/hash_calculator.cc
@@ -95,7 +95,8 @@
return RawHashOfBytes(data.data(), data.size(), out_hash);
}
-off_t HashCalculator::RawHashOfFile(const string& name, off_t length,
+off_t HashCalculator::RawHashOfFile(const string& name,
+ off_t length,
brillo::Blob* out_hash) {
HashCalculator calc;
off_t res = calc.UpdateFile(name, length);
diff --git a/common/hash_calculator.h b/common/hash_calculator.h
index 06d2cfb..b7e4d86 100644
--- a/common/hash_calculator.h
+++ b/common/hash_calculator.h
@@ -71,9 +71,9 @@
static bool RawHashOfBytes(const void* data,
size_t length,
brillo::Blob* out_hash);
- static bool RawHashOfData(const brillo::Blob& data,
- brillo::Blob* out_hash);
- static off_t RawHashOfFile(const std::string& name, off_t length,
+ static bool RawHashOfData(const brillo::Blob& data, brillo::Blob* out_hash);
+ static off_t RawHashOfFile(const std::string& name,
+ off_t length,
brillo::Blob* out_hash);
private:
diff --git a/common/hash_calculator_unittest.cc b/common/hash_calculator_unittest.cc
index 79f22ad..e8f73d5 100644
--- a/common/hash_calculator_unittest.cc
+++ b/common/hash_calculator_unittest.cc
@@ -38,11 +38,9 @@
// $ echo -n hi | openssl dgst -sha256 -binary |
// hexdump -v -e '" " 12/1 "0x%02x, " "\n"'
static const uint8_t kExpectedRawHash[] = {
- 0x8f, 0x43, 0x43, 0x46, 0x64, 0x8f, 0x6b, 0x96,
- 0xdf, 0x89, 0xdd, 0xa9, 0x01, 0xc5, 0x17, 0x6b,
- 0x10, 0xa6, 0xd8, 0x39, 0x61, 0xdd, 0x3c, 0x1a,
- 0xc8, 0x8b, 0x59, 0xb2, 0xdc, 0x32, 0x7a, 0xa4
-};
+ 0x8f, 0x43, 0x43, 0x46, 0x64, 0x8f, 0x6b, 0x96, 0xdf, 0x89, 0xdd,
+ 0xa9, 0x01, 0xc5, 0x17, 0x6b, 0x10, 0xa6, 0xd8, 0x39, 0x61, 0xdd,
+ 0x3c, 0x1a, 0xc8, 0x8b, 0x59, 0xb2, 0xdc, 0x32, 0x7a, 0xa4};
class HashCalculatorTest : public ::testing::Test {};
@@ -148,9 +146,7 @@
TEST_F(HashCalculatorTest, AbortTest) {
// Just make sure we don't crash and valgrind doesn't detect memory leaks
- {
- HashCalculator calc;
- }
+ { HashCalculator calc; }
{
HashCalculator calc;
calc.Update("h", 1);
diff --git a/common/http_common.cc b/common/http_common.cc
index d07ced3..5f234b0 100644
--- a/common/http_common.cc
+++ b/common/http_common.cc
@@ -24,34 +24,34 @@
namespace chromeos_update_engine {
-const char *GetHttpResponseDescription(HttpResponseCode code) {
+const char* GetHttpResponseDescription(HttpResponseCode code) {
static const struct {
HttpResponseCode code;
const char* description;
} http_response_table[] = {
- { kHttpResponseOk, "OK" },
- { kHttpResponseCreated, "Created" },
- { kHttpResponseAccepted, "Accepted" },
- { kHttpResponseNonAuthInfo, "Non-Authoritative Information" },
- { kHttpResponseNoContent, "No Content" },
- { kHttpResponseResetContent, "Reset Content" },
- { kHttpResponsePartialContent, "Partial Content" },
- { kHttpResponseMultipleChoices, "Multiple Choices" },
- { kHttpResponseMovedPermanently, "Moved Permanently" },
- { kHttpResponseFound, "Found" },
- { kHttpResponseSeeOther, "See Other" },
- { kHttpResponseNotModified, "Not Modified" },
- { kHttpResponseUseProxy, "Use Proxy" },
- { kHttpResponseTempRedirect, "Temporary Redirect" },
- { kHttpResponseBadRequest, "Bad Request" },
- { kHttpResponseUnauth, "Unauthorized" },
- { kHttpResponseForbidden, "Forbidden" },
- { kHttpResponseNotFound, "Not Found" },
- { kHttpResponseRequestTimeout, "Request Timeout" },
- { kHttpResponseInternalServerError, "Internal Server Error" },
- { kHttpResponseNotImplemented, "Not Implemented" },
- { kHttpResponseServiceUnavailable, "Service Unavailable" },
- { kHttpResponseVersionNotSupported, "HTTP Version Not Supported" },
+ {kHttpResponseOk, "OK"},
+ {kHttpResponseCreated, "Created"},
+ {kHttpResponseAccepted, "Accepted"},
+ {kHttpResponseNonAuthInfo, "Non-Authoritative Information"},
+ {kHttpResponseNoContent, "No Content"},
+ {kHttpResponseResetContent, "Reset Content"},
+ {kHttpResponsePartialContent, "Partial Content"},
+ {kHttpResponseMultipleChoices, "Multiple Choices"},
+ {kHttpResponseMovedPermanently, "Moved Permanently"},
+ {kHttpResponseFound, "Found"},
+ {kHttpResponseSeeOther, "See Other"},
+ {kHttpResponseNotModified, "Not Modified"},
+ {kHttpResponseUseProxy, "Use Proxy"},
+ {kHttpResponseTempRedirect, "Temporary Redirect"},
+ {kHttpResponseBadRequest, "Bad Request"},
+ {kHttpResponseUnauth, "Unauthorized"},
+ {kHttpResponseForbidden, "Forbidden"},
+ {kHttpResponseNotFound, "Not Found"},
+ {kHttpResponseRequestTimeout, "Request Timeout"},
+ {kHttpResponseInternalServerError, "Internal Server Error"},
+ {kHttpResponseNotImplemented, "Not Implemented"},
+ {kHttpResponseServiceUnavailable, "Service Unavailable"},
+ {kHttpResponseVersionNotSupported, "HTTP Version Not Supported"},
};
bool is_found = false;
@@ -63,17 +63,16 @@
return (is_found ? http_response_table[i].description : "(unsupported)");
}
-HttpResponseCode StringToHttpResponseCode(const char *s) {
+HttpResponseCode StringToHttpResponseCode(const char* s) {
return static_cast<HttpResponseCode>(strtoul(s, nullptr, 10));
}
-
-const char *GetHttpContentTypeString(HttpContentType type) {
+const char* GetHttpContentTypeString(HttpContentType type) {
static const struct {
HttpContentType type;
const char* str;
} http_content_type_table[] = {
- { kHttpContentTypeTextXml, "text/xml" },
+ {kHttpContentTypeTextXml, "text/xml"},
};
bool is_found = false;
diff --git a/common/http_common.h b/common/http_common.h
index 6d444ed..7a68da0 100644
--- a/common/http_common.h
+++ b/common/http_common.h
@@ -24,39 +24,38 @@
// Enumeration type for HTTP response codes.
enum HttpResponseCode {
- kHttpResponseUndefined = 0,
- kHttpResponseOk = 200,
- kHttpResponseCreated = 201,
- kHttpResponseAccepted = 202,
- kHttpResponseNonAuthInfo = 203,
- kHttpResponseNoContent = 204,
- kHttpResponseResetContent = 205,
- kHttpResponsePartialContent = 206,
- kHttpResponseMultipleChoices = 300,
- kHttpResponseMovedPermanently = 301,
- kHttpResponseFound = 302,
- kHttpResponseSeeOther = 303,
- kHttpResponseNotModified = 304,
- kHttpResponseUseProxy = 305,
- kHttpResponseTempRedirect = 307,
- kHttpResponseBadRequest = 400,
- kHttpResponseUnauth = 401,
- kHttpResponseForbidden = 403,
- kHttpResponseNotFound = 404,
- kHttpResponseRequestTimeout = 408,
- kHttpResponseReqRangeNotSat = 416,
+ kHttpResponseUndefined = 0,
+ kHttpResponseOk = 200,
+ kHttpResponseCreated = 201,
+ kHttpResponseAccepted = 202,
+ kHttpResponseNonAuthInfo = 203,
+ kHttpResponseNoContent = 204,
+ kHttpResponseResetContent = 205,
+ kHttpResponsePartialContent = 206,
+ kHttpResponseMultipleChoices = 300,
+ kHttpResponseMovedPermanently = 301,
+ kHttpResponseFound = 302,
+ kHttpResponseSeeOther = 303,
+ kHttpResponseNotModified = 304,
+ kHttpResponseUseProxy = 305,
+ kHttpResponseTempRedirect = 307,
+ kHttpResponseBadRequest = 400,
+ kHttpResponseUnauth = 401,
+ kHttpResponseForbidden = 403,
+ kHttpResponseNotFound = 404,
+ kHttpResponseRequestTimeout = 408,
+ kHttpResponseReqRangeNotSat = 416,
kHttpResponseInternalServerError = 500,
- kHttpResponseNotImplemented = 501,
- kHttpResponseServiceUnavailable = 503,
+ kHttpResponseNotImplemented = 501,
+ kHttpResponseServiceUnavailable = 503,
kHttpResponseVersionNotSupported = 505,
};
// Returns a standard HTTP status line string for a given response code.
-const char *GetHttpResponseDescription(HttpResponseCode code);
+const char* GetHttpResponseDescription(HttpResponseCode code);
// Converts a string beginning with an HTTP error code into numerical value.
-HttpResponseCode StringToHttpResponseCode(const char *s);
-
+HttpResponseCode StringToHttpResponseCode(const char* s);
// Enumeration type for HTTP Content-Type.
enum HttpContentType {
@@ -65,7 +64,7 @@
};
// Returns a standard HTTP Content-Type string.
-const char *GetHttpContentTypeString(HttpContentType type);
+const char* GetHttpContentTypeString(HttpContentType type);
} // namespace chromeos_update_engine
diff --git a/common/http_fetcher.cc b/common/http_fetcher.cc
index 73c0d48..5a98dfc 100644
--- a/common/http_fetcher.cc
+++ b/common/http_fetcher.cc
@@ -29,7 +29,8 @@
CancelProxyResolution();
}
-void HttpFetcher::SetPostData(const void* data, size_t size,
+void HttpFetcher::SetPostData(const void* data,
+ size_t size,
HttpContentType type) {
post_data_set_ = true;
post_data_.clear();
diff --git a/common/http_fetcher.h b/common/http_fetcher.h
index 1f5c945..2b4fc83 100644
--- a/common/http_fetcher.h
+++ b/common/http_fetcher.h
@@ -73,9 +73,7 @@
void SetProxies(const std::deque<std::string>& proxies) {
proxies_ = proxies;
}
- const std::string& GetCurrentProxy() const {
- return proxies_.front();
- }
+ const std::string& GetCurrentProxy() const { return proxies_.front(); }
bool HasProxy() const { return !proxies_.empty(); }
void PopProxy() { proxies_.pop_front(); }
diff --git a/common/http_fetcher_unittest.cc b/common/http_fetcher_unittest.cc
index 00ea128..237ea20 100644
--- a/common/http_fetcher_unittest.cc
+++ b/common/http_fetcher_unittest.cc
@@ -58,30 +58,29 @@
using std::string;
using std::unique_ptr;
using std::vector;
+using testing::_;
using testing::DoAll;
using testing::Return;
using testing::SaveArg;
-using testing::_;
namespace {
-const int kBigLength = 100000;
-const int kMediumLength = 1000;
+const int kBigLength = 100000;
+const int kMediumLength = 1000;
const int kFlakyTruncateLength = 29000;
-const int kFlakySleepEvery = 3;
-const int kFlakySleepSecs = 10;
+const int kFlakySleepEvery = 3;
+const int kFlakySleepSecs = 10;
} // namespace
namespace chromeos_update_engine {
-static const char *kUnusedUrl = "unused://unused";
+static const char* kUnusedUrl = "unused://unused";
-static inline string LocalServerUrlForPath(in_port_t port,
- const string& path) {
+static inline string LocalServerUrlForPath(in_port_t port, const string& path) {
string port_str = (port ? base::StringPrintf(":%hu", port) : "");
- return base::StringPrintf("http://127.0.0.1%s%s", port_str.c_str(),
- path.c_str());
+ return base::StringPrintf(
+ "http://127.0.0.1%s%s", port_str.c_str(), path.c_str());
}
//
@@ -93,24 +92,18 @@
// This makes it an abstract class (dirty but works).
virtual ~HttpServer() = 0;
- virtual in_port_t GetPort() const {
- return 0;
- }
+ virtual in_port_t GetPort() const { return 0; }
bool started_;
};
HttpServer::~HttpServer() {}
-
class NullHttpServer : public HttpServer {
public:
- NullHttpServer() {
- started_ = true;
- }
+ NullHttpServer() { started_ = true; }
};
-
class PythonHttpServer : public HttpServer {
public:
PythonHttpServer() : port_(0) {
@@ -175,9 +168,7 @@
http_server_->Kill(SIGTERM, 10);
}
- in_port_t GetPort() const override {
- return port_;
- }
+ in_port_t GetPort() const override { return port_; }
private:
static const char* kServerListeningMsgPrefix;
@@ -202,9 +193,7 @@
proxy_resolver_.set_num_proxies(num_proxies);
return NewLargeFetcher(&proxy_resolver_);
}
- HttpFetcher* NewLargeFetcher() {
- return NewLargeFetcher(1);
- }
+ HttpFetcher* NewLargeFetcher() { return NewLargeFetcher(1); }
virtual HttpFetcher* NewSmallFetcher(ProxyResolver* proxy_resolver) = 0;
HttpFetcher* NewSmallFetcher() {
@@ -225,9 +214,7 @@
virtual HttpServer* CreateServer() = 0;
- FakeHardware* fake_hardware() {
- return &fake_hardware_;
- }
+ FakeHardware* fake_hardware() { return &fake_hardware_; }
protected:
DirectProxyResolver proxy_resolver_;
@@ -255,9 +242,7 @@
bool IsHttpSupported() const override { return true; }
bool IsFileFetcher() const override { return false; }
- HttpServer* CreateServer() override {
- return new NullHttpServer;
- }
+ HttpServer* CreateServer() override { return new NullHttpServer; }
};
class LibcurlHttpFetcherTest : public AnyHttpFetcherTest {
@@ -281,9 +266,8 @@
}
string BigUrl(in_port_t port) const override {
- return LocalServerUrlForPath(port,
- base::StringPrintf("/download/%d",
- kBigLength));
+ return LocalServerUrlForPath(
+ port, base::StringPrintf("/download/%d", kBigLength));
}
string SmallUrl(in_port_t port) const override {
return LocalServerUrlForPath(port, "/foo");
@@ -301,9 +285,7 @@
// Nothing to do.
}
- HttpServer* CreateServer() override {
- return new PythonHttpServer;
- }
+ HttpServer* CreateServer() override { return new PythonHttpServer; }
};
class MultiRangeHttpFetcherTest : public LibcurlHttpFetcherTest {
@@ -422,9 +404,7 @@
T test_;
protected:
- HttpFetcherTest() {
- loop_.SetAsCurrent();
- }
+ HttpFetcherTest() { loop_.SetAsCurrent(); }
void TearDown() override {
EXPECT_EQ(0, brillo::MessageLoopRunMaxIterations(&loop_, 1));
@@ -432,7 +412,7 @@
private:
static void TypeConstraint(T* a) {
- AnyHttpFetcherTest *b = a;
+ AnyHttpFetcherTest* b = a;
if (b == 0) // Silence compiler warning of unused variable.
*b = a;
}
@@ -447,7 +427,6 @@
HttpFetcherTestTypes;
TYPED_TEST_CASE(HttpFetcherTest, HttpFetcherTestTypes);
-
namespace {
class HttpFetcherTestDelegate : public HttpFetcherDelegate {
public:
@@ -490,7 +469,6 @@
string data;
};
-
void StartTransfer(HttpFetcher* http_fetcher, const string& url) {
http_fetcher->BeginTransfer(url);
}
@@ -504,10 +482,10 @@
unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
- this->loop_.PostTask(FROM_HERE, base::Bind(
- StartTransfer,
- fetcher.get(),
- this->test_.SmallUrl(server->GetPort())));
+ this->loop_.PostTask(FROM_HERE,
+ base::Bind(StartTransfer,
+ fetcher.get(),
+ this->test_.SmallUrl(server->GetPort())));
this->loop_.Run();
EXPECT_EQ(0, delegate.times_transfer_terminated_called_);
}
@@ -520,10 +498,10 @@
unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
- this->loop_.PostTask(FROM_HERE, base::Bind(
- StartTransfer,
- fetcher.get(),
- this->test_.BigUrl(server->GetPort())));
+ this->loop_.PostTask(
+ FROM_HERE,
+ base::Bind(
+ StartTransfer, fetcher.get(), this->test_.BigUrl(server->GetPort())));
this->loop_.Run();
EXPECT_EQ(0, delegate.times_transfer_terminated_called_);
}
@@ -544,10 +522,10 @@
unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
- this->loop_.PostTask(FROM_HERE, base::Bind(
- StartTransfer,
- fetcher.get(),
- this->test_.ErrorUrl(server->GetPort())));
+ this->loop_.PostTask(FROM_HERE,
+ base::Bind(StartTransfer,
+ fetcher.get(),
+ this->test_.ErrorUrl(server->GetPort())));
this->loop_.Run();
// Make sure that no bytes were received.
@@ -613,9 +591,7 @@
void TransferComplete(HttpFetcher* fetcher, bool successful) override {
MessageLoop::current()->BreakLoop();
}
- void TransferTerminated(HttpFetcher* fetcher) override {
- ADD_FAILURE();
- }
+ void TransferTerminated(HttpFetcher* fetcher) override { ADD_FAILURE(); }
void Unpause() {
CHECK(paused_);
paused_ = false;
@@ -708,9 +684,7 @@
once_ = false;
fetcher_->TerminateTransfer();
}
- void EndLoop() {
- MessageLoop::current()->BreakLoop();
- }
+ void EndLoop() { MessageLoop::current()->BreakLoop(); }
bool once_;
bool callback_once_;
unique_ptr<HttpFetcher> fetcher_;
@@ -721,8 +695,7 @@
if (delegate->once_) {
delegate->TerminateTransfer();
*my_id = MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(AbortingTimeoutCallback, delegate, my_id));
+ FROM_HERE, base::Bind(AbortingTimeoutCallback, delegate, my_id));
} else {
delegate->EndLoop();
*my_id = MessageLoop::kTaskIdNull;
@@ -744,8 +717,7 @@
MessageLoop::TaskId task_id = MessageLoop::kTaskIdNull;
task_id = this->loop_.PostTask(
- FROM_HERE,
- base::Bind(AbortingTimeoutCallback, &delegate, &task_id));
+ FROM_HERE, base::Bind(AbortingTimeoutCallback, &delegate, &task_id));
delegate.fetcher_->BeginTransfer(this->test_.BigUrl(server->GetPort()));
this->loop_.Run();
@@ -794,9 +766,7 @@
EXPECT_EQ(kHttpResponsePartialContent, fetcher->http_response_code());
MessageLoop::current()->BreakLoop();
}
- void TransferTerminated(HttpFetcher* fetcher) override {
- ADD_FAILURE();
- }
+ void TransferTerminated(HttpFetcher* fetcher) override { ADD_FAILURE(); }
string data;
};
} // namespace
@@ -812,15 +782,16 @@
unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
- this->loop_.PostTask(FROM_HERE, base::Bind(
- &StartTransfer,
- fetcher.get(),
- LocalServerUrlForPath(server->GetPort(),
- base::StringPrintf("/flaky/%d/%d/%d/%d",
- kBigLength,
- kFlakyTruncateLength,
- kFlakySleepEvery,
- kFlakySleepSecs))));
+ this->loop_.PostTask(FROM_HERE,
+ base::Bind(&StartTransfer,
+ fetcher.get(),
+ LocalServerUrlForPath(
+ server->GetPort(),
+ base::StringPrintf("/flaky/%d/%d/%d/%d",
+ kBigLength,
+ kFlakyTruncateLength,
+ kFlakySleepEvery,
+ kFlakySleepSecs))));
this->loop_.Run();
// verify the data we get back
@@ -875,7 +846,6 @@
};
} // namespace
-
TYPED_TEST(HttpFetcherTest, FailureTest) {
// This test ensures that a fetcher responds correctly when a server isn't
// available at all.
@@ -916,10 +886,10 @@
// expired.
fetcher->set_low_speed_limit(kDownloadLowSpeedLimitBps, 1);
- this->loop_.PostTask(FROM_HERE, base::Bind(
- StartTransfer,
- fetcher.get(),
- LocalServerUrlForPath(port, "/hang")));
+ this->loop_.PostTask(
+ FROM_HERE,
+ base::Bind(
+ StartTransfer, fetcher.get(), LocalServerUrlForPath(port, "/hang")));
this->loop_.Run();
EXPECT_EQ(1, delegate.times_transfer_complete_called_);
EXPECT_EQ(0, delegate.times_transfer_terminated_called_);
@@ -929,8 +899,8 @@
bool timeout = false;
auto callback = base::Bind([](bool* timeout) { *timeout = true; },
base::Unretained(&timeout));
- this->loop_.PostDelayedTask(FROM_HERE, callback,
- base::TimeDelta::FromSeconds(2));
+ this->loop_.PostDelayedTask(
+ FROM_HERE, callback, base::TimeDelta::FromSeconds(2));
EXPECT_TRUE(this->loop_.RunOnce(true));
EXPECT_TRUE(timeout);
}
@@ -1016,10 +986,10 @@
}
namespace {
-const HttpResponseCode kRedirectCodes[] = {
- kHttpResponseMovedPermanently, kHttpResponseFound, kHttpResponseSeeOther,
- kHttpResponseTempRedirect
-};
+const HttpResponseCode kRedirectCodes[] = {kHttpResponseMovedPermanently,
+ kHttpResponseFound,
+ kHttpResponseSeeOther,
+ kHttpResponseTempRedirect};
class RedirectHttpFetcherTestDelegate : public HttpFetcherDelegate {
public:
@@ -1041,9 +1011,7 @@
}
MessageLoop::current()->BreakLoop();
}
- void TransferTerminated(HttpFetcher* fetcher) override {
- ADD_FAILURE();
- }
+ void TransferTerminated(HttpFetcher* fetcher) override { ADD_FAILURE(); }
bool expected_successful_;
string data;
};
@@ -1057,10 +1025,11 @@
unique_ptr<HttpFetcher> fetcher(http_fetcher);
fetcher->set_delegate(&delegate);
- MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
- StartTransfer,
- fetcher.get(),
- LocalServerUrlForPath(server->GetPort(), url)));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(StartTransfer,
+ fetcher.get(),
+ LocalServerUrlForPath(server->GetPort(), url)));
MessageLoop::current()->Run();
if (expected_successful) {
// verify the data we get back
@@ -1081,9 +1050,8 @@
ASSERT_TRUE(server->started_);
for (size_t c = 0; c < arraysize(kRedirectCodes); ++c) {
- const string url = base::StringPrintf("/redirect/%d/download/%d",
- kRedirectCodes[c],
- kMediumLength);
+ const string url = base::StringPrintf(
+ "/redirect/%d/download/%d", kRedirectCodes[c], kMediumLength);
RedirectTest(server.get(), true, url, this->test_.NewLargeFetcher());
}
}
@@ -1144,9 +1112,7 @@
MessageLoop::current()->BreakLoop();
}
- void TransferTerminated(HttpFetcher* fetcher) override {
- ADD_FAILURE();
- }
+ void TransferTerminated(HttpFetcher* fetcher) override { ADD_FAILURE(); }
unique_ptr<HttpFetcher> fetcher_;
int expected_response_code_;
@@ -1168,7 +1134,9 @@
ASSERT_TRUE(multi_fetcher);
multi_fetcher->ClearRanges();
for (vector<pair<off_t, off_t>>::const_iterator it = ranges.begin(),
- e = ranges.end(); it != e; ++it) {
+ e = ranges.end();
+ it != e;
+ ++it) {
string tmp_str = base::StringPrintf("%jd+", it->first);
if (it->second > 0) {
base::StringAppendF(&tmp_str, "%jd", it->second);
@@ -1183,8 +1151,7 @@
multi_fetcher->set_delegate(&delegate);
MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(StartTransfer, multi_fetcher, url));
+ FROM_HERE, base::Bind(StartTransfer, multi_fetcher, url));
MessageLoop::current()->Run();
EXPECT_EQ(expected_size, delegate.data.size());
@@ -1309,9 +1276,9 @@
ranges.push_back(make_pair(99, 0));
MultiTest(this->test_.NewLargeFetcher(3),
this->test_.fake_hardware(),
- LocalServerUrlForPath(server->GetPort(),
- base::StringPrintf("/error-if-offset/%d/2",
- kBigLength)),
+ LocalServerUrlForPath(
+ server->GetPort(),
+ base::StringPrintf("/error-if-offset/%d/2", kBigLength)),
ranges,
"abcdefghijabcdefghijabcdejabcdefghijabcdef",
kBigLength - (99 - 25),
@@ -1332,9 +1299,9 @@
ranges.push_back(make_pair(99, 0));
MultiTest(this->test_.NewLargeFetcher(2),
this->test_.fake_hardware(),
- LocalServerUrlForPath(server->GetPort(),
- base::StringPrintf("/error-if-offset/%d/3",
- kBigLength)),
+ LocalServerUrlForPath(
+ server->GetPort(),
+ base::StringPrintf("/error-if-offset/%d/3", kBigLength)),
ranges,
"abcdefghijabcdefghijabcde", // only received the first chunk
25,
@@ -1427,9 +1394,7 @@
EXPECT_FALSE(successful);
MessageLoop::current()->BreakLoop();
}
- void TransferTerminated(HttpFetcher* fetcher) override {
- ADD_FAILURE();
- }
+ void TransferTerminated(HttpFetcher* fetcher) override { ADD_FAILURE(); }
};
void BlockedTransferTestHelper(AnyHttpFetcherTest* fetcher_test,
@@ -1447,11 +1412,13 @@
fetcher_test->fake_hardware()->SetIsOfficialBuild(is_official_build);
fetcher->set_delegate(&delegate);
- MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
- StartTransfer,
- fetcher.get(),
- LocalServerUrlForPath(server->GetPort(),
- fetcher_test->SmallUrl(server->GetPort()))));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ StartTransfer,
+ fetcher.get(),
+ LocalServerUrlForPath(server->GetPort(),
+ fetcher_test->SmallUrl(server->GetPort()))));
MessageLoop::current()->Run();
}
} // namespace
diff --git a/common/mock_hardware.h b/common/mock_hardware.h
index f972df2..84c0c5b 100644
--- a/common/mock_hardware.h
+++ b/common/mock_hardware.h
@@ -31,29 +31,25 @@
MockHardware() {
// Delegate all calls to the fake instance
ON_CALL(*this, IsOfficialBuild())
- .WillByDefault(testing::Invoke(&fake_,
- &FakeHardware::IsOfficialBuild));
+ .WillByDefault(testing::Invoke(&fake_, &FakeHardware::IsOfficialBuild));
ON_CALL(*this, IsNormalBootMode())
- .WillByDefault(testing::Invoke(&fake_,
- &FakeHardware::IsNormalBootMode));
+ .WillByDefault(
+ testing::Invoke(&fake_, &FakeHardware::IsNormalBootMode));
ON_CALL(*this, AreDevFeaturesEnabled())
- .WillByDefault(testing::Invoke(&fake_,
- &FakeHardware::AreDevFeaturesEnabled));
+ .WillByDefault(
+ testing::Invoke(&fake_, &FakeHardware::AreDevFeaturesEnabled));
ON_CALL(*this, IsOOBEEnabled())
- .WillByDefault(testing::Invoke(&fake_,
- &FakeHardware::IsOOBEEnabled));
+ .WillByDefault(testing::Invoke(&fake_, &FakeHardware::IsOOBEEnabled));
ON_CALL(*this, IsOOBEComplete(testing::_))
- .WillByDefault(testing::Invoke(&fake_,
- &FakeHardware::IsOOBEComplete));
+ .WillByDefault(testing::Invoke(&fake_, &FakeHardware::IsOOBEComplete));
ON_CALL(*this, GetHardwareClass())
- .WillByDefault(testing::Invoke(&fake_,
- &FakeHardware::GetHardwareClass));
+ .WillByDefault(
+ testing::Invoke(&fake_, &FakeHardware::GetHardwareClass));
ON_CALL(*this, GetFirmwareVersion())
- .WillByDefault(testing::Invoke(&fake_,
- &FakeHardware::GetFirmwareVersion));
+ .WillByDefault(
+ testing::Invoke(&fake_, &FakeHardware::GetFirmwareVersion));
ON_CALL(*this, GetECVersion())
- .WillByDefault(testing::Invoke(&fake_,
- &FakeHardware::GetECVersion));
+ .WillByDefault(testing::Invoke(&fake_, &FakeHardware::GetECVersion));
ON_CALL(*this, GetMinKernelKeyVersion())
.WillByDefault(
testing::Invoke(&fake_, &FakeHardware::GetMinKernelKeyVersion));
@@ -70,20 +66,20 @@
.WillByDefault(
testing::Invoke(&fake_, &FakeHardware::SetMaxKernelKeyRollforward));
ON_CALL(*this, GetPowerwashCount())
- .WillByDefault(testing::Invoke(&fake_,
- &FakeHardware::GetPowerwashCount));
+ .WillByDefault(
+ testing::Invoke(&fake_, &FakeHardware::GetPowerwashCount));
ON_CALL(*this, GetNonVolatileDirectory(testing::_))
- .WillByDefault(testing::Invoke(&fake_,
- &FakeHardware::GetNonVolatileDirectory));
+ .WillByDefault(
+ testing::Invoke(&fake_, &FakeHardware::GetNonVolatileDirectory));
ON_CALL(*this, GetPowerwashSafeDirectory(testing::_))
- .WillByDefault(testing::Invoke(&fake_,
- &FakeHardware::GetPowerwashSafeDirectory));
+ .WillByDefault(
+ testing::Invoke(&fake_, &FakeHardware::GetPowerwashSafeDirectory));
ON_CALL(*this, GetFirstActiveOmahaPingSent())
- .WillByDefault(testing::Invoke(&fake_,
- &FakeHardware::GetFirstActiveOmahaPingSent()));
+ .WillByDefault(testing::Invoke(
+ &fake_, &FakeHardware::GetFirstActiveOmahaPingSent()));
ON_CALL(*this, SetFirstActiveOmahaPingSent())
- .WillByDefault(testing::Invoke(&fake_,
- &FakeHardware::SetFirstActiveOmahaPingSent()));
+ .WillByDefault(testing::Invoke(
+ &fake_, &FakeHardware::SetFirstActiveOmahaPingSent()));
}
~MockHardware() override = default;
@@ -109,9 +105,7 @@
MOCK_CONST_METHOD0(GetFirstActiveOmahaPingSent, bool());
// Returns a reference to the underlying FakeHardware.
- FakeHardware& fake() {
- return fake_;
- }
+ FakeHardware& fake() { return fake_; }
private:
// The underlying FakeHardware.
@@ -120,7 +114,6 @@
DISALLOW_COPY_AND_ASSIGN(MockHardware);
};
-
} // namespace chromeos_update_engine
#endif // UPDATE_ENGINE_COMMON_MOCK_HARDWARE_H_
diff --git a/common/mock_http_fetcher.cc b/common/mock_http_fetcher.cc
index 9507c9d..10e3b9e 100644
--- a/common/mock_http_fetcher.cc
+++ b/common/mock_http_fetcher.cc
@@ -32,8 +32,8 @@
namespace chromeos_update_engine {
MockHttpFetcher::~MockHttpFetcher() {
- CHECK(timeout_id_ == MessageLoop::kTaskIdNull) <<
- "Call TerminateTransfer() before dtor.";
+ CHECK(timeout_id_ == MessageLoop::kTaskIdNull)
+ << "Call TerminateTransfer() before dtor.";
}
void MockHttpFetcher::BeginTransfer(const std::string& url) {
diff --git a/common/mock_http_fetcher.h b/common/mock_http_fetcher.h
index 00f4e2b..492e6ce 100644
--- a/common/mock_http_fetcher.h
+++ b/common/mock_http_fetcher.h
@@ -56,8 +56,8 @@
// Constructor overload for string data.
MockHttpFetcher(const char* data, size_t size, ProxyResolver* proxy_resolver)
- : MockHttpFetcher(reinterpret_cast<const uint8_t*>(data), size,
- proxy_resolver) {}
+ : MockHttpFetcher(
+ reinterpret_cast<const uint8_t*>(data), size, proxy_resolver) {}
// Cleans up all internal state. Does not notify delegate
~MockHttpFetcher() override;
@@ -77,9 +77,7 @@
void set_max_retry_count(int max_retry_count) override {}
// Dummy: no bytes were downloaded.
- size_t GetBytesDownloaded() override {
- return sent_size_;
- }
+ size_t GetBytesDownloaded() override { return sent_size_; }
// Begins the transfer if it hasn't already begun.
void BeginTransfer(const std::string& url) override;
@@ -107,9 +105,7 @@
// If set to true, this will EXPECT fail on BeginTransfer
void set_never_use(bool never_use) { never_use_ = never_use; }
- const brillo::Blob& post_data() const {
- return post_data_;
- }
+ const brillo::Blob& post_data() const { return post_data_; }
private:
// Sends data to the delegate and sets up a timeout callback if needed. There
diff --git a/common/mock_prefs.h b/common/mock_prefs.h
index 0e639a2..2582e19 100644
--- a/common/mock_prefs.h
+++ b/common/mock_prefs.h
@@ -30,8 +30,8 @@
public:
MOCK_CONST_METHOD2(GetString,
bool(const std::string& key, std::string* value));
- MOCK_METHOD2(SetString, bool(const std::string& key,
- const std::string& value));
+ MOCK_METHOD2(SetString,
+ bool(const std::string& key, const std::string& value));
MOCK_CONST_METHOD2(GetInt64, bool(const std::string& key, int64_t* value));
MOCK_METHOD2(SetInt64, bool(const std::string& key, const int64_t value));
diff --git a/common/multi_range_http_fetcher.cc b/common/multi_range_http_fetcher.cc
index 230106d..6ce3dae 100644
--- a/common/multi_range_http_fetcher.cc
+++ b/common/multi_range_http_fetcher.cc
@@ -95,8 +95,8 @@
size_t next_size = length;
Range range = ranges_[current_index_];
if (range.HasLength()) {
- next_size = std::min(next_size,
- range.length() - bytes_received_this_range_);
+ next_size =
+ std::min(next_size, range.length() - bytes_received_this_range_);
}
LOG_IF(WARNING, next_size <= 0) << "Asked to write length <= 0";
// bytes_received_this_range_ needs to be updated regardless of the delegate_
diff --git a/common/multi_range_http_fetcher.h b/common/multi_range_http_fetcher.h
index 763c287..f57ea7f 100644
--- a/common/multi_range_http_fetcher.h
+++ b/common/multi_range_http_fetcher.h
@@ -62,9 +62,7 @@
ranges_.push_back(Range(offset, size));
}
- void AddRange(off_t offset) {
- ranges_.push_back(Range(offset));
- }
+ void AddRange(off_t offset) { ranges_.push_back(Range(offset)); }
// HttpFetcher overrides.
void SetOffset(off_t offset) override;
diff --git a/common/platform_constants_android.cc b/common/platform_constants_android.cc
index 371fe26..9d8d30e 100644
--- a/common/platform_constants_android.cc
+++ b/common/platform_constants_android.cc
@@ -32,7 +32,7 @@
const char kOmahaResponseDeadlineFile[] = "";
const char kNonVolatileDirectory[] = "/data/misc/update_engine";
const char kPostinstallMountOptions[] =
- "context=u:object_r:postinstall_file:s0";
+ "context=u:object_r:postinstall_file:s0";
} // namespace constants
} // namespace chromeos_update_engine
diff --git a/common/platform_constants_chromeos.cc b/common/platform_constants_chromeos.cc
index 3653432..f1ac490 100644
--- a/common/platform_constants_chromeos.cc
+++ b/common/platform_constants_chromeos.cc
@@ -28,8 +28,7 @@
const char kUpdatePayloadPublicKeyPath[] =
"/usr/share/update_engine/update-payload-key.pub.pem";
const char kCACertificatesPath[] = "/usr/share/chromeos-ca-certificates";
-const char kOmahaResponseDeadlineFile[] =
- "/tmp/update-check-response-deadline";
+const char kOmahaResponseDeadlineFile[] = "/tmp/update-check-response-deadline";
// This directory is wiped during powerwash.
const char kNonVolatileDirectory[] = "/var/lib/update_engine";
const char kPostinstallMountOptions[] = "";
diff --git a/common/prefs_unittest.cc b/common/prefs_unittest.cc
index aa2eb04..cb6fc70 100644
--- a/common/prefs_unittest.cc
+++ b/common/prefs_unittest.cc
@@ -30,13 +30,13 @@
#include <gtest/gtest.h>
using std::string;
-using testing::Eq;
using testing::_;
+using testing::Eq;
namespace {
// Test key used along the tests.
const char kKey[] = "test-key";
-}
+} // namespace
namespace chromeos_update_engine {
@@ -49,7 +49,8 @@
}
bool SetValue(const string& key, const string& value) {
- return base::WriteFile(prefs_dir_.Append(key), value.data(),
+ return base::WriteFile(prefs_dir_.Append(key),
+ value.data(),
value.length()) == static_cast<int>(value.length());
}
@@ -143,16 +144,18 @@
}
TEST_F(PrefsTest, GetInt64Max) {
- ASSERT_TRUE(SetValue(kKey, base::StringPrintf(
- "%" PRIi64, std::numeric_limits<int64_t>::max())));
+ ASSERT_TRUE(SetValue(
+ kKey,
+ base::StringPrintf("%" PRIi64, std::numeric_limits<int64_t>::max())));
int64_t value;
EXPECT_TRUE(prefs_.GetInt64(kKey, &value));
EXPECT_EQ(std::numeric_limits<int64_t>::max(), value);
}
TEST_F(PrefsTest, GetInt64Min) {
- ASSERT_TRUE(SetValue(kKey, base::StringPrintf(
- "%" PRIi64, std::numeric_limits<int64_t>::min())));
+ ASSERT_TRUE(SetValue(
+ kKey,
+ base::StringPrintf("%" PRIi64, std::numeric_limits<int64_t>::min())));
int64_t value;
EXPECT_TRUE(prefs_.GetInt64(kKey, &value));
EXPECT_EQ(std::numeric_limits<int64_t>::min(), value);
diff --git a/common/subprocess.cc b/common/subprocess.cc
index 1715cb0..0131f10 100644
--- a/common/subprocess.cc
+++ b/common/subprocess.cc
@@ -101,7 +101,7 @@
} // namespace
void Subprocess::Init(
- brillo::AsynchronousSignalHandlerInterface* async_signal_handler) {
+ brillo::AsynchronousSignalHandlerInterface* async_signal_handler) {
if (subprocess_singleton_ == this)
return;
CHECK(subprocess_singleton_ == nullptr);
@@ -186,9 +186,10 @@
}
pid_t pid = record->proc.pid();
- CHECK(process_reaper_.WatchForChild(FROM_HERE, pid, base::Bind(
- &Subprocess::ChildExitedCallback,
- base::Unretained(this))));
+ CHECK(process_reaper_.WatchForChild(
+ FROM_HERE,
+ pid,
+ base::Bind(&Subprocess::ChildExitedCallback, base::Unretained(this))));
record->stdout_fd = record->proc.GetPipe(STDOUT_FILENO);
// Capture the subprocess output. Make our end of the pipe non-blocking.
@@ -237,10 +238,7 @@
// The default for SynchronousExec is to use kSearchPath since the code relies
// on that.
return SynchronousExecFlags(
- cmd,
- kRedirectStderrToStdout | kSearchPath,
- return_code,
- stdout);
+ cmd, kRedirectStderrToStdout | kSearchPath, return_code, stdout);
}
bool Subprocess::SynchronousExecFlags(const vector<string>& cmd,
@@ -297,7 +295,6 @@
}
}
-
Subprocess* Subprocess::subprocess_singleton_ = nullptr;
} // namespace chromeos_update_engine
diff --git a/common/subprocess.h b/common/subprocess.h
index 209158b..bc19d16 100644
--- a/common/subprocess.h
+++ b/common/subprocess.h
@@ -97,9 +97,7 @@
std::string* stdout);
// Gets the one instance.
- static Subprocess& Get() {
- return *subprocess_singleton_;
- }
+ static Subprocess& Get() { return *subprocess_singleton_; }
// Tries to log all in flight processes's output. It is used right before
// exiting the update_engine, probably when the subprocess caused a system
@@ -111,7 +109,7 @@
struct SubprocessRecord {
explicit SubprocessRecord(const ExecCallback& callback)
- : callback(callback) {}
+ : callback(callback) {}
// The callback supplied by the caller.
ExecCallback callback;
diff --git a/common/subprocess_unittest.cc b/common/subprocess_unittest.cc
index c8996db..104ef41 100644
--- a/common/subprocess_unittest.cc
+++ b/common/subprocess_unittest.cc
@@ -77,8 +77,10 @@
namespace {
-void ExpectedResults(int expected_return_code, const string& expected_output,
- int return_code, const string& output) {
+void ExpectedResults(int expected_return_code,
+ const string& expected_output,
+ int return_code,
+ const string& output) {
EXPECT_EQ(expected_return_code, return_code);
EXPECT_EQ(expected_output, output);
MessageLoop::current()->BreakLoop();
@@ -88,8 +90,8 @@
EXPECT_EQ(0, return_code);
const std::set<string> allowed_envs = {"LD_LIBRARY_PATH", "PATH"};
for (const string& key_value : brillo::string_utils::Split(output, "\n")) {
- auto key_value_pair = brillo::string_utils::SplitAtFirst(
- key_value, "=", true);
+ auto key_value_pair =
+ brillo::string_utils::SplitAtFirst(key_value, "=", true);
EXPECT_NE(allowed_envs.end(), allowed_envs.find(key_value_pair.first));
}
MessageLoop::current()->BreakLoop();
@@ -197,9 +199,7 @@
TEST_F(SubprocessTest, SynchronousEchoTest) {
vector<string> cmd = {
- kBinPath "/sh",
- "-c",
- "echo -n stdout-here; echo -n stderr-there >&2"};
+ kBinPath "/sh", "-c", "echo -n stdout-here; echo -n stderr-there >&2"};
int rc = -1;
string stdout;
ASSERT_TRUE(Subprocess::SynchronousExec(cmd, &rc, &stdout));
@@ -259,20 +259,24 @@
fifo_fd,
MessageLoop::WatchMode::kWatchRead,
false,
- base::Bind([](int fifo_fd, uint32_t tag) {
- char c;
- EXPECT_EQ(1, HANDLE_EINTR(read(fifo_fd, &c, 1)));
- EXPECT_EQ('X', c);
- LOG(INFO) << "Killing tag " << tag;
- Subprocess::Get().KillExec(tag);
- }, fifo_fd, tag));
+ base::Bind(
+ [](int fifo_fd, uint32_t tag) {
+ char c;
+ EXPECT_EQ(1,
+ HANDLE_EINTR(read(fifo_fd, &c, 1)));
+ EXPECT_EQ('X', c);
+ LOG(INFO) << "Killing tag " << tag;
+ Subprocess::Get().KillExec(tag);
+ },
+ fifo_fd,
+ tag));
// This test would leak a callback that runs when the child process exits
// unless we wait for it to run.
brillo::MessageLoopRunUntil(
- &loop_,
- TimeDelta::FromSeconds(120),
- base::Bind([] { return Subprocess::Get().subprocess_records_.empty(); }));
+ &loop_, TimeDelta::FromSeconds(120), base::Bind([] {
+ return Subprocess::Get().subprocess_records_.empty();
+ }));
EXPECT_TRUE(Subprocess::Get().subprocess_records_.empty());
// Check that there isn't anything else to read from the pipe.
char c;
diff --git a/common/test_utils.cc b/common/test_utils.cc
index 2e44ff8..50b0962 100644
--- a/common/test_utils.cc
+++ b/common/test_utils.cc
@@ -68,44 +68,31 @@
namespace test_utils {
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,
- 0xa5, 0x08, 0x70, 0x89, 0x79, 0x35, 0xe2, 0x3d,
- 0x56, 0xa4, 0x75, 0x73, 0xa3, 0x6d, 0xd1, 0xd5,
- 0x26, 0xbb, 0x9c, 0x60, 0xbd, 0x2f, 0x5a, 0xfa,
- 0xb7, 0xd4, 0x3a, 0x50, 0xa7, 0x6b, 0x3e, 0xfd,
- 0x61, 0x2b, 0x3a, 0x31, 0x30, 0x13, 0x33, 0x53,
- 0xdb, 0xd0, 0x32, 0x71, 0x5c, 0x39, 0xed, 0xda,
- 0xb4, 0x84, 0xca, 0xbc, 0xbd, 0x78, 0x1c, 0x0c,
- 0xd8, 0x0b, 0x41, 0xe8, 0xe1, 0xe0, 0x41, 0xad,
- 0x03, 0x12, 0xd3, 0x3d, 0xb8, 0x75, 0x9b, 0xe6,
- 0xd9, 0x01, 0xd0, 0x87, 0xf4, 0x36, 0xfa, 0xa7,
- 0x0a, 0xfa, 0xc5, 0x87, 0x65, 0xab, 0x9a, 0x7b,
- 0xeb, 0x58, 0x23, 0xf0, 0xa8, 0x0a, 0xf2, 0x33,
- 0x3a, 0xe2, 0xe3, 0x35, 0x74, 0x95, 0xdd, 0x3c,
- 0x59, 0x5a, 0xd9, 0x52, 0x3a, 0x3c, 0xac, 0xe5,
- 0x15, 0x87, 0x6d, 0x82, 0xbc, 0xf8, 0x7d, 0xbe,
- 0xca, 0xd3, 0x2c, 0xd6, 0xec, 0x38, 0xeb, 0xe4,
- 0x53, 0xb0, 0x4c, 0x3f, 0x39, 0x29, 0xf7, 0xa4,
- 0x73, 0xa8, 0xcb, 0x32, 0x50, 0x05, 0x8c, 0x1c,
- 0x1c, 0xca, 0xc9, 0x76, 0x0b, 0x8f, 0x6b, 0x57,
- 0x1f, 0x24, 0x2b, 0xba, 0x82, 0xba, 0xed, 0x58,
- 0xd8, 0xbf, 0xec, 0x06, 0x64, 0x52, 0x6a, 0x3f,
- 0xe4, 0xad, 0xce, 0x84, 0xb4, 0x27, 0x55, 0x14,
- 0xe3, 0x75, 0x59, 0x73, 0x71, 0x51, 0xea, 0xe8,
- 0xcc, 0xda, 0x4f, 0x09, 0xaf, 0xa4, 0xbc, 0x0e,
- 0xa6, 0x1f, 0xe2, 0x3a, 0xf8, 0x96, 0x7d, 0x30,
- 0x23, 0xc5, 0x12, 0xb5, 0xd8, 0x73, 0x6b, 0x71,
- 0xab, 0xf1, 0xd7, 0x43, 0x58, 0xa7, 0xc9, 0xf0,
- 0xe4, 0x85, 0x1c, 0xd6, 0x92, 0x50, 0x2c, 0x98,
- 0x36, 0xfe, 0x87, 0xaf, 0x43, 0x8f, 0x8f, 0xf5,
- 0x88, 0x48, 0x18, 0x42, 0xcf, 0x42, 0xc1, 0xa8,
- 0xe8, 0x05, 0x08, 0xa1, 0x45, 0x70, 0x5b, 0x8c,
- 0x39, 0x28, 0xab, 0xe9, 0x6b, 0x51, 0xd2, 0xcb,
- 0x30, 0x04, 0xea, 0x7d, 0x2f, 0x6e, 0x6c, 0x3b,
- 0x5f, 0x82, 0xd9, 0x5b, 0x89, 0x37, 0x65, 0x65,
- 0xbe, 0x9f, 0xa3, 0x5d,
+ 0xf2, 0xb7, 0x55, 0x92, 0xea, 0xa6, 0xc9, 0x57, 0xe0, 0xf8, 0xeb, 0x34,
+ 0x93, 0xd9, 0xc4, 0x8f, 0xcb, 0x20, 0xfa, 0x37, 0x4b, 0x40, 0xcf, 0xdc,
+ 0xa5, 0x08, 0x70, 0x89, 0x79, 0x35, 0xe2, 0x3d, 0x56, 0xa4, 0x75, 0x73,
+ 0xa3, 0x6d, 0xd1, 0xd5, 0x26, 0xbb, 0x9c, 0x60, 0xbd, 0x2f, 0x5a, 0xfa,
+ 0xb7, 0xd4, 0x3a, 0x50, 0xa7, 0x6b, 0x3e, 0xfd, 0x61, 0x2b, 0x3a, 0x31,
+ 0x30, 0x13, 0x33, 0x53, 0xdb, 0xd0, 0x32, 0x71, 0x5c, 0x39, 0xed, 0xda,
+ 0xb4, 0x84, 0xca, 0xbc, 0xbd, 0x78, 0x1c, 0x0c, 0xd8, 0x0b, 0x41, 0xe8,
+ 0xe1, 0xe0, 0x41, 0xad, 0x03, 0x12, 0xd3, 0x3d, 0xb8, 0x75, 0x9b, 0xe6,
+ 0xd9, 0x01, 0xd0, 0x87, 0xf4, 0x36, 0xfa, 0xa7, 0x0a, 0xfa, 0xc5, 0x87,
+ 0x65, 0xab, 0x9a, 0x7b, 0xeb, 0x58, 0x23, 0xf0, 0xa8, 0x0a, 0xf2, 0x33,
+ 0x3a, 0xe2, 0xe3, 0x35, 0x74, 0x95, 0xdd, 0x3c, 0x59, 0x5a, 0xd9, 0x52,
+ 0x3a, 0x3c, 0xac, 0xe5, 0x15, 0x87, 0x6d, 0x82, 0xbc, 0xf8, 0x7d, 0xbe,
+ 0xca, 0xd3, 0x2c, 0xd6, 0xec, 0x38, 0xeb, 0xe4, 0x53, 0xb0, 0x4c, 0x3f,
+ 0x39, 0x29, 0xf7, 0xa4, 0x73, 0xa8, 0xcb, 0x32, 0x50, 0x05, 0x8c, 0x1c,
+ 0x1c, 0xca, 0xc9, 0x76, 0x0b, 0x8f, 0x6b, 0x57, 0x1f, 0x24, 0x2b, 0xba,
+ 0x82, 0xba, 0xed, 0x58, 0xd8, 0xbf, 0xec, 0x06, 0x64, 0x52, 0x6a, 0x3f,
+ 0xe4, 0xad, 0xce, 0x84, 0xb4, 0x27, 0x55, 0x14, 0xe3, 0x75, 0x59, 0x73,
+ 0x71, 0x51, 0xea, 0xe8, 0xcc, 0xda, 0x4f, 0x09, 0xaf, 0xa4, 0xbc, 0x0e,
+ 0xa6, 0x1f, 0xe2, 0x3a, 0xf8, 0x96, 0x7d, 0x30, 0x23, 0xc5, 0x12, 0xb5,
+ 0xd8, 0x73, 0x6b, 0x71, 0xab, 0xf1, 0xd7, 0x43, 0x58, 0xa7, 0xc9, 0xf0,
+ 0xe4, 0x85, 0x1c, 0xd6, 0x92, 0x50, 0x2c, 0x98, 0x36, 0xfe, 0x87, 0xaf,
+ 0x43, 0x8f, 0x8f, 0xf5, 0x88, 0x48, 0x18, 0x42, 0xcf, 0x42, 0xc1, 0xa8,
+ 0xe8, 0x05, 0x08, 0xa1, 0x45, 0x70, 0x5b, 0x8c, 0x39, 0x28, 0xab, 0xe9,
+ 0x6b, 0x51, 0xd2, 0xcb, 0x30, 0x04, 0xea, 0x7d, 0x2f, 0x6e, 0x6c, 0x3b,
+ 0x5f, 0x82, 0xd9, 0x5b, 0x89, 0x37, 0x65, 0x65, 0xbe, 0x9f, 0xa3, 0x5d,
};
string Readlink(const string& path) {
@@ -205,8 +192,7 @@
return true;
}
-bool ExpectVectorsEq(const brillo::Blob& expected,
- const brillo::Blob& actual) {
+bool ExpectVectorsEq(const brillo::Blob& expected, const brillo::Blob& actual) {
EXPECT_EQ(expected.size(), actual.size());
if (expected.size() != actual.size())
return false;
diff --git a/common/test_utils.h b/common/test_utils.h
index 5be48cf..44b7aa1 100644
--- a/common/test_utils.h
+++ b/common/test_utils.h
@@ -87,14 +87,14 @@
class ScopedFilesystemUnmounter {
public:
explicit ScopedFilesystemUnmounter(const std::string& mountpoint)
- : mountpoint_(mountpoint),
- should_unmount_(true) {}
+ : mountpoint_(mountpoint), should_unmount_(true) {}
~ScopedFilesystemUnmounter() {
if (should_unmount_) {
utils::UnmountFilesystem(mountpoint_);
}
}
void set_should_unmount(bool unmount) { should_unmount_ = unmount; }
+
private:
const std::string mountpoint_;
bool should_unmount_;
@@ -183,10 +183,10 @@
class NoneType;
-template<typename T>
+template <typename T>
class ObjectFeederAction;
-template<typename T>
+template <typename T>
class ActionTraits<ObjectFeederAction<T>> {
public:
typedef T OutputObjectType;
@@ -195,7 +195,7 @@
// This is a simple Action class for testing. It feeds an object into
// another action.
-template<typename T>
+template <typename T>
class ObjectFeederAction : public Action<ObjectFeederAction<T>> {
public:
typedef NoneType InputObjectType;
@@ -210,17 +210,16 @@
}
static std::string StaticType() { return "ObjectFeederAction"; }
std::string Type() const { return StaticType(); }
- void set_obj(const T& out_obj) {
- out_obj_ = out_obj;
- }
+ void set_obj(const T& out_obj) { out_obj_ = out_obj; }
+
private:
T out_obj_;
};
-template<typename T>
+template <typename T>
class ObjectCollectorAction;
-template<typename T>
+template <typename T>
class ActionTraits<ObjectCollectorAction<T>> {
public:
typedef NoneType OutputObjectType;
@@ -229,7 +228,7 @@
// This is a simple Action class for testing. It receives an object from
// another action.
-template<typename T>
+template <typename T>
class ObjectCollectorAction : public Action<ObjectCollectorAction<T>> {
public:
typedef T InputObjectType;
@@ -245,6 +244,7 @@
static std::string StaticType() { return "ObjectCollectorAction"; }
std::string Type() const { return StaticType(); }
const T& object() const { return object_; }
+
private:
T object_;
};
diff --git a/common/utils.cc b/common/utils.cc
index c609013..34d97a2 100644
--- a/common/utils.cc
+++ b/common/utils.cc
@@ -86,8 +86,8 @@
// Return true if |disk_name| is an MTD or a UBI device. Note that this test is
// simply based on the name of the device.
bool IsMtdDeviceName(const string& disk_name) {
- return base::StartsWith(disk_name, "/dev/ubi",
- base::CompareCase::SENSITIVE) ||
+ return base::StartsWith(
+ disk_name, "/dev/ubi", base::CompareCase::SENSITIVE) ||
base::StartsWith(disk_name, "/dev/mtd", base::CompareCase::SENSITIVE);
}
@@ -228,13 +228,15 @@
int num_attempts = 0;
while (bytes_written < count) {
num_attempts++;
- ssize_t rc = pwrite(fd, c_buf + bytes_written, count - bytes_written,
+ ssize_t rc = pwrite(fd,
+ c_buf + bytes_written,
+ count - bytes_written,
offset + bytes_written);
// TODO(garnold) for debugging failure in chromium-os:31077; to be removed.
if (rc < 0) {
PLOG(ERROR) << "pwrite error; num_attempts=" << num_attempts
- << " bytes_written=" << bytes_written
- << " count=" << count << " offset=" << offset;
+ << " bytes_written=" << bytes_written << " count=" << count
+ << " offset=" << offset;
}
TEST_AND_RETURN_FALSE_ERRNO(rc >= 0);
bytes_written += rc;
@@ -262,13 +264,13 @@
return WriteAll(fd, buf, count);
}
-bool PReadAll(int fd, void* buf, size_t count, off_t offset,
- ssize_t* out_bytes_read) {
+bool PReadAll(
+ int fd, void* buf, size_t count, off_t offset, ssize_t* out_bytes_read) {
char* c_buf = static_cast<char*>(buf);
ssize_t bytes_read = 0;
while (bytes_read < static_cast<ssize_t>(count)) {
- ssize_t rc = pread(fd, c_buf + bytes_read, count - bytes_read,
- offset + bytes_read);
+ ssize_t rc =
+ pread(fd, c_buf + bytes_read, count - bytes_read, offset + bytes_read);
TEST_AND_RETURN_FALSE_ERRNO(rc >= 0);
if (rc == 0) {
break;
@@ -302,14 +304,14 @@
// Append |nbytes| of content from |buf| to the vector pointed to by either
// |vec_p| or |str_p|.
-static void AppendBytes(const uint8_t* buf, size_t nbytes,
+static void AppendBytes(const uint8_t* buf,
+ size_t nbytes,
brillo::Blob* vec_p) {
CHECK(buf);
CHECK(vec_p);
vec_p->insert(vec_p->end(), buf, buf + nbytes);
}
-static void AppendBytes(const uint8_t* buf, size_t nbytes,
- string* str_p) {
+static void AppendBytes(const uint8_t* buf, size_t nbytes, string* str_p) {
CHECK(buf);
CHECK(str_p);
str_p->append(buf, buf + nbytes);
@@ -387,7 +389,9 @@
return ReadFileChunkAndAppend(path, 0, -1, out_p);
}
-bool ReadFileChunk(const string& path, off_t offset, off_t size,
+bool ReadFileChunk(const string& path,
+ off_t offset,
+ off_t size,
brillo::Blob* out_p) {
return ReadFileChunkAndAppend(path, offset, size, out_p);
}
@@ -436,8 +440,8 @@
const unsigned int bytes_per_line = 16;
for (uint32_t i = 0; i < length; i += bytes_per_line) {
const unsigned int bytes_remaining = length - i;
- const unsigned int bytes_per_this_line = min(bytes_per_line,
- bytes_remaining);
+ const unsigned int bytes_per_this_line =
+ min(bytes_per_line, bytes_remaining);
char header[100];
int r = snprintf(header, sizeof(header), "0x%08x : ", i);
TEST_AND_RETURN(r == 13);
@@ -456,8 +460,8 @@
bool SplitPartitionName(const string& partition_name,
string* out_disk_name,
int* out_partition_num) {
- if (!base::StartsWith(partition_name, "/dev/",
- base::CompareCase::SENSITIVE)) {
+ if (!base::StartsWith(
+ partition_name, "/dev/", base::CompareCase::SENSITIVE)) {
LOG(ERROR) << "Invalid partition device name: " << partition_name;
return false;
}
@@ -489,8 +493,7 @@
// Special case for MMC devices which have the following naming scheme:
// mmcblk0p2
size_t disk_name_len = last_nondigit_pos;
- if (partition_name[last_nondigit_pos] != 'p' ||
- last_nondigit_pos == 0 ||
+ if (partition_name[last_nondigit_pos] != 'p' || last_nondigit_pos == 0 ||
!isdigit(partition_name[last_nondigit_pos - 1])) {
disk_name_len++;
}
@@ -498,8 +501,8 @@
}
if (out_partition_num) {
- string partition_str = partition_name.substr(last_nondigit_pos + 1,
- partition_name_len);
+ string partition_str =
+ partition_name.substr(last_nondigit_pos + 1, partition_name_len);
*out_partition_num = atoi(partition_str.c_str());
}
return true;
@@ -570,21 +573,15 @@
}
int exit_code;
- vector<string> cmd = {
- "ubiattach",
- "-m",
- base::StringPrintf("%d", volume_num),
- "-d",
- base::StringPrintf("%d", volume_num)
- };
+ vector<string> cmd = {"ubiattach",
+ "-m",
+ base::StringPrintf("%d", volume_num),
+ "-d",
+ base::StringPrintf("%d", volume_num)};
TEST_AND_RETURN_FALSE(Subprocess::SynchronousExec(cmd, &exit_code, nullptr));
TEST_AND_RETURN_FALSE(exit_code == 0);
- cmd = {
- "ubiblock",
- "--create",
- volume_path
- };
+ cmd = {"ubiblock", "--create", volume_path};
TEST_AND_RETURN_FALSE(Subprocess::SynchronousExec(cmd, &exit_code, nullptr));
TEST_AND_RETURN_FALSE(exit_code == 0);
@@ -604,7 +601,8 @@
GetTempName(base_filename_template, &filename_template));
DCHECK(filename || fd);
vector<char> buf(filename_template.value().size() + 1);
- memcpy(buf.data(), filename_template.value().data(),
+ memcpy(buf.data(),
+ filename_template.value().data(),
filename_template.value().size());
buf[filename_template.value().size()] = '\0';
@@ -638,8 +636,8 @@
rc = ioctl(fd, BLKROSET, &expected_flag);
if (rc != 0) {
- PLOG(ERROR) << "Marking block device " << device << " as read_only="
- << expected_flag;
+ PLOG(ERROR) << "Marking block device " << device
+ << " as read_only=" << expected_flag;
return false;
}
return true;
@@ -657,13 +655,16 @@
fstypes = {type.c_str()};
}
for (const char* fstype : fstypes) {
- int rc = mount(device.c_str(), mountpoint.c_str(), fstype, mountflags,
+ int rc = mount(device.c_str(),
+ mountpoint.c_str(),
+ fstype,
+ mountflags,
fs_mount_options.c_str());
if (rc == 0)
return true;
- PLOG(WARNING) << "Unable to mount destination device " << device
- << " on " << mountpoint << " as " << fstype;
+ PLOG(WARNING) << "Unable to mount destination device " << device << " on "
+ << mountpoint << " as " << fstype;
}
if (!type.empty()) {
LOG(ERROR) << "Unable to mount " << device << " with any supported type";
@@ -721,7 +722,8 @@
// Tries to parse the header of an ELF file to obtain a human-readable
// description of it on the |output| string.
-static bool GetFileFormatELF(const uint8_t* buffer, size_t size,
+static bool GetFileFormatELF(const uint8_t* buffer,
+ size_t size,
string* output) {
// 0x00: EI_MAG - ELF magic header, 4 bytes.
if (size < SELFMAG || memcmp(buffer, ELFMAG, SELFMAG) != 0)
@@ -855,12 +857,12 @@
Time::Exploded exp_time;
utc_time.UTCExplode(&exp_time);
return base::StringPrintf("%d/%d/%d %d:%02d:%02d GMT",
- exp_time.month,
- exp_time.day_of_month,
- exp_time.year,
- exp_time.hour,
- exp_time.minute,
- exp_time.second);
+ exp_time.month,
+ exp_time.day_of_month,
+ exp_time.year,
+ exp_time.hour,
+ exp_time.minute,
+ exp_time.second);
}
string ToString(bool b) {
@@ -869,12 +871,16 @@
string ToString(DownloadSource source) {
switch (source) {
- case kDownloadSourceHttpsServer: return "HttpsServer";
- case kDownloadSourceHttpServer: return "HttpServer";
- case kDownloadSourceHttpPeer: return "HttpPeer";
- case kNumDownloadSources: return "Unknown";
- // Don't add a default case to let the compiler warn about newly added
- // download sources which should be added here.
+ case kDownloadSourceHttpsServer:
+ return "HttpsServer";
+ case kDownloadSourceHttpServer:
+ return "HttpServer";
+ case kDownloadSourceHttpPeer:
+ return "HttpPeer";
+ case kNumDownloadSources:
+ return "Unknown";
+ // Don't add a default case to let the compiler warn about newly added
+ // download sources which should be added here.
}
return "Unknown";
@@ -882,12 +888,16 @@
string ToString(PayloadType payload_type) {
switch (payload_type) {
- case kPayloadTypeDelta: return "Delta";
- case kPayloadTypeFull: return "Full";
- case kPayloadTypeForcedFull: return "ForcedFull";
- case kNumPayloadTypes: return "Unknown";
- // Don't add a default case to let the compiler warn about newly added
- // payload types which should be added here.
+ case kPayloadTypeDelta:
+ return "Delta";
+ case kPayloadTypeFull:
+ return "Full";
+ case kPayloadTypeForcedFull:
+ return "ForcedFull";
+ case kNumPayloadTypes:
+ return "Unknown";
+ // Don't add a default case to let the compiler warn about newly added
+ // payload types which should be added here.
}
return "Unknown";
@@ -916,8 +926,8 @@
string StringVectorToString(const vector<string> &vec_str) {
string str = "[";
- for (vector<string>::const_iterator i = vec_str.begin();
- i != vec_str.end(); ++i) {
+ for (vector<string>::const_iterator i = vec_str.begin(); i != vec_str.end();
+ ++i) {
if (i != vec_str.begin())
str += ", ";
str += '"';
@@ -947,7 +957,7 @@
time_t unix_time = time.ToTimeT();
// Output of: date +"%s" --date="Jan 1, 2007 0:00 PST".
const time_t kOmahaEpoch = 1167638400;
- const int64_t kNumSecondsPerWeek = 7*24*3600;
+ const int64_t kNumSecondsPerWeek = 7 * 24 * 3600;
const int64_t kNumDaysPerWeek = 7;
time_t omaha_time = unix_time - kOmahaEpoch;
@@ -977,8 +987,10 @@
return false;
}
-bool ReadExtents(const string& path, const vector<Extent>& extents,
- brillo::Blob* out_data, ssize_t out_data_size,
+bool ReadExtents(const string& path,
+ const vector<Extent>& extents,
+ brillo::Blob* out_data,
+ ssize_t out_data_size,
size_t block_size) {
brillo::Blob data(out_data_size);
ssize_t bytes_read = 0;
diff --git a/common/utils.h b/common/utils.h
index 4b83cc4..9160d9f 100644
--- a/common/utils.h
+++ b/common/utils.h
@@ -46,7 +46,7 @@
// Formats |vec_str| as a string of the form ["<elem1>", "<elem2>"].
// Does no escaping, only use this for presentation in error messages.
-std::string StringVectorToString(const std::vector<std::string> &vec_str);
+std::string StringVectorToString(const std::vector<std::string>& vec_str);
// Calculates the p2p file id from payload hash and size
std::string CalculateP2PFileId(const brillo::Blob& payload_hash,
@@ -81,11 +81,14 @@
// Calls pread() repeatedly until count bytes are read, or EOF is reached.
// Returns number of bytes read in *bytes_read. Returns true on success.
-bool PReadAll(int fd, void* buf, size_t count, off_t offset,
- ssize_t* out_bytes_read);
+bool PReadAll(
+ int fd, void* buf, size_t count, off_t offset, ssize_t* out_bytes_read);
-bool PReadAll(const FileDescriptorPtr& fd, void* buf, size_t count,
- off_t offset, ssize_t* out_bytes_read);
+bool PReadAll(const FileDescriptorPtr& fd,
+ void* buf,
+ size_t count,
+ off_t offset,
+ ssize_t* out_bytes_read);
// Opens |path| for reading and appends its entire content to the container
// pointed to by |out_p|. Returns true upon successfully reading all of the
@@ -94,7 +97,9 @@
// |size| is not -1, only up to |size| bytes are read in.
bool ReadFile(const std::string& path, brillo::Blob* out_p);
bool ReadFile(const std::string& path, std::string* out_p);
-bool ReadFileChunk(const std::string& path, off_t offset, off_t size,
+bool ReadFileChunk(const std::string& path,
+ off_t offset,
+ off_t size,
brillo::Blob* out_p);
// Invokes |cmd| in a pipe and appends its stdout to the container pointed to by
@@ -155,8 +160,7 @@
// {"/dev/sda", 1} => "/dev/sda1"
// {"/dev/mmcblk2", 12} => "/dev/mmcblk2p12"
// Returns empty string when invalid parameters are passed in
-std::string MakePartitionName(const std::string& disk_name,
- int partition_num);
+std::string MakePartitionName(const std::string& disk_name, int partition_num);
// Similar to "MakePartitionName" but returns a name that is suitable for
// mounting. On NAND system we can write to "/dev/ubiX_0", which is what
@@ -217,12 +221,12 @@
HexDumpArray(vect.data(), vect.size());
}
-template<typename T>
-bool VectorIndexOf(const std::vector<T>& vect, const T& value,
+template <typename T>
+bool VectorIndexOf(const std::vector<T>& vect,
+ const T& value,
typename std::vector<T>::size_type* out_index) {
- typename std::vector<T>::const_iterator it = std::find(vect.begin(),
- vect.end(),
- value);
+ typename std::vector<T>::const_iterator it =
+ std::find(vect.begin(), vect.end(), value);
if (it == vect.end()) {
return false;
} else {
@@ -278,7 +282,7 @@
// into account so the result may up to one hour off. This is because
// the glibc date and timezone routines depend on the TZ environment
// variable and changing environment variables is not thread-safe.
-bool ConvertToOmahaInstallDate(base::Time time, int *out_num_days);
+bool ConvertToOmahaInstallDate(base::Time time, int* out_num_days);
// Look for the minor version value in the passed |store| and set
// |minor_version| to that value. Return whether the value was found and valid.
@@ -289,8 +293,10 @@
// extents are read from the file at |path|. |out_data_size| is the size of
// |out_data|. Returns false if the number of bytes to read given in
// |extents| does not equal |out_data_size|.
-bool ReadExtents(const std::string& path, const std::vector<Extent>& extents,
- brillo::Blob* out_data, ssize_t out_data_size,
+bool ReadExtents(const std::string& path,
+ const std::vector<Extent>& extents,
+ brillo::Blob* out_data,
+ ssize_t out_data_size,
size_t block_size);
// Read the current boot identifier and store it in |boot_id|. This identifier
@@ -322,7 +328,6 @@
} // namespace utils
-
// Utility class to close a file descriptor
class ScopedFdCloser {
public:
@@ -332,6 +337,7 @@
*fd_ = -1;
}
void set_should_close(bool should_close) { should_close_ = should_close; }
+
private:
int* fd_;
bool should_close_ = true;
@@ -342,8 +348,7 @@
class ScopedPathUnlinker {
public:
explicit ScopedPathUnlinker(const std::string& path)
- : path_(path),
- should_remove_(true) {}
+ : path_(path), should_remove_(true) {}
~ScopedPathUnlinker() {
if (should_remove_ && unlink(path_.c_str()) < 0) {
PLOG(ERROR) << "Unable to unlink path " << path_;
@@ -389,54 +394,54 @@
} // namespace chromeos_update_engine
-#define TEST_AND_RETURN_FALSE_ERRNO(_x) \
- do { \
- bool _success = static_cast<bool>(_x); \
- if (!_success) { \
- std::string _msg = \
- chromeos_update_engine::utils::ErrnoNumberAsString(errno); \
- LOG(ERROR) << #_x " failed: " << _msg; \
- return false; \
- } \
+#define TEST_AND_RETURN_FALSE_ERRNO(_x) \
+ do { \
+ bool _success = static_cast<bool>(_x); \
+ if (!_success) { \
+ std::string _msg = \
+ chromeos_update_engine::utils::ErrnoNumberAsString(errno); \
+ LOG(ERROR) << #_x " failed: " << _msg; \
+ return false; \
+ } \
} while (0)
-#define TEST_AND_RETURN_FALSE(_x) \
- do { \
- bool _success = static_cast<bool>(_x); \
- if (!_success) { \
- LOG(ERROR) << #_x " failed."; \
- return false; \
- } \
+#define TEST_AND_RETURN_FALSE(_x) \
+ do { \
+ bool _success = static_cast<bool>(_x); \
+ if (!_success) { \
+ LOG(ERROR) << #_x " failed."; \
+ return false; \
+ } \
} while (0)
-#define TEST_AND_RETURN_ERRNO(_x) \
- do { \
- bool _success = static_cast<bool>(_x); \
- if (!_success) { \
- std::string _msg = \
- chromeos_update_engine::utils::ErrnoNumberAsString(errno); \
- LOG(ERROR) << #_x " failed: " << _msg; \
- return; \
- } \
+#define TEST_AND_RETURN_ERRNO(_x) \
+ do { \
+ bool _success = static_cast<bool>(_x); \
+ if (!_success) { \
+ std::string _msg = \
+ chromeos_update_engine::utils::ErrnoNumberAsString(errno); \
+ LOG(ERROR) << #_x " failed: " << _msg; \
+ return; \
+ } \
} while (0)
-#define TEST_AND_RETURN(_x) \
- do { \
- bool _success = static_cast<bool>(_x); \
- if (!_success) { \
- LOG(ERROR) << #_x " failed."; \
- return; \
- } \
+#define TEST_AND_RETURN(_x) \
+ do { \
+ bool _success = static_cast<bool>(_x); \
+ if (!_success) { \
+ LOG(ERROR) << #_x " failed."; \
+ return; \
+ } \
} while (0)
-#define TEST_AND_RETURN_FALSE_ERRCODE(_x) \
- do { \
- errcode_t _error = (_x); \
- if (_error) { \
- errno = _error; \
- LOG(ERROR) << #_x " failed: " << _error; \
- return false; \
- } \
+#define TEST_AND_RETURN_FALSE_ERRCODE(_x) \
+ do { \
+ errcode_t _error = (_x); \
+ if (_error) { \
+ errno = _error; \
+ LOG(ERROR) << #_x " failed: " << _error; \
+ return false; \
+ } \
} while (0)
#endif // UPDATE_ENGINE_COMMON_UTILS_H_
diff --git a/common/utils_unittest.cc b/common/utils_unittest.cc
index b30b2d2..7d1c59e 100644
--- a/common/utils_unittest.cc
+++ b/common/utils_unittest.cc
@@ -39,16 +39,16 @@
namespace chromeos_update_engine {
-class UtilsTest : public ::testing::Test { };
+class UtilsTest : public ::testing::Test {};
TEST(UtilsTest, CanParseECVersion) {
// Should be able to parse and valid key value line.
EXPECT_EQ("12345", utils::ParseECVersion("fw_version=12345"));
- EXPECT_EQ("123456", utils::ParseECVersion(
- "b=1231a fw_version=123456 a=fasd2"));
+ EXPECT_EQ("123456",
+ utils::ParseECVersion("b=1231a fw_version=123456 a=fasd2"));
EXPECT_EQ("12345", utils::ParseECVersion("fw_version=12345"));
- EXPECT_EQ("00VFA616", utils::ParseECVersion(
- "vendor=\"sam\" fw_version=\"00VFA616\""));
+ EXPECT_EQ("00VFA616",
+ utils::ParseECVersion("vendor=\"sam\" fw_version=\"00VFA616\""));
// For invalid entries, should return the empty string.
EXPECT_EQ("", utils::ParseECVersion("b=1231a fw_version a=fasd2"));
@@ -172,21 +172,18 @@
utils::MakePartitionNameForMount("/dev/mmcblk0p2"));
EXPECT_EQ("/dev/loop0", utils::MakePartitionNameForMount("/dev/loop0"));
EXPECT_EQ("/dev/loop8", utils::MakePartitionNameForMount("/dev/loop8"));
- EXPECT_EQ("/dev/loop12p2",
- utils::MakePartitionNameForMount("/dev/loop12p2"));
+ EXPECT_EQ("/dev/loop12p2", utils::MakePartitionNameForMount("/dev/loop12p2"));
EXPECT_EQ("/dev/ubiblock5_0",
utils::MakePartitionNameForMount("/dev/ubiblock5_0"));
- EXPECT_EQ("/dev/mtd4",
- utils::MakePartitionNameForMount("/dev/ubi4_0"));
+ EXPECT_EQ("/dev/mtd4", utils::MakePartitionNameForMount("/dev/ubi4_0"));
EXPECT_EQ("/dev/ubiblock3_0",
utils::MakePartitionNameForMount("/dev/ubiblock3"));
EXPECT_EQ("/dev/mtd2", utils::MakePartitionNameForMount("/dev/ubi2"));
- EXPECT_EQ("/dev/ubi1_0",
- utils::MakePartitionNameForMount("/dev/ubiblock1"));
+ EXPECT_EQ("/dev/ubi1_0", utils::MakePartitionNameForMount("/dev/ubiblock1"));
}
TEST(UtilsTest, FuzzIntTest) {
- static const uint32_t kRanges[] = { 0, 1, 2, 20 };
+ static const uint32_t kRanges[] = {0, 1, 2, 20};
for (uint32_t range : kRanges) {
const int kValue = 50;
for (int tries = 0; tries < 100; ++tries) {
@@ -252,18 +249,12 @@
// which is not localized) so we only need to test the C locale
EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromMilliseconds(100)),
"0.1s");
- EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(0)),
- "0s");
- EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(1)),
- "1s");
- EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(59)),
- "59s");
- EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(60)),
- "1m0s");
- EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(61)),
- "1m1s");
- EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(90)),
- "1m30s");
+ EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(0)), "0s");
+ EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(1)), "1s");
+ EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(59)), "59s");
+ EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(60)), "1m0s");
+ EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(61)), "1m1s");
+ EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(90)), "1m30s");
EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(1205)),
"20m5s");
EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(3600)),
@@ -283,8 +274,7 @@
EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(200000) +
base::TimeDelta::FromMilliseconds(1)),
"2d7h33m20.001s");
- EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(-1)),
- "-1s");
+ EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(-1)), "-1s");
}
TEST(UtilsTest, ConvertToOmahaInstallDate) {
@@ -305,29 +295,29 @@
EXPECT_FALSE(utils::ConvertToOmahaInstallDate(
base::Time::FromTimeT(omaha_epoch - 1), &value));
EXPECT_FALSE(utils::ConvertToOmahaInstallDate(
- base::Time::FromTimeT(omaha_epoch - 100*24*3600), &value));
+ base::Time::FromTimeT(omaha_epoch - 100 * 24 * 3600), &value));
// Check that we jump from 0 to 7 exactly on the one-week mark, e.g.
// on Jan 8, 2007 0:00 PST.
EXPECT_TRUE(utils::ConvertToOmahaInstallDate(
- base::Time::FromTimeT(omaha_epoch + 7*24*3600 - 1), &value));
+ base::Time::FromTimeT(omaha_epoch + 7 * 24 * 3600 - 1), &value));
EXPECT_EQ(value, 0);
EXPECT_TRUE(utils::ConvertToOmahaInstallDate(
- base::Time::FromTimeT(omaha_epoch + 7*24*3600), &value));
+ base::Time::FromTimeT(omaha_epoch + 7 * 24 * 3600), &value));
EXPECT_EQ(value, 7);
// Check a couple of more values.
EXPECT_TRUE(utils::ConvertToOmahaInstallDate(
- base::Time::FromTimeT(omaha_epoch + 10*24*3600), &value));
+ base::Time::FromTimeT(omaha_epoch + 10 * 24 * 3600), &value));
EXPECT_EQ(value, 7);
EXPECT_TRUE(utils::ConvertToOmahaInstallDate(
- base::Time::FromTimeT(omaha_epoch + 20*24*3600), &value));
+ base::Time::FromTimeT(omaha_epoch + 20 * 24 * 3600), &value));
EXPECT_EQ(value, 14);
EXPECT_TRUE(utils::ConvertToOmahaInstallDate(
- base::Time::FromTimeT(omaha_epoch + 26*24*3600), &value));
+ base::Time::FromTimeT(omaha_epoch + 26 * 24 * 3600), &value));
EXPECT_EQ(value, 21);
EXPECT_TRUE(utils::ConvertToOmahaInstallDate(
- base::Time::FromTimeT(omaha_epoch + 29*24*3600), &value));
+ base::Time::FromTimeT(omaha_epoch + 29 * 24 * 3600), &value));
EXPECT_EQ(value, 28);
// The date Jun 4, 2007 0:00 PDT is a Monday and is hence a point