diff options
author | Ola x Nilsson <ola.x.nilsson@axis.com> | 2016-10-25 13:03:33 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-12-13 22:55:20 +0000 |
commit | 276523149914a75a939278b2e577383a2fdf3813 (patch) | |
tree | 3c321784a0902b290980562deeb93a1bf91a5d8e /meta-selftest/lib/recipetool | |
parent | 9170a88cbddd510e2cf93049af8825f20cb61426 (diff) | |
download | poky-276523149914a75a939278b2e577383a2fdf3813.tar.gz |
recipetool: selftest: Add test for recipetool plugin loading
Test that recipetool plugins are loaded in a well defined order.
(From OE-Core rev: 044de8424a454a7057906e44eb56e2134ebb17e4)
Signed-off-by: Ola x Nilsson <ola.x.nilsson@axis.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta-selftest/lib/recipetool')
-rw-r--r-- | meta-selftest/lib/recipetool/bbpath.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/meta-selftest/lib/recipetool/bbpath.py b/meta-selftest/lib/recipetool/bbpath.py new file mode 100644 index 0000000000..783b2dc769 --- /dev/null +++ b/meta-selftest/lib/recipetool/bbpath.py | |||
@@ -0,0 +1,41 @@ | |||
1 | import argparse | ||
2 | |||
3 | already_loaded = False | ||
4 | register_count = 0 | ||
5 | |||
6 | def plugin_name(filename): | ||
7 | return os.path.splitext(os.path.basename(filename))[0] | ||
8 | |||
9 | def plugin_init(plugins): | ||
10 | global already_loaded | ||
11 | already_loaded = plugin_name(__file__) in (plugin_name(p.__name__) for p in plugins) | ||
12 | |||
13 | def print_name(opts): | ||
14 | print (__file__) | ||
15 | |||
16 | def print_bbdir(opts): | ||
17 | print (__file__.replace('/lib/recipetool/bbpath.py','')) | ||
18 | |||
19 | def print_registered(opts): | ||
20 | #global kept_context | ||
21 | #print(kept_context.loaded) | ||
22 | print ("1") | ||
23 | |||
24 | def multiloaded(opts): | ||
25 | global already_loaded | ||
26 | print("yes" if already_loaded else "no") | ||
27 | |||
28 | def register_commands(subparsers): | ||
29 | global register_count | ||
30 | register_count += 1 | ||
31 | |||
32 | def addparser(name, helptxt, func): | ||
33 | parser = subparsers.add_parser(name, help=helptxt, | ||
34 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
35 | parser.set_defaults(func=func) | ||
36 | return parser | ||
37 | |||
38 | addparser('pluginfile', 'Print the filename of this plugin', print_name) | ||
39 | addparser('bbdir', 'Print the BBPATH directory of this plugin', print_bbdir) | ||
40 | addparser('count', 'How many times have this plugin been registered.', print_registered) | ||
41 | addparser('multiloaded', 'How many times have this plugin been initialized', multiloaded) | ||