All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: yocto@yoctoproject.org
Cc: richard.purdie@intel.com, "Aníbal Limón" <limon.anibal@gmail.com>,
	benjamin.esquivel@intel.com
Subject: [[PATCH][qa-tools] 03/16] toaster: Add helpers for clone, setup, start and stop.
Date: Tue,  9 Feb 2016 16:43:12 -0600	[thread overview]
Message-ID: <1455057798-3213-4-git-send-email-anibal.limon@linux.intel.com> (raw)
In-Reply-To: <1455057798-3213-1-git-send-email-anibal.limon@linux.intel.com>

From: Aníbal Limón <limon.anibal@gmail.com>

README.md: Toaster tests requires bash so add it.
TODO is add a sanity module for test this kind of issues
like shell compatibility.

Signed-off-by: Aníbal Limón <limon.anibal@gmail.com>
---
 README.md                |  4 ++++
 tests/toaster/helpers.py | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100644 tests/toaster/helpers.py

diff --git a/README.md b/README.md
index b5e6c8f..4efe1a8 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,10 @@ Scripts used by Yocto QA Team for automatize QA process.
 
 = Host requirements =
 
+All the test components REQUIRE bash as your default shell, you
+need to review if /bin/sh points to bash because some problems are
+detected when use dash.
+
 == Toaster ==
 
 - virtualenv for python
diff --git a/tests/toaster/helpers.py b/tests/toaster/helpers.py
new file mode 100644
index 0000000..49f34da
--- /dev/null
+++ b/tests/toaster/helpers.py
@@ -0,0 +1,43 @@
+import subprocess
+import os
+import shutil
+import signal
+
+TOASTER_TEST_BRANCH = 'toaster_tests'
+VENV_NAME = 'venv'
+SHELL_CMD = os.environ['SHELL'] if 'SHELL' in os.environ else "/bin/bash"
+
+def _execute_command(directory, cmd):
+    subprocess.check_call([SHELL_CMD, "-i", "-c", "cd %s; %s" % \
+        (directory, cmd)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+
+def _execute_command_venv(directory, venv, cmd):
+    _execute_command(directory, "source %s/%s/bin/activate; %s" % \
+        (directory, venv, cmd))
+
+def toaster_clone(directory, repo, ref='master', rm=False):
+    if os.path.exists(directory):
+        if rm:
+            shutil.rmtree(directory)
+        else:
+            raise IOError
+
+    subprocess.check_output([SHELL_CMD, "-i", "-c", "git clone %s %s" % \
+        (repo, directory)], stderr=subprocess.STDOUT)
+    _execute_command(directory, "git checkout %s -b %s" % \
+        (ref, TOASTER_TEST_BRANCH))
+
+def toaster_setup(directory):
+    _execute_command(directory, "virtualenv %s" % VENV_NAME)
+    _execute_command_venv(directory, VENV_NAME, "pip install -r" \
+        " bitbake/toaster-requirements.txt")
+
+def toaster_start(directory):
+    _execute_command_venv(directory, VENV_NAME,
+        "source %s/oe-init-build-env; source %s/bitbake/bin/toaster start" % \
+        (directory, directory))
+
+def toaster_stop(directory):
+    _execute_command_venv(directory, VENV_NAME,
+        "source %s/oe-init-build-env; source %s/bitbake/bin/toaster stop" % \
+        (directory, directory))
-- 
2.1.4



  parent reply	other threads:[~2016-02-09 22:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-09 22:43 [[PATCH][qa-tools] 00/16] Add Toaster test suite support Aníbal Limón
2016-02-09 22:43 ` [[PATCH][qa-tools] 01/16] README.md: Update instructions on how install host deps on debian Aníbal Limón
2016-02-09 22:43 ` [[PATCH][qa-tools] 02/16] utils/run/toaster.sh: Get rid of toaster shell script Aníbal Limón
2016-02-09 22:43 ` Aníbal Limón [this message]
2016-02-09 22:43 ` [[PATCH][qa-tools] 04/16] tests/toaster/__init__.py: Add support for clone/setup/start/stop Aníbal Limón
2016-02-09 22:43 ` [[PATCH][qa-tools] 05/16] tests/toaster/helpers.py: When execute bash remove interactive mode Aníbal Limón
2016-02-09 22:43 ` [[PATCH][qa-tools] 06/16] tests/toaster/helpers.py: Fix toaster_start deadlocks Aníbal Limón
2016-02-09 22:43 ` [[PATCH][qa-tools] 07/16] ts/toaster/helpers.py: Add new class ToasterHelper instead functions Aníbal Limón
2016-02-09 22:43 ` [[PATCH][qa-tools] 08/16] toaster/helper.py: Add force mode to stop method Aníbal Limón
2016-02-09 22:43 ` [[PATCH][qa-tools] 09/16] toaster/__init__.py: Update toaster test to match new ToasterHelper Aníbal Limón

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=1455057798-3213-4-git-send-email-anibal.limon@linux.intel.com \
    --to=anibal.limon@linux.intel.com \
    --cc=benjamin.esquivel@intel.com \
    --cc=limon.anibal@gmail.com \
    --cc=richard.purdie@intel.com \
    --cc=yocto@yoctoproject.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.