From 276bfdcee2f8ebd6f4745db4ad09b30f74b055df Mon Sep 17 00:00:00 2001 From: Bodong Yang Date: Mon, 13 May 2024 08:08:22 +0000 Subject: [PATCH] fix test_jetson_cboot --- otaclient/app/boot_control/_jetson_uefi.py | 10 +++++++--- tests/test_boot_control/test_jetson_cboot.py | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/otaclient/app/boot_control/_jetson_uefi.py b/otaclient/app/boot_control/_jetson_uefi.py index 628e1d21a..701bb5bd3 100644 --- a/otaclient/app/boot_control/_jetson_uefi.py +++ b/otaclient/app/boot_control/_jetson_uefi.py @@ -231,12 +231,13 @@ def __init__(self): logger.info(f"{bsp_version=}") # ------ sanity check, currently jetson-uefi only supports >= R35.2 ----- # + # only after R35.2, the Capsule Firmware update is available. if not bsp_version >= (35, 2, 0): _err_msg = f"jetson-uefi only supports BSP version >= R35.2, but get {bsp_version=}. " logger.error(_err_msg) raise JetsonUEFIBootControlError(_err_msg) - # NOTE: unified A/B is enabled by default and cannot be disabled after BSP R34. + # unified A/B is enabled by default and cannot be disabled after BSP R34. logger.info("unified A/B is enabled") # ------ check A/B slots ------ # @@ -252,6 +253,7 @@ def __init__(self): CMDHelperFuncs.get_parent_dev(current_rootfs_devpath).strip() ) + # --- detect boot device --- # self._external_rootfs = False parent_devname = parent_devpath.name if parent_devname.startswith(boot_cfg.MMCBLK_DEV_PREFIX): @@ -270,7 +272,7 @@ def __init__(self): f"/dev/{parent_devname}p{self._slot_id_partid[standby_slot]}" ) self.standby_rootfs_dev_partuuid = CMDHelperFuncs.get_attrs_by_dev( - "PARTUUID", f"{self.standby_rootfs_devpath}" + "PARTUUID", self.standby_rootfs_devpath ).strip() current_rootfs_dev_partuuid = CMDHelperFuncs.get_attrs_by_dev( "PARTUUID", current_rootfs_devpath @@ -282,7 +284,6 @@ def __init__(self): f"standby_rootfs(slot {standby_slot}): {self.standby_rootfs_devpath=}, {self.standby_rootfs_dev_partuuid=}" ) - # internal emmc partition self.standby_internal_emmc_devpath = f"/dev/{boot_cfg.INTERNAL_EMMC_DEVNAME}p{self._slot_id_partid[standby_slot]}" logger.info("finished jetson-uefi boot control startup") @@ -323,6 +324,7 @@ def __init__(self) -> None: active_slot_dev=self._uefi_control.curent_rootfs_devpath, active_slot_mount_point=cfg.ACTIVE_ROOT_MOUNT_POINT, ) + current_ota_status_dir = Path(boot_cfg.OTA_STATUS_DIR) standby_ota_status_dir = self._mp_control.standby_slot_mount_point / Path( boot_cfg.OTA_STATUS_DIR @@ -332,6 +334,8 @@ def __init__(self) -> None: self._firmware_ver_control = FirmwareBSPVersionControl( current_firmware_bsp_vf=current_ota_status_dir / boot_cfg.FIRMWARE_BSP_VERSION_FNAME, + # NOTE: standby slot's bsp version file might be not yet + # available before an OTA. standby_firmware_bsp_vf=standby_ota_status_dir / boot_cfg.FIRMWARE_BSP_VERSION_FNAME, ) diff --git a/tests/test_boot_control/test_jetson_cboot.py b/tests/test_boot_control/test_jetson_cboot.py index ce12fdf7a..8183eb57f 100644 --- a/tests/test_boot_control/test_jetson_cboot.py +++ b/tests/test_boot_control/test_jetson_cboot.py @@ -31,6 +31,7 @@ FirmwareBSPVersion, SlotID, parse_bsp_version, + update_extlinux_cfg, ) logger = logging.getLogger(__name__) @@ -140,4 +141,4 @@ def test_parse_bsp_version(_in: str, expected: BSPVersion): def test_update_extlinux_conf(_template_f: Path, _updated_f: Path, partuuid: str): _in = (TEST_DIR / _template_f).read_text() _expected = (TEST_DIR / _updated_f).read_text() - assert _CBootControl.update_extlinux_cfg(_in, partuuid) == _expected + assert update_extlinux_cfg(_in, partuuid) == _expected