All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] oe-selftest: crosstap: add tests for crosstap script
@ 2018-03-19 23:59 Yeoh Ee Peng
  2018-03-20  9:58 ` Alexander Kanavin
  2018-03-21 13:45 ` Alexander Kanavin
  0 siblings, 2 replies; 10+ messages in thread
From: Yeoh Ee Peng @ 2018-03-19 23:59 UTC (permalink / raw)
  To: openembedded-core

QA team were testing crosstap script  manually. Add automated
tests and systemtap file to test that crosstap script will
instructs SystemTap to print hello world in qemu. This test
will first built core-image-minimal image with tools-profile
& ssh-server-openssh features and build systemtap-native on
the host machine. Finally this test will boot the image with qemu
and then execute crosstap script to print hello world on qemu.

Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
---
 meta/lib/oeqa/files/trace_begin_hello.stp |  5 +++
 meta/lib/oeqa/selftest/cases/crosstap.py  | 65 +++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+)
 create mode 100644 meta/lib/oeqa/files/trace_begin_hello.stp
 create mode 100644 meta/lib/oeqa/selftest/cases/crosstap.py

diff --git a/meta/lib/oeqa/files/trace_begin_hello.stp b/meta/lib/oeqa/files/trace_begin_hello.stp
new file mode 100644
index 0000000..5ad5f15
--- /dev/null
+++ b/meta/lib/oeqa/files/trace_begin_hello.stp
@@ -0,0 +1,5 @@
+probe begin
+{
+  printf ("hello world\n")
+  exit ()
+}
\ No newline at end of file
diff --git a/meta/lib/oeqa/selftest/cases/crosstap.py b/meta/lib/oeqa/selftest/cases/crosstap.py
new file mode 100644
index 0000000..41c1d2f
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/crosstap.py
@@ -0,0 +1,65 @@
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, get_bb_var, runCmd
+import os
+import sys
+import logging
+import bb.tinfoil
+import bb.build
+import oeqa.targetcontrol
+
+class CrossTapTest(OESelftestTestCase):
+
+    def start_qemu_with_image(self, recipe, fstypes, cmd, targetlogger):
+        tinfoil = bb.tinfoil.Tinfoil()
+        tinfoil.prepare(config_only=False, quiet=True)
+        try:
+            tinfoil.logger.setLevel(logging.WARNING)
+            tinfoil.config_data.setVar("TEST_LOG_DIR", "${WORKDIR}/testimage")
+            tinfoil.config_data.setVar("TEST_QEMUBOOT_TIMEOUT", "1000")
+            # Tell QemuTarget() whether need find rootfs/kernel or not
+            #tinfoil.config_data.setVar("FIND_ROOTFS", '0')
+            recipedata = tinfoil.parse_recipe(recipe)
+            logdir = recipedata.getVar("TEST_LOG_DIR")
+            qemu = oeqa.targetcontrol.QemuTarget(recipedata, targetlogger, fstypes)
+        finally:
+            # We need to shut down tinfoil early here in case we actually want
+            # to run tinfoil-using utilities with the running QEMU instance.
+            # Luckily QemuTarget doesn't need it after the constructor.
+            tinfoil.shutdown()
+        print('DEBUG: qemu.deploy')
+        qemu.deploy()
+        try:
+            print('DEBUG: qemu.start')
+            qemu.start(ssh=True, launch_cmd=cmd, discard_writes=True)
+        except bb.build.FuncFailed:
+            raise Exception('Failed to start QEMU - see the logs in %s' % logdir)
+
+        return qemu
+
+    def test_crosstap_can_use_systemtap_on_qemu(self):
+        self.write_config('EXTRA_IMAGE_FEATURES += "tools-profile ssh-server-openssh"')
+        result = bitbake('core-image-minimal')
+        self.assertEqual(result.status, 0, msg="Bitbake core-image-minimal failed. Bitbake output: %s" % result.output)
+        result = bitbake('systemtap-native')
+        self.assertEqual(result.status, 0, msg="Bitbake systemtap-native failed. Bitbake output: %s" % result.output)
+
+        recipe = 'core-image-minimal'
+        fstypes = "ext4 iso hddimg wic.vmdk wic.qcow2 wic.vdi"
+        machine =  'qemux86'
+        deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
+        qemuboot_conf = "%s-%s.qemuboot.conf" % (recipe, machine)
+        qemuboot_conf = os.path.join(deploy_dir_image, qemuboot_conf)
+        cmd_common = "runqemu nographic"
+        cmd = "%s %s" % (cmd_common, qemuboot_conf)
+        # Need a non-'BitBake' logger to capture the runner output
+        targetlogger = logging.getLogger('TargetRunner')
+        targetlogger.setLevel(logging.DEBUG)
+        handler = logging.StreamHandler(sys.stdout)
+        targetlogger.addHandler(handler)
+        qemu = self.start_qemu_with_image(recipe, fstypes, cmd, targetlogger)
+        systap_file = os.path.join(self.tc.files_dir, 'trace_begin_hello.stp')
+        result = runCmd("crosstap root@%s %s" % (qemu.ip, systap_file))
+        qemu.stop()
+        targetlogger.removeHandler(handler)
+        print(result.output)
+        self.assertTrue('hello world' in result.output, 'Crosstap failed.')
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] oe-selftest: crosstap: add tests for crosstap script
  2018-03-19 23:59 [PATCH] oe-selftest: crosstap: add tests for crosstap script Yeoh Ee Peng
