From 0ba07f333c698701d87cbc1a9665bbb98b096b90 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Wed, 19 Jun 2024 09:14:10 +0000 Subject: [PATCH] update test_rpi_boot accordingly --- .../test_boot_control/test_rpi_boot.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/test_otaclient/test_boot_control/test_rpi_boot.py b/tests/test_otaclient/test_boot_control/test_rpi_boot.py index cffbbe51c..b8e99d9dc 100644 --- a/tests/test_otaclient/test_boot_control/test_rpi_boot.py +++ b/tests/test_otaclient/test_boot_control/test_rpi_boot.py @@ -92,6 +92,9 @@ class TestRPIBootControl: @pytest.fixture def rpi_boot_ab_slot(self, tmp_path: Path, ab_slots: SlotMeta): + self.model_file = tmp_path / "model" + self.model_file.write_text(rpi_boot_cfg.RPI_MODEL_HINT) + self.slot_a_mp = Path(ab_slots.slot_a) self.slot_b_mp = Path(ab_slots.slot_b) @@ -239,15 +242,16 @@ def test_rpi_boot_normal_update(self, mocker: pytest_mock.MockerFixture): from otaclient.app.boot_control._rpi_boot import RPIBootController # ------ patch rpi_boot_cfg for boot_controller_inst1.stage 1~3 ------# - _rpi_boot_cfg_path = f"{cfg.BOOT_CONTROL_CONFIG_MODULE_PATH}.rpi_boot_cfg" + rpi_boot_cfg_path = f"{cfg.BOOT_CONTROL_CONFIG_MODULE_PATH}.rpi_boot_cfg" mocker.patch( - f"{_rpi_boot_cfg_path}.SYSTEM_BOOT_MOUNT_POINT", str(self.system_boot) + f"{rpi_boot_cfg_path}.SYSTEM_BOOT_MOUNT_POINT", str(self.system_boot) ) - mocker.patch(f"{_rpi_boot_cfg_path}.ACTIVE_ROOTFS_PATH", str(self.slot_a_mp)) - mocker.patch(f"{_rpi_boot_cfg_path}.MOUNT_POINT", str(self.slot_b_mp)) + mocker.patch(f"{rpi_boot_cfg_path}.ACTIVE_ROOTFS_PATH", str(self.slot_a_mp)) + mocker.patch(f"{rpi_boot_cfg_path}.MOUNT_POINT", str(self.slot_b_mp)) mocker.patch( - f"{_rpi_boot_cfg_path}.ACTIVE_ROOT_MOUNT_POINT", str(self.slot_a_mp) + f"{rpi_boot_cfg_path}.ACTIVE_ROOT_MOUNT_POINT", str(self.slot_a_mp) ) + mocker.patch(f"{rpi_boot_cfg_path}.RPI_MODEL_FILE", str(self.model_file)) # ------ boot_controller_inst1.stage1: init ------ # rpi_boot_controller1 = RPIBootController() @@ -312,13 +316,8 @@ def test_rpi_boot_normal_update(self, mocker: pytest_mock.MockerFixture): assert not (self.system_boot / rpi_boot_cfg.SWITCH_BOOT_FLAG_FILE).is_file() # ------ boot_controller_inst2: first reboot ------ # - # patch rpi_boot_cfg for boot_controller_inst2 - _rpi_boot_cfg_path = f"{cfg.BOOT_CONTROL_CONFIG_MODULE_PATH}.rpi_boot_cfg" - mocker.patch( - f"{_rpi_boot_cfg_path}.SYSTEM_BOOT_MOUNT_POINT", str(self.system_boot) - ) - mocker.patch(f"{_rpi_boot_cfg_path}.ACTIVE_ROOTFS_PATH", str(self.slot_b_mp)) - mocker.patch(f"{_rpi_boot_cfg_path}.MOUNT_POINT", str(self.slot_a_mp)) + mocker.patch(f"{rpi_boot_cfg_path}.ACTIVE_ROOTFS_PATH", str(self.slot_b_mp)) + mocker.patch(f"{rpi_boot_cfg_path}.MOUNT_POINT", str(self.slot_a_mp)) # ------ boot_controller_inst2.stage1: finalize switchboot ------ # logger.info("1st reboot: finalize switch boot and update firmware....")