ruby-dbus-openplacos 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +504 -0
- data/NEWS +146 -0
- data/README +42 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/doc/tutorial/index.markdown +480 -0
- data/examples/gdbus/gdbus +255 -0
- data/examples/gdbus/gdbus.glade +184 -0
- data/examples/gdbus/launch.sh +4 -0
- data/examples/no-introspect/nm-test.rb +21 -0
- data/examples/no-introspect/tracker-test.rb +16 -0
- data/examples/rhythmbox/playpause.rb +25 -0
- data/examples/service/call_service.rb +25 -0
- data/examples/service/service_newapi.rb +51 -0
- data/examples/simple/call_introspect.rb +34 -0
- data/examples/simple/properties.rb +19 -0
- data/examples/utils/listnames.rb +11 -0
- data/examples/utils/notify.rb +19 -0
- data/lib/dbus/auth.rb +258 -0
- data/lib/dbus/bus.rb +947 -0
- data/lib/dbus/core_ext/class/attribute.rb +91 -0
- data/lib/dbus/core_ext/kernel/singleton_class.rb +14 -0
- data/lib/dbus/core_ext/module/remove_method.rb +12 -0
- data/lib/dbus/error.rb +44 -0
- data/lib/dbus/export.rb +124 -0
- data/lib/dbus/introspect.rb +570 -0
- data/lib/dbus/marshall.rb +443 -0
- data/lib/dbus/matchrule.rb +100 -0
- data/lib/dbus/message.rb +310 -0
- data/lib/dbus/type.rb +222 -0
- data/lib/dbus.rb +83 -0
- data/ruby-dbus-openplacos.gemspec +17 -0
- data/test/binding_test.rb +56 -0
- data/test/bus_driver_test.rb +22 -0
- data/test/dbus-launch-simple +35 -0
- data/test/dbus-limited-session.conf +28 -0
- data/test/property_test.rb +55 -0
- data/test/server_robustness_test.rb +72 -0
- data/test/server_test.rb +53 -0
- data/test/service_newapi.rb +197 -0
- data/test/session_bus_test_manual.rb +20 -0
- data/test/signal_test.rb +64 -0
- data/test/t1 +4 -0
- data/test/t2.rb +66 -0
- data/test/t3-ticket27.rb +18 -0
- data/test/t5-report-dbus-interface.rb +58 -0
- data/test/t6-loop.rb +82 -0
- data/test/test_env +13 -0
- data/test/test_server +39 -0
- data/test/variant_test.rb +66 -0
- metadata +118 -0
data/test/t6-loop.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Test the main loop
|
3
|
+
require "test/unit"
|
4
|
+
require "dbus"
|
5
|
+
|
6
|
+
def d(msg)
|
7
|
+
puts "#{$$} #{msg}" if $DEBUG
|
8
|
+
end
|
9
|
+
|
10
|
+
class MainLoopTest < Test::Unit::TestCase
|
11
|
+
def setup
|
12
|
+
@session_bus = DBus::ASessionBus.new
|
13
|
+
svc = @session_bus.service("org.ruby.service")
|
14
|
+
@obj = svc.object("/org/ruby/MyInstance")
|
15
|
+
@obj.introspect # necessary
|
16
|
+
@obj.default_iface = "org.ruby.Loop"
|
17
|
+
|
18
|
+
@loop = DBus::Main.new
|
19
|
+
@loop << @session_bus
|
20
|
+
end
|
21
|
+
|
22
|
+
# Hack the library internals so that there is a delay between
|
23
|
+
# sending a DBus call and listening for its reply, so that
|
24
|
+
# the bus has a chance to join the server messages and a race is reproducible
|
25
|
+
def call_lazily
|
26
|
+
class << @session_bus
|
27
|
+
alias :wait_for_message_orig :wait_for_message
|
28
|
+
def wait_for_message_lazy
|
29
|
+
d "I am so lazy"
|
30
|
+
sleep 1 # Give the server+bus a chance to join the messages
|
31
|
+
wait_for_message_orig
|
32
|
+
end
|
33
|
+
alias :wait_for_message :wait_for_message_lazy
|
34
|
+
end
|
35
|
+
|
36
|
+
yield
|
37
|
+
|
38
|
+
# undo
|
39
|
+
class << @session_bus
|
40
|
+
remove_method :wait_for_message
|
41
|
+
remove_method :wait_for_message_lazy
|
42
|
+
alias :wait_for_message :wait_for_message_orig
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_loop_quit(delay = 1)
|
47
|
+
@obj.on_signal "LongTaskEnd" do
|
48
|
+
d "Telling loop to quit"
|
49
|
+
@loop.quit
|
50
|
+
end
|
51
|
+
|
52
|
+
call_lazily do
|
53
|
+
# The method will sleep the requested amount of seconds
|
54
|
+
# (in another thread) before signalling LongTaskEnd
|
55
|
+
@obj.LongTaskBegin delay
|
56
|
+
end
|
57
|
+
|
58
|
+
# this thread will make the test fail if @loop.run does not return
|
59
|
+
dynamite = Thread.new do
|
60
|
+
d "Dynamite burning"
|
61
|
+
sleep 2
|
62
|
+
d "Dynamite explodes"
|
63
|
+
# We need to raise in the main thread.
|
64
|
+
# Simply raising here means the exception is ignored
|
65
|
+
# (until dynamite.join which we don't call) or
|
66
|
+
# (if abort_on_exception is set) it terminates the whole script.
|
67
|
+
Thread.main.raise RuntimeError, "The main loop did not quit in time"
|
68
|
+
end
|
69
|
+
|
70
|
+
@loop.run
|
71
|
+
d "Defusing dynamite"
|
72
|
+
# if we get here, defuse the bomb
|
73
|
+
dynamite.exit
|
74
|
+
# remove signal handler
|
75
|
+
@obj.on_signal "LongTaskEnd"
|
76
|
+
end
|
77
|
+
|
78
|
+
# https://bugzilla.novell.com/show_bug.cgi?id=537401
|
79
|
+
def test_loop_drained_socket
|
80
|
+
test_loop_quit 0
|
81
|
+
end
|
82
|
+
end
|
data/test/test_env
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#! /bin/bash
|
2
|
+
# test_env: set up the environment needed to run tests:
|
3
|
+
# - set up a private bus
|
4
|
+
# - run a test server on it
|
5
|
+
|
6
|
+
#export DBUS_VERBOSE=1
|
7
|
+
#export RUBYOPT="-d"
|
8
|
+
export RUBYOPT="$RUBYOPT -w"
|
9
|
+
./test_server \
|
10
|
+
./service_newapi.rb \
|
11
|
+
-- \
|
12
|
+
./dbus-launch-simple \
|
13
|
+
"$@"
|
data/test/test_server
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
# A wrapper for DBus tests
|
3
|
+
# Run a server (directly or by dbus activation) and then the test
|
4
|
+
# $0 server [args...] -- test [args...]
|
5
|
+
set -o errexit
|
6
|
+
|
7
|
+
while [ "$1" != "--" ]; do
|
8
|
+
SERVER="$SERVER $1"
|
9
|
+
shift
|
10
|
+
done
|
11
|
+
shift # --
|
12
|
+
|
13
|
+
setup_activation () {
|
14
|
+
SDIR=$XDG_DATA_DIRS/dbus-1/services
|
15
|
+
mkdir -p $SDIR
|
16
|
+
# FIXME Name is hardcoded
|
17
|
+
cat <<EOF > $SDIR/test.service
|
18
|
+
[D-BUS Service]
|
19
|
+
Name=org.ruby.service
|
20
|
+
Exec=$SERVER
|
21
|
+
EOF
|
22
|
+
}
|
23
|
+
|
24
|
+
run_server () {
|
25
|
+
echo -n "Hey, server, get on da bus... "
|
26
|
+
# start the server
|
27
|
+
$SERVER & sleep 3
|
28
|
+
echo "off we go!"
|
29
|
+
}
|
30
|
+
|
31
|
+
export XDG_DATA_DIRS=`mktemp -d dbus.activation.XXXXXX`
|
32
|
+
RM_FILES="$RM_FILES $XDG_DATA_DIRS"
|
33
|
+
setup_activation
|
34
|
+
#run_server
|
35
|
+
|
36
|
+
# Clean up at exit.
|
37
|
+
trap "rm -rf \$RM_FILES" EXIT TERM INT
|
38
|
+
|
39
|
+
"$@"
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Test marshalling variants according to ruby types
|
3
|
+
require "test/unit"
|
4
|
+
require "dbus"
|
5
|
+
|
6
|
+
class VariantTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@bus = DBus::ASessionBus.new
|
9
|
+
@svc = @bus.service("org.ruby.service")
|
10
|
+
end
|
11
|
+
|
12
|
+
def make_variant(a)
|
13
|
+
DBus::PacketMarshaller.make_variant(a)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_make_variant_scalar
|
17
|
+
# special case: do not fail immediately, marshaller will do that
|
18
|
+
assert_equal ["b", nil], make_variant(nil)
|
19
|
+
|
20
|
+
assert_equal ["b", true], make_variant(true)
|
21
|
+
# Integers
|
22
|
+
# no byte
|
23
|
+
assert_equal ["i", 42], make_variant(42)
|
24
|
+
# 3_000_000_000 can be u or x.
|
25
|
+
# less specific test: just run it thru a loopback
|
26
|
+
assert_equal ["x", 3_000_000_000], make_variant(3_000_000_000)
|
27
|
+
assert_equal ["x", 5_000_000_000], make_variant(5_000_000_000)
|
28
|
+
|
29
|
+
assert_equal ["d", 3.14], make_variant(3.14)
|
30
|
+
|
31
|
+
assert_equal ["s", "foo"], make_variant("foo")
|
32
|
+
assert_equal ["s", "bar"], make_variant(:bar)
|
33
|
+
|
34
|
+
# left: strruct, array, dict
|
35
|
+
# object path: detect exported objects?, signature
|
36
|
+
|
37
|
+
# # by Ruby types
|
38
|
+
# class Foo
|
39
|
+
# end
|
40
|
+
# make_variant(Foo.new)
|
41
|
+
# if we don;t understand a class, the error should be informative -> new exception
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_make_variant_array
|
45
|
+
ai = [1, 2, 3]
|
46
|
+
# as = ["one", "two", "three"]
|
47
|
+
# which?
|
48
|
+
# assert_equal ["ai", [1, 2, 3]], make_variant(ai)
|
49
|
+
assert_equal ["av", [["i", 1],
|
50
|
+
["i", 2],
|
51
|
+
["i", 3]]], make_variant(ai)
|
52
|
+
a0 = []
|
53
|
+
assert_equal ["av", []], make_variant(a0)
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_make_variant_hash
|
58
|
+
h = {"k1" => "v1", "k2" => "v2"}
|
59
|
+
assert_equal ["a{sv}", {
|
60
|
+
"k1" => ["s", "v1"],
|
61
|
+
"k2" => ["s", "v2"],
|
62
|
+
}], make_variant(h)
|
63
|
+
h0 = {}
|
64
|
+
assert_equal ["a{sv}", {}], make_variant(h0)
|
65
|
+
end
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-dbus-openplacos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 7
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Openplacos Team
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-02-24 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description:
|
23
|
+
email:
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- COPYING
|
30
|
+
- README
|
31
|
+
- NEWS
|
32
|
+
files:
|
33
|
+
- Rakefile
|
34
|
+
- VERSION
|
35
|
+
- doc/tutorial/index.markdown
|
36
|
+
- examples/gdbus/gdbus
|
37
|
+
- examples/gdbus/gdbus.glade
|
38
|
+
- examples/gdbus/launch.sh
|
39
|
+
- examples/no-introspect/nm-test.rb
|
40
|
+
- examples/no-introspect/tracker-test.rb
|
41
|
+
- examples/rhythmbox/playpause.rb
|
42
|
+
- examples/service/call_service.rb
|
43
|
+
- examples/service/service_newapi.rb
|
44
|
+
- examples/simple/call_introspect.rb
|
45
|
+
- examples/simple/properties.rb
|
46
|
+
- examples/utils/listnames.rb
|
47
|
+
- examples/utils/notify.rb
|
48
|
+
- lib/dbus.rb
|
49
|
+
- lib/dbus/auth.rb
|
50
|
+
- lib/dbus/bus.rb
|
51
|
+
- lib/dbus/core_ext/class/attribute.rb
|
52
|
+
- lib/dbus/core_ext/kernel/singleton_class.rb
|
53
|
+
- lib/dbus/core_ext/module/remove_method.rb
|
54
|
+
- lib/dbus/error.rb
|
55
|
+
- lib/dbus/export.rb
|
56
|
+
- lib/dbus/introspect.rb
|
57
|
+
- lib/dbus/marshall.rb
|
58
|
+
- lib/dbus/matchrule.rb
|
59
|
+
- lib/dbus/message.rb
|
60
|
+
- lib/dbus/type.rb
|
61
|
+
- ruby-dbus-openplacos.gemspec
|
62
|
+
- test/binding_test.rb
|
63
|
+
- test/bus_driver_test.rb
|
64
|
+
- test/dbus-launch-simple
|
65
|
+
- test/dbus-limited-session.conf
|
66
|
+
- test/property_test.rb
|
67
|
+
- test/server_robustness_test.rb
|
68
|
+
- test/server_test.rb
|
69
|
+
- test/service_newapi.rb
|
70
|
+
- test/session_bus_test_manual.rb
|
71
|
+
- test/signal_test.rb
|
72
|
+
- test/t1
|
73
|
+
- test/t2.rb
|
74
|
+
- test/t3-ticket27.rb
|
75
|
+
- test/t5-report-dbus-interface.rb
|
76
|
+
- test/t6-loop.rb
|
77
|
+
- test/test_env
|
78
|
+
- test/test_server
|
79
|
+
- test/variant_test.rb
|
80
|
+
- COPYING
|
81
|
+
- README
|
82
|
+
- NEWS
|
83
|
+
has_rdoc: true
|
84
|
+
homepage: https://github.com/flagos/ruby-dbus
|
85
|
+
licenses: []
|
86
|
+
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
hash: 3
|
98
|
+
segments:
|
99
|
+
- 0
|
100
|
+
version: "0"
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
requirements: []
|
111
|
+
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 1.4.1
|
114
|
+
signing_key:
|
115
|
+
specification_version: 3
|
116
|
+
summary: Fork from ruby-dbus
|
117
|
+
test_files: []
|
118
|
+
|