@ 2018-03-20  9:58 ` Alexander Kanavin
  2018-03-21 13:45 ` Alexander Kanavin
  1 sibling, 0 replies; 10+ messages in thread
From: Alexander Kanavin @ 2018-03-20  9:58 UTC (permalink / raw)
  To: Yeoh Ee Peng, openembedded-core; +Cc: Paul Eggleton

On 03/20/2018 01:59 AM, Yeoh Ee Peng wrote:
> QA team were testing crosstap script  manually. Add automated
> tests and systemtap file to test that crosstap script will
> instructs SystemTap to print hello world in qemu. This test
> will first built core-image-minimal image with tools-profile
> & ssh-server-openssh features and build systemtap-native on
> the host machine. Finally this test will boot the image with qemu
> and then execute crosstap script to print hello world on qemu.

Can this be rewritten as a runtime test case to be used with testimage? 
It seems like the code duplicates much of what testimage.bbclass does, 
and we generally try to avoid adding test cases that build and boot 
images in oe-selftest, as it adds to already large running time for it. 
The acceptable exception is when an image needs a really custom 
configuration, but this is not the case here - you can take 
core-image-sato-sdk for example, which comes pre-packaged with 
tools-profile and ssh server.

Alex


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] oe-selftest: crosstap: add tests for crosstap script
  2018-03-19 23:59 [PATCH] oe-selftest: crosstap: add tests for crosstap script Yeoh Ee Peng
  2018-03-20  9:58 ` Alexander Kanavin
@ 2018-03-21 13:45 ` Alexander Kanavin
  2018-03-22  0:50   ` Yeoh, Ee Peng
  1 sibling, 1 reply; 10+ messages in thread
From: Alexander Kanavin @ 2018-03-21 13:45 UTC (permalink / raw)
  To: Yeoh Ee Peng, openembedded-core

On 03/20/2018 01:59 AM, Yeoh Ee Peng wrote:
> +    def start_qemu_with_image(self, recipe, fstypes, cmd, targetlogger):
> +        tinfoil = bb.tinfoil.Tinfoil()
> +        tinfoil.prepare(config_only=False, quiet=True)
> +        try:
> +            tinfoil.logger.setLevel(logging.WARNING)
> +            tinfoil.config_data.setVar("TEST_LOG_DIR", "${WORKDIR}/testimage")
> +            tinfoil.config_data.setVar("TEST_QEMUBOOT_TIMEOUT", "1000")
> +            # Tell QemuTarget() whether need find rootfs/kernel or not
> +            #tinfoil.config_data.setVar("FIND_ROOTFS", '0')
> +            recipedata = tinfoil.parse_recipe(recipe)
> +            logdir = recipedata.getVar("TEST_LOG_DIR")
> +            qemu = oeqa.targetcontrol.QemuTarget(recipedata, targetlogger, fstypes)
> +        finally:
> +            # We need to shut down tinfoil early here in case we actually want
> +            # to run tinfoil-using utilities with the running QEMU instance.
> +            # Luckily QemuTarget doesn't need it after the constructor.
> +            tinfoil.shutdown()
> +        print('DEBUG: qemu.deploy')
> +        qemu.deploy()
> +        try:
> +            print('DEBUG: qemu.start')
> +            qemu.start(ssh=True, launch_cmd=cmd, discard_writes=True)
> +        except bb.build.FuncFailed:
> +            raise Exception('Failed to start QEMU - see the logs in %s' % logdir)
> +
> +        return qemu

Can you use runqemu from oeqa.utils.commands, instead of this custom 
hand-written invocation? There are plenty of examples in oe-selftests, e.g.:

                     with runqemu('core-image-minimal') as qemu:
                         # Make the test echo a string and search for 
that as
                         # run_serial()'s status code is useless.'
                         for filename in ("rootfs", "delayed-a", 
"delayed-b"):
                             status, output = qemu.run_serial("test -f 
%s && echo found" % os.path.join(targettestdir, filename))
                             self.assertEqual(output, "found", "%s was 
not present on boot" % filename)


Alex


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] oe-selftest: crosstap: add tests for crosstap script
  2018-03-21 13:45 ` Alexander Kanavin
