diff options
author | Akilesh Kailash <akailash@google.com> | 2022-06-08 04:52:29 +0000 |
---|---|---|
committer | Akilesh Kailash <akailash@google.com> | 2022-06-16 22:56:14 +0000 |
commit | ae04e7ede1d6e5dd914e3be099b85b586cefa905 (patch) | |
tree | 9c2b3ceec671c438d6142f295dea1815f0fa98d3 | |
parent | 18cf62712cf3fd1197ca15e2a7d4d1dd67131213 (diff) | |
download | core-ae04e7ede1d6e5dd914e3be099b85b586cefa905.tar.gz |
libsnapshot: Fix vts_libsnapshot_test for GRF with Vendor on S
If the vendor partition is on S and system partition is on T,
certain tests in vts_libsnapshot_test used to fail. This is primarily
because of inconsistent check between daemon and vts test.
vts test checks the userspace.snapshots.enabled property which is true on T
but never checks if the underlying vendor partition is on S. Hence,
vts test will enable userspace snapshots. However, daemon checks
the vendor partition and disables userspace snapshots thereby
leading to inconsistency.
This is only a problem on vts tests. The underlying OTA on devices
works fine as we have the vendor partition check.
Bug: 236311008
Test: vts_libsnapshot_test on S vendor and T system
vts_libsnapshot_test on T vendor and T system
Ignore-AOSP-First: cherry-pick from aosp
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Iad4f299bd2e07c9c01f5fbee6a20e2f01bf1778a
-rw-r--r-- | fs_mgr/libsnapshot/snapshot.cpp | 17 | ||||
-rw-r--r-- | fs_mgr/libsnapshot/snapshot_test.cpp | 23 |
2 files changed, 33 insertions, 7 deletions
diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp index a83f535b2..019b64a44 100644 --- a/fs_mgr/libsnapshot/snapshot.cpp +++ b/fs_mgr/libsnapshot/snapshot.cpp @@ -3273,8 +3273,21 @@ Return SnapshotManager::CreateUpdateSnapshots(const DeltaArchiveManifest& manife snapuserd_client_ = nullptr; } } else { - status.set_userspace_snapshots(!IsDmSnapshotTestingEnabled()); - if (IsDmSnapshotTestingEnabled()) { + bool userSnapshotsEnabled = true; + const std::string UNKNOWN = "unknown"; + const std::string vendor_release = android::base::GetProperty( + "ro.vendor.build.version.release_or_codename", UNKNOWN); + + // No user-space snapshots if vendor partition is on Android 12 + if (vendor_release.find("12") != std::string::npos) { + LOG(INFO) << "Userspace snapshots disabled as vendor partition is on Android: " + << vendor_release; + userSnapshotsEnabled = false; + } + + userSnapshotsEnabled = (userSnapshotsEnabled && !IsDmSnapshotTestingEnabled()); + status.set_userspace_snapshots(userSnapshotsEnabled); + if (!userSnapshotsEnabled) { is_snapshot_userspace_ = false; LOG(INFO) << "User-space snapshots disabled for testing"; } else { diff --git a/fs_mgr/libsnapshot/snapshot_test.cpp b/fs_mgr/libsnapshot/snapshot_test.cpp index 36abf712b..6a348b4e5 100644 --- a/fs_mgr/libsnapshot/snapshot_test.cpp +++ b/fs_mgr/libsnapshot/snapshot_test.cpp @@ -91,7 +91,7 @@ std::string fake_super; void MountMetadata(); bool ShouldUseCompression(); -bool ShouldUseUserspaceSnapshots(); +bool IsDaemonRequired(); class SnapshotTest : public ::testing::Test { public: @@ -1208,7 +1208,7 @@ TEST_F(SnapshotUpdateTest, FullUpdateFlow) { // Initiate the merge and wait for it to be completed. ASSERT_TRUE(init->InitiateMerge()); - ASSERT_EQ(init->IsSnapuserdRequired(), ShouldUseUserspaceSnapshots()); + ASSERT_EQ(init->IsSnapuserdRequired(), IsDaemonRequired()); { // We should have started in SECOND_PHASE since nothing shrinks. ASSERT_TRUE(AcquireLock()); @@ -1342,7 +1342,7 @@ TEST_F(SnapshotUpdateTest, SpaceSwapUpdate) { // Initiate the merge and wait for it to be completed. ASSERT_TRUE(init->InitiateMerge()); - ASSERT_EQ(init->IsSnapuserdRequired(), ShouldUseUserspaceSnapshots()); + ASSERT_EQ(init->IsSnapuserdRequired(), IsDaemonRequired()); { // Check that the merge phase is FIRST_PHASE until at least one call // to ProcessUpdateState() occurs. @@ -1450,7 +1450,7 @@ TEST_F(SnapshotUpdateTest, ConsistencyCheckResume) { // Initiate the merge and wait for it to be completed. ASSERT_TRUE(init->InitiateMerge()); - ASSERT_EQ(init->IsSnapuserdRequired(), ShouldUseUserspaceSnapshots()); + ASSERT_EQ(init->IsSnapuserdRequired(), IsDaemonRequired()); { // Check that the merge phase is FIRST_PHASE until at least one call // to ProcessUpdateState() occurs. @@ -2750,13 +2750,26 @@ void SnapshotTestEnvironment::TearDown() { } } -bool ShouldUseUserspaceSnapshots() { +bool IsDaemonRequired() { if (FLAGS_force_config == "dmsnap") { return false; } + + const std::string UNKNOWN = "unknown"; + const std::string vendor_release = + android::base::GetProperty("ro.vendor.build.version.release_or_codename", UNKNOWN); + + // No userspace snapshots if vendor partition is on Android 12 + // However, for GRF devices, snapuserd daemon will be on + // vendor ramdisk in Android 12. + if (vendor_release.find("12") != std::string::npos) { + return true; + } + if (!FLAGS_force_config.empty()) { return true; } + return IsUserspaceSnapshotsEnabled(); } |