Correct implementation of Spawn() in ConsoleBase

Now that this base-class function is called, it can produce an error on
test failure, since it passes an empty list for the arguments.

Rename the reset() function to prepare_for_spawn() and use that instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-08-02 10:36:31 -06:00
parent 455cee2b6d
commit ca30385c61
2 changed files with 7 additions and 10 deletions

View File

@@ -245,13 +245,13 @@ class ConsoleBase():
self.at_prompt_logevt = None
self.lab_mode = False
self.u_boot_version_string = None
self.reset()
self.prepare_for_spawn()
# http://stackoverflow.com/questions/7857352/python-regex-to-match-vt100-escape-sequences
self.re_vt100 = re.compile(r'(\x1b\[|\x9b)[^@-_]*[@-_]|\x1b[@-_]', re.I)
self.eval_patterns()
def reset(self):
def prepare_for_spawn(self):
"""Reset all settings as we are about to spawn a new connection"""
self.buf = ''
self.output = ''
@@ -261,13 +261,10 @@ class ConsoleBase():
self.logfile_read = None
def get_spawn(self):
"""This must be called by subclasses, to reset the system
Return a value to avoid:
console_base.py:348:12: E1128: Assigning result of a function
call, where the function returns None (assignment-from-none)
"""
self.reset()
# This is not called, ssubclass must define this.
# Return a value to avoid:
# console_base.py:348:12: E1128: Assigning result of a function
# call, where the function returns None (assignment-from-none)
return spawn.Spawn([])
def eval_patterns(self):

View File

@@ -55,7 +55,7 @@ class ConsoleExecAttach(ConsoleBase):
Returns:
A spawn.Spawn object that is attached to U-Boot.
"""
super().get_spawn()
self.prepare_for_spawn()
args = [self.config.board_type, self.config.board_identity]
s = Spawn(['u-boot-test-console'] + args)