]>
jfr.im git - solanum.git/blob - tools/smoketest.sh
2 # Simple test that compiles and runs ircd, verifying that certain aspects of
7 *) printf 'Usage: %s tarball\n' "$0" >&2; exit 64 ;;
10 rc
=0 ircdpid
= tarball
=${1:?}
13 *) tarball
=$PWD/$tarball ;;
15 dir
=$(mktemp -d "${TMPDIR:-/tmp}/ircdtest.XXXXXXXXXX") || exit 2
16 trap '[ -z "$ircdpid" ] || kill $ircdpid; rm -rf "$dir"' 0
18 tar xjf
"$tarball" || exit 2
20 srcdir
=${srcdir%.tbz2}
22 srcdir
=${srcdir%.tar.*}
24 cd "$srcdir" || exit 2
26 .
/configure
--prefix="$prefix" >"$dir/out" 2>&1 || { cat "$dir/out"; exit 2; }
27 make -j2 >"$dir/out" 2>&1 || { cat "$dir/out"; exit 2; }
28 make install >"$dir/out" 2>&1 || { cat "$dir/out"; exit 2; }
29 cd "$prefix" || exit 2
30 servername
=smoke
$(date +%Y%m%d%H%M%S).
test
32 sed -e '/^serverinfo/,/^}/s/name = ".*";/name = "'"$servername"'";/' \
33 -e '/^listen/,/^}/s/port = .*;/port = '"$port"';/' \
34 -e '/^blacklist/,/^}/s/^/#/' \
35 etc
/ircd.conf.example
>etc
/ircd.conf
|| exit 2
37 ircdpid
=$(cat etc/ircd.pid) || exit 2
39 echo "Will use servername $servername port $port, pid is $ircdpid"
41 echo 'USER testu . . :Test user'
46 echo "PRIVMSG #test :channel message via $servername"
47 echo "PRIVMSG @#test :chanops 1 via $servername"
48 echo "MODE #test +o test2"
49 echo "PRIVMSG @#test :chanops 2 via $servername"
52 } | nc
127.0.0.1 "$port" >out1
&
55 echo 'USER testu2 . . :Test user'
58 echo "PRIVMSG test1 :private message via $servername"
61 } | nc
127.0.0.1 "$port" >out2
&
63 if ! grep -q "^:$servername 001 test1 :" out1
; then
64 echo "FAIL: Missing 001 in out1 or wrong server"
67 if ! grep -q "^:$servername 001 test2 :" out2
; then
68 echo "FAIL: Missing 001 in out2 or wrong server"
71 if ! grep -q "^:test2!.*@.* PRIVMSG test1 :private message via $servername$cr\$" out1
; then
72 echo "FAIL: Missing private message in out1"
75 if ! grep -q "^:test1!.*@.* PRIVMSG #test :channel message via $servername$cr\$" out2
; then
76 echo "FAIL: Missing channel message in out2"
79 if grep -q "chanops 1 via" out2
; then
80 echo "FAIL: Wrong chanops message in out2"
83 if ! grep -q "^:test1!.* MODE #test +o test2[[:space:]]*$cr\$" out1
; then
84 echo "FAIL: Missing mode in out1"
87 if ! grep -q "^:test1!.* MODE #test +o test2[[:space:]]*$cr\$" out2
; then
88 echo "FAIL: Missing mode in out2"
91 if ! grep -q "^:test1!.* PRIVMSG @#test :chanops 2 via $servername$cr\$" out2
; then
92 echo "FAIL: Missing chanops message in out2"
95 if [ "$rc" -ne 0 ] && [ -t 0 ] && [ -t 1 ] && [ -t 2 ]; then
96 echo 'Starting shell for investigation...'
97 PS1
='ircd-smoketest$ ' sh
-i
99 if [ "$rc" -eq 0 ]; then