diff --git a/begetd.gni b/begetd.gni index 920fc32d0018e7bf593635322bcfb935089b85f1..1046b806ae182ba7f06bda41d8e718e21cb451de 100755 --- a/begetd.gni +++ b/begetd.gni @@ -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 diff --git a/interfaces/innerkits/include/fs_manager/fs_manager.h b/interfaces/innerkits/include/fs_manager/fs_manager.h index f0e1b52be90ec872ce0a9934fce46dc796a2c514..0446e7748c91593795bd726bd3423a44c40b7c4e 100644 --- a/interfaces/innerkits/include/fs_manager/fs_manager.h +++ b/interfaces/innerkits/include/fs_manager/fs_manager.h @@ -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); diff --git a/services/begetctl/BUILD.gn b/services/begetctl/BUILD.gn index 118071c1f80a2d85d4e69904513917d14d8d356c..c2f688054544f81ba4d160d112a1848633fc0118 100755 --- a/services/begetctl/BUILD.gn +++ b/services/begetctl/BUILD.gn @@ -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" ] diff --git a/test/unittest/innerkits/innerkits_unittest.cpp b/test/unittest/innerkits/innerkits_unittest.cpp index 847c917ee9713a686d6ad3841e3963cb14eab44b..32fba53094242c067b7cb90006e72db388415201 100644 --- a/test/unittest/innerkits/innerkits_unittest.cpp +++ b/test/unittest/innerkits/innerkits_unittest.cpp @@ -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 diff --git a/test/unittest/param/param_stub.cpp b/test/unittest/param/param_stub.cpp index 5cd9983a2166117d47fa466bc142dd6c5d7450fd..05c65e7be57e779ed7d56941bbf4b868b8eb7cc0 100644 --- a/test/unittest/param/param_stub.cpp +++ b/test/unittest/param/param_stub.cpp @@ -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); }