summaryrefslogtreecommitdiff
path: root/aosp/dynamic_partition_control_android_unittest.cc
diff options
context:
space:
mode:
authorKelvin Zhang <zhangkelvin@google.com>2020-11-05 13:52:00 -0500
committerKelvin Zhang <zhangkelvin@google.com>2020-11-23 14:49:17 -0500
commit91d95fa9454d56f486e49742039ddb92e10cf054 (patch)
tree12fd299e1333feb82157b245d8fd38e08f0967e6 /aosp/dynamic_partition_control_android_unittest.cc
parent098e79a0c348d2636fd102db081b4e03cb30ef9d (diff)
Do not map dynamic partitions on VABC devices
With VABC, we no longer need to map all partitions before reading/writing, so don't try to map them. 1. modify GetPartitionDevice to return empty path for target partitions on VABC 2. Add a separate GetMountableTargetDevice for obtaining a mountable device path, specifically for postinstall Test: treehugger Change-Id: Ib1f608914fc49c677ce7389140ca79b028171191
Diffstat (limited to 'aosp/dynamic_partition_control_android_unittest.cc')
-rw-r--r--aosp/dynamic_partition_control_android_unittest.cc84
1 files changed, 84 insertions, 0 deletions
diff --git a/aosp/dynamic_partition_control_android_unittest.cc b/aosp/dynamic_partition_control_android_unittest.cc
index 7e751dbf..af5ae2c0 100644
--- a/aosp/dynamic_partition_control_android_unittest.cc
+++ b/aosp/dynamic_partition_control_android_unittest.cc
@@ -16,6 +16,7 @@
#include "update_engine/aosp/dynamic_partition_control_android.h"
+#include <algorithm>
#include <set>
#include <vector>
@@ -38,6 +39,7 @@ using std::string;
using testing::_;
using testing::AnyNumber;
using testing::AnyOf;
+using testing::AtLeast;
using testing::Invoke;
using testing::NiceMock;
using testing::Not;
@@ -55,6 +57,8 @@ class DynamicPartitionControlAndroidTest : public ::testing::Test {
.WillByDefault(Return(FeatureFlag(FeatureFlag::Value::LAUNCH)));
ON_CALL(dynamicControl(), GetVirtualAbFeatureFlag())
.WillByDefault(Return(FeatureFlag(FeatureFlag::Value::NONE)));
+ ON_CALL(dynamicControl(), GetVirtualAbCompressionFeatureFlag())
+ .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::NONE)));
ON_CALL(dynamicControl(), GetDeviceDir(_))
.WillByDefault(Invoke([](auto path) {
@@ -217,6 +221,8 @@ class DynamicPartitionControlAndroidTestP
void SetUp() override {
DynamicPartitionControlAndroidTest::SetUp();
SetSlots(GetParam());
+ dynamicControl().SetSourceSlot(source());
+ dynamicControl().SetTargetSlot(target());
}
};
@@ -386,6 +392,84 @@ TEST_P(DynamicPartitionControlAndroidTestP,
EXPECT_EQ(GetDevice(T("bar")), bar_device);
}
+TEST_P(DynamicPartitionControlAndroidTestP, GetMountableDevicePath) {
+ ON_CALL(dynamicControl(), GetDynamicPartitionsFeatureFlag())
+ .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::LAUNCH)));
+ ON_CALL(dynamicControl(), GetVirtualAbFeatureFlag())
+ .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::LAUNCH)));
+ ON_CALL(dynamicControl(), GetVirtualAbCompressionFeatureFlag())
+ .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::NONE)));
+ ON_CALL(dynamicControl(), IsDynamicPartition(_)).WillByDefault(Return(true));
+
+ EXPECT_CALL(dynamicControl(),
+ DeviceExists(AnyOf(GetDevice(S("vendor")),
+ GetDevice(T("vendor")),
+ GetDevice(S("system")),
+ GetDevice(T("system")))))
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(
+ dynamicControl(),
+ GetState(AnyOf(S("vendor"), T("vendor"), S("system"), T("system"))))
+ .WillRepeatedly(Return(DmDeviceState::ACTIVE));
+
+ SetMetadata(source(), {{S("system"), 2_GiB}, {S("vendor"), 1_GiB}});
+ SetMetadata(target(), {{T("system"), 2_GiB}, {T("vendor"), 1_GiB}});
+ std::string device;
+ ASSERT_TRUE(dynamicControl().GetPartitionDevice(
+ "system", source(), source(), &device));
+ ASSERT_EQ(GetDmDevice(S("system")), device);
+
+ ASSERT_TRUE(dynamicControl().GetPartitionDevice(
+ "system", target(), source(), &device));
+ ASSERT_EQ(GetDevice(T("system")), device);
+
+ // If VABC is disabled, mountable device path should be same as device path.
+ auto device_info =
+ dynamicControl().GetPartitionDevice("system", target(), source());
+ ASSERT_TRUE(device_info.has_value());
+ ASSERT_EQ(device_info->mountable_device_path, device);
+}
+
+TEST_P(DynamicPartitionControlAndroidTestP, GetMountableDevicePathVABC) {
+ ON_CALL(dynamicControl(), GetDynamicPartitionsFeatureFlag())
+ .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::LAUNCH)));
+ ON_CALL(dynamicControl(), GetVirtualAbFeatureFlag())
+ .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::LAUNCH)));
+ ON_CALL(dynamicControl(), GetVirtualAbCompressionFeatureFlag())
+ .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::LAUNCH)));
+ EXPECT_CALL(dynamicControl(), IsDynamicPartition(_))
+ .Times(AtLeast(1))
+ .WillRepeatedly(Return(true));
+
+ EXPECT_CALL(dynamicControl(),
+ DeviceExists(AnyOf(GetDevice(S("vendor")),
+ GetDevice(T("vendor")),
+ GetDevice(S("system")),
+ GetDevice(T("system")))))
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(
+ dynamicControl(),
+ GetState(AnyOf(S("vendor"), T("vendor"), S("system"), T("system"))))
+ .WillRepeatedly(Return(DmDeviceState::ACTIVE));
+
+ SetMetadata(source(), {{S("system"), 2_GiB}, {S("vendor"), 1_GiB}});
+ SetMetadata(target(), {{T("system"), 2_GiB}, {T("vendor"), 1_GiB}});
+
+ std::string device;
+ ASSERT_TRUE(dynamicControl().GetPartitionDevice(
+ "system", source(), source(), &device));
+ ASSERT_EQ(GetDmDevice(S("system")), device);
+
+ ASSERT_TRUE(dynamicControl().GetPartitionDevice(
+ "system", target(), source(), &device));
+ ASSERT_EQ("", device);
+
+ auto device_info =
+ dynamicControl().GetPartitionDevice("system", target(), source());
+ ASSERT_TRUE(device_info.has_value());
+ ASSERT_EQ(device_info->mountable_device_path, GetDevice(T("system")));
+}
+
TEST_P(DynamicPartitionControlAndroidTestP,
GetPartitionDeviceWhenResumingUpdate) {
// Static partition bar_{a,b} exists.