summaryrefslogtreecommitdiff
path: root/update_status_utils.cc
diff options
context:
space:
mode:
authorJae Hoon Kim <kimjae@chromium.org>2019-08-01 17:45:30 -0700
committerCommit Bot <commit-bot@chromium.org>2019-08-05 22:02:13 +0000
commit916af851d46c3a546993ad639573fdb3c1c05ac9 (patch)
treee822e4239747052b001d41ee0be0a2d12cf563d0 /update_status_utils.cc
parent2fdbcae7f09000a7e4ea065567547b18601a2add (diff)
update_engine: Test update_engine printouts
These tests are added to enforce sensitive variables stay invariant with no room or future mistakes to occur again on breaking autotest and cros flash process. BUG=chromium:871340 TEST=FEATURES="test" emerge-$BOARD update_engine update_engine-client TEST=/usr/bin/update_engine_client --status TEST=cros flash $TEST_IP ../build/image/... # works Change-Id: Ibcce5c1dee56cf5bca201a86a143a87b033605bc Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/1732410 Tested-by: Jae Hoon Kim <kimjae@chromium.org> Auto-Submit: Jae Hoon Kim <kimjae@chromium.org> Reviewed-by: Amin Hassani <ahassani@chromium.org> Commit-Queue: Jae Hoon Kim <kimjae@chromium.org>
Diffstat (limited to 'update_status_utils.cc')
-rw-r--r--update_status_utils.cc31
1 files changed, 22 insertions, 9 deletions
diff --git a/update_status_utils.cc b/update_status_utils.cc
index a0aa2ed8..07583148 100644
--- a/update_status_utils.cc
+++ b/update_status_utils.cc
@@ -27,6 +27,19 @@ using update_engine::UpdateStatus;
namespace chromeos_update_engine {
+namespace {
+
+// Note: Do not change these, autotest depends on these string variables being
+// exactly these matches.
+const char kCurrentOp[] = "CURRENT_OP";
+const char kIsInstall[] = "IS_INSTALL";
+const char kLastCheckedTime[] = "LAST_CHECKED_TIME";
+const char kNewSize[] = "NEW_SIZE";
+const char kNewVersion[] = "NEW_VERSION";
+const char kProgress[] = "PROGRESS";
+
+} // namespace
+
const char* UpdateStatusToString(const UpdateStatus& status) {
switch (status) {
case UpdateStatus::IDLE:
@@ -61,21 +74,21 @@ string UpdateEngineStatusToString(const UpdateEngineStatus& status) {
KeyValueStore key_value_store;
#if BASE_VER < 576279
- key_value_store.SetString("LAST_CHECKED_TIME",
+ key_value_store.SetString(kLastCheckedTime,
base::Int64ToString(status.last_checked_time));
- key_value_store.SetString("PROGRESS", base::DoubleToString(status.progress));
- key_value_store.SetString("NEW_SIZE",
+ key_value_store.SetString(kProgress, base::DoubleToString(status.progress));
+ key_value_store.SetString(kNewSize,
base::Uint64ToString(status.new_size_bytes));
#else
- key_value_store.SetString("LAST_CHECKED_TIME",
+ key_value_store.SetString(kLastCheckedTime,
base::NumberToString(status.last_checked_time));
- key_value_store.SetString("PROGRESS", base::NumberToString(status.progress));
- key_value_store.SetString("NEW_SIZE",
+ key_value_store.SetString(kProgress, base::NumberToString(status.progress));
+ key_value_store.SetString(kNewSize,
base::NumberToString(status.new_size_bytes));
#endif
- key_value_store.SetString("CURRENT_OP", UpdateStatusToString(status.status));
- key_value_store.SetString("NEW_VERSION", status.new_version);
- key_value_store.SetBoolean("IS_INSTALL", status.is_install);
+ key_value_store.SetString(kCurrentOp, UpdateStatusToString(status.status));
+ key_value_store.SetString(kNewVersion, status.new_version);
+ key_value_store.SetBoolean(kIsInstall, status.is_install);
return key_value_store.SaveToString();
}