blob: 1fd471e611a554ea8e53809458c9c29e144c0d32 [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001#
2# SPDX-License-Identifier: MIT
3#
4
5from oeqa.runtime.case import OERuntimeTestCase
6from oeqa.core.decorator.depends import OETestDepends
7from oeqa.core.decorator.data import skipIfNotFeature
8from oeqa.runtime.decorator.package import OEHasPackage
9import threading
10import time
11
12class WestonTest(OERuntimeTestCase):
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000013 weston_log_file = '/tmp/weston-2.log'
Andrew Geissler82c905d2020-04-13 13:39:40 -050014
15 @classmethod
16 def tearDownClass(cls):
17 cls.tc.target.run('rm %s' % cls.weston_log_file)
18
19 @OETestDepends(['ssh.SSHTest.test_ssh'])
20 @OEHasPackage(['weston'])
21 def test_weston_running(self):
22 cmd ='%s | grep [w]eston-desktop-shell' % self.tc.target_cmds['ps']
23 status, output = self.target.run(cmd)
24 msg = ('Weston does not appear to be running %s' %
25 self.target.run(self.tc.target_cmds['ps'])[1])
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):
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000034 return 'export XDG_RUNTIME_DIR=/run/user/`id -u weston`; export WAYLAND_DISPLAY=wayland-1; %s' % cmd
Andrew Geissler82c905d2020-04-13 13:39:40 -050035
36 def run_weston_init(self):
Andrew Geissler6ce62a22020-11-30 19:58:47 -060037 if 'systemd' in self.tc.td['VIRTUAL-RUNTIME_init_manager']:
Andrew Geisslerc9f78652020-09-18 14:11:35 -050038 self.target.run('systemd-run --collect --unit=weston-ptest.service --uid=0 -p PAMName=login -p TTYPath=/dev/tty6 -E XDG_RUNTIME_DIR=/tmp -E WAYLAND_DISPLAY=wayland-0 /usr/bin/weston --socket=wayland-1 --log=%s' % self.weston_log_file)
39 else:
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000040 self.target.run(self.get_weston_command('openvt -- weston --socket=wayland-2 --log=%s' % self.weston_log_file))
Andrew Geissler82c905d2020-04-13 13:39:40 -050041
42 def get_new_wayland_processes(self, existing_wl_processes):
43 try_cnt = 0
44 while try_cnt < 5:
45 time.sleep(5 + 5*try_cnt)
46 try_cnt += 1
47 wl_processes = self.get_processes_of('weston-desktop-shell', 'existing and new')
48 new_wl_processes = [x for x in wl_processes if x not in existing_wl_processes]
49 if new_wl_processes:
50 return new_wl_processes, try_cnt
51
52 return new_wl_processes, try_cnt
53
Andrew Geissler6ce62a22020-11-30 19:58:47 -060054 @OEHasPackage(['wayland-utils'])
55 def test_wayland_info(self):
Andrew Geissler95ac1b82021-03-31 14:34:31 -050056 if 'systemd' in self.tc.td['VIRTUAL-RUNTIME_init_manager']:
57 command = 'XDG_RUNTIME_DIR=/run wayland-info'
58 else:
59 command = self.get_weston_command('wayland-info')
60 status, output = self.target.run(command)
Andrew Geissler6ce62a22020-11-30 19:58:47 -060061 self.assertEqual(status, 0, msg='wayland-info error: %s' % output)
Andrew Geissler82c905d2020-04-13 13:39:40 -050062
63 @OEHasPackage(['weston'])
64 def test_weston_can_initialize_new_wayland_compositor(self):
65 existing_wl_processes = self.get_processes_of('weston-desktop-shell', 'existing')
66 existing_weston_processes = self.get_processes_of('weston', 'existing')
67
68 weston_thread = threading.Thread(target=self.run_weston_init)
69 weston_thread.start()
70 new_wl_processes, try_cnt = self.get_new_wayland_processes(existing_wl_processes)
71 existing_and_new_weston_processes = self.get_processes_of('weston', 'existing and new')
72 new_weston_processes = [x for x in existing_and_new_weston_processes if x not in existing_weston_processes]
Andrew Geissler6ce62a22020-11-30 19:58:47 -060073 if 'systemd' in self.tc.td['VIRTUAL-RUNTIME_init_manager']:
Andrew Geisslerc9f78652020-09-18 14:11:35 -050074 self.target.run('systemctl stop weston-ptest.service')
75 else:
76 for w in new_weston_processes:
77 self.target.run('kill -9 %s' % w)
Andrew Geissler82c905d2020-04-13 13:39:40 -050078 __, weston_log = self.target.run('cat %s' % self.weston_log_file)
79 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))
Andrew Geissler615f2f12022-07-15 14:00:58 -050080
81 @skipIfNotFeature('x11', 'Test requires x11 to be in DISTRO_FEATURES')
82 @OEHasPackage(['weston'])
83 def test_weston_supports_xwayland(self):
84 cmd ='cat %s | grep "xserver listening on display"' % self.weston_log_file
85 status, output = self.target.run(cmd)
86 msg = ('xwayland does not appear to be running')
87 self.assertEqual(status, 0, msg=msg)