summaryrefslogtreecommitdiff
path: root/fastboot
diff options
context:
space:
mode:
authorDaniel Zheng <zhengdaniel@google.com>2023-08-25 14:02:24 -0700
committerDaniel Zheng <zhengdaniel@google.com>2023-08-30 12:59:29 -0700
commitafe1163ade57699c1d251f0ae06100a2af42b952 (patch)
treea53253dcbe412ae5fc93bc212a6505cc17a889bb /fastboot
parent2d4261ca4356839711b55397418bf63c334a9da3 (diff)
downloadcore-afe1163ade57699c1d251f0ae06100a2af42b952.tar.gz
Adding test for IsDynamicPartition
Adding a test case for checking if flash task is a dynamic partition flash task. This function is used since is-logical only works in fastbootd, and should_flash_in_userspace() only works if $ANDROID_PRODUCT_OUT is set. This function works with fastboot update when called in bootloader without $OUT dir set Test: fastboot_test Change-Id: I65309f97e04fdfc449e61de5cd3a6feff18bc9ab
Diffstat (limited to 'fastboot')
-rw-r--r--fastboot/task_test.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/fastboot/task_test.cpp b/fastboot/task_test.cpp
index 42be3cb65..1e25b6f63 100644
--- a/fastboot/task_test.cpp
+++ b/fastboot/task_test.cpp
@@ -234,6 +234,35 @@ TEST_F(ParseTest, CorrectTaskLists) {
<< "size of fastboot-info task list: " << fastboot_info_tasks.size()
<< " size of hardcoded task list: " << hardcoded_tasks.size();
}
+TEST_F(ParseTest, IsDynamicParitiontest) {
+ if (!get_android_product_out()) {
+ GTEST_SKIP();
+ }
+
+ LocalImageSource s;
+ fp->source = &s;
+
+ fastboot::MockFastbootDriver fb;
+ fp->fb = &fb;
+ fp->should_optimize_flash_super = true;
+ fp->should_use_fastboot_info = true;
+
+ std::vector<std::pair<std::string, bool>> test_cases = {
+ {"flash boot", false},
+ {"flash init_boot", false},
+ {"flash --apply-vbmeta vbmeta", false},
+ {"flash product", true},
+ {"flash system", true},
+ {"flash --slot-other system system_other.img", true},
+ };
+ for (auto& test : test_cases) {
+ std::unique_ptr<Task> task =
+ ParseFastbootInfoLine(fp.get(), android::base::Tokenize(test.first, " "));
+ auto flash_task = task->AsFlashTask();
+ ASSERT_FALSE(flash_task == nullptr);
+ ASSERT_EQ(FlashTask::IsDynamicParitition(fp->source, flash_task), test.second);
+ }
+}
TEST_F(ParseTest, CanOptimizeTest) {
if (!get_android_product_out()) {
@@ -275,6 +304,7 @@ TEST_F(ParseTest, CanOptimizeTest) {
ASSERT_EQ(OptimizedFlashSuperTask::CanOptimize(fp->source, tasks), test.second);
}
}
+
// Note: this test is exclusively testing that optimized flash super pattern matches a given task
// list and is able to optimized based on a correct sequence of tasks
TEST_F(ParseTest, OptimizedFlashSuperPatternMatchTest) {