summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Anderson <dvander@google.com>2019-05-06 16:59:41 -0700
committerDavid Anderson <dvander@google.com>2019-05-10 12:16:19 -0700
commit9a8b9e01638df61061f7eabd0db93407ff0f549a (patch)
tree242dc93a484ad1f9f152415e4a655bcc1b829999
parent377a244710ecfa35d3eb41c0261a3c4033d33f1e (diff)
downloadsystem_core-9a8b9e01638df61061f7eabd0db93407ff0f549a.tar.gz
system_core-9a8b9e01638df61061f7eabd0db93407ff0f549a.tar.bz2
system_core-9a8b9e01638df61061f7eabd0db93407ff0f549a.zip
Add a liblp test that we can parse the device's super partition.
Bug: 132112489 Test: liblp_test gtest Change-Id: I1c0950dc30f42cd232e0616191d1365cdfc6512d Merged-In: I1c0950dc30f42cd232e0616191d1365cdfc6512d
-rw-r--r--fs_mgr/liblp/io_test.cpp18
1 files changed, 18 insertions, 0 deletions
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 <android-base/file.h>
#include <android-base/unique_fd.h>
+#include <fs_mgr.h>
+#include <fstab/fstab.h>
#include <gtest/gtest.h>
#include <liblp/builder.h>
@@ -702,3 +704,19 @@ TEST(liblp, UpdateNonRetrofit) {
ASSERT_EQ(updated->block_devices.size(), static_cast<size_t>(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);
+ }
+}