From 495c521ed32e92ed0e39a425fd5ce79c581dbcda Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Tue, 6 Mar 2018 17:59:58 -0800 Subject: recovery: add libhidl-gen-utils depedency introduced as a depedency to libvintf. Test: builds Bug: 73556059 Change-Id: Ia51ba81ef462879481dcacb80d9ea9ea35e8b0bb --- Android.mk | 1 + tests/Android.mk | 1 + 2 files changed, 2 insertions(+) diff --git a/Android.mk b/Android.mk index e8b899450..510c66abe 100644 --- a/Android.mk +++ b/Android.mk @@ -167,6 +167,7 @@ LOCAL_STATIC_LIBRARIES := \ libcrypto \ libvintf_recovery \ libvintf \ + libhidl-gen-utils \ libtinyxml2 \ libbase \ libcutils \ diff --git a/tests/Android.mk b/tests/Android.mk index d911c25e4..b3584fe87 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -147,6 +147,7 @@ LOCAL_STATIC_LIBRARIES := \ libfs_mgr \ libvintf_recovery \ libvintf \ + libhidl-gen-utils \ libtinyxml2 \ libselinux \ libext4_utils \ -- cgit v1.2.3 From d612b23dfd58dbe5059ba53d8fd13cbb343b177c Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 12 Mar 2018 21:18:52 -0700 Subject: tests: Add ApplyPatchModesTest.PatchModeEmmcTargetWithBsdiffPatch test. /system/bin/applypatch on device is expected to work with bsdiff based recovery-from-boot patch automatically. Adding a test to ensure that's always the case. Bug: 72731506 Test: Run recovery_component_test on marlin. Change-Id: I56283cd3ce7cf0215cc3bb3619b206fa01d552c4 --- tests/component/applypatch_test.cpp | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/component/applypatch_test.cpp b/tests/component/applypatch_test.cpp index b6d092557..61e06adb6 100644 --- a/tests/component/applypatch_test.cpp +++ b/tests/component/applypatch_test.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "applypatch/applypatch.h" @@ -38,6 +39,8 @@ #include "otautil/cache_location.h" #include "otautil/print_sha1.h" +using namespace std::string_literals; + static void sha1sum(const std::string& fname, std::string* sha1, size_t* fsize = nullptr) { ASSERT_NE(nullptr, sha1); @@ -265,6 +268,54 @@ TEST_F(ApplyPatchModesTest, PatchModeEmmcTarget) { ASSERT_EQ(0, applypatch_modes(args3.size(), args3.data())); } +// Ensures that applypatch works with a bsdiff based recovery-from-boot.p. +TEST_F(ApplyPatchModesTest, PatchModeEmmcTargetWithBsdiffPatch) { + std::string boot_img_file = from_testdata_base("boot.img"); + std::string boot_img_sha1; + size_t boot_img_size; + sha1sum(boot_img_file, &boot_img_sha1, &boot_img_size); + + std::string recovery_img_file = from_testdata_base("recovery.img"); + std::string recovery_img_sha1; + size_t recovery_img_size; + sha1sum(recovery_img_file, &recovery_img_sha1, &recovery_img_size); + + // Generate the bsdiff patch of recovery-from-boot.p. + std::string src_content; + ASSERT_TRUE(android::base::ReadFileToString(boot_img_file, &src_content)); + + std::string tgt_content; + ASSERT_TRUE(android::base::ReadFileToString(recovery_img_file, &tgt_content)); + + TemporaryFile patch_file; + ASSERT_EQ(0, + bsdiff::bsdiff(reinterpret_cast(src_content.data()), src_content.size(), + reinterpret_cast(tgt_content.data()), tgt_content.size(), + patch_file.path, nullptr)); + + // applypatch : + std::string src_file_arg = + "EMMC:" + boot_img_file + ":" + std::to_string(boot_img_size) + ":" + boot_img_sha1; + TemporaryFile tgt_file; + std::string tgt_file_arg = "EMMC:"s + tgt_file.path; + std::string recovery_img_size_arg = std::to_string(recovery_img_size); + std::string patch_arg = boot_img_sha1 + ":" + patch_file.path; + std::vector args = { "applypatch", + src_file_arg.c_str(), + tgt_file_arg.c_str(), + recovery_img_sha1.c_str(), + recovery_img_size_arg.c_str(), + patch_arg.c_str() }; + ASSERT_EQ(0, applypatch_modes(args.size(), args.data())); + + // Double check the patched recovery image. + std::string tgt_file_sha1; + size_t tgt_file_size; + sha1sum(tgt_file.path, &tgt_file_sha1, &tgt_file_size); + ASSERT_EQ(recovery_img_size, tgt_file_size); + ASSERT_EQ(recovery_img_sha1, tgt_file_sha1); +} + TEST_F(ApplyPatchModesTest, PatchModeInvalidArgs) { // Invalid bonus file. ASSERT_NE(0, applypatch_modes(3, (const char* []){ "applypatch", "-b", "/doesntexist" })); -- cgit v1.2.3 From 91b48f9161a918e4af6233af7fa842b9af0a6bac Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Tue, 6 Mar 2018 17:59:58 -0800 Subject: recovery: add libhidl-gen-utils depedency introduced as a depedency to libvintf. Test: builds Bug: 73556059 Change-Id: Ia51ba81ef462879481dcacb80d9ea9ea35e8b0bb Merged-In: Ia51ba81ef462879481dcacb80d9ea9ea35e8b0bb --- Android.mk | 1 + tests/Android.mk | 1 + 2 files changed, 2 insertions(+) diff --git a/Android.mk b/Android.mk index 199cee7ec..461ad9449 100644 --- a/Android.mk +++ b/Android.mk @@ -179,6 +179,7 @@ LOCAL_STATIC_LIBRARIES += \ libcrypto \ libvintf_recovery \ libvintf \ + libhidl-gen-utils \ libtinyxml2 \ libbase \ libutils \ diff --git a/tests/Android.mk b/tests/Android.mk index d911c25e4..b3584fe87 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -147,6 +147,7 @@ LOCAL_STATIC_LIBRARIES := \ libfs_mgr \ libvintf_recovery \ libvintf \ + libhidl-gen-utils \ libtinyxml2 \ libselinux \ libext4_utils \ -- cgit v1.2.3