diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-02-04 14:13:57 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-02-08 08:00:27 +0000 |
commit | 7d73324af34e50726f806bc77dfb2d959e9d9e00 (patch) | |
tree | 22b1437e757549a8f63965bf5b7d542ea90aba41 /scripts/oe-selftest | |
parent | 336d28c413bafbba5662965998870d0154c2be0d (diff) | |
download | poky-7d73324af34e50726f806bc77dfb2d959e9d9e00.tar.gz |
scripts/oe-selftest: add command line option to list test classes
While trying to discover what tests are available, I felt the
need to be able to list all individual tests so I can run specific
tests.
This patch adds the "--list-classes" command line option that
lists the unit test classes and methods available.
(From OE-Core rev: f0ba400a398a172f9ebf953bb3a26e5d911a17d6)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/oe-selftest')
-rwxr-xr-x | scripts/oe-selftest | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/oe-selftest b/scripts/oe-selftest index 74c998bc43..a04e9fc96c 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest | |||
@@ -66,6 +66,7 @@ def get_args_parser(): | |||
66 | group.add_argument('--run-tests', required=False, action='store', nargs='*', dest="run_tests", default=None, help='Select what tests to run (modules, classes or test methods). Format should be: <module>.<class>.<test_method>') | 66 | group.add_argument('--run-tests', required=False, action='store', nargs='*', dest="run_tests", default=None, help='Select what tests to run (modules, classes or test methods). Format should be: <module>.<class>.<test_method>') |
67 | group.add_argument('--run-all-tests', required=False, action="store_true", dest="run_all_tests", default=False, help='Run all (unhidden) tests') | 67 | group.add_argument('--run-all-tests', required=False, action="store_true", dest="run_all_tests", default=False, help='Run all (unhidden) tests') |
68 | group.add_argument('--list-modules', required=False, action="store_true", dest="list_modules", default=False, help='List all available test modules.') | 68 | group.add_argument('--list-modules', required=False, action="store_true", dest="list_modules", default=False, help='List all available test modules.') |
69 | group.add_argument('--list-classes', required=False, action="store_true", dest="list_allclasses", default=False, help='List all available test classes.') | ||
69 | return parser | 70 | return parser |
70 | 71 | ||
71 | 72 | ||
@@ -138,6 +139,9 @@ def main(): | |||
138 | parser = get_args_parser() | 139 | parser = get_args_parser() |
139 | args = parser.parse_args() | 140 | args = parser.parse_args() |
140 | 141 | ||
142 | if args.list_allclasses: | ||
143 | args.list_modules = True | ||
144 | |||
141 | if args.list_modules: | 145 | if args.list_modules: |
142 | log.info('Listing all available test modules:') | 146 | log.info('Listing all available test modules:') |
143 | testslist = get_tests(include_hidden=True) | 147 | testslist = get_tests(include_hidden=True) |
@@ -147,6 +151,22 @@ def main(): | |||
147 | if module.startswith('_'): | 151 | if module.startswith('_'): |
148 | info = ' (hidden)' | 152 | info = ' (hidden)' |
149 | print module + info | 153 | print module + info |
154 | if args.list_allclasses: | ||
155 | try: | ||
156 | import importlib | ||
157 | modlib = importlib.import_module(test) | ||
158 | for v in vars(modlib): | ||
159 | t = vars(modlib)[v] | ||
160 | if isinstance(t, type(oeSelfTest)) and issubclass(t, oeSelfTest) and t!=oeSelfTest: | ||
161 | print " --", v | ||
162 | for method in dir(t): | ||
163 | if method.startswith("test_"): | ||
164 | print " -- --", method | ||
165 | |||
166 | except (AttributeError, ImportError) as e: | ||
167 | print e | ||
168 | pass | ||
169 | |||
150 | 170 | ||
151 | if args.run_tests or args.run_all_tests: | 171 | if args.run_tests or args.run_all_tests: |
152 | if not preflight_check(): | 172 | if not preflight_check(): |