Skip to content

Commit b8e21ac

Browse files
target: Check that the connection works cleanly upon connection
Check that executing the most basic command works without troubles or stderr content. If that's not the case, raise a TargetStableError.
1 parent f4fa7a3 commit b8e21ac

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

devlib/target.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ def connect(self, timeout=None, check_boot_completed=True):
292292
self.conn = self.get_connection(timeout=timeout)
293293
if check_boot_completed:
294294
self.wait_boot_complete(timeout)
295+
self.check_connection()
295296
self._resolve_paths()
296297
self.execute('mkdir -p {}'.format(quote(self.working_directory)))
297298
self.execute('mkdir -p {}'.format(quote(self.executables_directory)))
@@ -301,6 +302,14 @@ def connect(self, timeout=None, check_boot_completed=True):
301302
if self.platform.big_core and self.load_default_modules:
302303
self._install_module(get_module('bl'))
303304

305+
def check_connection(self):
306+
"""
307+
Check that the connection works without obvious issues.
308+
"""
309+
out = self.execute('true', as_root=False)
310+
if out.strip():
311+
raise TargetStableError('The shell seems to not be functional and adds content to stderr: {}'.format(out))
312+
304313
def disconnect(self):
305314
connections = self._conn.get_all_values()
306315
for conn in connections:

0 commit comments

Comments
 (0)