Skip to contentSkip to conversation

oeqa/runtime/weston: Enhance weston tests

PATCH Superseded Yeoh Ee Peng 1 participant 1 message Apr 17, 2020

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 oeqa/runtime/weston: Enhance weston tests

Existing weston test available make sure that a process for weston-desktop-shell exist when image boot up.

Enhance weston tests by:
- execute weston-info to make sure weston interface(s) are initialized
- execute weston and make sure it can initialize a new wayland compositor (retry checking for wayland processes up to 5 times)

[YOCTO# 10690]

---
 meta/lib/oeqa/runtime/cases/weston.py | 40 +++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
meta/lib/oeqa/runtime/cases/weston.py +40 -0
index f32599a..5c01765 100644
@@ -6,6 +6,8 @@ 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
+import threading
+import time
 
 class WestonTest(OERuntimeTestCase):
 
@@ -17,3 +19,41 @@ class WestonTest(OERuntimeTestCase):
         msg = ('Weston does not appear to be running %s' %
               self.target.run(self.tc.target_cmds['ps'])[1])
         self.assertEqual(status, 0, msg=msg)
+
+    def get_weston_command(self, cmd):
+        return 'export XDG_RUNTIME_DIR=/run/user/0; export DISPLAY=:0; %s' % cmd
+
+    def run_weston_init(self):
+        self.target.run(self.get_weston_command('weston'))
+
+    def get_new_wayland_process(self, existing_wl_processes):
+        try_cnt = 0
+        while try_cnt < 5:
+            time.sleep(5 + 5*try_cnt)
+            try_cnt += 1
+            status, output = self.target.run('pidof weston-desktop-shell')
+            self.assertEqual(status, 0, msg='Retrieve existing and new weston-desktop-shell processes error: %s' % output)
+            wl_processes = output.split(" ")
+            new_wl_processes = [x for x in wl_processes if x not in existing_wl_processes]
+            if new_wl_processes:
+                return new_wl_processes, try_cnt
+
+        return new_wl_processes, try_cnt
+
+    @OEHasPackage(['weston'])
+    def test_weston_info(self):
+        status, output = self.target.run(self.get_weston_command('weston-info'))
+        self.assertEqual(status, 0, msg='weston-info error: %s' % output)
+
+    @OEHasPackage(['weston'])
+    def test_weston_can_initialize_new_wayland_compositor(self):
+        status, output = self.target.run('pidof weston-desktop-shell')
+        self.assertEqual(status, 0, msg='Retrieve existing weston-desktop-shell processes error: %s' % output)
+        existing_wl_processes = output.split(" ")
+
+        weston_thread = threading.Thread(target=self.run_weston_init)
+        weston_thread.start()
+        new_wl_processes, try_cnt = self.get_new_wayland_process(existing_wl_processes)
+        self.assertTrue(new_wl_processes, msg='Check new weston-desktop-shell processes error: %s (try_cnt:%s)' % (new_wl_processes, try_cnt))
+        for wl in new_wl_processes:
+            self.target.run('kill -9 %s' % wl)
Signature · 1 line
2.7.4