Skip to content

Commit 86d60fd

Browse files
Chong Gucopybara-github
Chong Gu
authored andcommitted
[Fuchsia] Allow device reboot to fail before paving/flashing
If a device is paved/flashed with a bad image, this will ensure that the device gets repaved during a test run. Bug: 1405525 Change-Id: I3120d9b54eff018b1b2ffca0e3260a35cabc3646 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4162197 Reviewed-by: Zijie He <[email protected]> Auto-Submit: Chong Gu <[email protected]> Commit-Queue: Chong Gu <[email protected]> Cr-Commit-Position: refs/heads/main@{#1092088} NOKEYCHECK=True GitOrigin-RevId: bc5cf4a55aa0ab4812a5fa39162acd982e63f197
1 parent 1f98096 commit 86d60fd

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

fuchsia/test/flash_device.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ def _get_system_info(target: Optional[str]) -> Tuple[str, str]:
3333
if running_unattended():
3434
with ScopedFfxConfig('discovery.zedboot.enabled', 'true'):
3535
run_ffx_command(('target', 'reboot'), target_id=target)
36-
run_ffx_command(('target', 'wait', '-t', '180'), target)
36+
wait_cmd = run_ffx_command(('target', 'wait', '-t', '180'),
37+
target,
38+
check=False)
39+
if wait_cmd.returncode != 0:
40+
return ('', '')
3741

3842
info_cmd = run_ffx_command(('target', 'show', '--json'),
3943
target_id=target,

fuchsia/test/flash_device_unittests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,17 @@ def test_update_with_serial_num(self) -> None:
208208
should_pave=False)
209209
self.assertEqual(self._ffx_mock.call_count, 4)
210210

211+
def test_reboot_failure(self) -> None:
212+
"""Test update when |serial_num| is specified."""
213+
self._ffx_mock.return_value.returncode = 1
214+
with mock.patch('time.sleep'), \
215+
mock.patch('os.path.exists', return_value=True), \
216+
mock.patch('flash_device.running_unattended',
217+
return_value=True):
218+
required, _ = flash_device.update_required('check',
219+
_TEST_IMAGE_DIR, None)
220+
self.assertEqual(required, True)
221+
211222
# pylint: disable=no-self-use
212223
def test_update_calls_paving_if_specified(self) -> None:
213224
"""Test update calls pave if specified."""

0 commit comments

Comments
 (0)