diff --git a/fs_mgr/libsnapshot/snapshot_metadata_updater_test.cpp b/fs_mgr/libsnapshot/snapshot_metadata_updater_test.cpp index 337be4f68..5530e59f0 100644 --- a/fs_mgr/libsnapshot/snapshot_metadata_updater_test.cpp +++ b/fs_mgr/libsnapshot/snapshot_metadata_updater_test.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -42,6 +43,10 @@ namespace snapshot { class SnapshotMetadataUpdaterTest : public ::testing::TestWithParam { public: + SnapshotMetadataUpdaterTest() { + is_virtual_ab_ = android::base::GetBoolProperty("ro.virtual_ab.enabled", false); + } + void SetUp() override { target_slot_ = GetParam(); target_suffix_ = SlotSuffixForSlotNumber(target_slot_); @@ -122,6 +127,7 @@ class SnapshotMetadataUpdaterTest : public ::testing::TestWithParam { << "."; } + bool is_virtual_ab_; std::unique_ptr builder_; uint32_t target_slot_; std::string target_suffix_; diff --git a/fs_mgr/libsnapshot/snapshot_test.cpp b/fs_mgr/libsnapshot/snapshot_test.cpp index 7de37dbd9..634e0b491 100644 --- a/fs_mgr/libsnapshot/snapshot_test.cpp +++ b/fs_mgr/libsnapshot/snapshot_test.cpp @@ -78,7 +78,9 @@ void MountMetadata(); class SnapshotTest : public ::testing::Test { public: - SnapshotTest() : dm_(DeviceMapper::Instance()) {} + SnapshotTest() : dm_(DeviceMapper::Instance()) { + is_virtual_ab_ = android::base::GetBoolProperty("ro.virtual_ab.enabled", false); + } // This is exposed for main. void Cleanup() { @@ -88,6 +90,8 @@ class SnapshotTest : public ::testing::Test { protected: void SetUp() override { + if (!is_virtual_ab_) GTEST_SKIP() << "Test for Virtual A/B devices only"; + SnapshotTestPropertyFetcher::SetUp(); InitializeState(); CleanupTestArtifacts(); @@ -97,6 +101,8 @@ class SnapshotTest : public ::testing::Test { } void TearDown() override { + if (!is_virtual_ab_) return; + lock_ = nullptr; CleanupTestArtifacts(); @@ -329,6 +335,7 @@ class SnapshotTest : public ::testing::Test { return AssertionSuccess(); } + bool is_virtual_ab_; DeviceMapper& dm_; std::unique_ptr lock_; android::fiemap::IImageManager* image_manager_ = nullptr; @@ -754,6 +761,8 @@ INSTANTIATE_TEST_SUITE_P( class SnapshotUpdateTest : public SnapshotTest { public: void SetUp() override { + if (!is_virtual_ab_) GTEST_SKIP() << "Test for Virtual A/B devices only"; + SnapshotTest::SetUp(); Cleanup(); @@ -813,6 +822,8 @@ class SnapshotUpdateTest : public SnapshotTest { } } void TearDown() override { + if (!is_virtual_ab_) return; + Cleanup(); SnapshotTest::TearDown(); } @@ -1625,6 +1636,8 @@ class FlashAfterUpdateTest : public SnapshotUpdateTest, }; TEST_P(FlashAfterUpdateTest, FlashSlotAfterUpdate) { + if (!is_virtual_ab_) GTEST_SKIP() << "Test for Virtual A/B devices only"; + // OTA client blindly unmaps all partitions that are possibly mapped. for (const auto& name : {"sys_b", "vnd_b", "prd_b"}) { ASSERT_TRUE(sm->UnmapUpdateSnapshot(name)); @@ -1718,13 +1731,17 @@ INSTANTIATE_TEST_SUITE_P(Snapshot, FlashAfterUpdateTest, Combine(Values(0, 1), B // Test behavior of ImageManager::Create on low space scenario. These tests assumes image manager // uses /data as backup device. class ImageManagerTest : public SnapshotTest, public WithParamInterface { - public: + protected: void SetUp() override { + if (!is_virtual_ab_) GTEST_SKIP() << "Test for Virtual A/B devices only"; + SnapshotTest::SetUp(); userdata_ = std::make_unique(); ASSERT_TRUE(userdata_->Init(GetParam())); } void TearDown() override { + if (!is_virtual_ab_) return; + EXPECT_TRUE(!image_manager_->BackingImageExists(kImageName) || image_manager_->DeleteBackingImage(kImageName)); }