source: protocols/skype/t/livetest-bitlbee.sh @ 757e1e0

Last change on this file since 757e1e0 was 43b1cd7, checked in by Miklos Vajna <vmiklos@…>, at 2011-04-12T00:10:57Z

Merge bitlbee-skype into bitlbee

  • Property mode set to 100755
File size: 2.7 KB
Line 
1#!/usr/bin/env bash
2
3start_skyped()
4{
5        python ../skyped.py "$@" > skypedtest.pid
6        while true
7        do
8                [ -e skypedtest.pid ] || break
9                pid=$(sed 's/.*: //' skypedtest.pid)
10                if [ -n "$(ps -p $pid -o pid=)" ]; then
11                        sleep 5
12                else
13                        start_skyped "$@"
14                        break
15                fi
16        done
17}
18
19BITLBEE=$1
20typeset -ix PORT=`echo $2 | egrep '^[0-9]{1,5}$'`
21SCRIPT=$3
22shift 3
23
24[ -n "$SCRIPT" -a -n "$BITLBEE" -a -e "$SCRIPT" -a "$PORT" -ne 0 ] || { echo Syntax: `basename "$0"` bitlbee-executable listening-port test-script test-script-args; exit 1; }
25
26# Create or empty test dir
27mkdir livetest 2>/dev/null || rm livetest/bitlbeetest*.xml bitlbeetest.pid 2>/dev/null
28
29# Run the bee
30echo Running bitlbee...
31$VALGRIND $BITLBEE -n -c bitlbee.conf -d livetest/ -D -P bitlbeetest.pid -p $PORT 2>bitlbee.log &
32sleep 2
33
34# Check if it's really running
35kill -0 `cat bitlbeetest.pid 2>/dev/null ` 2>/dev/null || { echo Failed to run bitlbee daemon on port $PORT; exit 1; }
36
37if [ -z "$TUNNELED_MODE" ]; then
38        # Set up skyped
39
40        rm -rf etc
41        mkdir etc
42        cd etc
43        cp ../../skyped.cnf .
44        cp ~/.skyped/skyped.cert.pem .
45        cp ~/.skyped/skyped.key.pem .
46        cd ..
47        echo "[skyped]" > skyped.conf
48        echo "username = $TEST_SKYPE_ID" >> skyped.conf
49        SHA1=`which sha1sum`
50        if [ -z "$SHA1" ]; then
51                SHA1=`which sha1`
52        fi
53        if [ -z "$SHA1" ]; then
54                echo Test failed
55                echo "(Can't compute password for skyped.conf)"
56                exit 77
57        fi
58        echo "password = $(echo -n $TEST_SKYPE_PASSWORD|$SHA1|sed 's/ *-$//')" >> skyped.conf
59        # we use ~ here to test that resolve that syntax works
60        echo "cert = $(pwd|sed "s|$HOME|~|")/etc/skyped.cert.pem" >> skyped.conf
61        echo "key = $(pwd|sed "s|$HOME|~|")/etc/skyped.key.pem" >> skyped.conf
62        echo "port = 2727" >> skyped.conf
63
64        # Run skyped
65        start_skyped -c skyped.conf -l skypedtest.log &
66        sleep 2
67fi
68
69if [ "$TUNNELED_MODE" = "yes" ]; then
70        rm -f tunnel.pid
71        if [ -n "$TUNNEL_SCRIPT" ]; then
72                $TUNNEL_SCRIPT &
73                echo $! > tunnel.pid
74                sleep 5
75        fi
76fi
77
78# Run the test
79echo Running test script...
80"$SCRIPT" $*
81RET=$?
82
83if [ -z "$TUNNELED_MODE" ]; then
84        # skyped runs on another host: no means to kill it
85        # Kill skyped
86        killall -TERM skype
87        if [ -f skypedtest.pid ]; then
88                pid=$(sed 's/.*: //' skypedtest.pid)
89                rm skypedtest.pid
90                [ -n "$(ps -p $pid -o pid=)" ] && kill -TERM $pid
91        fi
92fi
93
94if [ "$TUNNELED_MODE" = "yes" ]; then
95        if [ -n "$TUNNEL_SCRIPT" ]; then
96                cat tunnel.pid >> /tmp/tunnel.pid
97                kill `cat tunnel.pid`
98                rm -f tunnel.pid
99        fi
100fi
101
102# Kill bee
103echo Killing bitlbee...
104kill `cat bitlbeetest.pid`
105
106if [ "$TUNNELED_MODE" = "yes" ]; then
107        # give the skyped a chance to timeout
108        sleep 30
109fi
110
111# Return test result
112[ $RET -eq 0 ] && echo Test passed
113[ $RET -ne 0 ] && echo Test failed
114[ $RET -eq 22 ] && echo '(timed out)'
115[ $RET -eq 66 ] && echo '(environment variables missing)'
116exit $RET
Note: See TracBrowser for help on using the repository browser.