From: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH] oe-selftest: crosstap: add tests for crosstap script
Date: Mon, 19 Mar 2018 16:59:47 -0700 [thread overview]
Message-ID: <1521503987-70014-1-git-send-email-ee.peng.yeoh@intel.com> (raw)
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
next reply other threads:[~2018-03-20 7:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-19 23:59 Yeoh Ee Peng [this message]
2018-03-20 9:58 ` [PATCH] oe-selftest: crosstap: add tests for crosstap script 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
-- strict thread matches above, loose matches on Subject: below --
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1521503987-70014-1-git-send-email-ee.peng.yeoh@intel.com \
--to=ee.peng.yeoh@intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox