From aedfef3c2f2834645654833bae6fd1daf6ca1040 Mon Sep 17 00:00:00 2001 From: Nikita Ioffe Date: Wed, 28 Apr 2021 13:54:14 +0100 Subject: Don't call into apexservice if device uses flattened apexes If device doesn't support updatable apexes (a.k.a. uses flattened apexes), then it won't have compressed apexes, so there is no need calling into apexd. Test: atest update_engine_unittests:ApexHandlerAndroidTest Test: build and flash aosp_cf_x86_phone_noapex-userdebug Test: m dist Test: python3 system/update_engine/scripts/update_device.py --file out/target/product/vsoc_x86_noapex/aosp_cf_x86_phone_noapex-ota-eng.ioffe.zip Test: checked OTA was successfully staged Bug: 185862111 Change-Id: Ibf9db757f3af37d23fb8248108b2b6d22c95dec7 --- aosp/apex_handler_android_unittest.cc | 39 ++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'aosp/apex_handler_android_unittest.cc') diff --git a/aosp/apex_handler_android_unittest.cc b/aosp/apex_handler_android_unittest.cc index 981ae9dd..847ccaad 100644 --- a/aosp/apex_handler_android_unittest.cc +++ b/aosp/apex_handler_android_unittest.cc @@ -41,7 +41,7 @@ ApexInfo CreateApexInfo(const std::string& package_name, return std::move(result); } -TEST(ApexHandlerAndroidTest, CalculateSize) { +TEST(ApexHandlerAndroidTest, CalculateSizeUpdatableApex) { ApexHandlerAndroid apex_handler; std::vector apex_infos; ApexInfo compressed_apex_1 = CreateApexInfo("sample1", 1, true, 1); @@ -52,10 +52,10 @@ TEST(ApexHandlerAndroidTest, CalculateSize) { apex_infos.push_back(uncompressed_apex); auto result = apex_handler.CalculateSize(apex_infos); ASSERT_TRUE(result.ok()); - EXPECT_EQ(*result, 3u); + ASSERT_EQ(*result, 3u); } -TEST(ApexHandlerAndroidTest, AllocateSpace) { +TEST(ApexHandlerAndroidTest, AllocateSpaceUpdatableApex) { ApexHandlerAndroid apex_handler; std::vector apex_infos; ApexInfo compressed_apex_1 = CreateApexInfo("sample1", 1, true, 1); @@ -64,10 +64,39 @@ TEST(ApexHandlerAndroidTest, AllocateSpace) { apex_infos.push_back(compressed_apex_1); apex_infos.push_back(compressed_apex_2); apex_infos.push_back(uncompressed_apex); - EXPECT_TRUE(apex_handler.AllocateSpace(apex_infos)); + ASSERT_TRUE(apex_handler.AllocateSpace(apex_infos)); // Should be able to pass empty list - EXPECT_TRUE(apex_handler.AllocateSpace({})); + ASSERT_TRUE(apex_handler.AllocateSpace({})); +} + +TEST(ApexHandlerAndroidTest, CalculateSizeFlattenedApex) { + FlattenedApexHandlerAndroid apex_handler; + std::vector apex_infos; + ApexInfo compressed_apex_1 = CreateApexInfo("sample1", 1, true, 1); + ApexInfo compressed_apex_2 = CreateApexInfo("sample2", 2, true, 2); + ApexInfo uncompressed_apex = CreateApexInfo("uncompressed", 1, false, 4); + apex_infos.push_back(compressed_apex_1); + apex_infos.push_back(compressed_apex_2); + apex_infos.push_back(uncompressed_apex); + auto result = apex_handler.CalculateSize(apex_infos); + ASSERT_TRUE(result.ok()); + ASSERT_EQ(*result, 0u); +} + +TEST(ApexHandlerAndroidTest, AllocateSpaceFlattenedApex) { + FlattenedApexHandlerAndroid apex_handler; + std::vector apex_infos; + ApexInfo compressed_apex_1 = CreateApexInfo("sample1", 1, true, 1); + ApexInfo compressed_apex_2 = CreateApexInfo("sample2", 2, true, 2); + ApexInfo uncompressed_apex = CreateApexInfo("uncompressed", 1, false, 4); + apex_infos.push_back(compressed_apex_1); + apex_infos.push_back(compressed_apex_2); + apex_infos.push_back(uncompressed_apex); + ASSERT_TRUE(apex_handler.AllocateSpace(apex_infos)); + + // Should be able to pass empty list + ASSERT_TRUE(apex_handler.AllocateSpace({})); } } // namespace chromeos_update_engine -- cgit v1.2.3