system/core
Revision | 06a80456743c0ad26ec360cce4c262bd8f2d25ca (tree) |
---|---|
Zeit | 2019-05-16 07:37:02 |
Autor | Hridya Valsaraju <hridya@goog...> |
Commiter | android-build-merger |
Merge "Allow CreateResizeDeleteLP test case to run on non-A/B devices" into qt-dev
am: 2c4803838e
Change-Id: Ie24284987a4423a67e2e26bd8095e96a428761e3
@@ -244,16 +244,29 @@ TEST_F(LogicalPartitionCompliance, FastbootRebootTest) { | ||
244 | 244 | // Testing creation/resize/delete of logical partitions |
245 | 245 | TEST_F(LogicalPartitionCompliance, CreateResizeDeleteLP) { |
246 | 246 | ASSERT_TRUE(UserSpaceFastboot()); |
247 | + std::string test_partition_name = "test_partition"; | |
248 | + std::string slot_count; | |
249 | + // Add suffix to test_partition_name if device is slotted. | |
250 | + EXPECT_EQ(fb->GetVar("slot-count", &slot_count), SUCCESS) << "getvar slot-count failed"; | |
251 | + int32_t num_slots = strtol(slot_count.c_str(), nullptr, 10); | |
252 | + if (num_slots > 0) { | |
253 | + std::string current_slot; | |
254 | + EXPECT_EQ(fb->GetVar("current-slot", ¤t_slot), SUCCESS) | |
255 | + << "getvar current-slot failed"; | |
256 | + std::string slot_suffix = "_" + current_slot; | |
257 | + test_partition_name += slot_suffix; | |
258 | + } | |
259 | + | |
247 | 260 | GTEST_LOG_(INFO) << "Testing 'fastboot create-logical-partition' command"; |
248 | - EXPECT_EQ(fb->CreatePartition("test_partition_a", "0"), SUCCESS) | |
261 | + EXPECT_EQ(fb->CreatePartition(test_partition_name, "0"), SUCCESS) | |
249 | 262 | << "create-logical-partition failed"; |
250 | 263 | GTEST_LOG_(INFO) << "Testing 'fastboot resize-logical-partition' command"; |
251 | - EXPECT_EQ(fb->ResizePartition("test_partition_a", "4096"), SUCCESS) | |
264 | + EXPECT_EQ(fb->ResizePartition(test_partition_name, "4096"), SUCCESS) | |
252 | 265 | << "resize-logical-partition failed"; |
253 | 266 | std::vector<char> buf(4096); |
254 | 267 | |
255 | 268 | GTEST_LOG_(INFO) << "Flashing a logical partition.."; |
256 | - EXPECT_EQ(fb->FlashPartition("test_partition_a", buf), SUCCESS) | |
269 | + EXPECT_EQ(fb->FlashPartition(test_partition_name, buf), SUCCESS) | |
257 | 270 | << "flash logical -partition failed"; |
258 | 271 | GTEST_LOG_(INFO) << "Rebooting to bootloader mode"; |
259 | 272 | // Reboot to bootloader mode and attempt to flash the logical partitions |
@@ -262,7 +275,7 @@ TEST_F(LogicalPartitionCompliance, CreateResizeDeleteLP) { | ||
262 | 275 | ReconnectFastbootDevice(); |
263 | 276 | ASSERT_FALSE(UserSpaceFastboot()); |
264 | 277 | GTEST_LOG_(INFO) << "Attempt to flash a logical partition.."; |
265 | - EXPECT_EQ(fb->FlashPartition("test_partition", buf), DEVICE_FAIL) | |
278 | + EXPECT_EQ(fb->FlashPartition(test_partition_name, buf), DEVICE_FAIL) | |
266 | 279 | << "flash logical partition must fail in bootloader"; |
267 | 280 | GTEST_LOG_(INFO) << "Rebooting back to fastbootd mode"; |
268 | 281 | fb->RebootTo("fastboot"); |
@@ -270,7 +283,7 @@ TEST_F(LogicalPartitionCompliance, CreateResizeDeleteLP) { | ||
270 | 283 | ReconnectFastbootDevice(); |
271 | 284 | ASSERT_TRUE(UserSpaceFastboot()); |
272 | 285 | GTEST_LOG_(INFO) << "Testing 'fastboot delete-logical-partition' command"; |
273 | - EXPECT_EQ(fb->DeletePartition("test_partition_a"), SUCCESS) | |
286 | + EXPECT_EQ(fb->DeletePartition(test_partition_name), SUCCESS) | |
274 | 287 | << "delete logical-partition failed"; |
275 | 288 | } |
276 | 289 |