summaryrefslogtreecommitdiffstats
path: root/fs_mgr/liblp/io_test.cpp
diff options
context:
space:
mode:
authorDavid Anderson <dvander@google.com>2018-10-10 18:49:36 -0700
committerDavid Anderson <dvander@google.com>2018-10-12 13:05:12 -0700
commitdb29503b4d4c5fa6144eed343c062b7c20aae649 (patch)
tree8f601679d13c7fc01ef640e8c3a2a23ec870334a /fs_mgr/liblp/io_test.cpp
parenta520c5e28b96b8a8a097bd65df36a1abb203216e (diff)
downloadsystem_core-db29503b4d4c5fa6144eed343c062b7c20aae649.tar.gz
system_core-db29503b4d4c5fa6144eed343c062b7c20aae649.tar.bz2
system_core-db29503b4d4c5fa6144eed343c062b7c20aae649.zip
liblp: Remove last_logical_sector from LpMetadataGeometry.
Now that backup metadata is stored at the start of the super partition, this field is no longer needed. In actuality, it was not needed even before then: both it and first_logical_sector exist for convenience, since they can be re-derived at any time given an LpMetadataGeometry. Bug: 116802789 Test: liblp_test gtest device with dynamic partitions flashes and boots Change-Id: I259a443097e689a0a9db7f822bbf1a52d40076dc
Diffstat (limited to 'fs_mgr/liblp/io_test.cpp')
-rw-r--r--fs_mgr/liblp/io_test.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/fs_mgr/liblp/io_test.cpp b/fs_mgr/liblp/io_test.cpp
index 220d651d7..92696f528 100644
--- a/fs_mgr/liblp/io_test.cpp
+++ b/fs_mgr/liblp/io_test.cpp
@@ -161,7 +161,6 @@ TEST(liblp, FlashAndReadback) {
EXPECT_EQ(exported->geometry.metadata_max_size, imported->geometry.metadata_max_size);
EXPECT_EQ(exported->geometry.metadata_slot_count, imported->geometry.metadata_slot_count);
EXPECT_EQ(exported->geometry.first_logical_sector, imported->geometry.first_logical_sector);
- EXPECT_EQ(exported->geometry.last_logical_sector, imported->geometry.last_logical_sector);
EXPECT_EQ(exported->header.major_version, imported->header.major_version);
EXPECT_EQ(exported->header.minor_version, imported->header.minor_version);
EXPECT_EQ(exported->header.header_size, imported->header.header_size);
@@ -207,13 +206,14 @@ TEST(liblp, UpdateAnyMetadataSlot) {
ASSERT_EQ(imported->partitions.size(), 1);
EXPECT_EQ(GetPartitionName(imported->partitions[0]), "vendor");
+ uint64_t last_sector = imported->geometry.block_device_size / LP_SECTOR_SIZE;
+
// Verify that we didn't overwrite anything in the logical paritition area.
// We expect the disk to be filled with 0xcc on creation so we can read
// this back and compare it.
char expected[LP_SECTOR_SIZE];
memset(expected, 0xcc, sizeof(expected));
- for (uint64_t i = imported->geometry.first_logical_sector;
- i <= imported->geometry.last_logical_sector; i++) {
+ for (uint64_t i = imported->geometry.first_logical_sector; i < last_sector; i++) {
char buffer[LP_SECTOR_SIZE];
ASSERT_GE(lseek(fd, i * LP_SECTOR_SIZE, SEEK_SET), 0);
ASSERT_TRUE(android::base::ReadFully(fd, buffer, sizeof(buffer)));
@@ -261,8 +261,6 @@ TEST(liblp, NoChangingGeometry) {
imported = ReadMetadata(fd, 0);
ASSERT_NE(imported, nullptr);
- imported->geometry.last_logical_sector--;
- ASSERT_FALSE(UpdatePartitionTable(fd, *imported.get(), 1));
}
// Test that changing one bit of metadata is enough to break the checksum.
@@ -370,9 +368,6 @@ TEST(liblp, TooManyPartitions) {
ASSERT_GE(lseek(fd, exported->geometry.first_logical_sector * LP_SECTOR_SIZE, SEEK_SET), 0);
ASSERT_TRUE(android::base::ReadFully(fd, buffer, sizeof(buffer)));
EXPECT_EQ(memcmp(expected, buffer, LP_SECTOR_SIZE), 0);
- ASSERT_GE(lseek(fd, exported->geometry.last_logical_sector * LP_SECTOR_SIZE, SEEK_SET), 0);
- ASSERT_TRUE(android::base::ReadFully(fd, buffer, sizeof(buffer)));
- EXPECT_EQ(memcmp(expected, buffer, LP_SECTOR_SIZE), 0);
}
// Test that we can read and write image files.