All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hongxu Jia <hongxu.jia@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Subject: [PATCH 1/1] targetcontrol.py: test sudo available while invoking runqemu
Date: Wed, 3 Sep 2014 14:32:14 +0800	[thread overview]
Message-ID: <30d04c9e34cd40ba2bb236823d3bc977d22346ca.1409725792.git.hongxu.jia@windriver.com> (raw)
In-Reply-To: <cover.1409725792.git.hongxu.jia@windriver.com>

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.jia@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)
-- 
1.9.1



  reply	other threads:[~2014-09-03  6:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-03  6:32 [PATCH 0/1] testimage/targetcontrol.py: test sudo available while invoking runqemu Hongxu Jia
2014-09-03  6:32 ` Hongxu Jia [this message]
2014-09-03  7:16   ` [PATCH 1/1] targetcontrol.py: " ChenQi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=30d04c9e34cd40ba2bb236823d3bc977d22346ca.1409725792.git.hongxu.jia@windriver.com \
    --to=hongxu.jia@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.