From 3d57c84476ce542a7d8d623cf1f208efc1a20026 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Sat, 9 Nov 2019 22:07:20 -0800 Subject: Consolidate the vendor space misc usage for Pixels The layout of the vendor space /misc partition was pretty confusing and lead to some usage conflicts. To formalize the layout, we create a pixel specific library with the definition & offset of various flags. The new library also handles the R/W. As a result, we will leave system domain /misc definitions in the libbootloader_message. We also switch the misc_writer binary to use more specific options instead of writing an arbitrary hex string. So we can avoid redefining the string & offset in both init script and recovery ui. Bug: 131775112 Test: unit tests pass, run misc_writer and check contents of /misc Change-Id: I00f8842a81d1929e31a1de4d5eb09575ffad47c0 --- tests/unit/bootloader_message_test.cpp | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'tests') diff --git a/tests/unit/bootloader_message_test.cpp b/tests/unit/bootloader_message_test.cpp index 95d875e69..731c8feb7 100644 --- a/tests/unit/bootloader_message_test.cpp +++ b/tests/unit/bootloader_message_test.cpp @@ -118,37 +118,3 @@ TEST(BootloaderMessageTest, update_bootloader_message_recovery_options_long) { ASSERT_EQ(std::string(sizeof(boot.reserved), '\0'), std::string(boot.reserved, sizeof(boot.reserved))); } - -TEST(BootloaderMessageTest, WriteMiscPartitionVendorSpace) { - TemporaryFile temp_misc; - ASSERT_TRUE(android::base::WriteStringToFile(std::string(4096, '\x00'), temp_misc.path)); - SetMiscBlockDeviceForTest(temp_misc.path); - - constexpr std::string_view kTestMessage = "kTestMessage"; - std::string err; - ASSERT_TRUE(WriteMiscPartitionVendorSpace(kTestMessage.data(), kTestMessage.size(), 0, &err)); - - std::string message; - message.resize(kTestMessage.size()); - ASSERT_TRUE(ReadMiscPartitionVendorSpace(message.data(), message.size(), 0, &err)); - ASSERT_EQ(kTestMessage, message); - - // Write with an offset. - ASSERT_TRUE(WriteMiscPartitionVendorSpace("\x00\x00", 2, 5, &err)); - ASSERT_TRUE(ReadMiscPartitionVendorSpace(message.data(), message.size(), 0, &err)); - ASSERT_EQ("kTest\x00\x00ssage"s, message); - - // Write with the right size. - auto start_offset = - WIPE_PACKAGE_OFFSET_IN_MISC - VENDOR_SPACE_OFFSET_IN_MISC - kTestMessage.size(); - ASSERT_TRUE( - WriteMiscPartitionVendorSpace(kTestMessage.data(), kTestMessage.size(), start_offset, &err)); - - // Out-of-bound write. - ASSERT_FALSE(WriteMiscPartitionVendorSpace(kTestMessage.data(), kTestMessage.size(), - start_offset + 1, &err)); - - // Message won't fit. - std::string long_message(WIPE_PACKAGE_OFFSET_IN_MISC - VENDOR_SPACE_OFFSET_IN_MISC + 1, 'a'); - ASSERT_FALSE(WriteMiscPartitionVendorSpace(long_message.data(), long_message.size(), 0, &err)); -} -- cgit v1.2.3