diff options
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/rust.py')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/rust.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/cases/rust.py b/meta/lib/oeqa/runtime/cases/rust.py new file mode 100644 index 0000000000..123c942012 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/rust.py | |||
@@ -0,0 +1,64 @@ | |||
1 | # | ||
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | |||
7 | from oeqa.runtime.case import OERuntimeTestCase | ||
8 | from oeqa.core.decorator.depends import OETestDepends | ||
9 | from oeqa.runtime.decorator.package import OEHasPackage | ||
10 | |||
11 | class RustCompileTest(OERuntimeTestCase): | ||
12 | |||
13 | @classmethod | ||
14 | def setUp(cls): | ||
15 | dst = '/tmp/' | ||
16 | src = os.path.join(cls.tc.files_dir, 'test.rs') | ||
17 | cls.tc.target.copyTo(src, dst) | ||
18 | |||
19 | @classmethod | ||
20 | def tearDown(cls): | ||
21 | files = '/tmp/test.rs /tmp/test' | ||
22 | cls.tc.target.run('rm %s' % files) | ||
23 | dirs = '/tmp/hello' | ||
24 | cls.tc.target.run('rm -r %s' % dirs) | ||
25 | |||
26 | @OETestDepends(['ssh.SSHTest.test_ssh']) | ||
27 | @OEHasPackage('rust') | ||
28 | @OEHasPackage('openssh-scp') | ||
29 | def test_rust_compile(self): | ||
30 | status, output = self.target.run('rustc /tmp/test.rs -o /tmp/test') | ||
31 | msg = 'rust compile failed, output: %s' % output | ||
32 | self.assertEqual(status, 0, msg=msg) | ||
33 | |||
34 | status, output = self.target.run('/tmp/test') | ||
35 | msg = 'running compiled file failed, output: %s' % output | ||
36 | self.assertEqual(status, 0, msg=msg) | ||
37 | |||
38 | @OETestDepends(['ssh.SSHTest.test_ssh']) | ||
39 | @OEHasPackage('cargo') | ||
40 | @OEHasPackage('openssh-scp') | ||
41 | def test_cargo_compile(self): | ||
42 | status, output = self.target.run('cargo new /tmp/hello') | ||
43 | msg = 'cargo new failed, output: %s' % output | ||
44 | self.assertEqual(status, 0, msg=msg) | ||
45 | |||
46 | status, output = self.target.run('cargo build --manifest-path=/tmp/hello/Cargo.toml') | ||
47 | msg = 'cargo build failed, output: %s' % output | ||
48 | self.assertEqual(status, 0, msg=msg) | ||
49 | |||
50 | status, output = self.target.run('cargo run --manifest-path=/tmp/hello/Cargo.toml') | ||
51 | msg = 'running compiled file failed, output: %s' % output | ||
52 | self.assertEqual(status, 0, msg=msg) | ||
53 | |||
54 | class RustCLibExampleTest(OERuntimeTestCase): | ||
55 | @OETestDepends(['ssh.SSHTest.test_ssh']) | ||
56 | @OEHasPackage('rust-c-lib-example-bin') | ||
57 | def test_rust_c_lib_example(self): | ||
58 | cmd = "rust-c-lib-example-bin test" | ||
59 | status, output = self.target.run(cmd) | ||
60 | msg = 'Exit status was not 0. Output: %s' % output | ||
61 | self.assertEqual(status, 0, msg=msg) | ||
62 | |||
63 | msg = 'Incorrect output: %s' % output | ||
64 | self.assertEqual(output, "Hello world in rust from C!", msg=msg) | ||