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 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8 | from oeqa.core.decorator.data import skipIfNotFeature |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 9 | from oeqa.runtime.decorator.package import OEHasPackage |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10 | |
| 11 | class StapTest(OERuntimeTestCase): |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 12 | @skipIfNotFeature('tools-profile', 'Test requires tools-profile to be in IMAGE_FEATURES') |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 13 | @OEHasPackage(['systemtap']) |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 14 | @OEHasPackage(['gcc-symlinks']) |
| 15 | @OEHasPackage(['kernel-devsrc']) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 16 | def test_stap(self): |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame^] | 17 | try: |
| 18 | cmd = 'make -j -C /usr/src/kernel scripts prepare' |
| 19 | status, output = self.target.run(cmd, 900) |
| 20 | self.assertEqual(status, 0, msg='\n'.join([cmd, output])) |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 21 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame^] | 22 | cmd = 'stap -v -p4 -m stap-hello --disable-cache -DSTP_NO_VERREL_CHECK -e \'probe oneshot { print("Hello, "); println("SystemTap!") }\'' |
| 23 | status, output = self.target.run(cmd, 900) |
| 24 | self.assertEqual(status, 0, msg='\n'.join([cmd, output])) |
| 25 | |
| 26 | cmd = 'staprun -v -R -b1 stap-hello.ko' |
| 27 | self.assertEqual(status, 0, msg='\n'.join([cmd, output])) |
| 28 | self.assertIn('Hello, SystemTap!', output, msg='\n'.join([cmd, output])) |
| 29 | except: |
| 30 | status, dmesg = self.target.run('dmesg') |
| 31 | if status == 0: |
| 32 | print(dmesg) |