aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTianjie Xu2017-09-26 19:02:43 -0500
committerandroid-build-merger2017-09-26 19:02:43 -0500
commiteb5e19401292a8f9a06ea86b7f2c66fc131321dc (patch)
treef5a6ad41984836a3ee94a96e273208f99368bfff /tests
parent6a5204ac8d533d5e32ae7d47296bc53dbc03b03c (diff)
parent7f54fe8841b2f4e104d17f673c54eb826d0155dd (diff)
downloadplatform-bootable-recovery-eb5e19401292a8f9a06ea86b7f2c66fc131321dc.tar.gz
platform-bootable-recovery-eb5e19401292a8f9a06ea86b7f2c66fc131321dc.tar.xz
platform-bootable-recovery-eb5e19401292a8f9a06ea86b7f2c66fc131321dc.zip
Merge "Output split information for imgdiff when handling large apks"
am: 7f54fe8841 Change-Id: I97ad82d84b16b46e9c0c0f8198d3ab73d43031b0
Diffstat (limited to 'tests')
-rw-r--r--tests/component/imgdiff_test.cpp48
1 files changed, 40 insertions, 8 deletions
diff --git a/tests/component/imgdiff_test.cpp b/tests/component/imgdiff_test.cpp
index 73516050..161d58d4 100644
--- a/tests/component/imgdiff_test.cpp
+++ b/tests/component/imgdiff_test.cpp
@@ -778,11 +778,13 @@ TEST(ImgdiffTest, zip_mode_store_large_apk) {
778 778
779 // Compute patch. 779 // Compute patch.
780 TemporaryFile patch_file; 780 TemporaryFile patch_file;
781 TemporaryFile split_info_file;
781 TemporaryDir debug_dir; 782 TemporaryDir debug_dir;
783 std::string split_info_arg = android::base::StringPrintf("--split-info=%s", split_info_file.path);
782 std::string debug_dir_arg = android::base::StringPrintf("--debug-dir=%s", debug_dir.path); 784 std::string debug_dir_arg = android::base::StringPrintf("--debug-dir=%s", debug_dir.path);
783 std::vector<const char*> args = { 785 std::vector<const char*> args = {
784 "imgdiff", "-z", "--block-limit=10", debug_dir_arg.c_str(), src_file.path, tgt_file.path, 786 "imgdiff", "-z", "--block-limit=10", split_info_arg.c_str(), debug_dir_arg.c_str(),
785 patch_file.path, 787 src_file.path, tgt_file.path, patch_file.path,
786 }; 788 };
787 ASSERT_EQ(0, imgdiff(args.size(), args.data())); 789 ASSERT_EQ(0, imgdiff(args.size(), args.data()));
788 790
@@ -864,14 +866,40 @@ TEST(ImgdiffTest, zip_mode_deflate_large_apk) {
864 866
865 // Compute patch. 867 // Compute patch.
866 TemporaryFile patch_file; 868 TemporaryFile patch_file;
869 TemporaryFile split_info_file;
867 TemporaryDir debug_dir; 870 TemporaryDir debug_dir;
868 ASSERT_TRUE(ZipModeImage::GeneratePatches(split_tgt_images, split_src_images, split_src_ranges, 871 ASSERT_TRUE(ZipModeImage::GeneratePatches(split_tgt_images, split_src_images, split_src_ranges,
869 patch_file.path, debug_dir.path)); 872 patch_file.path, split_info_file.path, debug_dir.path));
873
874 // Verify the content of split info.
875 // Expect 5 pieces of patch. ["a","b"; "c"; "d-0"; "d-1"; "e"]
876 std::string split_info_string;
877 android::base::ReadFileToString(split_info_file.path, &split_info_string);
878 std::vector<std::string> info_list =
879 android::base::Split(android::base::Trim(split_info_string), "\n");
880
881 ASSERT_EQ(static_cast<size_t>(7), info_list.size());
882 ASSERT_EQ("2", android::base::Trim(info_list[0]));
883 ASSERT_EQ("5", android::base::Trim(info_list[1]));
884
885 std::vector<size_t> patch_size;
886 for (size_t i = 0; i < 5; i++) {
887 struct stat st = {};
888 std::string path = android::base::StringPrintf("%s/patch-%zu", debug_dir.path, i);
889 ASSERT_EQ(0, stat(path.c_str(), &st));
890 patch_size.push_back(st.st_size);
891 }
892
893 ASSERT_EQ(std::to_string(patch_size[0]) + " 36864 2,22,31", android::base::Trim(info_list[2]));
894 ASSERT_EQ(std::to_string(patch_size[1]) + " 32768 2,31,40", android::base::Trim(info_list[3]));
895 ASSERT_EQ(std::to_string(patch_size[2]) + " 40960 2,0,11", android::base::Trim(info_list[4]));
896 ASSERT_EQ(std::to_string(patch_size[3]) + " 40960 2,11,21", android::base::Trim(info_list[5]));
897 ASSERT_EQ(std::to_string(patch_size[4]) + " 8833 4,21,22,40,41",
898 android::base::Trim(info_list[6]));
870 899
871 std::string tgt; 900 std::string tgt;
872 ASSERT_TRUE(android::base::ReadFileToString(tgt_file.path, &tgt)); 901 ASSERT_TRUE(android::base::ReadFileToString(tgt_file.path, &tgt));
873 902
874 // Expect 5 pieces of patch. ["a","b"; "c"; "d-0"; "d-1"; "e"]
875 GenerateAndCheckSplitTarget(debug_dir.path, 5, tgt); 903 GenerateAndCheckSplitTarget(debug_dir.path, 5, tgt);
876} 904}
877 905
@@ -901,11 +929,13 @@ TEST(ImgdiffTest, zip_mode_no_match_source) {
901 929
902 // Compute patch. 930 // Compute patch.
903 TemporaryFile patch_file; 931 TemporaryFile patch_file;
932 TemporaryFile split_info_file;
904 TemporaryDir debug_dir; 933 TemporaryDir debug_dir;
934 std::string split_info_arg = android::base::StringPrintf("--split-info=%s", split_info_file.path);
905 std::string debug_dir_arg = android::base::StringPrintf("--debug-dir=%s", debug_dir.path); 935 std::string debug_dir_arg = android::base::StringPrintf("--debug-dir=%s", debug_dir.path);
906 std::vector<const char*> args = { 936 std::vector<const char*> args = {
907 "imgdiff", "-z", "--block-limit=10", debug_dir_arg.c_str(), src_file.path, tgt_file.path, 937 "imgdiff", "-z", "--block-limit=10", debug_dir_arg.c_str(), split_info_arg.c_str(),
908 patch_file.path, 938 src_file.path, tgt_file.path, patch_file.path,
909 }; 939 };
910 ASSERT_EQ(0, imgdiff(args.size(), args.data())); 940 ASSERT_EQ(0, imgdiff(args.size(), args.data()));
911 941
@@ -941,11 +971,13 @@ TEST(ImgdiffTest, zip_mode_large_enough_limit) {
941 971
942 // Compute patch with a limit of 20 blocks. 972 // Compute patch with a limit of 20 blocks.
943 TemporaryFile patch_file; 973 TemporaryFile patch_file;
974 TemporaryFile split_info_file;
944 TemporaryDir debug_dir; 975 TemporaryDir debug_dir;
976 std::string split_info_arg = android::base::StringPrintf("--split-info=%s", split_info_file.path);
945 std::string debug_dir_arg = android::base::StringPrintf("--debug-dir=%s", debug_dir.path); 977 std::string debug_dir_arg = android::base::StringPrintf("--debug-dir=%s", debug_dir.path);
946 std::vector<const char*> args = { 978 std::vector<const char*> args = {
947 "imgdiff", "-z", "--block-limit=20", debug_dir_arg.c_str(), src_file.path, tgt_file.path, 979 "imgdiff", "-z", "--block-limit=20", split_info_arg.c_str(), debug_dir_arg.c_str(),
948 patch_file.path, 980 src_file.path, tgt_file.path, patch_file.path,
949 }; 981 };
950 ASSERT_EQ(0, imgdiff(args.size(), args.data())); 982 ASSERT_EQ(0, imgdiff(args.size(), args.data()));
951 983