Skip to contentSkip to conversation

qemurunner: Handle lack of data on run serial gracefully

PATCH New [email protected] 1 participant 1 message Sep 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemurunner: Handle lack of data on run serial gracefully

From: Mariano Lopez <[email protected]>

This changes the behavior when data was not received over the serial console when a command is run. With this the socket is no longer closed but it throws and exception that can handled in upper layers. With this the test can continue without throwing errors for not having the socket anymore.

[YOCTO #8118]

---
 meta/lib/oeqa/utils/dump.py       | 12 ++++++++++--
 meta/lib/oeqa/utils/qemurunner.py | 21 ++++++++++++---------
 2 files changed, 22 insertions(+), 11 deletions(-)
meta/lib/oeqa/utils/dump.py +10 -2
index 6067438..4ae871c 100644
@@ -12,6 +12,7 @@ def get_host_dumper(d):
 
 
 class BaseDumper(object):
+    """ Base class to dump commands from host/target """
 
     def __init__(self, cmds, parent_dir):
         self.cmds = []
@@ -53,6 +54,7 @@ class BaseDumper(object):
 
 
 class HostDumper(BaseDumper):
+    """ Class to get dumps from the host running the tests """
 
     def __init__(self, cmds, parent_dir):
         super(HostDumper, self).__init__(cmds, parent_dir)
@@ -66,6 +68,7 @@ class HostDumper(BaseDumper):
 
 
 class TargetDumper(BaseDumper):
+    """ Class to get dumps from target, it only works with QemuRunner """
 
     def __init__(self, cmds, parent_dir, qemurunner):
         super(TargetDumper, self).__init__(cmds, parent_dir)
@@ -75,5 +78,10 @@ class TargetDumper(BaseDumper):
         if dump_dir:
             self.dump_dir = dump_dir
         for cmd in self.cmds:
-            (status, output) = self.runner.run_serial(cmd)
-            self._write_dump(cmd.split()[0], output)
+            # We can continue with the testing if serial commands fail
+            try:
+                (status, output) = self.runner.run_serial(cmd)
+                self._write_dump(cmd.split()[0], output)
+            except:
+                print("Tried to dump info from target but "
+                        "serial console failed")
meta/lib/oeqa/utils/qemurunner.py +12 -9
index 4ce5d9c..3ad747a 100644
@@ -197,13 +197,17 @@ class QemuRunner:
                 self.stop()
                 return False
 
-            (status, output) = self.run_serial("root\n", raw=True)
-            if re.search("root@[a-zA-Z0-9\-]+:~#", output):
-                self.logged = True
-                logger.info("Logged as root in serial console")
-            else:
-                logger.info("Couldn't login into serial console"
-                        " as root using blank password")
+            # If we are not able to login the tests can continue
+            try:
+                (status, output) = self.run_serial("root\n", raw=True)
+                if re.search("root@[a-zA-Z0-9\-]+:~#", output):
+                    self.logged = True
+                    logger.info("Logged as root in serial console")
+                else:
+                    logger.info("Couldn't login into serial console"
+                            " as root using blank password")
+            except:
+                logger.info("Serial console failed while trying to login")
 
         else:
             logger.info("Qemu pid didn't appeared in %s seconds" % self.runqemutime)
@@ -321,8 +325,7 @@ class QemuRunner:
                         stopread = True
                         break
                 else:
-                    sock.close()
-                    stopread = True
+                    raise Exception("No data on serial console socket")
         if data:
             if raw:
                 status = 1
Signature · 1 line
1.8.4.5