[OE-core] [PATCH] scripts/oe-selftest: enhancement 7865
Costin Constantin
costin.c.constantin at intel.com
Sat Jun 13 20:58:38 UTC 2015
Signed-off-by: Costin Constantin <costin.c.constantin at intel.com>
---
scripts/oe-selftest | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/scripts/oe-selftest b/scripts/oe-selftest
index a04e9fc..1a89c31 100755
--- a/scripts/oe-selftest
+++ b/scripts/oe-selftest
@@ -16,7 +16,10 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# DESCRIPTION
-# This script runs tests defined in meta/lib/selftest/
+# This script runs tests defined in meta/lib/selftest/ for all $BUILDDIR/../meta* layers
+# In order to work, each meta* layer needs to have a relative lib/oeqa/selftest path to it.
+# Subdirectories to this relative path are accepted.
+# Test module names need to be unique between all layers.
# It's purpose is to automate the testing of different bitbake tools.
# To use it you just need to source your build environment setup script and
# add the meta-selftest layer to your BBLAYERS.
@@ -24,15 +27,26 @@
# Call the script as: "oe-selftest <module>.<Class>.<method>" to run just a single test
# E.g: "oe-selftest bboutput.BitbakeLayers" will run just the BitbakeLayers class from meta/lib/selftest/bboutput.py
-
import os
import sys
import unittest
import logging
import argparse
+import glob as g
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'meta/lib')))
+tests_path = g.glob(os.path.abspath(os.path.join(os.getenv("BUILDDIR"), "..", "meta*/lib/oeqa/selftest")))
+# adding tests paths to the sys.path enabling dynamic import further on
+# support for subdirectories is also added
+test_subdirs = []
+for pth in tests_path:
+ sys.path.insert(0, pth)
+ for sbd in g.glob(pth + "/*"):
+ if os.path.isdir(sbd):
+ sys.path.append(sbd)
+ test_subdirs.append(sbd)
+
import oeqa.selftest
import oeqa.utils.ftools as ftools
from oeqa.utils.commands import runCmd, get_bb_var, get_test_layer
@@ -125,14 +139,13 @@ def remove_inc_files():
def get_tests(exclusive_modules=[], include_hidden=False):
testslist = []
for x in exclusive_modules:
- testslist.append('oeqa.selftest.' + x)
+ testslist.append(x)
if not testslist:
- testpath = os.path.abspath(os.path.dirname(oeqa.selftest.__file__))
- files = sorted([f for f in os.listdir(testpath) if f.endswith('.py') and not (f.startswith('_') and not include_hidden) and not f.startswith('__') and f != 'base.py'])
- for f in files:
- module = 'oeqa.selftest.' + f[:-3]
- testslist.append(module)
-
+ for pth in (tests_path + test_subdirs) :
+ files = sorted([f for f in os.listdir(pth) if f.endswith('.py') and not (f.startswith('_') and not include_hidden) and not f.startswith('__') and f != 'base.py'])
+ for f in files:
+ module = f[:-3]
+ testslist.append(module)
return testslist
def main():
@@ -145,8 +158,7 @@ def main():
if args.list_modules:
log.info('Listing all available test modules:')
testslist = get_tests(include_hidden=True)
- for test in testslist:
- module = test.split('.')[-1]
+ for module in testslist:
info = ''
if module.startswith('_'):
info = ' (hidden)'
@@ -154,7 +166,7 @@ def main():
if args.list_allclasses:
try:
import importlib
- modlib = importlib.import_module(test)
+ modlib = importlib.import_module(module)
for v in vars(modlib):
t = vars(modlib)[v]
if isinstance(t, type(oeSelfTest)) and issubclass(t, oeSelfTest) and t!=oeSelfTest:
--
2.1.4
More information about the Openembedded-core
mailing list