update_engine: Merge remote-tracking branch 'cros/upstream' into cros/master
Since libchrome in AOSP is ahead of CrOS I had to guard against BASE_VER in a
few places to satisfy older libchromes.
file_fetcher.cc is now needed in delta_generator.
A few unittests need to be run as root.
BUG=chromium:916593
TEST=unittest
TEST=cros_generate_update_payload
TEST=cros flash
CQ-DEPEND=CL:1399261
Change-Id: If3497549e88e559f8ecc38f414259b9c774f4a44
diff --git a/update_manager/boxed_value.cc b/update_manager/boxed_value.cc
index 9e2971d..35bfb1f 100644
--- a/update_manager/boxed_value.cc
+++ b/update_manager/boxed_value.cc
@@ -51,26 +51,42 @@
template<>
string BoxedValue::ValuePrinter<int>(const void* value) {
const int* val = reinterpret_cast<const int*>(value);
+#if BASE_VER < 576279
return base::IntToString(*val);
+#else
+ return base::NumberToString(*val);
+#endif
}
template<>
string BoxedValue::ValuePrinter<unsigned int>(const void* value) {
const unsigned int* val = reinterpret_cast<const unsigned int*>(value);
+#if BASE_VER < 576279
return base::UintToString(*val);
+#else
+ return base::NumberToString(*val);
+#endif
}
template<>
string BoxedValue::ValuePrinter<int64_t>(const void* value) {
const int64_t* val = reinterpret_cast<const int64_t*>(value);
+#if BASE_VER < 576279
return base::Int64ToString(*val);
+#else
+ return base::NumberToString(*val);
+#endif
}
template<>
string BoxedValue::ValuePrinter<uint64_t>(const void* value) {
const uint64_t* val =
reinterpret_cast<const uint64_t*>(value);
- return base::Uint64ToString(static_cast<uint64_t>(*val));
+#if BASE_VER < 576279
+ return base::Uint64ToString(*val);
+#else
+ return base::NumberToString(*val);
+#endif
}
template<>
@@ -82,7 +98,11 @@
template<>
string BoxedValue::ValuePrinter<double>(const void* value) {
const double* val = reinterpret_cast<const double*>(value);
+#if BASE_VER < 576279
return base::DoubleToString(*val);
+#else
+ return base::NumberToString(*val);
+#endif
}
template<>
diff --git a/update_manager/boxed_value.h b/update_manager/boxed_value.h
index 5f41835..c40215e 100644
--- a/update_manager/boxed_value.h
+++ b/update_manager/boxed_value.h
@@ -70,8 +70,9 @@
// move constructor explicitly preventing it from accidental references,
// like in:
// BoxedValue new_box(std::move(other_box));
- BoxedValue(BoxedValue&& other) // NOLINT(build/c++11)
- : value_(other.value_), deleter_(other.deleter_),
+ BoxedValue(BoxedValue&& other) noexcept
+ : value_(other.value_),
+ deleter_(other.deleter_),
printer_(other.printer_) {
other.value_ = nullptr;
other.deleter_ = nullptr;
diff --git a/update_manager/chromeos_policy.cc b/update_manager/chromeos_policy.cc
index abb06c7..587ac67 100644
--- a/update_manager/chromeos_policy.cc
+++ b/update_manager/chromeos_policy.cc
@@ -86,6 +86,8 @@
case ErrorCode::kPayloadMismatchedType:
case ErrorCode::kUnsupportedMajorPayloadVersion:
case ErrorCode::kUnsupportedMinorPayloadVersion:
+ case ErrorCode::kPayloadTimestampError:
+ case ErrorCode::kVerityCalculationError:
LOG(INFO) << "Advancing download URL due to error "
<< chromeos_update_engine::utils::ErrorCodeToString(err_code)
<< " (" << static_cast<int>(err_code) << ")";
diff --git a/update_manager/evaluation_context_unittest.cc b/update_manager/evaluation_context_unittest.cc
index 1e61db7..d172885 100644
--- a/update_manager/evaluation_context_unittest.cc
+++ b/update_manager/evaluation_context_unittest.cc
@@ -20,6 +20,7 @@
#include <string>
#include <base/bind.h>
+#include <base/bind_helpers.h>
#include <brillo/message_loops/fake_message_loop.h>
#include <brillo/message_loops/message_loop_utils.h>
#include <gtest/gtest.h>
@@ -48,8 +49,6 @@
namespace {
-void DoNothing() {}
-
// Sets the value of the passed pointer to true.
void SetTrue(bool* value) {
*value = true;
@@ -207,7 +206,13 @@
fake_const_var_.reset(new string("Hello world!"));
EXPECT_EQ(*eval_ctx_->GetValue(&fake_const_var_), "Hello world!");
- EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(Bind(&DoNothing)));
+ EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
}
// Test that reevaluation occurs when an async variable it depends on changes.
@@ -277,11 +282,23 @@
EXPECT_TRUE(value);
// Ensure that we cannot reschedule an evaluation.
- EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(Bind(&DoNothing)));
+ EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
// Ensure that we can reschedule an evaluation after resetting expiration.
eval_ctx_->ResetExpiration();
- EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(Bind(&DoNothing)));
+ EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
}
// Test that we clear the events when destroying the EvaluationContext.
@@ -327,7 +344,13 @@
fake_poll_var_.reset(new string("Polled value"));
eval_ctx_->GetValue(&fake_async_var_);
eval_ctx_->GetValue(&fake_poll_var_);
- EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(Bind(&DoNothing)));
+ EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
// TearDown() checks for leaked observers on this async_variable, which means
// that our object is still alive after removing its reference.
}
@@ -420,7 +443,13 @@
// The "false" from IsWallclockTimeGreaterThan means that's not that timestamp
// yet, so this should schedule a callback for when that happens.
- EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(Bind(&DoNothing)));
+ EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
}
TEST_F(UmEvaluationContextTest,
@@ -430,7 +459,13 @@
// The "false" from IsMonotonicTimeGreaterThan means that's not that timestamp
// yet, so this should schedule a callback for when that happens.
- EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(Bind(&DoNothing)));
+ EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
}
TEST_F(UmEvaluationContextTest,
@@ -443,7 +478,13 @@
fake_clock_.GetWallclockTime() - TimeDelta::FromSeconds(1)));
// Callback should not be scheduled.
- EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(Bind(&DoNothing)));
+ EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
}
TEST_F(UmEvaluationContextTest,
@@ -456,7 +497,13 @@
fake_clock_.GetMonotonicTime() - TimeDelta::FromSeconds(1)));
// Callback should not be scheduled.
- EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(Bind(&DoNothing)));
+ EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
}
TEST_F(UmEvaluationContextTest, DumpContext) {
diff --git a/update_manager/update_time_restrictions_policy_impl_unittest.cc b/update_manager/update_time_restrictions_policy_impl_unittest.cc
index f7ee138..74e7f3c 100644
--- a/update_manager/update_time_restrictions_policy_impl_unittest.cc
+++ b/update_manager/update_time_restrictions_policy_impl_unittest.cc
@@ -57,8 +57,9 @@
fake_state_.device_policy_provider()
->var_auto_launched_kiosk_app_id()
->reset(new string("myapp"));
- base::Time time;
- CHECK(Time::FromLocalExploded(exploded, &time));
+
+ Time time;
+ EXPECT_TRUE(Time::FromLocalExploded(exploded, &time));
fake_clock_.SetWallclockTime(time);
SetUpDefaultTimeProvider();
fake_state_.device_policy_provider()