diff options
Diffstat (limited to 'meta/lib/oeqa/sdk/cases/rust.py')
-rw-r--r-- | meta/lib/oeqa/sdk/cases/rust.py | 57 |
1 files changed, 57 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..f5d437bb19 --- /dev/null +++ b/meta/lib/oeqa/sdk/cases/rust.py | |||
@@ -0,0 +1,57 @@ | |||
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.core.utils.path import remove_safe | ||
12 | from oeqa.sdk.case import OESDKTestCase | ||
13 | |||
14 | from oeqa.utils.subprocesstweak import errors_have_output | ||
15 | errors_have_output() | ||
16 | |||
17 | class RustCompileTest(OESDKTestCase): | ||
18 | td_vars = ['MACHINE'] | ||
19 | |||
20 | @classmethod | ||
21 | def setUpClass(self): | ||
22 | targetdir = os.path.join(self.tc.sdk_dir, "hello") | ||
23 | try: | ||
24 | shutil.rmtree(targetdir) | ||
25 | except FileNotFoundError: | ||
26 | pass | ||
27 | shutil.copytree(os.path.join(self.tc.sdk_files_dir, "rust/hello"), targetdir) | ||
28 | |||
29 | def setUp(self): | ||
30 | machine = self.td.get("MACHINE") | ||
31 | if not self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine): | ||
32 | raise unittest.SkipTest("RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain") | ||
33 | |||
34 | def test_cargo_build(self): | ||
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 build --target %s-gnu' % (self.tc.sdk_dir, sdksys)) | ||
57 | self._run('cd %s/hello; cargo run --target %s-gnu' % (self.tc.sdk_dir, sdksys)) | ||