Skip to content

Commit

Permalink
improve spread test, implement proper dbus activatable test app
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 committed Jan 11, 2017
1 parent f699690 commit 4e3ea5a
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 9 deletions.
2 changes: 1 addition & 1 deletion debian/snapd.install
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ usr/bin/snap-exec /usr/lib/snapd/
usr/bin/snapctl
usr/bin/snapd /usr/lib/snapd/

data/dbus/snapd.conf etc/dbus-1/session.d
data/dbus/snapd.conf etc/dbus-1/session.d
3 changes: 0 additions & 3 deletions tests/lib/snaps/basic-dbus-service/meta/gui/echo.service

This file was deleted.

5 changes: 0 additions & 5 deletions tests/lib/snaps/basic-dbus-service/meta/snap.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/python3

from gi.repository import GLib

import dbus
import dbus.service
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)


class ServerObject(dbus.service.Object):
def __init__(self):
bus_name = dbus.service.BusName(
'io.snapcraft.SnapDbusService',bus=dbus.SessionBus())
dbus.service.Object.__init__(self, bus_name, '/')
@dbus.service.method('io.snapcraft.ExampleInterface')
def ExampleMethod(self):
return "hello world"


if __name__ == "__main__":
server = ServerObject()
loop = GLib.MainLoop()
loop.run()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[D-BUS Service]
Name=io.snapcraft.SnapDbusService
Exec=test-snapd-dbus-service
20 changes: 20 additions & 0 deletions tests/lib/snaps/test-snapd-dbus-service/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: test-snapd-dbus-service
version: 1.0
summary: Python based example dbus service
description: ...
apps:
test-snapd-dbus-service:
# FIXME: set GI_TYPELIB_PATH=$SNAP/usr/lib/x86_64-linux-gnu/girepository-1.0
# FIXME2: confinement issues, this only works with devmode right now
command: bin/test-snapd-dbus-service
plugs: [network, network-bind]
parts:
test-snapd-dbus-service:
plugin: python3
stage-packages:
- python3-dbus
- python3-gi
- gir1.2-glib-2.0
copy:
plugin: dump
source: .
12 changes: 12 additions & 0 deletions tests/main/dbus-activated/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
summary: Test dbus activated snaps

execute: |
echo "Ensure we have a snap that is dbus service activated"
snap install test-snapd-dbus-service
if ps afx|grep test-snapd-dbus-service; then
echo "test-snapd-dbus-service already running! test broken"
exit 1
fi
echo "Then sending methods to it will wake it up"
dbus-send --print-reply --dest=io.snapcraft.SnapDbusService / io.snapcraft.ExampleInterface.ExampleMethod | MATCH hello

0 comments on commit 4e3ea5a

Please sign in to comment.