diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2023-04-26 02:45:43 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-04-26 02:45:43 +0000 |
commit | 2316bf2eafd31305f7e8101b98081f6107dcd7a4 (patch) | |
tree | 65ad0863d6d1dcc2f2c31ba2ef621bffea962fbe | |
parent | 3a4b134e841be2fefea2a6f46cec85ac29089330 (diff) | |
parent | b880578664c9d486b2bae51e540c8e6ff2af8017 (diff) | |
download | core-2316bf2eafd31305f7e8101b98081f6107dcd7a4.tar.gz |
Merge "libsnapshot: Fix test failures on certain configurations." into android12-tests-dev am: b880578664
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2563951
Change-Id: Iefd00dd6629a0850cffb7a4a170d8c831a7c2007
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | fs_mgr/libsnapshot/snapshot.cpp | 3 | ||||
-rw-r--r-- | fs_mgr/libsnapshot/snapshot_test.cpp | 34 | ||||
-rw-r--r-- | fs_mgr/libsnapshot/utility.cpp | 7 | ||||
-rw-r--r-- | fs_mgr/libsnapshot/utility.h | 1 |
4 files changed, 29 insertions, 16 deletions
diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp index 40cb35be1..9a9f400c4 100644 --- a/fs_mgr/libsnapshot/snapshot.cpp +++ b/fs_mgr/libsnapshot/snapshot.cpp @@ -2816,7 +2816,8 @@ Return SnapshotManager::CreateUpdateSnapshots(const DeltaArchiveManifest& manife << " writer.GetCowVersion(): " << writer.GetCowVersion(); bool use_compression = IsCompressionEnabled() && dap_metadata.vabc_enabled() && - !device_->IsRecovery() && cow_format_support; + !device_->IsRecovery() && cow_format_support && + KernelSupportsCompressedSnapshots(); std::string compression_algorithm; if (use_compression) { diff --git a/fs_mgr/libsnapshot/snapshot_test.cpp b/fs_mgr/libsnapshot/snapshot_test.cpp index 3a3aedc57..9291b03f8 100644 --- a/fs_mgr/libsnapshot/snapshot_test.cpp +++ b/fs_mgr/libsnapshot/snapshot_test.cpp @@ -125,6 +125,10 @@ class SnapshotTest : public ::testing::Test { sm->set_use_first_stage_snapuserd(false); } + bool DeviceSupportsCompression() { + return IsCompressionEnabled() && KernelSupportsCompressedSnapshots(); + } + void CleanupTestArtifacts() { // Normally cancelling inside a merge is not allowed. Since these // are tests, we don't care, destroy everything that might exist. @@ -327,7 +331,7 @@ class SnapshotTest : public ::testing::Test { DeltaArchiveManifest manifest; auto dynamic_partition_metadata = manifest.mutable_dynamic_partition_metadata(); - dynamic_partition_metadata->set_vabc_enabled(IsCompressionEnabled()); + dynamic_partition_metadata->set_vabc_enabled(DeviceSupportsCompression()); dynamic_partition_metadata->set_cow_version(android::snapshot::kCowVersionMajor); auto group = dynamic_partition_metadata->add_groups(); @@ -366,7 +370,7 @@ class SnapshotTest : public ::testing::Test { if (!res) { return res; } - } else if (!IsCompressionEnabled()) { + } else if (!DeviceSupportsCompression()) { std::string ignore; if (!MapUpdateSnapshot("test_partition_b", &ignore)) { return AssertionFailure() << "Failed to map test_partition_b"; @@ -425,7 +429,7 @@ TEST_F(SnapshotTest, CreateSnapshot) { ASSERT_TRUE(AcquireLock()); PartitionCowCreator cow_creator; - cow_creator.compression_enabled = IsCompressionEnabled(); + cow_creator.compression_enabled = DeviceSupportsCompression(); if (cow_creator.compression_enabled) { cow_creator.compression_algorithm = "gz"; } else { @@ -466,7 +470,7 @@ TEST_F(SnapshotTest, MapSnapshot) { ASSERT_TRUE(AcquireLock()); PartitionCowCreator cow_creator; - cow_creator.compression_enabled = IsCompressionEnabled(); + cow_creator.compression_enabled = DeviceSupportsCompression(); static const uint64_t kDeviceSize = 1024 * 1024; SnapshotStatus status; @@ -585,7 +589,7 @@ TEST_F(SnapshotTest, FirstStageMountAndMerge) { SnapshotStatus status; ASSERT_TRUE(init->ReadSnapshotStatus(lock_.get(), "test_partition_b", &status)); ASSERT_EQ(status.state(), SnapshotState::CREATED); - if (IsCompressionEnabled()) { + if (DeviceSupportsCompression()) { ASSERT_EQ(status.compression_algorithm(), "gz"); } else { ASSERT_EQ(status.compression_algorithm(), "none"); @@ -855,7 +859,7 @@ class SnapshotUpdateTest : public SnapshotTest { opener_ = std::make_unique<TestPartitionOpener>(fake_super); auto dynamic_partition_metadata = manifest_.mutable_dynamic_partition_metadata(); - dynamic_partition_metadata->set_vabc_enabled(IsCompressionEnabled()); + dynamic_partition_metadata->set_vabc_enabled(DeviceSupportsCompression()); dynamic_partition_metadata->set_cow_version(android::snapshot::kCowVersionMajor); // Create a fake update package metadata. @@ -975,7 +979,7 @@ class SnapshotUpdateTest : public SnapshotTest { } AssertionResult MapOneUpdateSnapshot(const std::string& name) { - if (IsCompressionEnabled()) { + if (DeviceSupportsCompression()) { std::unique_ptr<ISnapshotWriter> writer; return MapUpdateSnapshot(name, &writer); } else { @@ -985,7 +989,7 @@ class SnapshotUpdateTest : public SnapshotTest { } AssertionResult WriteSnapshotAndHash(const std::string& name) { - if (IsCompressionEnabled()) { + if (DeviceSupportsCompression()) { std::unique_ptr<ISnapshotWriter> writer; auto res = MapUpdateSnapshot(name, &writer); if (!res) { @@ -1158,7 +1162,7 @@ TEST_F(SnapshotUpdateTest, FullUpdateFlow) { // Initiate the merge and wait for it to be completed. ASSERT_TRUE(init->InitiateMerge()); - ASSERT_EQ(init->IsSnapuserdRequired(), IsCompressionEnabled()); + ASSERT_EQ(init->IsSnapuserdRequired(), DeviceSupportsCompression()); { // We should have started in SECOND_PHASE since nothing shrinks. ASSERT_TRUE(AcquireLock()); @@ -1187,7 +1191,7 @@ TEST_F(SnapshotUpdateTest, FullUpdateFlow) { // Test that shrinking and growing partitions at the same time is handled // correctly in VABC. TEST_F(SnapshotUpdateTest, SpaceSwapUpdate) { - if (!IsCompressionEnabled()) { + if (!DeviceSupportsCompression()) { // b/179111359 GTEST_SKIP() << "Skipping Virtual A/B Compression test"; } @@ -1255,7 +1259,7 @@ TEST_F(SnapshotUpdateTest, SpaceSwapUpdate) { // Initiate the merge and wait for it to be completed. ASSERT_TRUE(init->InitiateMerge()); - ASSERT_EQ(init->IsSnapuserdRequired(), IsCompressionEnabled()); + ASSERT_EQ(init->IsSnapuserdRequired(), DeviceSupportsCompression()); { // Check that the merge phase is FIRST_PHASE until at least one call // to ProcessUpdateState() occurs. @@ -1965,8 +1969,8 @@ TEST_F(SnapshotUpdateTest, DataWipeWithStaleSnapshots) { ASSERT_TRUE(AcquireLock()); PartitionCowCreator cow_creator = { - .compression_enabled = IsCompressionEnabled(), - .compression_algorithm = IsCompressionEnabled() ? "gz" : "none", + .compression_enabled = DeviceSupportsCompression(), + .compression_algorithm = DeviceSupportsCompression() ? "gz" : "none", }; SnapshotStatus status; status.set_name("sys_a"); @@ -2060,7 +2064,7 @@ TEST_F(SnapshotUpdateTest, Hashtree) { // Test for overflow bit after update TEST_F(SnapshotUpdateTest, Overflow) { - if (IsCompressionEnabled()) { + if (DeviceSupportsCompression()) { GTEST_SKIP() << "No overflow bit set for userspace COWs"; } @@ -2200,7 +2204,7 @@ class AutoKill final { }; TEST_F(SnapshotUpdateTest, DaemonTransition) { - if (!IsCompressionEnabled()) { + if (!DeviceSupportsCompression()) { GTEST_SKIP() << "Skipping Virtual A/B Compression test"; } diff --git a/fs_mgr/libsnapshot/utility.cpp b/fs_mgr/libsnapshot/utility.cpp index 4a2af1c10..e46bffbde 100644 --- a/fs_mgr/libsnapshot/utility.cpp +++ b/fs_mgr/libsnapshot/utility.cpp @@ -25,7 +25,9 @@ #include <android-base/properties.h> #include <android-base/strings.h> #include <fs_mgr/roots.h> +#include <libdm/dm.h> +using android::dm::DeviceMapper; using android::dm::kSectorSize; using android::fiemap::FiemapStatus; using android::fs_mgr::EnsurePathMounted; @@ -195,5 +197,10 @@ std::string GetOtherPartitionName(const std::string& name) { return name.substr(0, name.size() - suffix.size()) + other_suffix; } +bool KernelSupportsCompressedSnapshots() { + auto& dm = DeviceMapper::Instance(); + return dm.GetTargetByName("user", nullptr); +} + } // namespace snapshot } // namespace android diff --git a/fs_mgr/libsnapshot/utility.h b/fs_mgr/libsnapshot/utility.h index 671de9dbc..b0e565cfe 100644 --- a/fs_mgr/libsnapshot/utility.h +++ b/fs_mgr/libsnapshot/utility.h @@ -129,6 +129,7 @@ std::ostream& operator<<(std::ostream& os, const Now&); void AppendExtent(google::protobuf::RepeatedPtrField<chromeos_update_engine::Extent>* extents, uint64_t start_block, uint64_t num_blocks); +bool KernelSupportsCompressedSnapshots(); bool IsCompressionEnabled(); // Swap the suffix of a partition name. |