Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | # |
| 4 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5 | import os |
| 6 | |
| 7 | from oeqa.runtime.case import OERuntimeTestCase |
| 8 | from oeqa.core.decorator.depends import OETestDepends |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9 | from oeqa.core.decorator.data import skipIfNotFeature |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 10 | from oeqa.runtime.decorator.package import OEHasPackage |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 11 | |
| 12 | class StapTest(OERuntimeTestCase): |
| 13 | |
| 14 | @classmethod |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 15 | def setUp(cls): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 16 | src = os.path.join(cls.tc.runtime_files_dir, 'hello.stp') |
| 17 | dst = '/tmp/hello.stp' |
| 18 | cls.tc.target.copyTo(src, dst) |
| 19 | |
| 20 | @classmethod |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 21 | def tearDown(cls): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 22 | files = '/tmp/hello.stp' |
| 23 | cls.tc.target.run('rm %s' % files) |
| 24 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 25 | @skipIfNotFeature('tools-profile', |
| 26 | 'Test requires tools-profile to be in IMAGE_FEATURES') |
| 27 | @OETestDepends(['kernelmodule.KernelModuleTest.test_kernel_module']) |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 28 | @OEHasPackage(['systemtap']) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 29 | def test_stap(self): |
| 30 | cmds = [ |
| 31 | 'cd /usr/src/kernel && make scripts prepare', |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 32 | 'cd /lib/modules/`uname -r` && (if [ ! -e build ]; then ln -s /usr/src/kernel build; fi)', |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 33 | 'stap --disable-cache -DSTP_NO_VERREL_CHECK /tmp/hello.stp' |
| 34 | ] |
| 35 | for cmd in cmds: |
| 36 | status, output = self.target.run(cmd, 900) |
| 37 | self.assertEqual(status, 0, msg='\n'.join([cmd, output])) |