]> code.ossystems Code Review - openembedded-core.git/commitdiff
oeqa/runtime/stap: rewrite test
authorRoss Burton <ross@burtonini.com>
Fri, 14 Jan 2022 18:08:10 +0000 (18:08 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 15 Jan 2022 16:22:46 +0000 (16:22 +0000)
There's no need to copy files to the target when stap can take the short
probe directly.

Add more has-package decorators for the kernel source and GCC symlinks.
Remove the test dependencies as it's not a hard dependency.

Change the probe to print a message with some minimal logic, and verify
that the message was correctly constructed in the output.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oeqa/runtime/cases/stap.py
meta/lib/oeqa/runtime/files/hello.stp [deleted file]

index 5342f6ac34299cbc15cb0e395f1dec5579e1f09f..ac0125edb2ba0af55758c0139bc7cc9e7d613619 100644 (file)
@@ -5,33 +5,20 @@
 import os
 
 from oeqa.runtime.case import OERuntimeTestCase
-from oeqa.core.decorator.depends import OETestDepends
 from oeqa.core.decorator.data import skipIfNotFeature
 from oeqa.runtime.decorator.package import OEHasPackage
 
 class StapTest(OERuntimeTestCase):
-
-    @classmethod
-    def setUp(cls):
-        src = os.path.join(cls.tc.runtime_files_dir, 'hello.stp')
-        dst = '/tmp/hello.stp'
-        cls.tc.target.copyTo(src, dst)
-
-    @classmethod
-    def tearDown(cls):
-        files = '/tmp/hello.stp'
-        cls.tc.target.run('rm %s' % files)
-
-    @skipIfNotFeature('tools-profile',
-                      'Test requires tools-profile to be in IMAGE_FEATURES')
-    @OETestDepends(['kernelmodule.KernelModuleTest.test_kernel_module'])
+    @skipIfNotFeature('tools-profile', 'Test requires tools-profile to be in IMAGE_FEATURES')
     @OEHasPackage(['systemtap'])
+    @OEHasPackage(['gcc-symlinks'])
+    @OEHasPackage(['kernel-devsrc'])
     def test_stap(self):
-        cmds = [
-            'cd /usr/src/kernel && make scripts prepare',
-            'cd /lib/modules/`uname -r` && (if [ ! -e build ]; then ln -s /usr/src/kernel build; fi)',
-            'stap --disable-cache -DSTP_NO_VERREL_CHECK /tmp/hello.stp'
-            ]
-        for cmd in cmds:
-            status, output = self.target.run(cmd, 900)
-            self.assertEqual(status, 0, msg='\n'.join([cmd, output]))
+        cmd = 'make -C /usr/src/kernel scripts prepare'
+        status, output = self.target.run(cmd, 900)
+        self.assertEqual(status, 0, msg='\n'.join([cmd, output]))
+
+        cmd = 'stap -v --disable-cache -DSTP_NO_VERREL_CHECK -e \'probe oneshot { print("Hello, "); println("world!") }\''
+        status, output = self.target.run(cmd, 900)
+        self.assertEqual(status, 0, msg='\n'.join([cmd, output]))
+        self.assertIn('Hello, world!', output, msg='\n'.join([cmd, output]))
diff --git a/meta/lib/oeqa/runtime/files/hello.stp b/meta/lib/oeqa/runtime/files/hello.stp
deleted file mode 100644 (file)
index 3677147..0000000
+++ /dev/null
@@ -1 +0,0 @@
-probe oneshot { println("hello world") }