diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/host/imgdiff_test.cpp | 1 | ||||
-rw-r--r-- | tests/unit/install_test.cpp | 44 | ||||
-rw-r--r-- | tests/unit/package_test.cpp | 2 | ||||
-rw-r--r-- | tests/unit/zip_test.cpp | 4 |
4 files changed, 39 insertions, 12 deletions
diff --git a/tests/unit/host/imgdiff_test.cpp b/tests/unit/host/imgdiff_test.cpp index e76ccbdfb..978ac7c2b 100644 --- a/tests/unit/host/imgdiff_test.cpp +++ b/tests/unit/host/imgdiff_test.cpp @@ -35,7 +35,6 @@ using android::base::get_unaligned; -// Sanity check for the given imgdiff patch header. static void verify_patch_header(const std::string& patch, size_t* num_normal, size_t* num_raw, size_t* num_deflate) { const size_t size = patch.size(); diff --git a/tests/unit/install_test.cpp b/tests/unit/install_test.cpp index ee753494c..c3415479d 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; @@ -190,7 +190,7 @@ static void VerifyAbUpdateCommands(const std::string& serialno, bool success = t ZipArchiveHandle zip; ASSERT_EQ(0, OpenArchive(temp_file.path, &zip)); - ZipEntry payload_entry; + ZipEntry64 payload_entry; ASSERT_EQ(0, FindEntry(zip, "payload.bin", &payload_entry)); std::map<std::string, std::string> metadata; @@ -334,7 +334,7 @@ TEST(InstallTest, CheckPackageMetadata_device_type) { metadata = android::base::Join( std::vector<std::string>{ "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<std::string>{ "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<std::string> 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<std::string>{ "ota-type=AB", "pre-device=" + device, - "pre-build-incremental=dummy_build", + "pre-build-incremental=fake_build", "post-timestamp=" + std::to_string(std::numeric_limits<int64_t>::max()), }, "\n"); @@ -459,7 +459,35 @@ TEST(InstallTest, CheckPackageMetadata_ab_fingerprint) { std::vector<std::string>{ "ota-type=AB", "pre-device=" + device, - "pre-build=dummy_build_fingerprint", + "pre-build=fake_build_fingerprint", + "post-timestamp=" + std::to_string(std::numeric_limits<int64_t>::max()), + }, + "\n"); + TestCheckPackageMetadata(metadata, OtaType::AB, false); +} + +TEST(InstallTest, CheckPackageMetadata_dynamic_fingerprint) { + std::string device = android::base::GetProperty("ro.product.device", ""); + ASSERT_FALSE(device.empty()); + + std::string finger_print = android::base::GetProperty("ro.build.fingerprint", ""); + ASSERT_FALSE(finger_print.empty()); + + std::string metadata = android::base::Join( + std::vector<std::string>{ + "ota-type=AB", + "pre-device=please|work|" + device + "|please|work", + "pre-build=" + finger_print = "pass|this|test", + "post-timestamp=" + std::to_string(std::numeric_limits<int64_t>::max()), + }, + "\n"); + TestCheckPackageMetadata(metadata, OtaType::AB, true); + + metadata = android::base::Join( + std::vector<std::string>{ + "ota-type=AB", + "pre-device=" + device, + "pre-build=fake_build_fingerprint", "post-timestamp=" + std::to_string(std::numeric_limits<int64_t>::max()), }, "\n"); diff --git a/tests/unit/package_test.cpp b/tests/unit/package_test.cpp index 5e31f7fa5..164a93d57 100644 --- a/tests/unit/package_test.cpp +++ b/tests/unit/package_test.cpp @@ -106,7 +106,7 @@ TEST_F(PackageTest, GetZipArchiveHandle_extract_entry) { // Check that we can extract one zip entry. std::string_view entry_name = "dir1/file3.txt"; - ZipEntry entry; + ZipEntry64 entry; ASSERT_EQ(0, FindEntry(zip, entry_name, &entry)); std::vector<uint8_t> extracted(entry_name.size()); diff --git a/tests/unit/zip_test.cpp b/tests/unit/zip_test.cpp index 0753d64e1..e065bb859 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)); @@ -37,7 +37,7 @@ TEST(ZipTest, OpenFromMemory) { ASSERT_EQ(0, OpenArchiveFromMemory(map.addr, map.length, zip_path.c_str(), &handle)); static constexpr const char* BINARY_PATH = "META-INF/com/google/android/update-binary"; - ZipEntry binary_entry; + ZipEntry64 binary_entry; // Make sure the package opens correctly and its entry can be read. ASSERT_EQ(0, FindEntry(handle, BINARY_PATH, &binary_entry)); |