Skip to contentSkip to conversation

devtool: add new command for selftest

PATCH In review Ross Burton 2 participants 3 messages Oct 12, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 devtool: add new command for selftest

In selftest we want to exercise devtool's ability to use plugins from other layers, so add a basic command to reverse a string to meta-selftest.

---
 meta-selftest/lib/devtool/__init__.py |  0
 meta-selftest/lib/devtool/test.py     | 15 +++++++++++++++
 2 files changed, 15 insertions(+)
 create mode 100644 meta-selftest/lib/devtool/__init__.py
 create mode 100644 meta-selftest/lib/devtool/test.py
meta-selftest/lib/devtool/__init__.py new file +0 -0
new file mode 100644
index 0000000..e69de29
meta-selftest/lib/devtool/test.py new file +15 -0
new file mode 100644
index 0000000..106c322
@@ -0,0 +1,15 @@
+import argparse
+
+def plugin_init(pluginlist):
+    """Plugin initialization"""
+    pass
+
+def selftest_reverse(args, config, basepath, workspace):
+    """Reverse the value passed to verify the plugin is executing."""
+    print args.value[::-1]
+
+def register_commands(subparsers, context):
+    parser_build = subparsers.add_parser('selftest-reverse', help='Reverse value (for selftest)',
+                                         formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+    parser_build.add_argument('value', help='Value to reverse')
+    parser_build.set_defaults(func=selftest_reverse)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/2 oeqa/selftest: verify that devtool can use plugins in other layers

Verify that devtool can use plugins in other layers by invoking the "selftest-reverse" command provided by meta-selftest.

---
 meta/lib/oeqa/selftest/devtool.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
meta/lib/oeqa/selftest/devtool.py +12 -0
index baa56d6..396a680 100644
@@ -983,3 +983,15 @@ class DevtoolTests(DevtoolBase):
         self.track_for_cleanup(tempdir)
         self.track_for_cleanup(self.workspacedir)
         self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+
+    def test_devtool_layer_plugins(self):
+        """Test that devtool can use plugins from other layers.
+
+        This test executes the selftest-reverse command from meta-selftest."""
+
+        self.track_for_cleanup(self.workspacedir)
+        self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+
+        s = "Microsoft Made No Profit From Anyone's Zunes Yo"
+        result = runCmd("devtool --quiet selftest-reverse \"%s\"" % s)
+        self.assertEqual(result.output, s[::-1])
Signature · 1 line
2.1.4
#2 lore raw

Re: [PATCH 2/2] oeqa/selftest: verify that devtool can use plugins in other layers

Hi Ross,

Quoted 2 lines · On Monday 12 October 2015 13:03:25 Ross Burton wrote:

Verify that devtool can use plugins in other layers by invoking the "selftest-reverse" command provided by meta-selftest.

I would squash these two patches together; additionally the no-op plugin_init() is no longer required these days. Otherwise looks OK.

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre