summaryrefslogtreecommitdiffstats
path: root/tests/component
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2017-03-26 20:00:19 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-03-26 20:00:20 +0200
commitb4c4f8c494c4e9bd559c9f16b799c0307bc8ac4a (patch)
treef4d32300e412b9a865a83e8867c40eab60a3ef86 /tests/component
parentMerge "Don't fail ReadArgs if length to parse is 0" (diff)
parentapplypatch: Drop the support for patching non-EMMC targets. (diff)
downloadandroid_bootable_recovery-b4c4f8c494c4e9bd559c9f16b799c0307bc8ac4a.tar
android_bootable_recovery-b4c4f8c494c4e9bd559c9f16b799c0307bc8ac4a.tar.gz
android_bootable_recovery-b4c4f8c494c4e9bd559c9f16b799c0307bc8ac4a.tar.bz2
android_bootable_recovery-b4c4f8c494c4e9bd559c9f16b799c0307bc8ac4a.tar.lz
android_bootable_recovery-b4c4f8c494c4e9bd559c9f16b799c0307bc8ac4a.tar.xz
android_bootable_recovery-b4c4f8c494c4e9bd559c9f16b799c0307bc8ac4a.tar.zst
android_bootable_recovery-b4c4f8c494c4e9bd559c9f16b799c0307bc8ac4a.zip
Diffstat (limited to 'tests/component')
-rw-r--r--tests/component/applypatch_test.cpp124
1 files changed, 0 insertions, 124 deletions
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<std::string> 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<std::string> 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<std::string> 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<std::string> 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 <bonus-file> <src-file> <tgt-file> <tgt-sha1> <tgt-size> <src-sha1>:<patch>
- TemporaryFile tmp1;
- std::string patch = boot_img_sha1 + ":" + from_testdata_base("recovery-from-boot.p");
- std::vector<const char*> 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 <src-file> <tgt-file> <tgt-sha1> <tgt-size> <src-sha1>:<patch>
- TemporaryFile tmp2;
- patch = boot_img_sha1 + ":" + from_testdata_base("recovery-from-boot-with-bonus.p");
- std::vector<const char*> 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 <bonus-file> <src-file> <tgt-file> <tgt-sha1> <tgt-size> \
- // <src-sha1-fake>:<patch1> <src-sha1>:<patch2>
- 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<const char*> 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;