source: protocols/skype/t/irssi/livetest-irssi.sh @ 693ff09

Last change on this file since 693ff09 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: 3.0 KB
Line 
1#!/usr/bin/env bash
2ISCRIPT=$1
3OPT=$2
4
5[ -n "$ISCRIPT" ] || { echo Syntax: `basename "$0"` irssi-test-script; exit 1; }
6
7# Load variables from test
8eval `sed -e '1,/^###/!d;/^###/d' "$ISCRIPT"`
9
10#if [ "$OPT" == "checkvars" ]; then echo $TESTNEEDEDVARS; fi
11RET=0
12
13# Check if we have the neccessary environment variables for this test
14for var in $TESTNEEDEDVARS; do
15        if [ -z `eval echo \$\{$var\}` ]; then
16                if [ "$OPT" != "checkvars" ]; then 
17                        echo Need environment variable "$var" for this test.
18                        exit 66
19                else
20                        echo $var
21                        RET=66
22                fi
23        fi
24done
25
26# if we got this far we're OK
27if [ "$OPT" == "checkvars" ]; then exit $RET; fi
28
29[ -n "$PORT" ] || { echo 'Need the bitlbee listening port as environment variable PORT'; exit 1; }
30
31# Setup the irssi dir
32(
33        rm -r dotirssi
34        mkdir -p dotirssi/scripts dotirssi/logs
35        cp "`dirname $0`"/trigger.pl dotirssi/scripts &&
36        echo 'script load trigger.pl' >dotirssi/startup
37) &>/dev/null || { echo Failed to setup irssi testdir; exit 1; }
38
39# write irssi config
40
41echo '
42
43aliases = {
44        runtest = "'`sed -e "1,/^###/d;s/@LOGIN@/$TESTLOGIN/;s/@PASSWORD@/$TESTPASSWORD/" "$ISCRIPT" | tr '\n' ';'`'";
45        expectbee  = "/trigger add -publics -channels &bitlbee -regexp";
46        expectjoin = "/trigger add -joins -masks *!$0@* $1-";
47        expectmsg  = "/trigger add -privmsgs -masks *!$0@* $1-";
48};
49
50servers = ( { address = "localhost"; chatnet = "local"; port = "'$PORT'"; autoconnect="yes";});
51
52settings = {
53  settings_autosave = "no";
54  core = { real_name = "bitlbee-test"; user_name = "bitlbee-test"; nick = "bitlbeetest"; };
55  "fe-text" = { actlist_sort = "refnum"; };
56};
57
58chatnets = { local = { type = "IRC"; autosendcmd = "/runtest"; }; };
59
60logs = {
61"dotirssi/logs/status.log" = { auto_open = "yes"; level = "ALL"; items = ( { type = "window"; name = "1"; } ); };
62"dotirssi/logs/control.log" = { auto_open = "yes"; level = "ALL"; items = ( { type = "target"; name = "&bitlbee"; } ); };
63' >dotirssi/config
64
65for nick in $TESTLOGNICKS; do 
66        echo '
67        "dotirssi/logs/'$nick'.log" = { auto_open = "yes"; level = "ALL"; items = ( { type = "target"; name = "'$nick'"; } ); };
68                ' >>dotirssi/config
69done
70
71echo '};' >>dotirssi/config
72
73# Go!
74
75echo Running irssi...
76screen -D -m irssi --config=dotirssi/config --home=dotirssi/ & 
77
78# output logs
79
80submitlogs() {
81        perl -p -i -e "s/$TESTLOGIN/---TESTLOGIN---/;s/$TESTPASSWORD/---TESTPASSWORD---/" dotirssi/logs/*.log
82
83        if [ "$OPT" == "tgz" ]; then
84                tar czf "`dirname $0`"/"`basename "$ISCRIPT"`".logs.tgz dotirssi/logs/*.log
85        elif [ "$OPT" == "ctest" ]; then 
86                echo CTEST_FULL_OUTPUT
87                for log in dotirssi/logs/*.log; do
88                        echo -n '<DartMeasurement name="'$log'" type="text/string"><![CDATA['
89                        cat "$log"
90                        echo "]]></DartMeasurement>"
91                done
92        else
93                echo Test logs: dotirssi/logs/*.log
94        fi
95}
96
97# timeout stuff
98
99t=$TESTDURATION
100intval=1
101while (( t >= intval )); do
102        sleep $intval
103        kill -0 $! &>/dev/null || { echo screen/irssi terminated.; submitlogs; bash -c "cd dotirssi/logs && $TESTCHECKRESULT" >/dev/null; exit $?; }
104        t=$(( t - $intval ))
105done
106echo Killing screen/irssi...
107kill $!
108submitlogs
109exit 22
Note: See TracBrowser for help on using the repository browser.