Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodong-Yang committed Oct 19, 2024
1 parent 3882ecc commit 137a664
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions tests/test_otaclient/test_boot_control/test_ota_status_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from otaclient.boot_control._common import OTAStatusFilesControl
from otaclient.boot_control.configs import BaseConfig as cfg
from otaclient_api.v2 import types as api_types
from otaclient_common.common import read_str_from_file, write_str_to_file
from otaclient_common._io import read_str_from_file, write_str_to_file_atomic

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -110,11 +110,11 @@ def test_ota_status_files_loading(
):
logger.info(f"{test_case=}")
# ------ setup ------ #
write_str_to_file(
write_str_to_file_atomic(
self.slot_a_status_file,
input_slot_a_status.name if input_slot_a_status else "",
)
write_str_to_file(self.slot_a_slot_in_use_file, input_slot_a_slot_in_use)
write_str_to_file_atomic(self.slot_a_slot_in_use_file, input_slot_a_slot_in_use)

# ------ execution ------ #
status_control = OTAStatusFilesControl(
Expand Down Expand Up @@ -193,10 +193,14 @@ def test_switching_boot(
"""First reboot after OTA from slot_a to slot_b."""
logger.info(f"{test_case=}")
# ------ setup ------ #
write_str_to_file(self.slot_a_status_file, api_types.StatusOta.FAILURE.name)
write_str_to_file(self.slot_a_slot_in_use_file, self.slot_b)
write_str_to_file(self.slot_b_status_file, api_types.StatusOta.UPDATING.name)
write_str_to_file(self.slot_b_slot_in_use_file, self.slot_b)
write_str_to_file_atomic(
self.slot_a_status_file, api_types.StatusOta.FAILURE.name
)
write_str_to_file_atomic(self.slot_a_slot_in_use_file, self.slot_b)
write_str_to_file_atomic(
self.slot_b_status_file, api_types.StatusOta.UPDATING.name
)
write_str_to_file_atomic(self.slot_b_slot_in_use_file, self.slot_b)

# ------ execution ------ #
# otaclient boots on slot_b
Expand Down Expand Up @@ -249,10 +253,14 @@ def test_switching_boot(
def test_accidentally_boots_back_to_standby(self):
"""slot_a should be active slot but boots back to slot_b."""
# ------ setup ------ #
write_str_to_file(self.slot_a_status_file, api_types.StatusOta.SUCCESS.name)
write_str_to_file(self.slot_a_slot_in_use_file, self.slot_a)
write_str_to_file(self.slot_b_status_file, api_types.StatusOta.FAILURE.name)
write_str_to_file(self.slot_b_slot_in_use_file, self.slot_a)
write_str_to_file_atomic(
self.slot_a_status_file, api_types.StatusOta.SUCCESS.name
)
write_str_to_file_atomic(self.slot_a_slot_in_use_file, self.slot_a)
write_str_to_file_atomic(
self.slot_b_status_file, api_types.StatusOta.FAILURE.name
)
write_str_to_file_atomic(self.slot_b_slot_in_use_file, self.slot_a)

# ------ execution ------ #
# otaclient accidentally boots on slot_b
Expand Down

0 comments on commit 137a664

Please sign in to comment.