From: <Qi.Chen@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Subject: [OE-core][PATCH V3 2/2] oeqa/selftest/sdk: add test_sdk_runqemu
Date: Fri, 27 Feb 2026 02:24:21 +0000 [thread overview]
Message-ID: <20260227022421.4072802-2-Qi.Chen@windriver.com> (raw)
In-Reply-To: <20260227022421.4072802-1-Qi.Chen@windriver.com>
From: Chen Qi <Qi.Chen@windriver.com>
Add test case to ensure runqemu works in SDK.
Using runqemu from SDK has been supported for many years. Add a
test case to ensure we have no regression.
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
meta/lib/oeqa/selftest/cases/sdk.py | 88 ++++++++++++++++++++++++++++-
1 file changed, 87 insertions(+), 1 deletion(-)
diff --git a/meta/lib/oeqa/selftest/cases/sdk.py b/meta/lib/oeqa/selftest/cases/sdk.py
index 3971365029..ee1e4ca420 100644
--- a/meta/lib/oeqa/selftest/cases/sdk.py
+++ b/meta/lib/oeqa/selftest/cases/sdk.py
@@ -4,7 +4,13 @@
# SPDX-License-Identifier: MIT
#
-import os.path
+import os
+import shutil
+import subprocess
+import glob
+import time
+import select
+from tempfile import TemporaryDirectory
from oeqa.selftest.case import OESelftestTestCase
from oeqa.utils.commands import bitbake, get_bb_vars
@@ -37,3 +43,83 @@ IMAGE_INSTALL:append = " selftest-hello"
path = os.path.join(vars["SDK_DEPLOY"], vars["TOOLCHAIN_OUTPUTNAME"] + ".target.manifest")
self.assertNotEqual(os.path.getsize(path), 0, msg="Target manifest is empty")
self.assertIn("selftest-hello", self.load_manifest(path))
+
+ def test_sdk_runqemu(self):
+ """Test using runqemu from SDK which has no bitbake available"""
+
+ def path_with_no_bitbake():
+ orig_paths = os.environ["PATH"].split(":")
+ new_paths = []
+ for orig_path in orig_paths:
+ if not os.access(os.path.join(orig_path, "bitbake"), os.X_OK):
+ new_paths.append(orig_path)
+ return ":".join(new_paths)
+
+ def runqemu_works_from_sdk(sdk_dir, sdk_env, machine, path, timeout=360):
+ env = os.environ.copy()
+ env["PATH"] = path
+
+ cmd = f'cd {sdk_dir}; . {sdk_env}; runqemu {machine} snapshot slirp nographic'
+ self.logger.info(f"Running {cmd}")
+ proc = subprocess.Popen(
+ ['bash', '-c', cmd],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ text=True,
+ bufsize=1,
+ env=env
+ )
+ buffer = ""
+ start = time.time()
+ while time.time() - start < timeout:
+ if proc.poll() is not None:
+ chunk = proc.stdout.read()
+ if chunk:
+ buffer += chunk
+ return ('Linux version' in buffer, "\n".join(buffer.split('\n')[-10:]))
+ ready, _, _ = select.select([proc.stdout], [], [], 0.1)
+ if ready:
+ chunk = proc.stdout.read(4096)
+ if chunk:
+ buffer += chunk
+ if "Linux version" in buffer:
+ proc.terminate()
+ return (True, "\n".join(buffer.split('\n')[-10:]))
+ time.sleep(0.1)
+ proc.terminate()
+ time.sleep(5)
+ if proc.poll() is None:
+ proc.kill()
+ return (False, "\n".join(buffer.split('\n')[-10:]))
+
+ image = "core-image-minimal"
+
+ self.write_config('QEMU_USE_KVM = "1"')
+
+ # generate image and SDK
+ bitbake(f"{image}")
+ bitbake(f"{image} -c populate_sdk")
+
+ # create a temporary destdir to test runqemu from SDK
+ with TemporaryDirectory() as tmpdir:
+ self.logger.debug(f"Created tempdir: {tmpdir}")
+ vars = get_bb_vars(["DEPLOY_DIR_IMAGE", "SDK_DEPLOY", "TOOLCHAIN_OUTPUTNAME", "MACHINE"], image)
+ machine = vars["MACHINE"]
+ image_dir = vars["DEPLOY_DIR_IMAGE"]
+ sdk_path = os.path.join(vars["SDK_DEPLOY"], vars["TOOLCHAIN_OUTPUTNAME"] + ".sh")
+ self.logger.debug(f"machine: {machine}")
+ self.logger.debug(f"image_dir: {image_dir}")
+ self.logger.debug(f"sdk_path: {sdk_path}")
+ dst_image_dir = os.path.join(tmpdir, os.path.basename(image_dir))
+ shutil.copytree(image_dir, dst_image_dir)
+ subprocess.check_call(f"{sdk_path} -d {tmpdir} -y", shell=True)
+ sdk_env = glob.glob(tmpdir + '/environment-setup-*')[0]
+ self.logger.debug(f"sdk_env: {sdk_env}")
+
+ path = path_with_no_bitbake()
+ self.logger.debug(f"path: {path}")
+
+ runqemu_works, output = runqemu_works_from_sdk(tmpdir, sdk_env, machine, path)
+ self.logger.debug(f"runqemu works in SDK: {runqemu_works}\n{output}")
+
+ self.assertTrue(runqemu_works, f"runqemu does not work in SDK\n{output}")
--
2.43.0
prev parent reply other threads:[~2026-02-27 2:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 2:24 [OE-core][PATCH V3 1/2] runqemu: restore support to run inside SDK Qi.Chen
2026-02-27 2:24 ` Qi.Chen [this message]
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=20260227022421.4072802-2-Qi.Chen@windriver.com \
--to=qi.chen@windriver.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