Thread (51 messages) 51 messages, 2 authors, 2021-05-29
STALE1877d

[PATCH v3 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

From: Vinay Kumar <hidden>
Date: 2021-05-21 13:29:34
Subsystem: the rest · Maintainer: Linus Torvalds

Build remote-test-server copy to image and execute
remotely through background ssh. Execute testing
through do_check.

We are booting qemuimage in "nographic" mode along with additional
qemuparams,
'-monitor telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null'

Note:
'-serial mon:stdio -serial': To fix below run-time errors while testing
"failed with Connection reset by peer"

Signed-off-by: Vinay Kumar <redacted>
---
 meta/lib/oeqa/selftest/cases/rust.py | 50 ++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
diff --git a/meta/lib/oeqa/selftest/cases/rust.py b/meta/lib/oeqa/selftest/cases/rust.py
new file mode 100644
index 0000000000..fc900d536f
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/rust.py
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: MIT
+import os
+from oeqa.core.decorator import OETestTag
+from oeqa.core.case import OEPTestResultTestCase
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu, Command
+from oeqa.utils.sshcontrol import SSHControl
+import threading
+
+class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
+
+	def run_check_emulated(self, *args, **kwargs):
+		# build remote-test-server before image build
+		recipe = "rust-testsuite"
+		bitbake("{} -c compile".format(recipe))
+
+		# Get build directory path
+		builddir = get_bb_var("B", "rust-testsuite")
+
+		# build core-image-minimal with required packages
+		default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp"]
+		features = []
+		features.append('IMAGE_FEATURES += "ssh-server-openssh"')
+		features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages)))
+		self.write_config("\n".join(features))
+		bitbake("core-image-minimal")
+
+		# wrap the execution with a qemu instance
+		with runqemu("core-image-minimal", runqemuparams = "nographic", qemuparams= " -monitor \
+                        telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null") as qemu:
+
+			# Copy remote-test-server through scp and execute through background ssh
+			ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user="root", timeout=600)
+			ssh.copy_to(builddir + "/" + "build/x86_64-unknown-linux-gnu/stage2-tools-bin/remote-test-server","~/")
+			t_thread = threading.Thread(target=ssh.run, args=("~/remote-test-server -v remote",))
+			t_thread.start()
+
+			# Set TEST_DEVICE_ADDR to image ip
+			cmd  = "export TEST_DEVICE_ADDR=%s:12345;" % qemu.ip
+			runCmd(cmd)
+
+                        # Test execution
+			bitbake("{} -c check".format(recipe))
+			# Stop ssh background execution
+			t_thread.stop()
+
+@OETestTag("toolchain-system")
+class RustSelfTestSystemEmulated(RustSelfTestBase):
+	def test_rust(self):
+		self.run_check_emulated("rust")
-- 
2.17.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help