* [PATCH 1/6] oeqa/oetest.py: Add class ExportTestContext
2016-05-02 13:19 [PATCH 0/6] Decouple testexport from testimage mariano.lopez
@ 2016-05-02 13:19 ` mariano.lopez
2016-05-02 13:19 ` [PATCH 2/6] testexport.bbclass: Split testimage class mariano.lopez
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mariano.lopez @ 2016-05-02 13:19 UTC (permalink / raw)
To: openembedded-core
From: Mariano Lopez <mariano.lopez@linux.intel.com>
Adding the class is needed to separate the exported test
from the test image; both test run under different conditions,
i.e. an exported test doesn't require to change the signal
handling.
This change adds clasess ExportTestContext and ImageTestContext,
both of them inherits from RuntimeTestContext. Also refactors
RuntimeTestContext class, to keep the code common in this class.
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
meta/lib/oeqa/oetest.py | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index 3ed5bb8..bef9ac4 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -331,14 +331,13 @@ class TestContext(object):
return runner.run(self.suite)
-class ImageTestContext(TestContext):
- def __init__(self, d, target, host_dumper):
- super(ImageTestContext, self).__init__(d)
+class RuntimeTestContext(TestContext):
+ def __init__(self, d, target):
+ super(RuntimeTestContext, self).__init__(d)
self.tagexp = d.getVar("TEST_SUITES_TAGS", True)
self.target = target
- self.host_dumper = host_dumper
manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True),
d.getVar("IMAGE_LINK_NAME", True) + ".manifest")
@@ -352,15 +351,6 @@ class ImageTestContext(TestContext):
else:
self.pkgmanifest = ""
- self.sigterm = False
- self.origsigtermhandler = signal.getsignal(signal.SIGTERM)
- signal.signal(signal.SIGTERM, self._sigterm_exception)
-
- def _sigterm_exception(self, signum, stackframe):
- bb.warn("TestImage received SIGTERM, shutting down...")
- self.sigterm = True
- self.target.stop()
-
def _get_test_namespace(self):
return "runtime"
@@ -382,9 +372,29 @@ class ImageTestContext(TestContext):
return [t for t in self.d.getVar("TEST_SUITES", True).split() if t != "auto"]
def loadTests(self):
- super(ImageTestContext, self).loadTests()
+ super(RuntimeTestContext, self).loadTests()
setattr(oeRuntimeTest, "pscmd", "ps -ef" if oeTest.hasPackage("procps") else "ps")
+class ImageTestContext(RuntimeTestContext):
+ def __init__(self, d, target, host_dumper):
+ super(ImageTestContext, self).__init__(d, target)
+
+ self.host_dumper = host_dumper
+
+ self.sigterm = False
+ self.origsigtermhandler = signal.getsignal(signal.SIGTERM)
+ signal.signal(signal.SIGTERM, self._sigterm_exception)
+
+ def _sigterm_exception(self, signum, stackframe):
+ bb.warn("TestImage received SIGTERM, shutting down...")
+ self.sigterm = True
+ self.target.stop()
+
+class ExportTestContext(RuntimeTestContext):
+ def __init__(self, d, target):
+ super(ExportTestContext, self).__init__(d, target)
+ self.sigterm = None
+
class SDKTestContext(TestContext):
def __init__(self, d, sdktestdir, sdkenv, tcname, *args):
super(SDKTestContext, self).__init__(d)
--
2.6.6
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/6] testexport.bbclass: Split testimage class
2016-05-02 13:19 [PATCH 0/6] Decouple testexport from testimage mariano.lopez
2016-05-02 13:19 ` [PATCH 1/6] oeqa/oetest.py: Add class ExportTestContext mariano.lopez
@ 2016-05-02 13:19 ` mariano.lopez
2016-05-02 13:19 ` [PATCH 3/6] oeqa/runexported.py: Remove host dumper mariano.lopez
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mariano.lopez @ 2016-05-02 13:19 UTC (permalink / raw)
To: openembedded-core
From: Mariano Lopez <mariano.lopez@linux.intel.com>
This adds a new class that only export tests of images,
the code was taken from testimage class and most of it
wasn't modified. Just add some vars for the new class.
testexport class require testimage class to get the
test suites defined for all the images.
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
meta/classes/testexport.bbclass | 150 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 150 insertions(+)
create mode 100644 meta/classes/testexport.bbclass
diff --git a/meta/classes/testexport.bbclass b/meta/classes/testexport.bbclass
new file mode 100644
index 0000000..0aac030
--- /dev/null
+++ b/meta/classes/testexport.bbclass
@@ -0,0 +1,150 @@
+# Copyright (C) 2016 Intel Corporation
+#
+# Released under the MIT license (see COPYING.MIT)
+#
+#
+# testexport.bbclass allows to execute runtime test outside OE environment.
+# Most of the tests are commands run on target image over ssh.
+# To use it add testexport to global inherit and call your target image with -c testexport
+# You can try it out like this:
+# - First build an image. i.e. core-image-sato
+# - Add INHERIT += "testexport" in local.conf
+# - Then bitbake core-image-sato -c testexport. That will generate the directory structure
+# to execute the runtime tests using runexported.py.
+#
+# For more information on TEST_SUITES check testimage class.
+
+TEST_LOG_DIR ?= "${WORKDIR}/testexport"
+TEST_EXPORT_DIR ?= "${TMPDIR}/testexport/${PN}"
+TEST_TARGET ?= "simpleremote"
+TEST_TARGET_IP ?= ""
+TEST_SERVER_IP ?= ""
+
+TEST_EXPORT_DEPENDS = ""
+TEST_EXPORT_LOCK = "${TMPDIR}/testimage.lock"
+
+python do_testexport() {
+ testexport_main(d)
+}
+
+addtask testexport
+do_testimage[nostamp] = "1"
+do_testimage[depends] += "${TEST_EXPORT_DEPENDS}"
+do_testimage[lockfiles] += "${TEST_EXPORT_LOCK}"
+
+def exportTests(d,tc):
+ import json
+ import shutil
+ import pkgutil
+ import re
+
+ exportpath = d.getVar("TEST_EXPORT_DIR", True)
+
+ savedata = {}
+ savedata["d"] = {}
+ savedata["target"] = {}
+ for key in tc.__dict__:
+ # special cases
+ if key not in ['d', 'target', 'suite']:
+ savedata[key] = getattr(tc, key)
+ savedata["target"]["ip"] = tc.target.ip or d.getVar("TEST_TARGET_IP", True)
+ savedata["target"]["server_ip"] = tc.target.server_ip or d.getVar("TEST_SERVER_IP", True)
+
+ keys = [ key for key in d.keys() if not key.startswith("_") and not key.startswith("BB") \
+ and not key.startswith("B_pn") and not key.startswith("do_") and not d.getVarFlag(key, "func", True)]
+ for key in keys:
+ try:
+ savedata["d"][key] = d.getVar(key, True)
+ except bb.data_smart.ExpansionError:
+ # we don't care about those anyway
+ pass
+
+ json_file = os.path.join(exportpath, "testdata.json")
+ with open(json_file, "w") as f:
+ json.dump(savedata, f, skipkeys=True, indent=4, sort_keys=True)
+
+ # Replace absolute path with relative in the file
+ exclude_path = os.path.join(d.getVar("COREBASE", True),'meta','lib','oeqa')
+ f1 = open(json_file,'r').read()
+ f2 = open(json_file,'w')
+ m = f1.replace(exclude_path,'oeqa')
+ f2.write(m)
+ f2.close()
+
+ # now start copying files
+ # we'll basically copy everything under meta/lib/oeqa, with these exceptions
+ # - oeqa/targetcontrol.py - not needed
+ # - oeqa/selftest - something else
+ # That means:
+ # - all tests from oeqa/runtime defined in TEST_SUITES (including from other layers)
+ # - the contents of oeqa/utils and oeqa/runtime/files
+ # - oeqa/oetest.py and oeqa/runexport.py (this will get copied to exportpath not exportpath/oeqa)
+ # - __init__.py files
+ bb.utils.mkdirhier(os.path.join(exportpath, "oeqa/runtime/files"))
+ bb.utils.mkdirhier(os.path.join(exportpath, "oeqa/utils"))
+ # copy test modules, this should cover tests in other layers too
+ bbpath = d.getVar("BBPATH", True).split(':')
+ for t in tc.testslist:
+ isfolder = False
+ if re.search("\w+\.\w+\.test_\S+", t):
+ t = '.'.join(t.split('.')[:3])
+ mod = pkgutil.get_loader(t)
+ # More depth than usual?
+ if (t.count('.') > 2):
+ for p in bbpath:
+ foldername = os.path.join(p, 'lib', os.sep.join(t.split('.')).rsplit(os.sep, 1)[0])
+ if os.path.isdir(foldername):
+ isfolder = True
+ target_folder = os.path.join(exportpath, "oeqa", "runtime", os.path.basename(foldername))
+ if not os.path.exists(target_folder):
+ shutil.copytree(foldername, target_folder)
+ if not isfolder:
+ shutil.copy2(mod.filename, os.path.join(exportpath, "oeqa/runtime"))
+ # copy __init__.py files
+ oeqadir = pkgutil.get_loader("oeqa").filename
+ shutil.copy2(os.path.join(oeqadir, "__init__.py"), os.path.join(exportpath, "oeqa"))
+ shutil.copy2(os.path.join(oeqadir, "runtime/__init__.py"), os.path.join(exportpath, "oeqa/runtime"))
+ # copy oeqa/oetest.py and oeqa/runexported.py
+ shutil.copy2(os.path.join(oeqadir, "oetest.py"), os.path.join(exportpath, "oeqa"))
+ shutil.copy2(os.path.join(oeqadir, "runexported.py"), exportpath)
+ # copy oeqa/utils/*.py
+ for root, dirs, files in os.walk(os.path.join(oeqadir, "utils")):
+ for f in files:
+ if f.endswith(".py"):
+ shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/utils"))
+ # copy oeqa/runtime/files/*
+ for root, dirs, files in os.walk(os.path.join(oeqadir, "runtime/files")):
+ for f in files:
+ shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/runtime/files"))
+
+ bb.plain("Exported tests to: %s" % exportpath)
+
+def testexport_main(d):
+ from oeqa.oetest import ExportTestContext
+ from oeqa.targetcontrol import get_target_controller
+ from oeqa.utils.dump import get_host_dumper
+
+ bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True))
+ bb.utils.remove(d.getVar("TEST_EXPORT_DIR", True), recurse=True)
+ bb.utils.mkdirhier(d.getVar("TEST_EXPORT_DIR", True))
+
+ # the robot dance
+ target = get_target_controller(d)
+
+ # test context
+ tc = ExportTestContext(d, target)
+
+ # this is a dummy load of tests
+ # we are doing that to find compile errors in the tests themselves
+ # before booting the image
+ try:
+ tc.loadTests()
+ except Exception as e:
+ import traceback
+ bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
+
+ exportTests(d,tc)
+
+testexport_main[vardepsexclude] =+ "BB_ORIGENV"
+
+inherit testimage
--
2.6.6
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/6] oeqa/runexported.py: Remove host dumper
2016-05-02 13:19 [PATCH 0/6] Decouple testexport from testimage mariano.lopez
2016-05-02 13:19 ` [PATCH 1/6] oeqa/oetest.py: Add class ExportTestContext mariano.lopez
2016-05-02 13:19 ` [PATCH 2/6] testexport.bbclass: Split testimage class mariano.lopez
@ 2016-05-02 13:19 ` mariano.lopez
2016-05-02 13:19 ` [PATCH 4/6] testimage.bbclass: Remove exported test mariano.lopez
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mariano.lopez @ 2016-05-02 13:19 UTC (permalink / raw)
To: openembedded-core
From: Mariano Lopez <mariano.lopez@linux.intel.com>
The host dumper is used to get information about the host
running the test when a test fails. This is used for the
autobuilders of Yocto Project.
Now that exported tests have thier own class the host dumper
is not necessary anymore.
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
meta/lib/oeqa/runexported.py | 5 -----
1 file changed, 5 deletions(-)
diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py
index cc89e13..f333879 100755
--- a/meta/lib/oeqa/runexported.py
+++ b/meta/lib/oeqa/runexported.py
@@ -116,16 +116,11 @@ def main():
for key in loaded["target"].keys():
setattr(target, key, loaded["target"][key])
- host_dumper = get_host_dumper(d)
- host_dumper.parent_dir = loaded["host_dumper"]["parent_dir"]
- host_dumper.cmds = loaded["host_dumper"]["cmds"]
-
target.exportStart()
tc = ExportTestContext(d)
setattr(tc, "d", d)
setattr(tc, "target", target)
- setattr(tc, "host_dumper", host_dumper)
for key in loaded.keys():
if key != "d" and key != "target" and key != "host_dumper":
setattr(tc, key, loaded[key])
--
2.6.6
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 4/6] testimage.bbclass: Remove exported test
2016-05-02 13:19 [PATCH 0/6] Decouple testexport from testimage mariano.lopez
` (2 preceding siblings ...)
2016-05-02 13:19 ` [PATCH 3/6] oeqa/runexported.py: Remove host dumper mariano.lopez
@ 2016-05-02 13:19 ` mariano.lopez
2016-05-02 13:19 ` [PATCH 5/6] oetest.py: Add default pscmd to oeTest mariano.lopez
2016-05-02 13:19 ` [PATCH 6/6] oetest.py: Use the real ExportTestContext in exported tests mariano.lopez
5 siblings, 0 replies; 7+ messages in thread
From: mariano.lopez @ 2016-05-02 13:19 UTC (permalink / raw)
To: openembedded-core
From: Mariano Lopez <mariano.lopez@linux.intel.com>
Exported tests now have their own class, so
the code in testimage is not needed anymore.
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
meta/classes/testimage.bbclass | 137 +++++------------------------------------
1 file changed, 17 insertions(+), 120 deletions(-)
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index e77bb11..a2e13df 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -30,7 +30,6 @@
TEST_LOG_DIR ?= "${WORKDIR}/testimage"
TEST_EXPORT_DIR ?= "${TMPDIR}/testimage/${PN}"
-TEST_EXPORT_ONLY ?= "0"
RPMTESTSUITE = "${@bb.utils.contains('IMAGE_PKGTYPE', 'rpm', 'smart rpm', '', d)}"
MINTESTSUITE = "ping"
@@ -62,8 +61,6 @@ TEST_SUITES ?= "${DEFAULT_TEST_SUITES}"
TEST_QEMUBOOT_TIMEOUT ?= "1000"
TEST_TARGET ?= "qemu"
-TEST_TARGET_IP ?= ""
-TEST_SERVER_IP ?= ""
TESTIMAGEDEPENDS = ""
TESTIMAGEDEPENDS_qemuall = "qemu-native:do_populate_sysroot qemu-helper-native:do_populate_sysroot"
@@ -108,97 +105,6 @@ do_testimage[nostamp] = "1"
do_testimage[depends] += "${TESTIMAGEDEPENDS}"
do_testimage[lockfiles] += "${TESTIMAGELOCK}"
-def exportTests(d,tc):
- import json
- import shutil
- import pkgutil
- import re
-
- exportpath = d.getVar("TEST_EXPORT_DIR", True)
-
- savedata = {}
- savedata["d"] = {}
- savedata["target"] = {}
- savedata["host_dumper"] = {}
- for key in tc.__dict__:
- # special cases
- if key not in ['d', 'target', 'host_dumper', 'suite']:
- savedata[key] = getattr(tc, key)
- savedata["target"]["ip"] = tc.target.ip or d.getVar("TEST_TARGET_IP", True)
- savedata["target"]["server_ip"] = tc.target.server_ip or d.getVar("TEST_SERVER_IP", True)
-
- keys = [ key for key in d.keys() if not key.startswith("_") and not key.startswith("BB") \
- and not key.startswith("B_pn") and not key.startswith("do_") and not d.getVarFlag(key, "func", True)]
- for key in keys:
- try:
- savedata["d"][key] = d.getVar(key, True)
- except bb.data_smart.ExpansionError:
- # we don't care about those anyway
- pass
-
- savedata["host_dumper"]["parent_dir"] = tc.host_dumper.parent_dir
- savedata["host_dumper"]["cmds"] = tc.host_dumper.cmds
-
- json_file = os.path.join(exportpath, "testdata.json")
- with open(json_file, "w") as f:
- json.dump(savedata, f, skipkeys=True, indent=4, sort_keys=True)
-
- # Replace absolute path with relative in the file
- exclude_path = os.path.join(d.getVar("COREBASE", True),'meta','lib','oeqa')
- f1 = open(json_file,'r').read()
- f2 = open(json_file,'w')
- m = f1.replace(exclude_path,'oeqa')
- f2.write(m)
- f2.close()
-
- # now start copying files
- # we'll basically copy everything under meta/lib/oeqa, with these exceptions
- # - oeqa/targetcontrol.py - not needed
- # - oeqa/selftest - something else
- # That means:
- # - all tests from oeqa/runtime defined in TEST_SUITES (including from other layers)
- # - the contents of oeqa/utils and oeqa/runtime/files
- # - oeqa/oetest.py and oeqa/runexport.py (this will get copied to exportpath not exportpath/oeqa)
- # - __init__.py files
- bb.utils.mkdirhier(os.path.join(exportpath, "oeqa/runtime/files"))
- bb.utils.mkdirhier(os.path.join(exportpath, "oeqa/utils"))
- # copy test modules, this should cover tests in other layers too
- bbpath = d.getVar("BBPATH", True).split(':')
- for t in tc.testslist:
- isfolder = False
- if re.search("\w+\.\w+\.test_\S+", t):
- t = '.'.join(t.split('.')[:3])
- mod = pkgutil.get_loader(t)
- # More depth than usual?
- if (t.count('.') > 2):
- for p in bbpath:
- foldername = os.path.join(p, 'lib', os.sep.join(t.split('.')).rsplit(os.sep, 1)[0])
- if os.path.isdir(foldername):
- isfolder = True
- target_folder = os.path.join(exportpath, "oeqa", "runtime", os.path.basename(foldername))
- if not os.path.exists(target_folder):
- shutil.copytree(foldername, target_folder)
- if not isfolder:
- shutil.copy2(mod.filename, os.path.join(exportpath, "oeqa/runtime"))
- # copy __init__.py files
- oeqadir = pkgutil.get_loader("oeqa").filename
- shutil.copy2(os.path.join(oeqadir, "__init__.py"), os.path.join(exportpath, "oeqa"))
- shutil.copy2(os.path.join(oeqadir, "runtime/__init__.py"), os.path.join(exportpath, "oeqa/runtime"))
- # copy oeqa/oetest.py and oeqa/runexported.py
- shutil.copy2(os.path.join(oeqadir, "oetest.py"), os.path.join(exportpath, "oeqa"))
- shutil.copy2(os.path.join(oeqadir, "runexported.py"), exportpath)
- # copy oeqa/utils/*.py
- for root, dirs, files in os.walk(os.path.join(oeqadir, "utils")):
- for f in files:
- if f.endswith(".py"):
- shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/utils"))
- # copy oeqa/runtime/files/*
- for root, dirs, files in os.walk(os.path.join(oeqadir, "runtime/files")):
- for f in files:
- shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/runtime/files"))
-
- bb.plain("Exported tests to: %s" % exportpath)
-
def testimage_main(d):
import unittest
import os
@@ -210,11 +116,7 @@ def testimage_main(d):
from oeqa.utils.dump import get_host_dumper
pn = d.getVar("PN", True)
- export = oe.utils.conditional("TEST_EXPORT_ONLY", "1", True, False, d)
bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True))
- if export:
- bb.utils.remove(d.getVar("TEST_EXPORT_DIR", True), recurse=True)
- bb.utils.mkdirhier(d.getVar("TEST_EXPORT_DIR", True))
# we need the host dumper in test context
host_dumper = get_host_dumper(d)
@@ -234,29 +136,24 @@ def testimage_main(d):
import traceback
bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
- if export:
+ target.deploy()
+ try:
+ target.start()
+ starttime = time.time()
+ result = tc.runTests()
+ stoptime = time.time()
+ if result.wasSuccessful():
+ bb.plain("%s - Ran %d test%s in %.3fs" % (pn, result.testsRun, result.testsRun != 1 and "s" or "", stoptime - starttime))
+ msg = "%s - OK - All required tests passed" % pn
+ skipped = len(result.skipped)
+ if skipped:
+ msg += " (skipped=%d)" % skipped
+ bb.plain(msg)
+ else:
+ raise bb.build.FuncFailed("%s - FAILED - check the task log and the ssh log" % pn )
+ finally:
signal.signal(signal.SIGTERM, tc.origsigtermhandler)
- tc.origsigtermhandler = None
- exportTests(d,tc)
- else:
- target.deploy()
- try:
- target.start()
- starttime = time.time()
- result = tc.runTests()
- stoptime = time.time()
- if result.wasSuccessful():
- bb.plain("%s - Ran %d test%s in %.3fs" % (pn, result.testsRun, result.testsRun != 1 and "s" or "", stoptime - starttime))
- msg = "%s - OK - All required tests passed" % pn
- skipped = len(result.skipped)
- if skipped:
- msg += " (skipped=%d)" % skipped
- bb.plain(msg)
- else:
- raise bb.build.FuncFailed("%s - FAILED - check the task log and the ssh log" % pn )
- finally:
- signal.signal(signal.SIGTERM, tc.origsigtermhandler)
- target.stop()
+ target.stop()
testimage_main[vardepsexclude] =+ "BB_ORIGENV"
--
2.6.6
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 5/6] oetest.py: Add default pscmd to oeTest
2016-05-02 13:19 [PATCH 0/6] Decouple testexport from testimage mariano.lopez
` (3 preceding siblings ...)
2016-05-02 13:19 ` [PATCH 4/6] testimage.bbclass: Remove exported test mariano.lopez
@ 2016-05-02 13:19 ` mariano.lopez
2016-05-02 13:19 ` [PATCH 6/6] oetest.py: Use the real ExportTestContext in exported tests mariano.lopez
5 siblings, 0 replies; 7+ messages in thread
From: mariano.lopez @ 2016-05-02 13:19 UTC (permalink / raw)
To: openembedded-core
From: Mariano Lopez <mariano.lopez@linux.intel.com>
pscmd is used by some tests to get the process
running on the target. If the test are exported
there won't be any pscmd attibute in the oeTest.
This adds "ps" as default pscmd.
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
meta/lib/oeqa/oetest.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index bef9ac4..6a908ee 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -54,6 +54,7 @@ def filterByTagExp(testsuite, tagexp):
@LogResults
class oeTest(unittest.TestCase):
+ pscmd = "ps"
longMessage = True
@classmethod
@@ -373,7 +374,8 @@ class RuntimeTestContext(TestContext):
def loadTests(self):
super(RuntimeTestContext, self).loadTests()
- setattr(oeRuntimeTest, "pscmd", "ps -ef" if oeTest.hasPackage("procps") else "ps")
+ if oeTest.hasPackage("procps"):
+ oeRuntimeTest.pscmd = "ps -ef"
class ImageTestContext(RuntimeTestContext):
def __init__(self, d, target, host_dumper):
--
2.6.6
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 6/6] oetest.py: Use the real ExportTestContext in exported tests
2016-05-02 13:19 [PATCH 0/6] Decouple testexport from testimage mariano.lopez
` (4 preceding siblings ...)
2016-05-02 13:19 ` [PATCH 5/6] oetest.py: Add default pscmd to oeTest mariano.lopez
@ 2016-05-02 13:19 ` mariano.lopez
5 siblings, 0 replies; 7+ messages in thread
From: mariano.lopez @ 2016-05-02 13:19 UTC (permalink / raw)
To: openembedded-core
From: Mariano Lopez <mariano.lopez@linux.intel.com>
There are parts of the fuctionallity missing when using the
dummy ExportTestContext class in runexported.py.
This changes the use of ExportTestContext dummy class from
runexported.py to the real class in oetest.py.
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
meta/lib/oeqa/oetest.py | 26 +++++++++++++++++---------
meta/lib/oeqa/runexported.py | 16 ++--------------
2 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index 6a908ee..70db119 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -186,11 +186,19 @@ def custom_verbose(msg, *args, **kwargs):
_buffer_logger = ""
class TestContext(object):
- def __init__(self, d):
+ def __init__(self, d, exported=False):
self.d = d
self.testsuites = self._get_test_suites()
- self.testslist = self._get_tests_list(d.getVar("BBPATH", True).split(':'))
+
+ if exported:
+ path = [os.path.dirname(os.path.abspath(__file__))]
+ extrapath = ""
+ else:
+ path = d.getVar("BBPATH", True).split(':')
+ extrapath = "lib/oeqa"
+
+ self.testslist = self._get_tests_list(path, extrapath)
self.testsrequired = self._get_test_suites_required()
self.filesdir = os.path.join(os.path.dirname(os.path.abspath(
@@ -213,7 +221,7 @@ class TestContext(object):
return " ".join(tcs)
# return test list by type also filter if TEST_SUITES is specified
- def _get_tests_list(self, bbpath):
+ def _get_tests_list(self, bbpath, extrapath):
testslist = []
type = self._get_test_namespace()
@@ -227,11 +235,11 @@ class TestContext(object):
continue
found = False
for p in bbpath:
- if os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname + '.py')):
+ if os.path.exists(os.path.join(p, extrapath, type, testname + ".py")):
testslist.append("oeqa." + type + "." + testname)
found = True
break
- elif os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname.split(".")[0] + '.py')):
+ elif os.path.exists(os.path.join(p, extrapath, type, testname.split(".")[0] + ".py")):
testslist.append("oeqa." + type + "." + testname)
found = True
break
@@ -333,8 +341,8 @@ class TestContext(object):
return runner.run(self.suite)
class RuntimeTestContext(TestContext):
- def __init__(self, d, target):
- super(RuntimeTestContext, self).__init__(d)
+ def __init__(self, d, target, exported=False):
+ super(RuntimeTestContext, self).__init__(d, exported)
self.tagexp = d.getVar("TEST_SUITES_TAGS", True)
@@ -393,8 +401,8 @@ class ImageTestContext(RuntimeTestContext):
self.target.stop()
class ExportTestContext(RuntimeTestContext):
- def __init__(self, d, target):
- super(ExportTestContext, self).__init__(d, target)
+ def __init__(self, d, target, exported=False):
+ super(ExportTestContext, self).__init__(d, target, exported)
self.sigterm = None
class SDKTestContext(TestContext):
diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py
index f333879..52c1171 100755
--- a/meta/lib/oeqa/runexported.py
+++ b/meta/lib/oeqa/runexported.py
@@ -30,7 +30,7 @@ except ImportError:
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "oeqa")))
-from oeqa.oetest import TestContext
+from oeqa.oetest import ExportTestContext
from oeqa.utils.sshcontrol import SSHControl
from oeqa.utils.dump import get_host_dumper
@@ -69,10 +69,6 @@ class MyDataDict(dict):
def getVar(self, key, unused = None):
return self.get(key, "")
-class ExportTestContext(TestContext):
- def __init__(self, d):
- self.d = d
-
def main():
parser = argparse.ArgumentParser()
@@ -111,20 +107,12 @@ def main():
if not os.path.isdir(d["DEPLOY_DIR"]):
print("WARNING: The path to DEPLOY_DIR does not exist: %s" % d["DEPLOY_DIR"])
-
target = FakeTarget(d)
for key in loaded["target"].keys():
setattr(target, key, loaded["target"][key])
target.exportStart()
- tc = ExportTestContext(d)
-
- setattr(tc, "d", d)
- setattr(tc, "target", target)
- for key in loaded.keys():
- if key != "d" and key != "target" and key != "host_dumper":
- setattr(tc, key, loaded[key])
-
+ tc = ExportTestContext(d, target, True)
tc.loadTests()
tc.runTests()
--
2.6.6
^ permalink raw reply related [flat|nested] 7+ messages in thread