Skip to contentSkip to conversation

oeqa/runtime/rust: Add basic compile/run test

PATCH In review Alex Kiernan 3 participants 5 messages Dec 19, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 oeqa/runtime/rust: Add basic compile/run test

---
 meta/lib/oeqa/files/test.rs         |  2 ++
 meta/lib/oeqa/runtime/cases/rust.py | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 meta/lib/oeqa/files/test.rs
meta/lib/oeqa/files/test.rs new file +2 -0
new file mode 100644
index 000000000000..f79c691f0853
@@ -0,0 +1,2 @@
+fn main() {
+}
meta/lib/oeqa/runtime/cases/rust.py +24 -0
index 55b280d61d8a..186bb0d79e15 100644
@@ -8,6 +8,30 @@ from oeqa.runtime.case import OERuntimeTestCase
 from oeqa.core.decorator.depends import OETestDepends
 from oeqa.runtime.decorator.package import OEHasPackage
 
+class RustCompileTest(OERuntimeTestCase):
+
+    @classmethod
+    def setUp(cls):
+        dst = '/tmp/'
+        src = os.path.join(cls.tc.files_dir, 'test.rs')
+        cls.tc.target.copyTo(src, dst)
+
+    @classmethod
+    def tearDown(cls):
+        files = '/tmp/test.rs /tmp/test'
+        cls.tc.target.run('rm %s' % files)
+
+    @OETestDepends(['ssh.SSHTest.test_ssh'])
+    @OEHasPackage(['rust'])
+    def test_rust_compile(self):
+        status, output = self.target.run('rustc /tmp/test.rs -o /tmp/test')
+        msg = 'rust compile failed, output: %s' % output
+        self.assertEqual(status, 0, msg=msg)
+
+        status, output = self.target.run('/tmp/test')
+        msg = 'running compiled file failed, output: %s' % output
+        self.assertEqual(status, 0, msg=msg)
+
 class RustHelloworldTest(OERuntimeTestCase):
     @OETestDepends(['ssh.SSHTest.test_ssh'])
     @OEHasPackage(['rust-hello-world'])
Signature · 1 line
2.39.0
#1 lore raw
Quoted 41 lines · Alex Kiernan
---
 meta/lib/oeqa/files/test.rs         |  2 ++
 meta/lib/oeqa/runtime/cases/rust.py | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 meta/lib/oeqa/files/test.rs
meta/lib/oeqa/files/test.rs new file +2 -0
new file mode 100644
index 000000000000..f79c691f0853
@@ -0,0 +1,2 @@
+fn main() {
+}
meta/lib/oeqa/runtime/cases/rust.py +17 -0
index 55b280d61d8a..186bb0d79e15 100644
@@ -8,6 +8,30 @@ from oeqa.runtime.case import OERuntimeTestCase
 from oeqa.core.decorator.depends import OETestDepends
 from oeqa.runtime.decorator.package import OEHasPackage
 
+class RustCompileTest(OERuntimeTestCase):
+
+    @classmethod
+    def setUp(cls):
+        dst = '/tmp/'
+        src = os.path.join(cls.tc.files_dir, 'test.rs')
+        cls.tc.target.copyTo(src, dst)
+
+    @classmethod
+    def tearDown(cls):
+        files = '/tmp/test.rs /tmp/test'
+        cls.tc.target.run('rm %s' % files)
+
+    @OETestDepends(['ssh.SSHTest.test_ssh'])
+    @OEHasPackage(['rust'])
+    def test_rust_compile(self):
+        status, output = self.target.run('rustc /tmp/test.rs -o /tmp/test')

meta/lib/oeqa/runtime/cases/rust.py from oeqa.runtime.case import OERuntimeTestCase · line 37

Quoted 10 lines
meta/lib/oeqa/runtime/cases/rust.py +7 -0
+        msg = 'rust compile failed, output: %s' % output
+        self.assertEqual(status, 0, msg=msg)
+
+        status, output = self.target.run('/tmp/test')
+        msg = 'running compiled file failed, output: %s' % output
+        self.assertEqual(status, 0, msg=msg)
+
 class RustHelloworldTest(OERuntimeTestCase):
     @OETestDepends(['ssh.SSHTest.test_ssh'])
     @OEHasPackage(['rust-hello-world'])

One thing I wasn't clear on with this, is how I ensure that rust is actually installed on the test image during CI, so this test runs?

Signature · 1 line
Alex Kiernan
#2 lore raw
Quoted 47 lines · Alex Kiernan
Quoted 46 lines · Alex Kiernan
---
 meta/lib/oeqa/files/test.rs         |  2 ++
 meta/lib/oeqa/runtime/cases/rust.py | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 meta/lib/oeqa/files/test.rs
meta/lib/oeqa/files/test.rs new file +2 -0
new file mode 100644
index 000000000000..f79c691f0853
@@ -0,0 +1,2 @@
+fn main() {
+}
meta/lib/oeqa/runtime/cases/rust.py +22 -0
index 55b280d61d8a..186bb0d79e15 100644
@@ -8,6 +8,30 @@ from oeqa.runtime.case import OERuntimeTestCase
 from oeqa.core.decorator.depends import OETestDepends
 from oeqa.runtime.decorator.package import OEHasPackage
 
