tests/dbus-runner: Forward logind methods when not in KVM
This means one can run meta-dbus-runner.py effectively mocking everything relevant except logind itself, meaning one can run from a TTY and get permission to mode set etc, while still mocking things like gsd-color, colord, etc. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2618>
This commit is contained in:
@ -1,6 +1,21 @@
|
||||
import dbus
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
host_system_bus_connection = None
|
||||
|
||||
|
||||
def ensure_system_bus(address):
|
||||
global host_system_bus_connection
|
||||
|
||||
if host_system_bus_connection is None:
|
||||
bus = dbus.bus.BusConnection(address)
|
||||
host_system_bus_connection = bus
|
||||
|
||||
return host_system_bus_connection
|
||||
|
||||
|
||||
def open_file_direct(major, minor):
|
||||
sysfs_uevent_path = '/sys/dev/char/{}:{}/uevent'.format(major, minor)
|
||||
@ -19,3 +34,14 @@ def open_file_direct(major, minor):
|
||||
unix_fd = dbus.types.UnixFd(fd)
|
||||
os.close(fd)
|
||||
return (unix_fd, False)
|
||||
|
||||
|
||||
def call_host(address, object_path, interface, method, typesig, args):
|
||||
bus = ensure_system_bus(address)
|
||||
|
||||
return bus.call_blocking('org.freedesktop.login1',
|
||||
object_path,
|
||||
interface,
|
||||
method,
|
||||
typesig,
|
||||
args)
|
||||
|
Reference in New Issue
Block a user