summaryrefslogtreecommitdiffstats
path: root/meta-selftest/lib
diff options
context:
space:
mode:
authorOla x Nilsson <ola.x.nilsson@axis.com>2016-10-25 13:03:33 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-13 22:55:20 +0000
commit276523149914a75a939278b2e577383a2fdf3813 (patch)
tree3c321784a0902b290980562deeb93a1bf91a5d8e /meta-selftest/lib
parent9170a88cbddd510e2cf93049af8825f20cb61426 (diff)
downloadpoky-276523149914a75a939278b2e577383a2fdf3813.tar.gz
poky-276523149914a75a939278b2e577383a2fdf3813.tar.bz2
poky-276523149914a75a939278b2e577383a2fdf3813.zip
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')
-rw-r--r--meta-selftest/lib/recipetool/bbpath.py41
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 @@
+import argparse
+
+already_loaded = False
+register_count = 0
+
+def plugin_name(filename):
+ return os.path.splitext(os.path.basename(filename))[0]
+
+def plugin_init(plugins):
+ global already_loaded
+ already_loaded = plugin_name(__file__) in (plugin_name(p.__name__) for p in plugins)
+
+def print_name(opts):
+ print (__file__)
+
+def print_bbdir(opts):
+ print (__file__.replace('/lib/recipetool/bbpath.py',''))
+
+def print_registered(opts):
+ #global kept_context
+ #print(kept_context.loaded)
+ print ("1")
+
+def multiloaded(opts):
+ global already_loaded
+ print("yes" if already_loaded else "no")
+
+def register_commands(subparsers):
+ global register_count
+ register_count += 1
+
+ def addparser(name, helptxt, func):
+ parser = subparsers.add_parser(name, help=helptxt,
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+ parser.set_defaults(func=func)
+ return parser
+
+ addparser('pluginfile', 'Print the filename of this plugin', print_name)
+ addparser('bbdir', 'Print the BBPATH directory of this plugin', print_bbdir)
+ addparser('count', 'How many times have this plugin been registered.', print_registered)
+ addparser('multiloaded', 'How many times have this plugin been initialized', multiloaded)