[05/26] rust-hello-world: test at runtime

Message ID 20211215224034.1814148-5-alex@linutronix.de
State Accepted, archived
Commit 14bb638b0df7acfa6aa89abf4625357f8cde886b
Headers show
Series [01/26] insane: add Inactive-Upstream to possible patch status list | expand

Commit Message

Alexander Kanavin Dec. 15, 2021, 10:40 p.m. UTC
This adds a smoke check for whether the rust toolchain actually
produces working executables across a range of architectures.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/classes/testimage.bbclass                |  2 +-
 meta/lib/oeqa/runtime/cases/rust.py           | 19 +++++++++++++++++++
 .../packagegroup-core-tools-testapps.bb       |  3 +++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 meta/lib/oeqa/runtime/cases/rust.py

Patch

diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index 66de0e07c6..1c5fd4ee6a 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -61,7 +61,7 @@  BASICTESTSUITE = "\
     ping date df ssh scp python perl gi ptest parselogs \
     logrotate connman systemd oe_syslog pam stap ldd xorg \
     kernelmodule gcc buildcpio buildlzip buildgalculator \
-    dnf rpm opkg apt weston go"
+    dnf rpm opkg apt weston go rust"
 
 DEFAULT_TEST_SUITES = "${BASICTESTSUITE}"
 
diff --git a/meta/lib/oeqa/runtime/cases/rust.py b/meta/lib/oeqa/runtime/cases/rust.py
new file mode 100644
index 0000000000..b3d6cf7f37
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/rust.py
@@ -0,0 +1,19 @@ 
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class RustHelloworldTest(OERuntimeTestCase):
+    @OETestDepends(['ssh.SSHTest.test_ssh'])
+    @OEHasPackage(['rust-hello-world'])
+    def test_rusthelloworld(self):
+        cmd = "rust-hello-world"
+        status, output = self.target.run(cmd)
+        msg = 'Exit status was not 0. Output: %s' % output
+        self.assertEqual(status, 0, msg=msg)
+
+        msg = 'Incorrect output: %s' % output
+        self.assertEqual(output, "Hello, world!", msg=msg)
diff --git a/meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb b/meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb
index 1fee1c925d..e05e329020 100644
--- a/meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb
+++ b/meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb
@@ -25,6 +25,8 @@  GOTOOLS ?= "go-helloworld"
 GOTOOLS:powerpc ?= ""
 GOTOOLS:riscv32 ?= ""
 
+RUSTTOOLS ?= "rust-hello-world"
+
 GSTEXAMPLES ?= "gst-examples"
 GSTEXAMPLES:riscv64 = ""
 
@@ -57,4 +59,5 @@  RDEPENDS:${PN} = "\
     ${@bb.utils.contains('DISTRO_FEATURES', 'x11 opengl', "${X11GLTOOLS}", "", d)} \
     ${@bb.utils.contains('DISTRO_FEATURES', '3g', "${3GTOOLS}", "", d)} \
     ${GOTOOLS} \
+    ${RUSTTOOLS} \
     "