From 78d15141733324ef89d1d5d04799e0f2cf4a41e1 Mon Sep 17 00:00:00 2001 From: Tianjie Date: Wed, 22 Jul 2020 17:40:09 -0700 Subject: =?UTF-8?q?Update=20language=20to=20comply=20with=20Android?= =?UTF-8?q?=E2=80=99s=20inclusive=20language=20guidance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https: //source.android.com/setup/contribute/respectful-code Bug: 161896447 Test: Unit tests pass Change-Id: I0f3f0333dbccc94241a096ca5d3d9bc28c281492 --- applypatch/imgdiff.cpp | 15 ++++++++------- applypatch/include/applypatch/imgdiff_image.h | 4 ++-- tests/testdata/ziptest_dummy-update.zip | Bin 1090065 -> 0 bytes tests/testdata/ziptest_fake-update.zip | Bin 0 -> 1090065 bytes tests/unit/install_test.cpp | 16 ++++++++-------- tests/unit/zip_test.cpp | 2 +- 6 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 tests/testdata/ziptest_dummy-update.zip create mode 100644 tests/testdata/ziptest_fake-update.zip diff --git a/applypatch/imgdiff.cpp b/applypatch/imgdiff.cpp index 91007ac3b..85860281a 100644 --- a/applypatch/imgdiff.cpp +++ b/applypatch/imgdiff.cpp @@ -1038,20 +1038,21 @@ bool ZipModeImage::AddSplitImageFromChunkList(const ZipModeImage& tgt_image, split_tgt_image.Initialize(aligned_tgt_chunks, {}); split_tgt_image.MergeAdjacentNormalChunks(); - // Construct the dummy source file based on the src_ranges. - std::vector src_content; + // Construct the split source file based on the split src ranges. + std::vector split_src_content; for (const auto& r : split_src_ranges) { size_t end = std::min(src_image.file_content_.size(), r.second * BLOCK_SIZE); - src_content.insert(src_content.end(), src_image.file_content_.begin() + r.first * BLOCK_SIZE, - src_image.file_content_.begin() + end); + split_src_content.insert(split_src_content.end(), + src_image.file_content_.begin() + r.first * BLOCK_SIZE, + src_image.file_content_.begin() + end); } // We should not have an empty src in our design; otherwise we will encounter an error in - // bsdiff since src_content.data() == nullptr. - CHECK(!src_content.empty()); + // bsdiff since split_src_content.data() == nullptr. + CHECK(!split_src_content.empty()); ZipModeImage split_src_image(true); - split_src_image.Initialize(split_src_chunks, src_content); + split_src_image.Initialize(split_src_chunks, split_src_content); split_tgt_images->push_back(std::move(split_tgt_image)); split_src_images->push_back(std::move(split_src_image)); diff --git a/applypatch/include/applypatch/imgdiff_image.h b/applypatch/include/applypatch/imgdiff_image.h index 671605160..aa8d129c3 100644 --- a/applypatch/include/applypatch/imgdiff_image.h +++ b/applypatch/include/applypatch/imgdiff_image.h @@ -211,7 +211,7 @@ class ZipModeImage : public Image { bool Initialize(const std::string& filename) override; - // Initialize a dummy ZipModeImage from an existing ImageChunk vector. For src img pieces, we + // Initialize a fake ZipModeImage from an existing ImageChunk vector. For src img pieces, we // reconstruct a new file_content based on the source ranges; but it's not needed for the tgt img // pieces; because for each chunk both the data and their offset within the file are unchanged. void Initialize(const std::vector& chunks, const std::vector& file_content) { @@ -265,7 +265,7 @@ class ZipModeImage : public Image { const std::vector& split_src_images, std::vector& split_src_ranges, size_t total_tgt_size); - // Construct the dummy split images based on the chunks info and source ranges; and move them into + // Construct the fake split images based on the chunks info and source ranges; and move them into // the given vectors. Return true if we add a new split image into |split_tgt_images|, and // false otherwise. static bool AddSplitImageFromChunkList(const ZipModeImage& tgt_image, diff --git a/tests/testdata/ziptest_dummy-update.zip b/tests/testdata/ziptest_dummy-update.zip deleted file mode 100644 index 6976bf155..000000000 Binary files a/tests/testdata/ziptest_dummy-update.zip and /dev/null differ diff --git a/tests/testdata/ziptest_fake-update.zip b/tests/testdata/ziptest_fake-update.zip new file mode 100644 index 000000000..6976bf155 Binary files /dev/null and b/tests/testdata/ziptest_fake-update.zip differ diff --git a/tests/unit/install_test.cpp b/tests/unit/install_test.cpp index 90c4b1409..fc7c2bf2f 100644 --- a/tests/unit/install_test.cpp +++ b/tests/unit/install_test.cpp @@ -76,7 +76,7 @@ TEST(InstallTest, read_metadata_from_package_smoke) { TEST(InstallTest, read_metadata_from_package_no_entry) { TemporaryFile temp_file; - BuildZipArchive({ { "dummy_entry", "" } }, temp_file.release(), kCompressStored); + BuildZipArchive({ { "fake_entry", "" } }, temp_file.release(), kCompressStored); ZipArchiveHandle zip; ASSERT_EQ(0, OpenArchive(temp_file.path, &zip)); @@ -153,7 +153,7 @@ TEST(InstallTest, SetUpNonAbUpdateCommands) { TEST(InstallTest, SetUpNonAbUpdateCommands_MissingUpdateBinary) { TemporaryFile temp_file; // The archive must have something to be opened correctly. - BuildZipArchive({ { "dummy_entry", "" } }, temp_file.release(), kCompressStored); + BuildZipArchive({ { "fake_entry", "" } }, temp_file.release(), kCompressStored); // Missing update binary. ZipArchiveHandle zip; @@ -334,7 +334,7 @@ TEST(InstallTest, CheckPackageMetadata_device_type) { metadata = android::base::Join( std::vector{ "ota-type=BRICK", - "pre-device=dummy_device_type", + "pre-device=fake_device_type", }, "\n"); TestCheckPackageMetadata(metadata, OtaType::BRICK, false); @@ -358,7 +358,7 @@ TEST(InstallTest, CheckPackageMetadata_serial_number_smoke) { std::vector{ "ota-type=BRICK", "pre-device=" + device, - "serialno=dummy_serial", + "serialno=fake_serial", }, "\n"); TestCheckPackageMetadata(metadata, OtaType::BRICK, false); @@ -383,7 +383,7 @@ TEST(InstallTest, CheckPackageMetadata_multiple_serial_number) { ASSERT_NE("", serialno); std::vector serial_numbers; - // Creates a dummy serial number string. + // Creates a fake serial number string. for (char c = 'a'; c <= 'z'; c++) { serial_numbers.emplace_back(serialno.size(), c); } @@ -431,7 +431,7 @@ TEST(InstallTest, CheckPackageMetadata_ab_build_version) { std::vector{ "ota-type=AB", "pre-device=" + device, - "pre-build-incremental=dummy_build", + "pre-build-incremental=fake_build", "post-timestamp=" + std::to_string(std::numeric_limits::max()), }, "\n"); @@ -459,7 +459,7 @@ TEST(InstallTest, CheckPackageMetadata_ab_fingerprint) { std::vector{ "ota-type=AB", "pre-device=" + device, - "pre-build=dummy_build_fingerprint", + "pre-build=fake_build_fingerprint", "post-timestamp=" + std::to_string(std::numeric_limits::max()), }, "\n"); @@ -487,7 +487,7 @@ TEST(InstallTest, CheckPackageMetadata_dynamic_fingerprint) { std::vector{ "ota-type=AB", "pre-device=" + device, - "pre-build=dummy_build_fingerprint", + "pre-build=fake_build_fingerprint", "post-timestamp=" + std::to_string(std::numeric_limits::max()), }, "\n"); diff --git a/tests/unit/zip_test.cpp b/tests/unit/zip_test.cpp index 0753d64e1..ec9585c79 100644 --- a/tests/unit/zip_test.cpp +++ b/tests/unit/zip_test.cpp @@ -28,7 +28,7 @@ #include "otautil/sysutil.h" TEST(ZipTest, OpenFromMemory) { - std::string zip_path = from_testdata_base("ziptest_dummy-update.zip"); + std::string zip_path = from_testdata_base("ziptest_fake-update.zip"); MemMapping map; ASSERT_TRUE(map.MapFile(zip_path)); -- cgit v1.2.3