@ 2018-03-22  0:50   ` Yeoh, Ee Peng
  2018-03-22 11:38     ` Alexander Kanavin
  0 siblings, 1 reply; 10+ messages in thread
From: Yeoh, Ee Peng @ 2018-03-22  0:50 UTC (permalink / raw)
  To: Alexander Kanavin, openembedded-core

Hi Alex,

From my understanding, oeqa.utils.commands.runqemu will start and stop qemu in a single call. 
For crosstap testcase, it require the steps below:
	- start qemu
	- call to crosstap to ssh into qemu to use systemtap
	- stop qemu

Therefore, crosstap testcase use the oeqa.targetcontrol.QemuTarget (used by runqemu) to first start qemu, perform call to crosstap, then stop qemu. 

Please let me know if there was any alternative way. 

Thank you very much for your inputs and help!

Thanks,
Ee Peng 

-----Original Message-----
From: Alexander Kanavin [mailto:alexander.kanavin@linux.intel.com] 
Sent: Wednesday, March 21, 2018 9:45 PM
To: Yeoh, Ee Peng <ee.peng.yeoh@intel.com>; openembedded-core@lists.openembedded.org
Subject: Re: [OE-core] [PATCH] oe-selftest: crosstap: add tests for crosstap script

On 03/20/2018 01:59 AM, Yeoh Ee Peng wrote:
> +    def start_qemu_with_image(self, recipe, fstypes, cmd, targetlogger):
> +        tinfoil = bb.tinfoil.Tinfoil()
> +        tinfoil.prepare(config_only=False, quiet=True)
> +        try:
> +            tinfoil.logger.setLevel(logging.WARNING)
> +            tinfoil.config_data.setVar("TEST_LOG_DIR", "${WORKDIR}/testimage")
> +            tinfoil.config_data.setVar("TEST_QEMUBOOT_TIMEOUT", "1000")
> +            # Tell QemuTarget() whether need find rootfs/kernel or not
> +            #tinfoil.config_data.setVar("FIND_ROOTFS", '0')
> +            recipedata = tinfoil.parse_recipe(recipe)
> +            logdir = recipedata.getVar("TEST_LOG_DIR")
> +            qemu = oeqa.targetcontrol.QemuTarget(recipedata, targetlogger, fstypes)
> +        finally:
> +            # We need to shut down tinfoil early here in case we actually want
> +            # to run tinfoil-using utilities with the running QEMU instance.
> +            # Luckily QemuTarget doesn't need it after the constructor.
> +            tinfoil.shutdown()
> +        print('DEBUG: qemu.deploy')
> +        qemu.deploy()
> +        try:
> +            print('DEBUG: qemu.start')
> +            qemu.start(ssh=True, launch_cmd=cmd, discard_writes=True)
> +        except bb.build.FuncFailed:
> +            raise Exception('Failed to start QEMU - see the logs in 
> + %s' % logdir)
> +
> +        return qemu

Can you use runqemu from oeqa.utils.commands, instead of this custom hand-written invocation? There are plenty of examples in oe-selftests, e.g.:

                     with runqemu('core-image-minimal') as qemu:
                         # Make the test echo a string and search for that as
                         # run_serial()'s status code is useless.'
                         for filename in ("rootfs", "delayed-a",
"delayed-b"):
                             status, output = qemu.run_serial("test -f %s && echo found" % os.path.join(targettestdir, filename))
                             self.assertEqual(output, "found", "%s was not present on boot" % filename)


Alex

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] oe-selftest: crosstap: add tests for crosstap script
  2018-03-22  0:50   ` Yeoh, Ee Peng
@ 2018-03-22 11:38     ` Alexander Kanavin
  2018-03-23  1:32       ` Yeoh, Ee Peng
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Kanavin @ 2018-03-22 11:38 UTC (permalink / raw)
  To: Yeoh, Ee Peng, openembedded-core; +Cc: Paul Eggleton

On 03/22/2018 02:50 AM, Yeoh, Ee Peng wrote:
>  From my understanding, oeqa.utils.commands.runqemu will start and stop qemu in a single call.

That's not the case at all. Please look at the example below again:

                     with runqemu('core-image-minimal') as qemu:
                          # Make the test echo a string and search for 
that as
                          # run_serial()'s status code is useless.'
                          for filename in ("rootfs", "delayed-a",
"delayed-b"):
                              status, output = qemu.run_serial("test -f 
%s && echo found" % os.path.join(targettestdir, filename))
                              self.assertEqual(output, "found", "%s was 
not present on boot" % filename)

It starts qemu, then does things (qemu.run_serial() ) with that running 
qemu instance. How and where qemu gets stopped is the 'magic' of 'with' 
statement.

The key part is that runqemu() has a @contextmanager decorator and 
contains this statement inside:

	yield qemu

which 'suspends' the runqemu() execution and resumes the caller 
function, passing it the qemu object. Once the 'with' block completes in 
the caller, the runqemu() function is allowed to resume and clean up the 
running qemu instance. It's definitely not a synchronous call/return 
thing. You can read all about it here:

https://docs.python.org/3/library/contextlib.html


> For crosstap testcase, it require the steps below:
> 	- start qemu
> 	- call to crosstap to ssh into qemu to use systemtap
> 	- stop qemu
> 
> Therefore, crosstap testcase use the oeqa.targetcontrol.QemuTarget (used by runqemu) to first start qemu, perform call to crosstap, then stop qemu.

runqemu() was written for precisely this use case.


Alex


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] oe-selftest: crosstap: add tests for crosstap script
  2018-03-22 11:38     ` Alexander Kanavin
