From 7e682ed97d0ece00b6ad19d998a9ac3a885a8186 Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Fri, 17 Jan 2020 17:47:24 +0000 Subject: [PATCH] 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. --- devlib/target.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/devlib/target.py b/devlib/target.py index 2b8296c..da712de 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -292,6 +292,7 @@ class Target(object): self.conn = self.get_connection(timeout=timeout) if check_boot_completed: self.wait_boot_complete(timeout) + self.check_connection() self._resolve_paths() self.execute('mkdir -p {}'.format(quote(self.working_directory))) self.execute('mkdir -p {}'.format(quote(self.executables_directory))) @@ -301,6 +302,14 @@ class Target(object): if self.platform.big_core and self.load_default_modules: self._install_module(get_module('bl')) + def check_connection(self): + """ + Check that the connection works without obvious issues. + """ + out = self.execute('true', as_root=False) + if out.strip(): + raise TargetStableError('The shell seems to not be functional and adds content to stderr: {}'.format(out)) + def disconnect(self): connections = self._conn.get_all_values() for conn in connections: