diff options
Diffstat (limited to 'meta/lib/oeqa/sdk/cases/rust.py')
-rw-r--r-- | meta/lib/oeqa/sdk/cases/rust.py | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/meta/lib/oeqa/sdk/cases/rust.py b/meta/lib/oeqa/sdk/cases/rust.py new file mode 100644 index 0000000000..4b115bebf5 --- /dev/null +++ b/meta/lib/oeqa/sdk/cases/rust.py | |||
@@ -0,0 +1,58 @@ | |||
1 | # | ||
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | |||
7 | import os | ||
8 | import shutil | ||
9 | import unittest | ||
10 | |||
11 | from oeqa.sdk.case import OESDKTestCase | ||
12 | |||
13 | from oeqa.utils.subprocesstweak import errors_have_output | ||
14 | errors_have_output() | ||
15 | |||
16 | class RustCompileTest(OESDKTestCase): | ||
17 | td_vars = ['MACHINE'] | ||
18 | |||
19 | @classmethod | ||
20 | def setUpClass(self): | ||
21 | targetdir = os.path.join(self.tc.sdk_dir, "hello") | ||
22 | try: | ||
23 | shutil.rmtree(targetdir) | ||
24 | except FileNotFoundError: | ||
25 | pass | ||
26 | shutil.copytree(os.path.join(self.tc.sdk_files_dir, "rust/hello"), targetdir) | ||
27 | |||
28 | def setUp(self): | ||
29 | machine = self.td.get("MACHINE") | ||
30 | if not self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine): | ||
31 | raise unittest.SkipTest("RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain") | ||
32 | |||
33 | def test_cargo_build(self): | ||
34 | self._run('cd %s/hello; cargo add zstd' % (self.tc.sdk_dir)) | ||
35 | self._run('cd %s/hello; cargo build' % self.tc.sdk_dir) | ||
36 | |||
37 | class RustHostCompileTest(OESDKTestCase): | ||
38 | td_vars = ['MACHINE', 'SDK_SYS'] | ||
39 | |||
40 | @classmethod | ||
41 | def setUpClass(self): | ||
42 | targetdir = os.path.join(self.tc.sdk_dir, "hello") | ||
43 | try: | ||
44 | shutil.rmtree(targetdir) | ||
45 | except FileNotFoundError: | ||
46 | pass | ||
47 | shutil.copytree(os.path.join(self.tc.sdk_files_dir, "rust/hello"), targetdir) | ||
48 | |||
49 | def setUp(self): | ||
50 | machine = self.td.get("MACHINE") | ||
51 | if not self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine): | ||
52 | raise unittest.SkipTest("RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain") | ||
53 | |||
54 | def test_cargo_build(self): | ||
55 | sdksys = self.td.get("SDK_SYS") | ||
56 | self._run('cd %s/hello; cargo add zstd' % (self.tc.sdk_dir)) | ||
57 | self._run('cd %s/hello; cargo build --target %s-gnu' % (self.tc.sdk_dir, sdksys)) | ||
58 | self._run('cd %s/hello; cargo run --target %s-gnu' % (self.tc.sdk_dir, sdksys)) | ||