[1/7] runfvp: propagate the exit code correctly

Message ID 20220331183117.22389-1-ross.burton@arm.com
State New
Headers show
Series [1/7] runfvp: propagate the exit code correctly | expand

Commit Message

Ross Burton March 31, 2022, 6:31 p.m. UTC
runfvp could encounter an error but the exit code remained as 0.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 scripts/runfvp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Jon Mason April 1, 2022, 12:53 a.m. UTC | #1
On Thu, 31 Mar 2022 19:31:11 +0100, Ross Burton wrote:
> runfvp could encounter an error but the exit code remained as 0.

Applied, thanks!

[1/7] runfvp: propagate the exit code correctly
      commit: 1a7c48e5f6cfe916e6e7d1b1076f4f9aa3230a19
[2/7] runfvp: check for telnet
      commit: 58f3251598a618cc16fc186102a1783efed660ab
[3/7] runfvp: strip all suffixes from the image when calculating .fvpconf name
      commit: 3a0dbcd37fbfc74b528ab47c78d50080f301f61d
[4/7] arm/oeqa: add basic runfvp test cases
      commit: 2b5cc5da3ea1f8898cb29c60ee6b2fd67bc437a4
[5/7] CI: clean up assignments in base.yml
      commit: ba7803e5138ae0295362b16c93eab5e3ec0cb6bd
[6/7] CI: add basic selftest job
      commit: 5289c05289335d1786d0c70f12a335281f04fd86
[7/7] arm/oeqa: add no-op runtime test
      commit: e4cc4d01cac2d4c1e8b798de42a1644bc869078a

Best regards,

Patch

diff --git a/scripts/runfvp b/scripts/runfvp
index c20455fd..5cab0949 100755
--- a/scripts/runfvp
+++ b/scripts/runfvp
@@ -221,6 +221,9 @@  async def start_fvp(cli, console_cb):
 
     if await fvp_process.wait() != 0:
         logger.info(f"{cli[0]} quit with code {fvp_process.returncode}")
+        return fvp_process.returncode
+    else:
+        return 0
 
 def runfvp(cli_args):
     args, fvp_args = parse_args(cli_args)
@@ -234,7 +237,7 @@  def runfvp(cli_args):
         expected_terminal = config["console"]
         if not expected_terminal:
             logger.error("--console used but FVP_CONSOLE not set in machine configuration")
-            sys.exit(1)
+            return 1
     else:
         expected_terminal = None
 
@@ -252,9 +255,10 @@  def runfvp(cli_args):
         # When we can assume Py3.7+, this can simply be asyncio.run()
         loop = asyncio.get_event_loop()
         console_cb = expected_terminal and console_started or None
-        loop.run_until_complete(asyncio.gather(start_fvp(cli, console_cb=console_cb)))
+        return loop.run_until_complete(start_fvp(cli, console_cb=console_cb))
     except asyncio.CancelledError:
-        pass
+        # This means telnet exited, which isn't an error
+        return 0
 
 if __name__ == "__main__":
     try:
@@ -264,6 +268,6 @@  if __name__ == "__main__":
         if sys.stdin.isatty():
             signal.signal(signal.SIGTTOU, signal.SIG_IGN)
             os.tcsetpgrp(sys.stdin.fileno(), os.getpgrp())
-        runfvp(sys.argv[1:])
+        sys.exit(runfvp(sys.argv[1:]))
     except KeyboardInterrupt:
         pass