~ubuntu-branches/ubuntu/utopic/libdbus-ruby/utopic

« back to all changes in this revision

Viewing changes to test/test_server

  • Committer: Bazaar Package Importer
  • Author(s): Paul van Tilburg, Gunnar Wolf, Paul van Tilburg
  • Date: 2010-02-14 21:12:08 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100214211208-zb8wnxcq9izet9hf
Tags: 0.2.12-1
[ Gunnar Wolf ]
* Changed section to Ruby as per ftp-masters' request

[ Paul van Tilburg ]
* New upstream release.
* debian/control:
  - Bumped standards version to 3.8.4.
  - Added missing ${misc:Depends} to libdbus-ruby and libdbus-ruby1.8.
* debian/watch:
  - Updated the URL to the new location on github (closes: #558602).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
# A wrapper for DBus tests
 
3
# Sets up a private session bus and calls all its arguments in turn
 
4
# exiting on first failure
 
5
# $0 server [-k] [arg1 arg2...] -- test1 test2...
 
6
set -o errexit
 
7
 
 
8
KEEP_GOING=false
 
9
if [ "$1" = "-k" ]; then
 
10
    KEEP_GOING=true
 
11
    shift
 
12
fi
 
13
 
 
14
while [ "$1" != "--" ]; do
 
15
  SERVER="$SERVER $1"
 
16
  shift
 
17
done
 
18
shift # --
 
19
 
 
20
# This launches the bus daemon,
 
21
# exports DBUS_SESSION_BUS_ADDRESS and sets DBUS_SESSION_BUS_PID
 
22
my_dbus_launch () {
 
23
    # reimplementing dbus-launch because it is in dbus-1-x11.rpm
 
24
    PF=`mktemp dbus.pid.XXXXXX` || exit
 
25
    AF=`mktemp dbus.addr.XXXXXX` || exit
 
26
 
 
27
    dbus-daemon --session --print-address=3 3>$AF --print-pid=4 4>$PF &
 
28
    # wait for the daemon to print the info
 
29
    TRIES=0
 
30
    while [ ! -s $AF -o ! -s $PF ]; do
 
31
        sleep 0.1
 
32
        TRIES=`expr $TRIES + 1`
 
33
        if [ $TRIES -gt 100 ]; then echo "dbus-daemon failed?"; exit 1; fi
 
34
    done
 
35
    DBUS_SESSION_BUS_PID=$(cat $PF)
 
36
    export DBUS_SESSION_BUS_ADDRESS=$(cat $AF)
 
37
    # Clean up at exit. This will also kill the server.
 
38
    trap "kill $DBUS_SESSION_BUS_PID; rm $AF $PF" EXIT TERM INT
 
39
}
 
40
 
 
41
setup_activation () {
 
42
    SDIR=$XDG_DATA_DIRS/dbus-1/services
 
43
    mkdir -p $SDIR
 
44
    cat <<EOF > $SDIR/test.service
 
45
[D-BUS Service]
 
46
Name=org.ruby.service
 
47
Exec=$SERVER
 
48
EOF
 
49
}
 
50
 
 
51
run_server () {
 
52
    echo -n "Hey, server, get on da bus... "
 
53
    # start the server
 
54
    $SERVER & sleep 3
 
55
    echo "off we go!"
 
56
}
 
57
 
 
58
export XDG_DATA_DIRS=`mktemp -d dbus.activation.XXXXXX`
 
59
my_dbus_launch
 
60
setup_activation
 
61
#run_server
 
62
 
 
63
while [ -n "$1" ]; do
 
64
  echo Running $1
 
65
  $1 || $KEEP_GOING
 
66
  shift
 
67
done
 
68
 
 
69
rm -r $XDG_DATA_DIRS
 
70
echo Done