-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve spread test, implement proper dbus activatable test app
- Loading branch information
Showing
7 changed files
with
60 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
tests/lib/snaps/test-snapd-dbus-service/bin/test-snapd-dbus-service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
3 changes: 3 additions & 0 deletions
3
tests/lib/snaps/test-snapd-dbus-service/meta/gui/test-snapd-dbus.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |