summaryrefslogtreecommitdiffstats
path: root/tests/component
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-06-07 18:56:19 +0200
committerTao Bao <tbao@google.com>2018-06-07 19:43:24 +0200
commitffede3e8d9b2a6cb6c431ccad69cb341c22f7e45 (patch)
tree2aa0d8763515e8f7706c8fd8b78a034f3bd564b4 /tests/component
parentMerge "updater: Replace the reference arguments with pointers." (diff)
downloadandroid_bootable_recovery-ffede3e8d9b2a6cb6c431ccad69cb341c22f7e45.tar
android_bootable_recovery-ffede3e8d9b2a6cb6c431ccad69cb341c22f7e45.tar.gz
android_bootable_recovery-ffede3e8d9b2a6cb6c431ccad69cb341c22f7e45.tar.bz2
android_bootable_recovery-ffede3e8d9b2a6cb6c431ccad69cb341c22f7e45.tar.lz
android_bootable_recovery-ffede3e8d9b2a6cb6c431ccad69cb341c22f7e45.tar.xz
android_bootable_recovery-ffede3e8d9b2a6cb6c431ccad69cb341c22f7e45.tar.zst
android_bootable_recovery-ffede3e8d9b2a6cb6c431ccad69cb341c22f7e45.zip
Diffstat (limited to 'tests/component')
-rw-r--r--tests/component/updater_test.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/component/updater_test.cpp b/tests/component/updater_test.cpp
index 6f3a3a2a7..fe4f45e15 100644
--- a/tests/component/updater_test.cpp
+++ b/tests/component/updater_test.cpp
@@ -100,7 +100,8 @@ static void BuildUpdatePackage(const PackageEntries& entries, int fd) {
}
static void RunBlockImageUpdate(bool is_verify, const PackageEntries& entries,
- const std::string& image_file, const std::string& result) {
+ const std::string& image_file, const std::string& result,
+ CauseCode cause_code = kNoCause) {
CHECK(entries.find("transfer_list") != entries.end());
// Build the update package.
@@ -124,7 +125,7 @@ static void RunBlockImageUpdate(bool is_verify, const PackageEntries& entries,
std::string script = is_verify ? "block_image_verify" : "block_image_update";
script += R"((")" + image_file + R"(", package_extract_file("transfer_list"), ")" + new_data +
R"(", "patch_data"))";
- expect(result.c_str(), script.c_str(), kNoCause, &updater_info);
+ expect(result.c_str(), script.c_str(), cause_code, &updater_info);
ASSERT_EQ(0, fclose(updater_info.cmd_pipe));
CloseArchive(handle);
@@ -504,6 +505,24 @@ TEST_F(UpdaterTest, show_progress) {
ASSERT_EQ(0, fclose(updater_info.cmd_pipe));
}
+TEST_F(UpdaterTest, block_image_update_parsing_error) {
+ std::vector<std::string> transfer_list{
+ // clang-format off
+ "4",
+ "2",
+ "0",
+ // clang-format on
+ };
+
+ PackageEntries entries{
+ { "new_data", "" },
+ { "patch_data", "" },
+ { "transfer_list", android::base::Join(transfer_list, '\n') },
+ };
+
+ RunBlockImageUpdate(false, entries, image_file_, "", kArgsParsingFailure);
+}
+
TEST_F(UpdaterTest, block_image_update_patch_data) {
std::string src_content = std::string(4096, 'a') + std::string(4096, 'c');
std::string tgt_content = std::string(4096, 'b') + std::string(4096, 'd');