All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] testimage/targetcontrol.py: test sudo available while invoking runqemu
@ 2014-09-03  6:32 Hongxu Jia
  2014-09-03  6:32 ` [PATCH 1/1] targetcontrol.py: " Hongxu Jia
  0 siblings, 1 reply; 3+ messages in thread
From: Hongxu Jia @ 2014-09-03  6:32 UTC (permalink / raw)
  To: openembedded-core

The following changes since commit 83ebcb1f0c6ec48c526d14324b3b2037f0f4fe43:

  bitbake: process: Ensure abnormal exits set an error level (2014-09-02 18:10:37 +0100)

are available in the git repository at:

  git://git.pokylinux.org/poky-contrib hongxu/fix-testimage
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=hongxu/fix-testimage

Hongxu Jia (1):
  targetcontrol.py: test sudo available while invoking runqemu

 meta/lib/oeqa/targetcontrol.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

-- 
1.9.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] targetcontrol.py: test sudo available while invoking runqemu
  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
  2014-09-03  7:16   ` ChenQi
  0 siblings, 1 reply; 3+ messages in thread
From: Hongxu Jia @ 2014-09-03  6:32 UTC (permalink / raw)
  To: openembedded-core

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] targetcontrol.py: test sudo available while invoking runqemu
  2014-09-03  6:32 ` [PATCH 1/1] targetcontrol.py: " Hongxu Jia
@ 2014-09-03  7:16   ` ChenQi
  0 siblings, 0 replies; 3+ messages in thread
From: ChenQi @ 2014-09-03  7:16 UTC (permalink / raw)
  To: openembedded-core

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.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)

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-03  7:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-03  6:32 [PATCH 0/1] testimage/targetcontrol.py: test sudo available while invoking runqemu Hongxu Jia
2014-09-03  6:32 ` [PATCH 1/1] targetcontrol.py: " Hongxu Jia
2014-09-03  7:16   ` ChenQi

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.