Message ID | 20221219141840.26358-1-alex.kiernan@gmail.com |
---|---|
State | Accepted, archived |
Commit | d60323008accc3ddb6384fddea576b3032b5e672 |
Headers | show |
Series | oeqa/runtime/rust: Add basic compile/run test | expand |
On Mon, Dec 19, 2022 at 2:19 PM Alex Kiernan <alex.kiernan@gmail.com> wrote: > > Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> > --- > 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 > > diff --git a/meta/lib/oeqa/files/test.rs b/meta/lib/oeqa/files/test.rs > new file mode 100644 > index 000000000000..f79c691f0853 > --- /dev/null > +++ b/meta/lib/oeqa/files/test.rs > @@ -0,0 +1,2 @@ > +fn main() { > +} > diff --git a/meta/lib/oeqa/runtime/cases/rust.py b/meta/lib/oeqa/runtime/cases/rust.py > index 55b280d61d8a..186bb0d79e15 100644 > --- a/meta/lib/oeqa/runtime/cases/rust.py > +++ b/meta/lib/oeqa/runtime/cases/rust.py > @@ -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']) 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?
On Mon, 2022-12-19 at 14:28 +0000, Alex Kiernan wrote: > On Mon, Dec 19, 2022 at 2:19 PM Alex Kiernan <alex.kiernan@gmail.com> wrote: > > > > Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> > > --- > > 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 > > > > diff --git a/meta/lib/oeqa/files/test.rs b/meta/lib/oeqa/files/test.rs > > new file mode 100644 > > index 000000000000..f79c691f0853 > > --- /dev/null > > +++ b/meta/lib/oeqa/files/test.rs > > @@ -0,0 +1,2 @@ > > +fn main() { > > +} > > diff --git a/meta/lib/oeqa/runtime/cases/rust.py b/meta/lib/oeqa/runtime/cases/rust.py > > index 55b280d61d8a..186bb0d79e15 100644 > > --- a/meta/lib/oeqa/runtime/cases/rust.py > > +++ b/meta/lib/oeqa/runtime/cases/rust.py > > @@ -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']) > > 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
But we need to add rust to core-image-sato-sdk then, if it's not there yet. Alex On Mon, 19 Dec 2022 at 15:32, Richard Purdie <richard.purdie@linuxfoundation.org> wrote: > > On Mon, 2022-12-19 at 14:28 +0000, Alex Kiernan wrote: > > On Mon, Dec 19, 2022 at 2:19 PM Alex Kiernan <alex.kiernan@gmail.com> wrote: > > > > > > Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> > > > --- > > > 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 > > > > > > diff --git a/meta/lib/oeqa/files/test.rs b/meta/lib/oeqa/files/test.rs > > > new file mode 100644 > > > index 000000000000..f79c691f0853 > > > --- /dev/null > > > +++ b/meta/lib/oeqa/files/test.rs > > > @@ -0,0 +1,2 @@ > > > +fn main() { > > > +} > > > diff --git a/meta/lib/oeqa/runtime/cases/rust.py b/meta/lib/oeqa/runtime/cases/rust.py > > > index 55b280d61d8a..186bb0d79e15 100644 > > > --- a/meta/lib/oeqa/runtime/cases/rust.py > > > +++ b/meta/lib/oeqa/runtime/cases/rust.py > > > @@ -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']) > > > > 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: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
On Mon, 2022-12-19 at 15:38 +0100, Alexander Kanavin wrote:
> 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
diff --git a/meta/lib/oeqa/files/test.rs b/meta/lib/oeqa/files/test.rs new file mode 100644 index 000000000000..f79c691f0853 --- /dev/null +++ b/meta/lib/oeqa/files/test.rs @@ -0,0 +1,2 @@ +fn main() { +} diff --git a/meta/lib/oeqa/runtime/cases/rust.py b/meta/lib/oeqa/runtime/cases/rust.py index 55b280d61d8a..186bb0d79e15 100644 --- a/meta/lib/oeqa/runtime/cases/rust.py +++ b/meta/lib/oeqa/runtime/cases/rust.py @@ -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'])
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> --- 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