HardwareInterface::IsPartitionUpdateValid: fine grained error
Let the function emit an error code instead of a boolean to indicate
details of the error that is encountered.
For every partition, if downgrade is detected, emit
kPayloadTimestampError. In this case, still check other partitions for
more severe errors before returning this error.
In some cases, e.g. DeltaArchiveManifest carries a version field that is
not a recognized format, or timestamp sysprops in Android is not an
integer, report a more severe error.
If only downgrade errors are encountered, AllowDowngrade() can still
override the result, and proceed with the update; but, AllowDowngrade
cannot override those severe errors.
Test: update_engine_unittest
Bug: 162623577
Bug: 162553432
Change-Id: Ifc2a6fcd66239c755fb4f6528c3d8c6848afcb27
diff --git a/common/utils_unittest.cc b/common/utils_unittest.cc
index 37871d2..d73b3da 100644
--- a/common/utils_unittest.cc
+++ b/common/utils_unittest.cc
@@ -482,11 +482,13 @@
}
TEST(UtilsTest, ValidatePerPartitionTimestamp) {
- ASSERT_FALSE(utils::IsTimestampNewer("10", "5"));
- ASSERT_TRUE(utils::IsTimestampNewer("10", "11"));
- ASSERT_FALSE(utils::IsTimestampNewer("10", "lol"));
- ASSERT_FALSE(utils::IsTimestampNewer("lol", "ZZZ"));
- ASSERT_TRUE(utils::IsTimestampNewer("10", ""));
+ ASSERT_EQ(ErrorCode::kPayloadTimestampError,
+ utils::IsTimestampNewer("10", "5"));
+ ASSERT_EQ(ErrorCode::kSuccess, utils::IsTimestampNewer("10", "11"));
+ ASSERT_EQ(ErrorCode::kDownloadManifestParseError,
+ utils::IsTimestampNewer("10", "lol"));
+ ASSERT_EQ(ErrorCode::kError, utils::IsTimestampNewer("lol", "ZZZ"));
+ ASSERT_EQ(ErrorCode::kSuccess, utils::IsTimestampNewer("10", ""));
}
} // namespace chromeos_update_engine