diff options
author | Yifan Hong <elsk@google.com> | 2020-08-13 13:59:54 -0700 |
---|---|---|
committer | Treehugger Robot <treehugger-gerrit@google.com> | 2020-08-19 18:42:31 +0000 |
commit | 8d6df9ac7a70f4b07ebb86f50fb3548b693acad5 (patch) | |
tree | 0173db33bc1bd984878ca8bd254a8f0b4e3b051d /dynamic_partition_control_android_unittest.cc | |
parent | b753e0e9258170dce7c62733eed78e616b4a37b2 (diff) |
Check allocatable space correctly when sideloading on VAB
On a device with Virtual A/B, when sideloading and there's
not enough space in super partition to hold CoW, update_engine
falls back to overwriting all source partitions. In that case,
the allocatable space should be the whole super partition, not
a half of it.
Also update doc comments.
Test: unit test. RecoveryErrorShouldDeleteSource fails without the patch
but succeeds with the patch.
Bug: 163613538
Change-Id: I6bd6895a7eabeb4e8436e57b0ac6830c11d1e98f
Diffstat (limited to 'dynamic_partition_control_android_unittest.cc')
-rw-r--r-- | dynamic_partition_control_android_unittest.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/dynamic_partition_control_android_unittest.cc b/dynamic_partition_control_android_unittest.cc index 4154b36c..223e177d 100644 --- a/dynamic_partition_control_android_unittest.cc +++ b/dynamic_partition_control_android_unittest.cc @@ -113,21 +113,24 @@ class DynamicPartitionControlAndroidTest : public ::testing::Test { // |slot|. void SetMetadata(uint32_t slot, const PartitionSuffixSizes& sizes, - uint32_t partition_attr = 0) { + uint32_t partition_attr = 0, + uint64_t super_size = kDefaultSuperSize) { EXPECT_CALL(dynamicControl(), LoadMetadataBuilder(GetSuperDevice(slot), slot)) .Times(AnyNumber()) - .WillRepeatedly(Invoke([sizes, partition_attr](auto, auto) { + .WillRepeatedly(Invoke([=](auto, auto) { return NewFakeMetadata(PartitionSuffixSizesToManifest(sizes), - partition_attr); + partition_attr, + super_size); })); EXPECT_CALL(dynamicControl(), LoadMetadataBuilder(GetSuperDevice(slot), slot, _)) .Times(AnyNumber()) - .WillRepeatedly(Invoke([sizes, partition_attr](auto, auto, auto) { + .WillRepeatedly(Invoke([=](auto, auto, auto) { return NewFakeMetadata(PartitionSuffixSizesToManifest(sizes), - partition_attr); + partition_attr, + super_size); })); } @@ -1006,8 +1009,11 @@ TEST_P(SnapshotPartitionTestP, RecoveryErrorShouldDeleteSource) { return dynamicControl().RealPrepareDynamicPartitionsForUpdate( source_slot, target_slot, manifest, delete_source); })); + // Only one slot of space in super + uint64_t super_size = kDefaultGroupSize + 1_MiB; // Expectation on PrepareDynamicPartitionsForUpdate - SetMetadata(source(), {{S("system"), 2_GiB}, {S("vendor"), 1_GiB}}); + SetMetadata( + source(), {{S("system"), 2_GiB}, {S("vendor"), 1_GiB}}, 0, super_size); ExpectUnmap({T("system"), T("vendor")}); // Expect that the source partitions aren't present in target super metadata. ExpectStoreMetadata({{T("system"), 3_GiB}, {T("vendor"), 1_GiB}}); |