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