@ 2018-03-23  1:32       ` Yeoh, Ee Peng
  0 siblings, 0 replies; 10+ messages in thread
From: Yeoh, Ee Peng @ 2018-03-23  1:32 UTC (permalink / raw)
  To: Alexander Kanavin, openembedded-core; +Cc: Paul Eggleton

Hi Alex,

Thank you very much for your great sharing!
Yes, understood now, let me refactor this testcase to use runqemu instead. 

Thanks,
Ee Peng 

-----Original Message-----
From: Alexander Kanavin [mailto:alexander.kanavin@linux.intel.com] 
Sent: Thursday, March 22, 2018 7:38 PM
To: Yeoh, Ee Peng <ee.peng.yeoh@intel.com>; openembedded-core@lists.openembedded.org
Cc: Paul Eggleton <paul.eggleton@linux.intel.com>
Subject: Re: [OE-core] [PATCH] oe-selftest: crosstap: add tests for crosstap script

On 03/22/2018 02:50 AM, Yeoh, Ee Peng wrote:
>  From my understanding, oeqa.utils.commands.runqemu will start and stop qemu in a single call.

That's not the case at all. Please look at the example below again:

                     with runqemu('core-image-minimal') as qemu:
                          # Make the test echo a string and search for that as
                          # run_serial()'s status code is useless.'
                          for filename in ("rootfs", "delayed-a",
"delayed-b"):
                              status, output = qemu.run_serial("test -f %s && echo found" % os.path.join(targettestdir, filename))
                              self.assertEqual(output, "found", "%s was not present on boot" % filename)

It starts qemu, then does things (qemu.run_serial() ) with that running qemu instance. How and where qemu gets stopped is the 'magic' of 'with' 
statement.

The key part is that runqemu() has a @contextmanager decorator and contains this statement inside:

	yield qemu

which 'suspends' the runqemu() execution and resumes the caller function, passing it the qemu object. Once the 'with' block completes in the caller, the runqemu() function is allowed to resume and clean up the running qemu instance. It's definitely not a synchronous call/return thing. You can read all about it here:

https://docs.python.org/3/library/contextlib.html


> For crosstap testcase, it require the steps below:
> 	- start qemu
> 	- call to crosstap to ssh into qemu to use systemtap
> 	- stop qemu
> 
> Therefore, crosstap testcase use the oeqa.targetcontrol.QemuTarget (used by runqemu) to first start qemu, perform call to crosstap, then stop qemu.

runqemu() was written for precisely this use case.


Alex

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] oe-selftest: crosstap: add tests for crosstap script
@ 2018-04-10 18:32 Yeoh Ee Peng
  0 siblings, 0 replies; 10+ messages in thread
From: Yeoh Ee Peng @ 2018-04-10 18:32 UTC (permalink / raw)
  To: openembedded-core

QA team were testing crosstap script manually. Add automated
tests and systemtap file to test that crosstap script will
instructs SystemTap to print hello world in qemu. This test
will first built core-image-minimal image with tools-profile
& ssh-server-openssh features and build systemtap-native on
the host machine. Finally this test will boot the image with qemu
and then execute crosstap script to print hello world on qemu.

Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
---
 meta/lib/oeqa/files/trace_begin_hello.stp |  5 +++++
 meta/lib/oeqa/selftest/cases/crosstap.py  | 25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 meta/lib/oeqa/files/trace_begin_hello.stp
 create mode 100644 meta/lib/oeqa/selftest/cases/crosstap.py

diff --git a/meta/lib/oeqa/files/trace_begin_hello.stp b/meta/lib/oeqa/files/trace_begin_hello.stp
new file mode 100644
index 0000000..5ad5f15
--- /dev/null
+++ b/meta/lib/oeqa/files/trace_begin_hello.stp
@@ -0,0 +1,5 @@
+probe begin
+{
+  printf ("hello world\n")
+  exit ()
+}
\ No newline at end of file
diff --git a/meta/lib/oeqa/selftest/cases/crosstap.py b/meta/lib/oeqa/selftest/cases/crosstap.py
new file mode 100644
index 0000000..57523cb
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/crosstap.py
@@ -0,0 +1,25 @@
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, get_bb_vars, runCmd, runqemu
+import os
+
+class CrossTapTest(OESelftestTestCase):
+
+    def test_crosstap_can_use_systemtap_on_qemu(self):
+        self.write_config('EXTRA_IMAGE_FEATURES += "tools-profile ssh-server-openssh"')
+        result = bitbake('core-image-minimal')
+        self.assertEqual(result.status, 0, msg="Bitbake core-image-minimal failed. Bitbake output: %s" % result.output)
+        result = bitbake('systemtap-native')
+        self.assertEqual(result.status, 0, msg="Bitbake systemtap-native failed. Bitbake output: %s" % result.output)
+
+        recipe = 'core-image-minimal'
+        bb_vars = get_bb_vars(['MACHINE', 'DEPLOY_DIR_IMAGE'])
+        machine =  bb_vars['MACHINE']
+        deploy_dir_image = bb_vars['DEPLOY_DIR_IMAGE']
+        qemuboot_conf = "%s-%s.qemuboot.conf" % (recipe, machine)
+        qemuboot_conf = os.path.join(deploy_dir_image, qemuboot_conf)
+        cmd_common = "runqemu nographic"
+        cmd = "%s %s" % (cmd_common, qemuboot_conf)
+        with runqemu(recipe, ssh=True, launch_cmd=cmd) as qemu:
+            systap_file = os.path.join(self.tc.files_dir, 'trace_begin_hello.stp')
+            result = runCmd("crosstap root@%s %s" % (qemu.ip, systap_file))
+        self.assertTrue('hello world' in result.output, 'Crosstap failed.')
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] oe-selftest: crosstap: add tests for crosstap script
  2018-03-27 10:31 ` Alexander Kanavin
