!1047 optimize A/B partition startup

Merge pull request !1047 from cheng_jinsong/slot
This commit is contained in:
openharmony_ci 2022-08-10 09:41:51 +00:00 committed by Gitee
commit dbf39231d8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 32 additions and 7 deletions

View File

@ -16,6 +16,7 @@ declare_args() {
enable_ohos_startup_init_feature_deviceinfo = true
param_test = true
control_test = false
enable_ohos_startup_init_feature_ab_partition = false
# init begetctl support liteos
enable_ohos_startup_init_feature_begetctl_liteos = false

View File

@ -72,7 +72,8 @@ typedef struct SlotInfo {
} SlotInfo;
Fstab* LoadFstabFromCommandLine(void);
int GetSlotInfo(void);
int GetBootSlots(void);
int GetCurrentSlot(void);
void ReleaseFstab(Fstab *fstab);
Fstab *ReadFstabFromFile(const char *file, bool procMounts);
FstabItem *FindFstabItemForPath(Fstab fstab, const char *path);

View File

@ -125,7 +125,7 @@ if (defined(ohos_lite)) {
"dump_service",
]
if (product_name == "rk3568") {
if (enable_ohos_startup_init_feature_ab_partition) {
sources += [ "partitionslot.cpp" ]
external_deps +=
[ "drivers_peripheral_partitionslot:libpartition_slot_manager" ]

View File

@ -117,4 +117,23 @@ HWTEST_F(InnerkitsUnitTest, GetMountFlags_unitest, TestSize.Level1)
ReleaseFstab(fstab);
fstab = nullptr;
}
HWTEST_F(InnerkitsUnitTest, GetSlotInfo_unittest, TestSize.Level1)
{
EXPECT_NE(GetBootSlots(), -1);
EXPECT_NE(GetCurrentSlot(), -1);
}
HWTEST_F(InnerkitsUnitTest, LoadFstabFromCommandLine_unittest, TestSize.Level1)
{
EXPECT_NE(LoadFstabFromCommandLine(), (Fstab *)NULL);
}
HWTEST_F(InnerkitsUnitTest, GetBlockDevicePath_unittest, TestSize.Level1)
{
char devicePath[MAX_BUFFER_LEN] = {0};
EXPECT_EQ(GetBlockDevicePath("/vendor", devicePath, MAX_BUFFER_LEN), 0);
EXPECT_EQ(GetBlockDevicePath("/misc", devicePath, MAX_BUFFER_LEN), 0);
EXPECT_EQ(GetBlockDevicePath("/invalid", devicePath, MAX_BUFFER_LEN), -1);
}
} // namespace init_ut

View File

@ -343,14 +343,18 @@ void PrepareCmdLineHasSn()
// for cmdline
const char *cmdLineHasSnroot = "bootgroup=device.charge.group earlycon=uart8250,mmio32,0xfe660000 "
"root=PARTUUID=614e0000-0000 rw rootwait rootfstype=ext4 console=ttyFIQ0 hardware=rk3568"
" BOOT_IMAGE=/kernel ohos.boot.sn=/test init=/init ohos.required_mount.system="
"/dev/block/platform/soc/10100000.himci.eMMC/by-name/misc@none@none@none@wait,required";
" BOOT_IMAGE=/kernel ohos.boot.sn=/test init=/init";
CreateTestFile(BOOT_CMD_LINE, cmdLineHasSnroot);
LoadParamFromCmdLine();
const char *cmdLineHasntSn = "bootgroup=device.charge.group earlycon=uart8250,mmio32,0xfe660000 "
"root=PARTUUID=614e0000-0000 rw rootwait rootfstype=ext4 console=ttyFIQ0 hardware=rk3568"
" BOOT_IMAGE=/kernel init=/init ohos.required_mount.system="
"/dev/block/platform/soc/10100000.himci.eMMC/by-name/misc@none@none@none@wait,required";
"root=PARTUUID=614e0000-0000 rw rootwait rootfstype=ext4 console=ttyFIQ0 hardware=rk3568 "
"BOOT_IMAGE=/kernel init=/init default_boot_device=fe310000.sdhci bootslots=2 "
"ohos.required_mount.system="
"/dev/block/platform/fe310000.sdhci/by-name/system@/usr@ext4@ro,barrier=1@wait,required "
"ohos.required_mount.vendor="
"/dev/block/platform/fe310000.sdhci/by-name/vendor@/vendor@ext4@ro,barrier=1@wait,required "
"ohos.required_mount.misc="
"/dev/block/platform/fe310000.sdhci/by-name/misc@none@none@none@wait,required";
CreateTestFile(BOOT_CMD_LINE, cmdLineHasntSn);
}