diff options
author | Costin Constantin <costin.c.constantin@intel.com> | 2016-02-22 14:32:55 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-28 11:32:58 +0000 |
commit | d2a563c32c62908a8c8eb9618f86a3fc9e5fe5bc (patch) | |
tree | 2c0c93b65fe57b0f6f4bea1815acaaa370f37dd7 | |
parent | 7f58b9298cc14dfa2a337a8177a82245b3b45513 (diff) | |
download | poky-d2a563c32c62908a8c8eb9618f86a3fc9e5fe5bc.tar.gz |
oe-selftest: Add support for lib/oeqa/selftest subdirectories
This patch adds functionality to allow creating subdirectories inside
lib/oeqa/selftest for all layers present in BBLAYERS. Like this, test
cases can be grouped into organized directories.
Addresses [YOCTO #7865]
(From OE-Core rev: 445b84456659ebb355149f6b0dca543b0bb2679c)
Signed-off-by: Costin Constantin <costin.c.constantin@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | scripts/oe-selftest | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/scripts/oe-selftest b/scripts/oe-selftest index bd9cbe0826..de98a6cb0d 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest | |||
@@ -162,19 +162,33 @@ def remove_inc_files(): | |||
162 | except: | 162 | except: |
163 | pass | 163 | pass |
164 | 164 | ||
165 | |||
166 | def get_tests_modules(include_hidden=False): | ||
167 | modules_list = list() | ||
168 | for modules_path in oeqa.selftest.__path__: | ||
169 | for (p, d, f) in os.walk(modules_path): | ||
170 | files = sorted([f for f in os.listdir(p) if f.endswith('.py') and not (f.startswith('_') and not include_hidden) and not f.startswith('__') and f != 'base.py']) | ||
171 | for f in files: | ||
172 | submodules = p.split("selftest")[-1] | ||
173 | module = "" | ||
174 | if submodules: | ||
175 | module = 'oeqa.selftest' + submodules.replace("/",".") + "." + f.split('.py')[0] | ||
176 | else: | ||
177 | module = 'oeqa.selftest.' + f.split('.py')[0] | ||
178 | if module not in modules_list: | ||
179 | modules_list.append(module) | ||
180 | return modules_list | ||
181 | |||
182 | |||
165 | def get_tests(exclusive_modules=[], include_hidden=False): | 183 | def get_tests(exclusive_modules=[], include_hidden=False): |
166 | testslist = [] | 184 | test_modules = list() |
167 | for x in exclusive_modules: | 185 | for x in exclusive_modules: |
168 | testslist.append('oeqa.selftest.' + x) | 186 | test_modules.append('oeqa.selftest.' + x) |
169 | if not testslist: | 187 | if not test_modules: |
170 | for testpath in oeqa.selftest.__path__: | 188 | inc_hidden = include_hidden |
171 | 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']) | 189 | test_modules = get_tests_modules(inc_hidden) |
172 | for f in files: | ||
173 | module = 'oeqa.selftest.' + f[:-3] | ||
174 | if module not in testslist: | ||
175 | testslist.append(module) | ||
176 | 190 | ||
177 | return testslist | 191 | return test_modules |
178 | 192 | ||
179 | 193 | ||
180 | class Tc: | 194 | class Tc: |
@@ -221,23 +235,12 @@ def get_tests_from_module(tmod): | |||
221 | 235 | ||
222 | 236 | ||
223 | def get_all_tests(): | 237 | def get_all_tests(): |
224 | tmodules = set() | ||
225 | testlist = [] | ||
226 | prefix = 'oeqa.selftest.' | ||
227 | |||
228 | # Get all the test modules (except the hidden ones) | 238 | # Get all the test modules (except the hidden ones) |
229 | for tpath in oeqa.selftest.__path__: | 239 | testlist = [] |
230 | files = sorted([f for f in os.listdir(tpath) if f.endswith('.py') and not | 240 | tests_modules = get_tests_modules() |
231 | f.startswith(('_', '__')) and f != 'base.py']) | ||
232 | for f in files: | ||
233 | tmodules.add(prefix + f.rstrip('.py')) | ||
234 | |||
235 | # Get all the tests from modules | 241 | # Get all the tests from modules |
236 | tmodules = sorted(list(tmodules)) | 242 | for tmod in sorted(tests_modules): |
237 | |||
238 | for tmod in tmodules: | ||
239 | testlist += get_tests_from_module(tmod) | 243 | testlist += get_tests_from_module(tmod) |
240 | |||
241 | return testlist | 244 | return testlist |
242 | 245 | ||
243 | 246 | ||
@@ -481,7 +484,7 @@ def main(): | |||
481 | log.info('Listing all available test modules:') | 484 | log.info('Listing all available test modules:') |
482 | testslist = get_tests(include_hidden=True) | 485 | testslist = get_tests(include_hidden=True) |
483 | for test in testslist: | 486 | for test in testslist: |
484 | module = test.split('.')[-1] | 487 | module = test.split('oeqa.selftest.')[-1] |
485 | info = '' | 488 | info = '' |
486 | if module.startswith('_'): | 489 | if module.startswith('_'): |
487 | info = ' (hidden)' | 490 | info = ' (hidden)' |