Documentation
¶
Overview ¶
Package dbustest runs private dbus-daemons for tests, so services that export or call D-Bus objects are exercised over a real bus without touching the user's session or system bus. Each bus is configured from a file the helper writes itself, so a test needs dbus-daemon on PATH and nothing in /etc, where a distro's session.conf may be absent (NixOS, minimal containers).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SessionConn ¶
SessionConn opens a connection to the session bus the test pointed at a private bus (Session or UseAsSessionBus), closed at cleanup.
func SocketPath ¶
SocketPath is a fresh bus socket path, removed with the test, in a directory short enough for AF_UNIX's 108-byte sun_path (sockdir). A bus stopped there can be followed by another at the same path, which a client dialing that fixed address sees as the bus restarting.
Types ¶
type Bus ¶
type Bus struct {
// Address is the bus address, for dbus.Connect or
// DBUS_SESSION_BUS_ADDRESS.
Address string
// contains filtered or unexported fields
}
Bus is one private bus.
func Session ¶
Session starts a private bus and makes it the test's session bus, for daemon and CLI halves that both dial the session bus.
func Start ¶
Start launches a dbus-daemon on a fresh socket (SocketPath) for the test and stops it at cleanup. A missing dbus-daemon fails the test: the dev shell provides one.
func StartAt ¶
StartAt launches a dbus-daemon bound to sock for the test and stops it at cleanup. The bus accepts connections once StartAt returns.
func (*Bus) Conn ¶
Conn opens a new authenticated connection to the bus, closed at cleanup. Each call is a distinct peer with its own unique name.
func (*Bus) Stop ¶
Stop terminates the daemon and waits for it to exit, so a bus started next at the same socket does not race a dying one; connections to it see the bus go away. Stopping again does nothing.
func (*Bus) UseAsSessionBus ¶
UseAsSessionBus points DBUS_SESSION_BUS_ADDRESS at the bus for the test, for code that dials the session bus itself.
func (*Bus) UseAsSystemBus ¶
UseAsSystemBus points DBUS_SYSTEM_BUS_ADDRESS at the bus for the test, for code that dials the system bus itself.
type Var ¶
type Var[T any] struct { // contains filtered or unexported fields }
Var is state a bus handler writes and the test reads. A method call and its reply cross a socket, which the race detector cannot see as ordering, so a plain captured variable reads as a race even when the round trip orders it. Var's lock makes the ordering visible.