From f5de989a55c239d6091264a912c43b98f37c004e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 6 May 2019 16:59:41 -0700 Subject: [PATCH] Add a liblp test that we can parse the device's super partition. Bug: 132112489 Test: liblp_test gtest Change-Id: I1c0950dc30f42cd232e0616191d1365cdfc6512d --- fs_mgr/liblp/io_test.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fs_mgr/liblp/io_test.cpp b/fs_mgr/liblp/io_test.cpp index 8fc02cbde..fcef1f0d0 100644 --- a/fs_mgr/liblp/io_test.cpp +++ b/fs_mgr/liblp/io_test.cpp @@ -21,6 +21,8 @@ #include #include +#include +#include #include #include @@ -702,3 +704,19 @@ TEST(liblp, UpdateNonRetrofit) { ASSERT_EQ(updated->block_devices.size(), static_cast(1)); EXPECT_EQ(GetBlockDevicePartitionName(updated->block_devices[0]), "super"); } + +TEST(liblp, ReadSuperPartition) { + auto slot_suffix = fs_mgr_get_slot_suffix(); + auto slot_number = SlotNumberForSlotSuffix(slot_suffix); + auto super_name = fs_mgr_get_super_partition_name(slot_number); + auto metadata = ReadMetadata(super_name, slot_number); + ASSERT_NE(metadata, nullptr); + + if (!slot_suffix.empty()) { + auto other_slot_suffix = fs_mgr_get_other_slot_suffix(); + auto other_slot_number = SlotNumberForSlotSuffix(other_slot_suffix); + auto other_super_name = fs_mgr_get_super_partition_name(other_slot_number); + auto other_metadata = ReadMetadata(other_super_name, other_slot_number); + ASSERT_NE(other_metadata, nullptr); + } +}