5
func TestSessionBus(t *testing.T) {
12
func TestSystemBus(t *testing.T) {
19
func TestSend(t *testing.T) {
20
bus, err := SessionBus()
24
ch := make(chan *Call, 1)
28
Headers: map[HeaderField]Variant{
29
FieldDestination: MakeVariant(bus.Names()[0]),
30
FieldPath: MakeVariant(ObjectPath("/org/freedesktop/DBus")),
31
FieldInterface: MakeVariant("org.freedesktop.DBus.Peer"),
32
FieldMember: MakeVariant("Ping"),
35
call := bus.Send(msg, ch)
44
func (server) Double(i int64) (int64, *Error) {
48
func BenchmarkCall(b *testing.B) {
51
bus, err := SessionBus()
55
name := bus.Names()[0]
56
obj := bus.BusObject()
58
for i := 0; i < b.N; i++ {
59
err := obj.Call("org.freedesktop.DBus.GetNameOwner", 0, name).Store(&s)
64
b.Errorf("got %s, wanted %s", s, name)
69
func BenchmarkCallAsync(b *testing.B) {
71
bus, err := SessionBus()
75
name := bus.Names()[0]
76
obj := bus.BusObject()
77
c := make(chan *Call, 50)
78
done := make(chan struct{})
80
for i := 0; i < b.N; i++ {
85
s := v.Body[0].(string)
87
b.Errorf("got %s, wanted %s", s, name)
93
for i := 0; i < b.N; i++ {
94
obj.Go("org.freedesktop.DBus.GetNameOwner", 0, c, name)
99
func BenchmarkServe(b *testing.B) {
101
srv, err := SessionBus()
105
cli, err := SessionBusPrivate()
109
if err = cli.Auth(nil); err != nil {
112
if err = cli.Hello(); err != nil {
115
benchmarkServe(b, srv, cli)
118
func BenchmarkServeAsync(b *testing.B) {
120
srv, err := SessionBus()
124
cli, err := SessionBusPrivate()
128
if err = cli.Auth(nil); err != nil {
131
if err = cli.Hello(); err != nil {
134
benchmarkServeAsync(b, srv, cli)
137
func BenchmarkServeSameConn(b *testing.B) {
139
bus, err := SessionBus()
144
benchmarkServe(b, bus, bus)
147
func BenchmarkServeSameConnAsync(b *testing.B) {
149
bus, err := SessionBus()
154
benchmarkServeAsync(b, bus, bus)
157
func benchmarkServe(b *testing.B, srv, cli *Conn) {
160
dest := srv.Names()[0]
161
srv.Export(server{}, "/org/guelfey/DBus/Test", "org.guelfey.DBus.Test")
162
obj := cli.Object(dest, "/org/guelfey/DBus/Test")
164
for i := 0; i < b.N; i++ {
165
err = obj.Call("org.guelfey.DBus.Test.Double", 0, int64(i)).Store(&r)
170
b.Errorf("got %d, wanted %d", r, 2*int64(i))
175
func benchmarkServeAsync(b *testing.B, srv, cli *Conn) {
176
dest := srv.Names()[0]
177
srv.Export(server{}, "/org/guelfey/DBus/Test", "org.guelfey.DBus.Test")
178
obj := cli.Object(dest, "/org/guelfey/DBus/Test")
179
c := make(chan *Call, 50)
180
done := make(chan struct{})
182
for i := 0; i < b.N; i++ {
187
i, r := v.Args[0].(int64), v.Body[0].(int64)
189
b.Errorf("got %d, wanted %d", r, 2*i)
195
for i := 0; i < b.N; i++ {
196
obj.Go("org.guelfey.DBus.Test.Double", 0, c, int64(i))