From a3727e832775d015df05f1c544ba61187214effc Mon Sep 17 00:00:00 2001 From: chengjinsong Date: Tue, 9 Aug 2022 17:41:31 +0800 Subject: [PATCH] slot Signed-off-by: chengjinsong Change-Id: I1268dc5c0c03408956bb17214088a402b89e4ee9 --- begetd.gni | 1 + .../innerkits/include/fs_manager/fs_manager.h | 3 ++- services/begetctl/BUILD.gn | 2 +- .../unittest/innerkits/innerkits_unittest.cpp | 19 +++++++++++++++++++ test/unittest/param/param_stub.cpp | 14 +++++++++----- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/begetd.gni b/begetd.gni index 920fc32d..1046b806 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 f0e1b52b..0446e774 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 118071c1..c2f68805 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 847c917e..32fba530 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 5cd9983a..05c65e7b 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); } -- GitLab