On 09/03/2014 02:32 PM, Hongxu Jia wrote:
While TEST_TARGET is qemu, the QemuRunner class invokes runqemu
to start qemu, and runqemu needs sudo to set up tap interface.

While sudo is not available, the exit of QemuRunner will cost 60
seconds and the exit message is not clear, so we add sudo available
test for QemuRunner before invoking runqemu. Here is the example:
...
ERROR: We need setting up tap interface under sudo
sudo: a password is required

ERROR: Function failed: do_testimage
...

Signed-off-by: Hongxu Jia <hongxu....@windriver.com>
---
  meta/lib/oeqa/targetcontrol.py | 12 ++++++++++++
  1 file changed, 12 insertions(+)

diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index cc582dd..f6af5be 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -15,10 +15,22 @@ from oeqa.utils.qemurunner import QemuRunner
  from oeqa.controllers.testtargetloader import TestTargetLoader
  from abc import ABCMeta, abstractmethod
+def test_sudo_available(d):
+    res = subprocess.call('sudo -n ls', shell=True)
+    p = subprocess.Popen('sudo -n ls',
+                         shell=True,
+                         stdout=subprocess.PIPE,
+                         stderr=subprocess.PIPE)
+    if p.wait() != 0:
+        msg = "We need setting up tap interface under sudo\n"
+        msg += p.communicate()[1]
+        bb.fatal(msg)
+
  def get_target_controller(d):
      testtarget = d.getVar("TEST_TARGET", True)
      # old, simple names
      if testtarget == "qemu":
+        test_sudo_available(d)
          return QemuTarget(d)
      elif testtarget == "simpleremote":
          return SimpleRemoteTarget(d)

root privilege is sometimes not necessary here.
For example, if the system has already got a tap interface available there, we don't need the root privilege.

//Chen Qi
--
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to