diff options
author | Per Larsen <perlarsen@google.com> | 2022-11-03 22:49:47 +0000 |
---|---|---|
committer | Per Larsen <perlarsen@google.com> | 2022-11-04 22:04:30 +0000 |
commit | 0f4bd417e6f3eaccc0ddddbd095e0d70bd161561 (patch) | |
tree | b972e442f08edee07302512946da552cf1aa38f7 | |
parent | 35a55691dd222bd131fb4509c8b2b223ec493e1b (diff) | |
download | generic-arm64-0f4bd417e6f3eaccc0ddddbd095e0d70bd161561.tar.gz |
project/qemu: run.py wait for QEMU when interactive
If run is called without the --headless flag, QEMU is running
interactively. This means that run.py must wait for the user to
quit QEMU before calling qemu.Runner.shutdown() to terminate
execution cleanly.
Bug: None
Test: build qemu-generic-arm64-test-debug then run
build-root/build-qemu-genric-arm64-test-debug/run without
any arguments
Change-Id: I7a2176093a76c9802f4e46a229743b5369e53b1d
-rw-r--r-- | project/qemu/qemu.py | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/project/qemu/qemu.py b/project/qemu/qemu.py index 23be8a2..a82afa8 100644 --- a/project/qemu/qemu.py +++ b/project/qemu/qemu.py @@ -19,7 +19,10 @@ import tempfile import time import threading -from qemu_error import AdbFailure, ConfigError, RunnerGenericError, RunnerError, Timeout +from typing import Optional, List + +import qemu_options # pylint: disable=import-error +from qemu_error import AdbFailure, ConfigError, RunnerGenericError, Timeout # ADB expects its first console on 5554, and control on 5555 @@ -935,10 +938,9 @@ class Runner(object): self.shutdown() raise - def run(self, boot_tests: Optional[List] = None, android_tests: Optional[List] = None, - timeout: Optional[int] = None): + timeout: Optional[int] = None) -> List[int]: """Run boot or android tests. Runs boot_tests through test_runner, android_tests through ADB, @@ -976,30 +978,25 @@ class Runner(object): try: self.launch(RunnerState.BOOTLOADER if boot_tests else RunnerState.ANDROID) + test_results = [] if boot_tests: - return [self.boottest_run(boot_tests, timeout)] + test_results.append(self.boottest_run(boot_tests, timeout)) if android_tests: - session: RunnerSession = self.session - test_results = [] - - try: - for android_test in android_tests: - test_result = self.androidtest_run([android_test], - timeout) - test_results.append(test_result) - if test_result: - session.has_error = True - break - return test_results - # Finally is used here to ensure that ADB failures do not - # take away the user's serial console in interactive mode. - finally: - if self.interactive: - # The user is responsible for quitting QEMU - session.qemu_proc.wait() - - return [] # nothing to do + for android_test in android_tests: + test_result = self.androidtest_run([android_test], timeout) + test_results.append(test_result) + if test_result: + assert self.session # appease mypy + self.session.has_error = True + break + + return test_results finally: + # The wait on QEMU is done here to ensure that ADB failures do not + # take away the user's serial console in interactive mode. + if self.interactive and self.session: + # The user is responsible for quitting QEMU + self.session.qemu_proc.wait() self.shutdown() |