@ 2018-03-28  0:41   ` Yeoh, Ee Peng
  0 siblings, 0 replies; 10+ messages in thread
From: Yeoh, Ee Peng @ 2018-03-28  0:41 UTC (permalink / raw)
  To: Alexander Kanavin, openembedded-core

Hi Alex,

Yes, reusing existing runqemu made this testcase more concise and easier to maintain. Thank you very much for your inputs and sharing! 

Thanks,
Ee Peng 
-----Original Message-----
From: Alexander Kanavin [mailto:alexander.kanavin@linux.intel.com] 
Sent: Tuesday, March 27, 2018 6:32 PM
To: Yeoh, Ee Peng <ee.peng.yeoh@intel.com>; openembedded-core@lists.openembedded.org
Subject: Re: [OE-core] [PATCH] oe-selftest: crosstap: add tests for crosstap script

On 03/27/2018 04:37 AM, Yeoh Ee Peng wrote:
> QA team were testing crosstap script manually. Add automated tests and 
> systemtap file to test that crosstap script will instructs SystemTap 
> to print hello world in qemu. This test will first built 
> core-image-minimal image with tools-profile & ssh-server-openssh 
> features and build systemtap-native on the host machine. Finally this 
> test will boot the image with qemu and then execute crosstap script to 
> print hello world on qemu.

Thanks, this looks much nicer now, doesn't it? :) I have no further comments, this is fine.

Alex

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] oe-selftest: crosstap: add tests for crosstap script
  2018-03-27  1:37 Yeoh Ee Peng
@ 2018-03-27 10:31 ` Alexander Kanavin
  2018-03-28  0:41   ` Yeoh, Ee Peng
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Kanavin @ 2018-03-27 10:31 UTC (permalink / raw)
  To: Yeoh Ee Peng, openembedded-core

On 03/27/2018 04:37 AM, Yeoh Ee Peng wrote:
> QA team were testing crosstap script manually. Add automated
> tests and systemtap file to test that crosstap script will
> instructs SystemTap to print hello world in qemu. This test
> will first built core-image-minimal image with tools-profile
> & ssh-server-openssh features and build systemtap-native on
> the host machine. Finally this test will boot the image with qemu
> and then execute crosstap script to print hello world on qemu.

Thanks, this looks much nicer now, doesn't it? :) I have no further 
comments, this is fine.

Alex


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] oe-selftest: crosstap: add tests for crosstap script
@ 2018-03-27  1:37 Yeoh Ee Peng
  2018-03-27 10:31 ` Alexander Kanavin
  0 siblings, 1 reply; 10+ messages in thread
