summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Stanacar <stefanx.stanacar@intel.com>2013-08-25 01:46:55 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-28 23:36:08 +0100
commit5fba9d8c6c9982f59b0285fe17e91e162e25d495 (patch)
tree1623f5b4f1d02f54aa5b2274ef02275027b004b3
parent62d14181e7a8531c9894999efbacbe5f7cc7e199 (diff)
downloadpoky-1.5_M4.rc1.tar.gz
classes/testimage: add support for finding tests in other layers1.5_M4.rc1
A layer can add tests in lib/oeqa/runtime (provided it extends BBPATH as normal) and enable them with TEST_SUITES_append = " testname". Test module names shouldn't collide though. (From OE-Core rev: e1e347a2d509303e1c566450b0f2b485d3d6629f) Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/testimage.bbclass55
-rw-r--r--meta/lib/oeqa/runtime/__init__.py3
2 files changed, 46 insertions, 12 deletions
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index b30c841cec..4eef0be1d6 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -17,6 +17,7 @@
17# Each name in TEST_SUITES represents a required test for the image. (no skipping allowed) 17# Each name in TEST_SUITES represents a required test for the image. (no skipping allowed)
18# Appending "auto" means that it will try to run all tests that are suitable for the image (each test decides that on it's own). 18# Appending "auto" means that it will try to run all tests that are suitable for the image (each test decides that on it's own).
19# Note that order in TEST_SUITES is important (it's the order tests run) and it influences tests dependencies. 19# Note that order in TEST_SUITES is important (it's the order tests run) and it influences tests dependencies.
20# A layer can add its own tests in lib/oeqa/runtime, provided it extends BBPATH as normal in its layer.conf.
20 21
21# TEST_LOG_DIR contains a ssh log (what command is running, output and return codes) and a qemu boot log till login 22# TEST_LOG_DIR contains a ssh log (what command is running, output and return codes) and a qemu boot log till login
22# Booting is handled by this class, and it's not a test in itself. 23# Booting is handled by this class, and it's not a test in itself.
@@ -41,6 +42,43 @@ do_testimage[nostamp] = "1"
41do_testimage[depends] += "qemu-native:do_populate_sysroot" 42do_testimage[depends] += "qemu-native:do_populate_sysroot"
42do_testimage[depends] += "qemu-helper-native:do_populate_sysroot" 43do_testimage[depends] += "qemu-helper-native:do_populate_sysroot"
43 44
45
46def get_tests_list(d):
47 testsuites = d.getVar("TEST_SUITES", True).split()
48 bbpath = d.getVar("BBPATH", True).split(':')
49
50 # This relies on lib/ under each directory in BBPATH being added to sys.path
51 # (as done by default in base.bbclass)
52 testslist = []
53 for testname in testsuites:
54 if testname != "auto":
55 found = False
56 for p in bbpath:
57 if os.path.exists(os.path.join(p, 'lib', 'oeqa', 'runtime', testname + '.py')):
58 testslist.append("oeqa.runtime." + testname)
59 found = True
60 break
61 if not found:
62 bb.error('Test %s specified in TEST_SUITES could not be found in lib/oeqa/runtime under BBPATH' % testname)
63
64 if "auto" in testsuites:
65 def add_auto_list(path):
66 if not os.path.exists(os.path.join(path, '__init__.py')):
67 bb.fatal('Tests directory %s exists but is missing __init__.py' % path)
68 files = sorted([f for f in os.listdir(path) if f.endswith('.py') and not f.startswith('_')])
69 for f in files:
70 module = 'oeqa.runtime.' + f[:-3]
71 if module not in testslist:
72 testslist.append(module)
73
74 for p in bbpath:
75 testpath = os.path.join(p, 'lib', 'oeqa', 'runtime')
76 bb.debug(2, 'Searching for tests in %s' % testpath)
77 if os.path.exists(testpath):
78 add_auto_list(testpath)
79
80 return testslist
81
44def testimage_main(d): 82def testimage_main(d):
45 import unittest 83 import unittest
46 import os 84 import os
@@ -55,23 +93,16 @@ def testimage_main(d):
55 bb.utils.mkdirhier(testdir) 93 bb.utils.mkdirhier(testdir)
56 94
57 # tests in TEST_SUITES become required tests 95 # tests in TEST_SUITES become required tests
58 # they won't be skipped even if they aren't suitable for a default image (like xorg for minimal) 96 # they won't be skipped even if they aren't suitable for a image (like xorg for minimal)
59 testsuites = d.getVar("TEST_SUITES", True) 97 # testslist is what we'll actually pass to the unittest loader
60 # testslist is what we'll run and order matters 98 testslist = get_tests_list(d)
61 testslist = [ x for x in testsuites.split() if x != "auto" ] 99 testsrequired = [t for t in d.getVar("TEST_SUITES", True).split() if t != "auto"]
62 # if we have auto search for other modules
63 if "auto" in testsuites:
64 for f in os.listdir(os.path.dirname(os.path.abspath(oeqa.runtime.__file__))):
65 if f.endswith('.py') and not f.startswith('_') and f[:-3] not in testslist:
66 testslist.append(f[:-3])
67
68 testslist = [ "oeqa.runtime." + x for x in testslist ]
69 100
70 class TestContext: 101 class TestContext:
71 def __init__(self): 102 def __init__(self):
72 self.d = d 103 self.d = d
73 self.testslist = testslist 104 self.testslist = testslist
74 self.testsrequired = testsuites.split() 105 self.testsrequired = testsrequired
75 self.filesdir = os.path.join(os.path.dirname(os.path.abspath(oeqa.runtime.__file__)),"files") 106 self.filesdir = os.path.join(os.path.dirname(os.path.abspath(oeqa.runtime.__file__)),"files")
76 107
77 # test context 108 # test context
diff --git a/meta/lib/oeqa/runtime/__init__.py b/meta/lib/oeqa/runtime/__init__.py
index e69de29bb2..4cf3fa76b6 100644
--- a/meta/lib/oeqa/runtime/__init__.py
+++ b/meta/lib/oeqa/runtime/__init__.py
@@ -0,0 +1,3 @@
1# Enable other layers to have tests in the same named directory
2from pkgutil import extend_path
3__path__ = extend_path(__path__, __name__)