summaryrefslogtreecommitdiff
path: root/fastboot/fuzzy_fastboot/main.cpp
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-03-21 03:17:32 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-03-21 03:17:32 +0000
commit5cd09cb24cb256b3db74fb8bcefad0eef23e7ddc (patch)
tree9700ada9740f2e30adbd08cfe3c1b976dcd5426e /fastboot/fuzzy_fastboot/main.cpp
parent19b83992eb877d78740c3e747df0122091edfe01 (diff)
parentcb7f2dde10761440c75519cb85f667417f9945d1 (diff)
Snap for 5392835 from cb7f2dde10761440c75519cb85f667417f9945d1 to qt-release
Change-Id: Iee6e0753afd500f14a79e06220f32a945ad80fd2
Diffstat (limited to 'fastboot/fuzzy_fastboot/main.cpp')
-rw-r--r--fastboot/fuzzy_fastboot/main.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/fastboot/fuzzy_fastboot/main.cpp b/fastboot/fuzzy_fastboot/main.cpp
index ef3477109..7ffc7d57c 100644
--- a/fastboot/fuzzy_fastboot/main.cpp
+++ b/fastboot/fuzzy_fastboot/main.cpp
@@ -177,6 +177,93 @@ TEST(USBFunctionality, USBConnect) {
}
}
+// Test commands related to super partition
+TEST_F(LogicalPartitionCompliance, SuperPartition) {
+ ASSERT_TRUE(UserSpaceFastboot());
+ std::string partition_type;
+ // getvar partition-type:super must fail for retrofit devices because the
+ // partition does not exist.
+ if (fb->GetVar("partition-type:super", &partition_type) == SUCCESS) {
+ std::string is_logical;
+ EXPECT_EQ(fb->GetVar("is-logical:super", &is_logical), SUCCESS)
+ << "getvar is-logical:super failed";
+ EXPECT_EQ(is_logical, "no") << "super must not be a logical partition";
+ std::string super_name;
+ EXPECT_EQ(fb->GetVar("super-partition-name", &super_name), SUCCESS)
+ << "'getvar super-partition-name' failed";
+ EXPECT_EQ(super_name, "super") << "'getvar super-partition-name' must return 'super' for "
+ "device with a super partition";
+ }
+}
+
+// Test 'fastboot getvar is-logical'
+TEST_F(LogicalPartitionCompliance, GetVarIsLogical) {
+ ASSERT_TRUE(UserSpaceFastboot());
+ std::string has_slot;
+ EXPECT_EQ(fb->GetVar("has-slot:system", &has_slot), SUCCESS) << "getvar has-slot:system failed";
+ std::string is_logical_cmd;
+ if (has_slot == "yes") {
+ std::string current_slot;
+ EXPECT_EQ(fb->GetVar("current-slot", &current_slot), SUCCESS)
+ << "getvar current-slot failed";
+ is_logical_cmd = "is-logical:system_" + current_slot;
+ } else {
+ is_logical_cmd = "is-logical:system";
+ }
+ std::string is_logical;
+ EXPECT_EQ(fb->GetVar(is_logical_cmd, &is_logical), SUCCESS) << "getvar is-logical failed";
+ ASSERT_EQ(is_logical, "yes");
+}
+
+TEST_F(LogicalPartitionCompliance, FastbootRebootTest) {
+ ASSERT_TRUE(UserSpaceFastboot());
+ GTEST_LOG_(INFO) << "Rebooting to bootloader mode";
+ // Test 'fastboot reboot bootloader' from fastbootd
+ fb->RebootTo("bootloader");
+
+ // Test fastboot reboot fastboot from bootloader
+ ReconnectFastbootDevice();
+ ASSERT_FALSE(UserSpaceFastboot());
+ GTEST_LOG_(INFO) << "Rebooting back to fastbootd mode";
+ fb->RebootTo("fastboot");
+
+ ReconnectFastbootDevice();
+ ASSERT_TRUE(UserSpaceFastboot());
+}
+
+// Testing creation/resize/delete of logical partitions
+TEST_F(LogicalPartitionCompliance, CreateResizeDeleteLP) {
+ ASSERT_TRUE(UserSpaceFastboot());
+ GTEST_LOG_(INFO) << "Testing 'fastboot create-logical-partition' command";
+ EXPECT_EQ(fb->CreatePartition("test_partition_a", "0"), SUCCESS)
+ << "create-logical-partition failed";
+ GTEST_LOG_(INFO) << "Testing 'fastboot resize-logical-partition' command";
+ EXPECT_EQ(fb->ResizePartition("test_partition_a", "4096"), SUCCESS)
+ << "resize-logical-partition failed";
+ std::vector<char> buf(4096);
+
+ GTEST_LOG_(INFO) << "Flashing a logical partition..";
+ EXPECT_EQ(fb->FlashPartition("test_partition_a", buf), SUCCESS)
+ << "flash logical -partition failed";
+ GTEST_LOG_(INFO) << "Rebooting to bootloader mode";
+ // Reboot to bootloader mode and attempt to flash the logical partitions
+ fb->RebootTo("bootloader");
+
+ ReconnectFastbootDevice();
+ ASSERT_FALSE(UserSpaceFastboot());
+ GTEST_LOG_(INFO) << "Attempt to flash a logical partition..";
+ EXPECT_EQ(fb->FlashPartition("test_partition", buf), DEVICE_FAIL)
+ << "flash logical partition must fail in bootloader";
+ GTEST_LOG_(INFO) << "Rebooting back to fastbootd mode";
+ fb->RebootTo("fastboot");
+
+ ReconnectFastbootDevice();
+ ASSERT_TRUE(UserSpaceFastboot());
+ GTEST_LOG_(INFO) << "Testing 'fastboot delete-logical-partition' command";
+ EXPECT_EQ(fb->DeletePartition("test_partition_a"), SUCCESS)
+ << "delete logical-partition failed";
+}
+
// Conformance tests
TEST_F(Conformance, GetVar) {
std::string product;