From: Yeoh Ee Peng @ 2018-03-27  1:37 UTC (permalink / raw)
  To: openembedded-core

QA team were testing crosstap script manually. Add automated
tests and systemtap file to test that crosstap script will
instructs SystemTap to print hello world in qemu. This test
will first built core-image-minimal image with tools-profile
& ssh-server-openssh features and build systemtap-native on
the host machine. Finally this test will boot the image with qemu
and then execute crosstap script to print hello world on qemu.

Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
---
 meta/lib/oeqa/files/trace_begin_hello.stp |  5 +++++
 meta/lib/oeqa/selftest/cases/crosstap.py  | 25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 meta/lib/oeqa/files/trace_begin_hello.stp
 create mode 100644 meta/lib/oeqa/selftest/cases/crosstap.py

diff --git a/meta/lib/oeqa/files/trace_begin_hello.stp b/meta/lib/oeqa/files/trace_begin_hello.stp
new file mode 100644
index 0000000..5ad5f15
--- /dev/null
+++ b/meta/lib/oeqa/files/trace_begin_hello.stp
@@ -0,0 +1,5 @@
+probe begin
+{
+  printf ("hello world\n")
+  exit ()
+}
\ No newline at end of file
diff --git a/meta/lib/oeqa/selftest/cases/crosstap.py b/meta/lib/oeqa/selftest/cases/crosstap.py
new file mode 100644
index 0000000..57523cb
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/crosstap.py
@@ -0,0 +1,25 @@
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, get_bb_vars, runCmd, runqemu
+import os
+
+class CrossTapTest(OESelftestTestCase):
+
+    def test_crosstap_can_use_systemtap_on_qemu(self):
+        self.write_config('EXTRA_IMAGE_FEATURES += "tools-profile ssh-server-openssh"')
+        result = bitbake('core-image-minimal')
+        self.assertEqual(result.status, 0, msg="Bitbake core-image-minimal failed. Bitbake output: %s" % result.output)
+        result = bitbake('systemtap-native')
+        self.assertEqual(result.status, 0, msg="Bitbake systemtap-native failed. Bitbake output: %s" % result.output)
+
+        recipe = 'core-image-minimal'
+        bb_vars = get_bb_vars(['MACHINE', 'DEPLOY_DIR_IMAGE'])
+        machine =  bb_vars['MACHINE']
+        deploy_dir_image = bb_vars['DEPLOY_DIR_IMAGE']
+        qemuboot_conf = "%s-%s.qemuboot.conf" % (recipe, machine)
+        qemuboot_conf = os.path.join(deploy_dir_image, qemuboot_conf)
+        cmd_common = "runqemu nographic"
+        cmd = "%s %s" % (cmd_common, qemuboot_conf)
+        with runqemu(recipe, ssh=True, launch_cmd=cmd) as qemu:
+            systap_file = os.path.join(self.tc.files_dir, 'trace_begin_hello.stp')
+            result = runCmd("crosstap root@%s %s" % (qemu.ip, systap_file))
+        self.assertTrue('hello world' in result.output, 'Crosstap failed.')
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-04-11  1:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-19 23:59 [PATCH] oe-selftest: crosstap: add tests for crosstap script Yeoh Ee Peng
2018-03-20  9:58 ` Alexander Kanavin
2018-03-21 13:45 ` Alexander Kanavin
2018-03-22  0:50   ` Yeoh, Ee Peng
2018-03-22 11:38     ` Alexander Kanavin
2018-03-23  1:32       ` Yeoh, Ee Peng
2018-03-27  1:37 Yeoh Ee Peng
2018-03-27 10:31 ` Alexander Kanavin
2018-03-28  0:41   ` Yeoh, Ee Peng
2018-04-10 18:32 Yeoh Ee Peng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.