+class RustCompileTest(OERuntimeTestCase):
+
+    @classmethod
+    def setUp(cls):
+        dst = '/tmp/'
+        src = os.path.join(cls.tc.files_dir, 'test.rs')
+        cls.tc.target.copyTo(src, dst)
+
+    @classmethod
+    def tearDown(cls):
+        files = '/tmp/test.rs /tmp/test'
+        cls.tc.target.run('rm %s' % files)
+
+    @OETestDepends(['ssh.SSHTest.test_ssh'])
+    @OEHasPackage(['rust'])
+    def test_rust_compile(self):
+        status, output = self.target.run('rustc /tmp/test.rs -o /tmp/test')
+        msg = 'rust compile failed, output: %s' % output
+        self.assertEqual(status, 0, msg=msg)
+
+        status, output = self.target.run('/tmp/test')
+        msg = 'running compiled file failed, output: %s' % output
Quoted 8 lines

meta/lib/oeqa/runtime/cases/rust.py from oeqa.runtime.case import OERuntimeTestCase · line 37

Quoted 5 lines
meta/lib/oeqa/runtime/cases/rust.py +2 -0
+        self.assertEqual(status, 0, msg=msg)
+
 class RustHelloworldTest(OERuntimeTestCase):
     @OETestDepends(['ssh.SSHTest.test_ssh'])
     @OEHasPackage(['rust-hello-world'])

One thing I wasn't clear on with this, is how I ensure that rust is actually installed on the test image during CI, so this test runs?

Isn't that what you're doing with:

@OEHasPackage(['rust'])

?

Cheers,

Richard

#3 lore raw

But we need to add rust to core-image-sato-sdk then, if it's not there yet.

Alex

Quoted 77 lines · Richard Purdie
Quoted 47 lines · Alex Kiernan
Quoted 46 lines · Alex Kiernan
---
 meta/lib/oeqa/files/test.rs         |  2 ++
 meta/lib/oeqa/runtime/cases/rust.py | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 meta/lib/oeqa/files/test.rs
meta/lib/oeqa/files/test.rs new file +2 -0
new file mode 100644
index 000000000000..f79c691f0853
@@ -0,0 +1,2 @@
+fn main() {
+}
meta/lib/oeqa/runtime/cases/rust.py +22 -0
index 55b280d61d8a..186bb0d79e15 100644
@@ -8,6 +8,30 @@ from oeqa.runtime.case import OERuntimeTestCase
 from oeqa.core.decorator.depends import OETestDepends
 from oeqa.runtime.decorator.package import OEHasPackage
 
+class RustCompileTest(OERuntimeTestCase):
+
+    @classmethod
+    def setUp(cls):
+        dst = '/tmp/'
+        src = os.path.join(cls.tc.files_dir, 'test.rs')
+        cls.tc.target.copyTo(src, dst)
+
+    @classmethod
+    def tearDown(cls):
+        files = '/tmp/test.rs /tmp/test'
+        cls.tc.target.run('rm %s' % files)
+
+    @OETestDepends(['ssh.SSHTest.test_ssh'])
+    @OEHasPackage(['rust'])
+    def test_rust_compile(self):
+        status, output = self.target.run('rustc /tmp/test.rs -o /tmp/test')
+        msg = 'rust compile failed, output: %s' % output
+        self.assertEqual(status, 0, msg=msg)
+
+        status, output = self.target.run('/tmp/test')
+        msg = 'running compiled file failed, output: %s' % output
Quoted 8 lines

meta/lib/oeqa/runtime/cases/rust.py from oeqa.runtime.case import OERuntimeTestCase · line 37

Quoted 5 lines
meta/lib/oeqa/runtime/cases/rust.py +2 -0
+        self.assertEqual(status, 0, msg=msg)
+
 class RustHelloworldTest(OERuntimeTestCase):
     @OETestDepends(['ssh.SSHTest.test_ssh'])
     @OEHasPackage(['rust-hello-world'])

One thing I wasn't clear on with this, is how I ensure that rust is actually installed on the test image during CI, so this test runs?

Isn't that what you're doing with:

@OEHasPackage(['rust'])

?

Cheers,

Richard

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#174816): https://lists.openembedded.org/g/openembedded-core/message/174816
Mute This Topic: https://lists.openembedded.org/mt/95765437/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw
Quoted 1 line · Alexander Kanavin

But we need to add rust to core-image-sato-sdk then, if it's not there yet.

Ah, I misunderstood you question. The sdk tooling comes from:

classes-recipe/core-image.bbclass:FEATURE_PACKAGES_tools-sdk = "packagegroup-core-sdk packagegroup-core-standalone-sdk-target"

so maybe making recipes-core/packagegroups/packagegroup-core-sdk.bb have something a bit like SDK_TOOLCHAIN_LANGS in classes- recipe/populate_sdk_base.bbclass?

Cheers,

Richard