Patrick Williams | db4c27e | 2022-08-05 08:10:29 -0500 | [diff] [blame] | 1 | # |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
Patrick Williams | db4c27e | 2022-08-05 08:10:29 -0500 | [diff] [blame] | 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) |
Patrick Williams | ac13d5f | 2023-11-24 18:59:46 -0600 | [diff] [blame] | 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)) |