fix(hftest): fix telnet communication in FvpDriverBothWorlds
Telnet connection with the model has to have model's lifetime; creating
a new connection for each test looses part of the messages.
Change-Id: I6f8970722f5aa472a965bf9989c53e1fd97fb7ac
Signed-off-by: Federico Recanati <federico.recanati@arm.com>
diff --git a/test/hftest/hftest.py b/test/hftest/hftest.py
index e3df464..ea29bc5 100755
--- a/test/hftest/hftest.py
+++ b/test/hftest/hftest.py
@@ -618,9 +618,17 @@
stderr = self.fvp_out_f)
# Sleep 1 sec so connect to model via telnet doesn't fail
time.sleep(1.0)
+ # Start telnet session
+ try:
+ self.comm = Telnet("localhost", 5000)
+ except ConnectionError as e:
+ self.finish()
+ raise e
+
def process_terminate(self):
""" Terminate fvp model's process, and reset internal field """
+ self.comm.close() # Close telnet connection
self.process.terminate()
# To give the system time to terminate the process
time.sleep(1.0)
@@ -636,25 +644,20 @@
test_log = f"{' '.join(self.fvp_args)}\n"
- try:
- with Telnet("localhost", 5000) as comm:
- # Obtaining HFTEST_CTRL_GET_COMMAND_LINE in logs should be quick
- test_log += comm.read_until(
- HFTEST_CTRL_GET_COMMAND_LINE.encode("ascii"),
- timeout=5.0).decode("ascii")
+ # Obtaining HFTEST_CTRL_GET_COMMAND_LINE in logs should be quick
+ test_log += self.comm.read_until(
+ HFTEST_CTRL_GET_COMMAND_LINE.encode("ascii"),
+ timeout=5.0).decode("ascii")
- if HFTEST_CTRL_GET_COMMAND_LINE in test_log:
- # Send command to instruct partition to execute test
- comm.write(f"{test_args}\n".encode("ascii"))
+ if HFTEST_CTRL_GET_COMMAND_LINE in test_log:
+ # Send self.command to instruct partition to execute test
+ self.comm.write(f"{test_args}\n".encode("ascii"))
- timeout = 80.0 if is_long_running else 10.0
- test_log += comm.read_until(HFTEST_CTRL_FINISHED.encode("ascii"),
- timeout=timeout).decode("ascii")
- else:
- print("VM not ready to fetch test command")
- except ConnectionError as e:
- self.finish()
- raise e
+ timeout = 80.0 if is_long_running else 10.0
+ test_log += self.comm.read_until(HFTEST_CTRL_FINISHED.encode("ascii"),
+ timeout=timeout).decode("ascii")
+ else:
+ print("VM not ready to fetch test command")
# Check wether test went well:
if HFTEST_CTRL_FINISHED not in test_log: