summaryrefslogtreecommitdiffstats
path: root/meta-selftest
diff options
context:
space:
mode:
authorOla x Nilsson <ola.x.nilsson@axis.com>2016-10-25 13:03:32 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-13 22:55:20 +0000
commit9170a88cbddd510e2cf93049af8825f20cb61426 (patch)
tree7471369b6966e912938ac4b35bafa30a3f4971dd /meta-selftest
parent2b7abbb383aad1f7ce6d392756b0c1b7666db95a (diff)
downloadpoky-9170a88cbddd510e2cf93049af8825f20cb61426.tar.gz
devtool: selftest: add test for devtool plugin loading
Test that devtool plugins are loaded in a well defined order. (From OE-Core rev: 0de81f0c8b29d8b442b3d099c3bec3fd345b6bfe) 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')
-rw-r--r--meta-selftest/lib/devtool/bbpath.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/meta-selftest/lib/devtool/bbpath.py b/meta-selftest/lib/devtool/bbpath.py
new file mode 100644
index 0000000000..5e8ffb3af6
--- /dev/null
+++ b/meta-selftest/lib/devtool/bbpath.py
@@ -0,0 +1,44 @@
1import argparse
2
3already_loaded = False
4kept_context = None
5
6def plugin_name(filename):
7 return os.path.splitext(os.path.basename(filename))[0]
8
9def plugin_init(plugins):
10 global already_loaded
11 already_loaded = plugin_name(__file__) in (plugin_name(p.__name__) for p in plugins)
12
13def print_name(args, config, basepath, workspace):
14 print (__file__)
15
16def print_bbdir(args, config, basepath, workspace):
17 print (__file__.replace('/lib/devtool/bbpath.py',''))
18
19def print_registered(args, config, basepath, workspace):
20 global kept_context
21 print(kept_context.loaded)
22
23def multiloaded(args, config, basepath, workspace):
24 global already_loaded
25 print("yes" if already_loaded else "no")
26
27def register_commands(subparsers, context):
28 global kept_context
29 kept_context = context
30 if 'loaded' in context.__dict__:
31 context.loaded += 1
32 else:
33 context.loaded = 1
34
35 def addparser(name, helptxt, func):
36 parser = subparsers.add_parser(name, help=helptxt,
37 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
38 parser.set_defaults(func=func)
39 return parser
40
41 addparser('pluginfile', 'Print the filename of this plugin', print_name)
42 addparser('bbdir', 'Print the BBPATH directory of this plugin', print_bbdir)
43 addparser('count', 'How many times have this plugin been registered.', print_registered)
44 addparser('multiloaded', 'How many times have this plugin been initialized', multiloaded)