[oe-commits] Mariano Lopez : qemurunner.py: Added raw mode in run_serial

git at git.openembedded.org git at git.openembedded.org
Sun Aug 16 08:32:44 UTC 2015


Module: openembedded-core.git
Branch: master-next
Commit: b8ead7c0929c4096e50b481a608f5d0c09eab29d
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=b8ead7c0929c4096e50b481a608f5d0c09eab29d

Author: Mariano Lopez <mariano.lopez at linux.intel.com>
Date:   Wed Aug 12 07:02:21 2015 +0000

qemurunner.py: Added raw mode in run_serial

Raw mode allows to send the command without sending
'echo $?' for validation; Also this doesn't remove the
command or the prompt from the output returned. In raw
mode validation is done if there is output.

This raw mode would be useful for validate the prompt
when a user logs in.

[YOCTO #8118]

Signed-off-by: Mariano Lopez <mariano.lopez at linux.intel.com>
Signed-off-by: Ross Burton <ross.burton at intel.com>

---

 meta/lib/oeqa/utils/qemurunner.py | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index fc2e244..3e604d8 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -177,7 +177,7 @@ class QemuRunner:
                 self.stop()
                 return False
 
-            (status, output) = self.run_serial("root\n")
+            (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")
@@ -274,9 +274,11 @@ class QemuRunner:
             if "qemu-system" in basecmd and "-serial tcp" in commands[p]:
                 return [int(p),commands[p]]
 
-    def run_serial(self, command):
+    def run_serial(self, command, raw=False):
         # We assume target system have echo to get command status
-        self.server_socket.sendall("%s; echo $?\n" % command)
+        if not raw:
+            command = "%s; echo $?\n" % command
+        self.server_socket.sendall(command)
         data = ''
         status = 0
         stopread = False
@@ -291,15 +293,18 @@ class QemuRunner:
                                 sock.close()
                                 stopread = True
         if data:
-            # Remove first line (command line) and last line (prompt)
-            data = data[data.find('$?\r\n')+4:data.rfind('\r\n')]
-            index = data.rfind('\r\n')
-            if index == -1:
-                status_cmd = data
-                data = ""
-            else:
-                status_cmd = data[index+2:]
-                data = data[:index]
-            if (status_cmd == "0"):
+            if raw:
                 status = 1
+            else:
+                # Remove first line (command line) and last line (prompt)
+                data = data[data.find('$?\r\n')+4:data.rfind('\r\n')]
+                index = data.rfind('\r\n')
+                if index == -1:
+                    status_cmd = data
+                    data = ""
+                else:
+                    status_cmd = data[index+2:]
+                    data = data[:index]
+                if (status_cmd == "0"):
+                    status = 1
         return (status, str(data))



More information about the Openembedded-commits mailing list