diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/c_cpp.py')
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/c_cpp.py | 60 | 
1 files changed, 60 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/c_cpp.py b/meta/lib/oeqa/selftest/cases/c_cpp.py new file mode 100644 index 0000000000..9a70ce29f5 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/c_cpp.py  | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | # | ||
| 2 | # Copyright OpenEmbedded Contributors | ||
| 3 | # | ||
| 4 | # SPDX-License-Identifier: MIT | ||
| 5 | # | ||
| 6 | |||
| 7 | from oeqa.selftest.case import OESelftestTestCase | ||
| 8 | from oeqa.core.decorator.data import skipIfNotQemuUsermode | ||
| 9 | from oeqa.utils.commands import bitbake | ||
| 10 | |||
| 11 | |||
| 12 | class CCppTests(OESelftestTestCase): | ||
| 13 | |||
| 14 | @skipIfNotQemuUsermode() | ||
| 15 | def _qemu_usermode(self, recipe_name): | ||
| 16 | self.add_command_to_tearDown("bitbake -c clean %s" % recipe_name) | ||
| 17 | bitbake("%s -c run_tests" % recipe_name) | ||
| 18 | |||
| 19 | @skipIfNotQemuUsermode() | ||
| 20 | def _qemu_usermode_failing(self, recipe_name): | ||
| 21 | config = 'PACKAGECONFIG:pn-%s = "failing_test"' % recipe_name | ||
| 22 | self.write_config(config) | ||
| 23 | self.add_command_to_tearDown("bitbake -c clean %s" % recipe_name) | ||
| 24 | result = bitbake("%s -c run_tests" % recipe_name, ignore_status=True) | ||
| 25 | self.assertNotEqual(0, result.status, "command: %s is expected to fail but passed, status: %s, output: %s, error: %s" % ( | ||
| 26 | result.command, result.status, result.output, result.error)) | ||
| 27 | |||
| 28 | |||
| 29 | class CMakeTests(CCppTests): | ||
| 30 | def test_cmake_qemu(self): | ||
| 31 | """Test for cmake-qemu.bbclass good case | ||
| 32 | |||
| 33 | compile the cmake-example and verify the CTests pass in qemu-user. | ||
| 34 | qemu-user is configured by CMAKE_CROSSCOMPILING_EMULATOR. | ||
| 35 | """ | ||
| 36 | self._qemu_usermode("cmake-example") | ||
| 37 | |||
| 38 | def test_cmake_qemu_failing(self): | ||
| 39 | """Test for cmake-qemu.bbclass bad case | ||
| 40 | |||
| 41 | Break the comparison in the test code and verify the CTests do not pass. | ||
| 42 | """ | ||
| 43 | self._qemu_usermode_failing("cmake-example") | ||
| 44 | |||
| 45 | |||
| 46 | class MesonTests(CCppTests): | ||
| 47 | def test_meson_qemu(self): | ||
| 48 | """Test the qemu-user feature of the meson.bbclass good case | ||
| 49 | |||
| 50 | compile the meson-example and verify the Unit Test pass in qemu-user. | ||
| 51 | qemu-user is configured by meson's exe_wrapper option. | ||
| 52 | """ | ||
| 53 | self._qemu_usermode("meson-example") | ||
| 54 | |||
| 55 | def test_meson_qemu_failing(self): | ||
| 56 | """Test the qemu-user feature of the meson.bbclass bad case | ||
| 57 | |||
| 58 | Break the comparison in the test code and verify the Unit Test does not pass in qemu-user. | ||
| 59 | """ | ||
| 60 | self._qemu_usermode_failing("meson-example") | ||
