diff mbox series

[2/3] oeqa/sdk: Add basic rust cargo test

Message ID 20220726142413.2262729-2-richard.purdie@linuxfoundation.org
State New
Headers show
Series [1/3] native: Clear TUNE_FEATURES/ABIEXTENSION | expand

Commit Message

Richard Purdie July 26, 2022, 2:24 p.m. UTC
From: Otavio Salvador <otavio@ossystems.com.br>

Add a QA test to the SDK to test that a basic cargo build works.

[RP: Tweaked to work for multilibs and updated to match toolchain changes]

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/lib/oeqa/sdk/cases/rust.py               | 33 +++++++++++++++++++
 meta/lib/oeqa/sdk/files/rust/hello/Cargo.toml |  6 ++++
 .../lib/oeqa/sdk/files/rust/hello/src/main.rs |  3 ++
 3 files changed, 42 insertions(+)
 create mode 100644 meta/lib/oeqa/sdk/cases/rust.py
 create mode 100644 meta/lib/oeqa/sdk/files/rust/hello/Cargo.toml
 create mode 100644 meta/lib/oeqa/sdk/files/rust/hello/src/main.rs

Comments

Luca Ceresoli July 27, 2022, 4:48 p.m. UTC | #1
Hello Richard,

On Tue, 26 Jul 2022 15:24:12 +0100
"Richard Purdie" <richard.purdie@linuxfoundation.org> wrote:

> From: Otavio Salvador <otavio@ossystems.com.br>
> 
> Add a QA test to the SDK to test that a basic cargo build works.
> 
> [RP: Tweaked to work for multilibs and updated to match toolchain changes]
> 
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

We have a build failure with this series applied:

https://autobuilder.yoctoproject.org/typhoon/#/builders/44/builds/5615/steps/26/logs/stdio

Attached is the do_testsdk log.
Otavio Salvador July 27, 2022, 5:15 p.m. UTC | #2
Em qua., 27 de jul. de 2022 às 13:48, Luca Ceresoli via
lists.openembedded.org <luca.ceresoli=bootlin.com@lists.openembedded.org>
escreveu:

> On Tue, 26 Jul 2022 15:24:12 +0100
> "Richard Purdie" <richard.purdie@linuxfoundation.org> wrote:
>
> > From: Otavio Salvador <otavio@ossystems.com.br>
> >
> > Add a QA test to the SDK to test that a basic cargo build works.
> >
> > [RP: Tweaked to work for multilibs and updated to match toolchain
> changes]
> >
> > Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> > Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
>
> We have a build failure with this series applied:
>
>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/44/builds/5615/steps/26/logs/stdio
>
> Attached is the do_testsdk log.
>

It seems the SDK test directory is being reused, so it failed as file
already exists.
diff mbox series

Patch

diff --git a/meta/lib/oeqa/sdk/cases/rust.py b/meta/lib/oeqa/sdk/cases/rust.py
new file mode 100644
index 00000000000..c122b64d0c5
--- /dev/null
+++ b/meta/lib/oeqa/sdk/cases/rust.py
@@ -0,0 +1,33 @@ 
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+import shutil
+import unittest
+
+from oeqa.core.utils.path import remove_safe
+from oeqa.sdk.case import OESDKTestCase
+
+from oeqa.utils.subprocesstweak import errors_have_output
+errors_have_output()
+
+class RustCompileTest(OESDKTestCase):
+    td_vars = ['MACHINE']
+
+    @classmethod
+    def setUpClass(self):
+        targetdir = os.path.join(self.tc.sdk_dir, "hello")
+        try:
+            os.removedirs(targetdir)
+        except OSError:
+            pass
+        shutil.copytree(os.path.join(self.tc.sdk_files_dir, "rust/hello"), targetdir)
+
+    def setUp(self):
+        machine = self.td.get("MACHINE")
+        if not self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine):
+            raise unittest.SkipTest("RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain")
+
+    def test_cargo_build(self):
+        self._run('cd %s/hello; cargo build' % self.tc.sdk_dir)
diff --git a/meta/lib/oeqa/sdk/files/rust/hello/Cargo.toml b/meta/lib/oeqa/sdk/files/rust/hello/Cargo.toml
new file mode 100644
index 00000000000..fe619478a68
--- /dev/null
+++ b/meta/lib/oeqa/sdk/files/rust/hello/Cargo.toml
@@ -0,0 +1,6 @@ 
+[package]
+name = "hello"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
diff --git a/meta/lib/oeqa/sdk/files/rust/hello/src/main.rs b/meta/lib/oeqa/sdk/files/rust/hello/src/main.rs
new file mode 100644
index 00000000000..a06c03f82ae
--- /dev/null
+++ b/meta/lib/oeqa/sdk/files/rust/hello/src/main.rs
@@ -0,0 +1,3 @@ 
+fn main() {
+    println!("Hello, OpenEmbedded world!");
+}