summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYeoh Ee Peng <ee.peng.yeoh@intel.com>2020-04-21 08:50:09 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-04-26 14:00:49 +0100
commit2492d4fa531cad8d4d23ccacd79b761a26427419 (patch)
treea8ac60490cd4bd78317cac1f50f229f4ec6b375b
parentae1be0d1d1cdc48c4b7c6328e02f0c12d5252fd9 (diff)
downloadpoky-2492d4fa531cad8d4d23ccacd79b761a26427419.tar.gz
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) - enable weston logging for debugging when fail to initialize wayland compositor [YOCTO# 10690] (From OE-Core rev: d06552c588bde8fc15c23d8fc2eb00a4243cbc3b) Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/runtime/cases/weston.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/cases/weston.py b/meta/lib/oeqa/runtime/cases/weston.py
index f32599afc3..ac29eca6e4 100644
--- a/meta/lib/oeqa/runtime/cases/weston.py
+++ b/meta/lib/oeqa/runtime/cases/weston.py
@@ -6,8 +6,15 @@ from oeqa.runtime.case import OERuntimeTestCase
6from oeqa.core.decorator.depends import OETestDepends 6from oeqa.core.decorator.depends import OETestDepends
7from oeqa.core.decorator.data import skipIfNotFeature 7from oeqa.core.decorator.data import skipIfNotFeature
8from oeqa.runtime.decorator.package import OEHasPackage 8from oeqa.runtime.decorator.package import OEHasPackage
9import threading
10import time
9 11
10class WestonTest(OERuntimeTestCase): 12class WestonTest(OERuntimeTestCase):
13 weston_log_file = '/tmp/weston.log'
14
15 @classmethod
16 def tearDownClass(cls):
17 cls.tc.target.run('rm %s' % cls.weston_log_file)
11 18
12 @OETestDepends(['ssh.SSHTest.test_ssh']) 19 @OETestDepends(['ssh.SSHTest.test_ssh'])
13 @OEHasPackage(['weston']) 20 @OEHasPackage(['weston'])
@@ -17,3 +24,46 @@ class WestonTest(OERuntimeTestCase):
17 msg = ('Weston does not appear to be running %s' % 24 msg = ('Weston does not appear to be running %s' %
18 self.target.run(self.tc.target_cmds['ps'])[1]) 25 self.target.run(self.tc.target_cmds['ps'])[1])
19 self.assertEqual(status, 0, msg=msg) 26 self.assertEqual(status, 0, msg=msg)
27
28 def get_processes_of(self, target, error_msg):
29 status, output = self.target.run('pidof %s' % target)
30 self.assertEqual(status, 0, msg='Retrieve %s (%s) processes error: %s' % (target, error_msg, output))
31 return output.split(" ")
32
33 def get_weston_command(self, cmd):
34 return 'export XDG_RUNTIME_DIR=/run/user/0; export WAYLAND_DISPLAY=wayland-0; %s' % cmd
35
36 def run_weston_init(self):
37 self.target.run(self.get_weston_command('weston --log=%s' % self.weston_log_file))
38
39 def get_new_wayland_processes(self, existing_wl_processes):
40 try_cnt = 0
41 while try_cnt < 5:
42 time.sleep(5 + 5*try_cnt)
43 try_cnt += 1
44 wl_processes = self.get_processes_of('weston-desktop-shell', 'existing and new')
45 new_wl_processes = [x for x in wl_processes if x not in existing_wl_processes]
46 if new_wl_processes:
47 return new_wl_processes, try_cnt
48
49 return new_wl_processes, try_cnt
50
51 @OEHasPackage(['weston'])
52 def test_weston_info(self):
53 status, output = self.target.run(self.get_weston_command('weston-info'))
54 self.assertEqual(status, 0, msg='weston-info error: %s' % output)
55
56 @OEHasPackage(['weston'])
57 def test_weston_can_initialize_new_wayland_compositor(self):
58 existing_wl_processes = self.get_processes_of('weston-desktop-shell', 'existing')
59 existing_weston_processes = self.get_processes_of('weston', 'existing')
60
61 weston_thread = threading.Thread(target=self.run_weston_init)
62 weston_thread.start()
63 new_wl_processes, try_cnt = self.get_new_wayland_processes(existing_wl_processes)
64 existing_and_new_weston_processes = self.get_processes_of('weston', 'existing and new')
65 new_weston_processes = [x for x in existing_and_new_weston_processes if x not in existing_weston_processes]
66 for w in new_weston_processes:
67 self.target.run('kill -9 %s' % w)
68 __, weston_log = self.target.run('cat %s' % self.weston_log_file)
69 self.assertTrue(new_wl_processes, msg='Could not get new weston-desktop-shell processes (%s, try_cnt:%s) weston log: %s' % (new_wl_processes, try_cnt, weston_log))