From 40e144dae877654f75e65242535036058ea48f58 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 15 Mar 2017 01:10:58 -0700 Subject: applypatch: Drop the support for patching non-EMMC targets. Patching regular files is used in file-based OTA only, which has become obsolete. Bug: 35853185 Test: Apply an incremental that patches the boot.img. Test: /system/bin/install-recovery.sh works. Test: recovery_component_test passes. Change-Id: Id44e42c4bc63f2162ecc8a6df1cb528b7ae6b0a9 --- tests/component/applypatch_test.cpp | 124 ------------------------------------ 1 file changed, 124 deletions(-) (limited to 'tests/component') diff --git a/tests/component/applypatch_test.cpp b/tests/component/applypatch_test.cpp index d178303aa..5cba68f8a 100644 --- a/tests/component/applypatch_test.cpp +++ b/tests/component/applypatch_test.cpp @@ -280,66 +280,6 @@ TEST_F(ApplyPatchCacheTest, CheckCacheMissingFailure) { ASSERT_NE(0, applypatch_check(&old_file[0], sha1s)); } -TEST_F(ApplyPatchFullTest, ApplyInPlace) { - std::vector sha1s = { bad_sha1_a, old_sha1 }; - ASSERT_EQ(0, applypatch(&old_file[0], "-", &new_sha1[0], new_size, sha1s, patches, nullptr)); - ASSERT_TRUE(file_cmp(old_file, new_file)); - - // reapply, applypatch is idempotent so it should succeed - ASSERT_EQ(0, applypatch(&old_file[0], "-", &new_sha1[0], new_size, sha1s, patches, nullptr)); - ASSERT_TRUE(file_cmp(old_file, new_file)); -} - -TEST_F(ApplyPatchFullTest, ApplyInNewLocation) { - std::vector sha1s = { bad_sha1_a, old_sha1 }; - // Apply bsdiff patch to new location. - ASSERT_EQ( - 0, applypatch(&old_file[0], &output_loc[0], &new_sha1[0], new_size, sha1s, patches, nullptr)); - ASSERT_TRUE(file_cmp(output_loc, new_file)); - - // Reapply to the same location. - ASSERT_EQ( - 0, applypatch(&old_file[0], &output_loc[0], &new_sha1[0], new_size, sha1s, patches, nullptr)); - ASSERT_TRUE(file_cmp(output_loc, new_file)); -} - -TEST_F(ApplyPatchFullTest, ApplyCorruptedInNewLocation) { - std::vector sha1s = { bad_sha1_a, old_sha1 }; - // Apply bsdiff patch to new location with corrupted source. - mangle_file(old_file); - ASSERT_EQ( - 0, applypatch(&old_file[0], &output_loc[0], &new_sha1[0], new_size, sha1s, patches, nullptr)); - ASSERT_TRUE(file_cmp(output_loc, new_file)); - - // Reapply bsdiff patch to new location with corrupted source. - ASSERT_EQ( - 0, applypatch(&old_file[0], &output_loc[0], &new_sha1[0], new_size, sha1s, patches, nullptr)); - ASSERT_TRUE(file_cmp(output_loc, new_file)); -} - -TEST_F(ApplyPatchDoubleCacheTest, ApplyDoubleCorruptedInNewLocation) { - std::vector sha1s = { bad_sha1_a, old_sha1 }; - - // Apply bsdiff patch to new location with corrupted source and copy (no new file). - // Expected to fail. - mangle_file(old_file); - mangle_file(cache_file); - ASSERT_NE( - 0, applypatch(&old_file[0], &output_loc[0], &new_sha1[0], new_size, sha1s, patches, nullptr)); - ASSERT_FALSE(file_cmp(output_loc, new_file)); - - // Expected to fail again on retry. - ASSERT_NE( - 0, applypatch(&old_file[0], &output_loc[0], &new_sha1[0], new_size, sha1s, patches, nullptr)); - ASSERT_FALSE(file_cmp(output_loc, new_file)); - - // Expected to fail with incorrect new file. - mangle_file(output_loc); - ASSERT_NE( - 0, applypatch(&old_file[0], &output_loc[0], &new_sha1[0], new_size, sha1s, patches, nullptr)); - ASSERT_FALSE(file_cmp(output_loc, new_file)); -} - TEST(ApplyPatchModesTest, InvalidArgs) { // At least two args (including the filename). ASSERT_EQ(2, applypatch_modes(1, (const char* []){ "applypatch" })); @@ -348,70 +288,6 @@ TEST(ApplyPatchModesTest, InvalidArgs) { ASSERT_EQ(2, applypatch_modes(2, (const char* []){ "applypatch", "-x" })); } -TEST(ApplyPatchModesTest, PatchMode) { - std::string boot_img = from_testdata_base("boot.img"); - size_t boot_img_size; - std::string boot_img_sha1; - sha1sum(boot_img, &boot_img_sha1, &boot_img_size); - - std::string recovery_img = from_testdata_base("recovery.img"); - std::string recovery_img_sha1; - size_t size; - sha1sum(recovery_img, &recovery_img_sha1, &size); - std::string recovery_img_size = std::to_string(size); - std::string bonus_file = from_testdata_base("bonus.file"); - - // applypatch -b : - TemporaryFile tmp1; - std::string patch = boot_img_sha1 + ":" + from_testdata_base("recovery-from-boot.p"); - std::vector args = { - "applypatch", - "-b", - bonus_file.c_str(), - boot_img.c_str(), - tmp1.path, - recovery_img_sha1.c_str(), - recovery_img_size.c_str(), - patch.c_str() - }; - ASSERT_EQ(0, applypatch_modes(args.size(), args.data())); - - // applypatch : - TemporaryFile tmp2; - patch = boot_img_sha1 + ":" + from_testdata_base("recovery-from-boot-with-bonus.p"); - std::vector args2 = { - "applypatch", - boot_img.c_str(), - tmp2.path, - recovery_img_sha1.c_str(), - recovery_img_size.c_str(), - patch.c_str() - }; - ASSERT_EQ(0, applypatch_modes(args2.size(), args2.data())); - - // applypatch -b \ - // : : - TemporaryFile tmp3; - std::string bad_sha1_a = android::base::StringPrintf("%040x", rand()); - std::string bad_sha1_b = android::base::StringPrintf("%040x", rand()); - std::string patch1 = bad_sha1_a + ":" + from_testdata_base("recovery-from-boot.p"); - std::string patch2 = boot_img_sha1 + ":" + from_testdata_base("recovery-from-boot.p"); - std::string patch3 = bad_sha1_b + ":" + from_testdata_base("recovery-from-boot.p"); - std::vector args3 = { - "applypatch", - "-b", - bonus_file.c_str(), - boot_img.c_str(), - tmp3.path, - recovery_img_sha1.c_str(), - recovery_img_size.c_str(), - patch1.c_str(), - patch2.c_str(), - patch3.c_str() - }; - ASSERT_EQ(0, applypatch_modes(args3.size(), args3.data())); -} - TEST(ApplyPatchModesTest, PatchModeEmmcTarget) { std::string boot_img = from_testdata_base("boot.img"); size_t boot_img_size; -- cgit v1.2.3