dbustest

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dbustest starts a private dbus-daemon 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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SessionConn

func SessionConn(t *testing.T) *dbus.Conn

SessionConn opens a connection to the session bus the test pointed at a private bus (Session or UseAsSessionBus), closed at cleanup.

Types

type Bus

type Bus struct {
	// Address is the bus address, for Dial or DBUS_SESSION_BUS_ADDRESS.
	Address string
}

Bus is one private bus.

func Session

func Session(t *testing.T) *Bus

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

func Start(t *testing.T) *Bus

Start launches a dbus-daemon for the test and stops it at cleanup. A missing dbus-daemon fails the test: the dev shell provides one.

func (*Bus) Conn

func (b *Bus) Conn(t *testing.T) *dbus.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) UseAsSessionBus

func (b *Bus) UseAsSessionBus(t *testing.T)

UseAsSessionBus points DBUS_SESSION_BUS_ADDRESS at the bus for the test, for code that dials the session bus itself.

func (*Bus) UseAsSystemBus

func (b *Bus) UseAsSystemBus(t *testing.T)

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.

func (*Var[T]) Load

func (v *Var[T]) Load() T

Load returns the current value.

func (*Var[T]) Store

func (v *Var[T]) Store(value T)

Store replaces the value.

func (*Var[T]) Update

func (v *Var[T]) Update(fn func(T) T) T

Update changes the value in place and returns the result.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL