summaryrefslogtreecommitdiffstats
path: root/tests/component
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-12-15 23:32:36 +0100
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-12-15 23:32:37 +0100
commit26d972c9d2d75a2a96d63123f0313e5c9e70a73f (patch)
tree92da6e8d0b0d4a799a8849d99c17a10b108378f6 /tests/component
parentMerge "tests: Add tests for bootloader_message." (diff)
parentAdd update_bootloader_message() to fix two-step OTAs. (diff)
downloadandroid_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.tar
android_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.tar.gz
android_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.tar.bz2
android_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.tar.lz
android_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.tar.xz
android_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.tar.zst
android_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.zip
Diffstat (limited to 'tests/component')
-rw-r--r--tests/component/bootloader_message_test.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/component/bootloader_message_test.cpp b/tests/component/bootloader_message_test.cpp
index cff129cfc..dbcaf619e 100644
--- a/tests/component/bootloader_message_test.cpp
+++ b/tests/component/bootloader_message_test.cpp
@@ -137,3 +137,29 @@ TEST_F(BootloaderMessageTest, write_bootloader_message_options_long) {
ASSERT_EQ(std::string(sizeof(boot.reserved), '\0'),
std::string(boot.reserved, sizeof(boot.reserved)));
}
+
+TEST_F(BootloaderMessageTest, update_bootloader_message) {
+ // Inject some bytes into boot, which should be not overwritten later.
+ bootloader_message boot;
+ strlcpy(boot.recovery, "random message", sizeof(boot.recovery));
+ strlcpy(boot.reserved, "reserved bytes", sizeof(boot.reserved));
+ std::string err;
+ ASSERT_TRUE(write_bootloader_message(boot, &err)) << "Failed to write BCB: " << err;
+
+ // Update the BCB message.
+ std::vector<std::string> options = { "option1", "option2" };
+ ASSERT_TRUE(update_bootloader_message(options, &err)) << "Failed to update BCB: " << err;
+
+ bootloader_message boot_verify;
+ ASSERT_TRUE(read_bootloader_message(&boot_verify, &err)) << "Failed to read BCB: " << err;
+
+ // Verify that command and recovery fields should be set.
+ ASSERT_EQ("boot-recovery", std::string(boot_verify.command));
+ std::string expected = "recovery\n" + android::base::Join(options, "\n") + "\n";
+ ASSERT_EQ(expected, std::string(boot_verify.recovery));
+
+ // The rest should be intact.
+ ASSERT_EQ(std::string(boot.status), std::string(boot_verify.status));
+ ASSERT_EQ(std::string(boot.stage), std::string(boot_verify.stage));
+ ASSERT_EQ(std::string(boot.reserved), std::string(boot_verify.reserved));
+}