serval-dna/tests/vomp

148 lines
4.3 KiB
Plaintext
Raw Normal View History

2014-02-03 05:21:48 +00:00
#!/bin/bash
# Tests for voice calls
#
# Copyright 2012 Serval Project, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
source "${0%/*}/../testframework.sh"
source "${0%/*}/../testdefs.sh"
2014-04-10 01:44:46 +00:00
setup() {
setup_servald
assert_no_servald_processes
start_servald_instances +A +B
}
2014-02-03 05:21:48 +00:00
teardown() {
stop_all_servald_servers
kill_all_servald_processes
assert_no_servald_processes
report_all_servald_servers
}
configure_servald_server() {
create_single_identity
add_servald_interface
executeOk_servald config \
set debug.mdprequests on \
set debug.monitor on \
set debug.vomp on \
2014-04-10 01:44:46 +00:00
set vomp.dial_timeout_ms 1000 \
set vomp.ring_timeout_ms 5000 \
set vomp.network_timeout_ms 5000 \
2014-02-03 05:21:48 +00:00
set log.console.level DEBUG \
set log.console.show_time on
}
2014-04-10 01:44:46 +00:00
vomp_console() {
# Note, this might block and stall the test, but I need to predict where stdout is going to be
# perhaps add an argument to execute?
$servald console <&8 >"$1"
2014-02-03 05:21:48 +00:00
}
2014-04-10 01:44:46 +00:00
send_cmd() {
tfw_log "sending $1 to $2"
# Note, this might block and stall the test...
echo "$1" >> "$2"
2014-02-03 05:21:48 +00:00
}
2014-04-10 01:44:46 +00:00
init_console() {
eval ${instance_name}_IN="$PWD/${instance_name}_IN"
eval ${instance_name}_OUT="$PWD/${instance_name}_OUT"
mkfifo "$PWD/${instance_name}_IN"
exec 8<>"$PWD/${instance_name}_IN"
fork vomp_console "$PWD/${instance_name}_OUT"
exec 8>&-
2014-02-03 05:21:48 +00:00
}
2014-04-10 01:44:46 +00:00
doc_nophone="Attempt to dial a node with no phone"
test_nophone() {
2014-02-03 05:21:48 +00:00
set_instance +A
2014-04-10 01:44:46 +00:00
init_console
send_cmd "call $SIDB $DIDA $DIDB" "$A_IN"
wait_until grep "^Call ended$" "$A_OUT"
send_cmd "quit" "$A_IN"
fork_wait_all
tfw_cat "$A_OUT"
}
doc_hangup="Hangup instead of answering"
test_hangup() {
foreach_instance +A +B init_console
send_cmd "call $SIDA $DIDB $DIDA" "$B_IN"
wait_until grep "^Dialling$" "$B_OUT"
wait_until grep "^Incoming call" "$A_OUT"
wait_until grep "^Codec list" "$A_OUT"
wait_until grep "^Codec list" "$B_OUT"
wait_until grep "^Ringing$" "$B_OUT"
send_cmd "hangup" "$A_IN"
wait_until grep "^Call ended$" "$A_OUT"
wait_until grep "^Call ended$" "$B_OUT"
send_cmd "quit" "$A_IN"
send_cmd "quit" "$B_IN"
fork_wait_all
tfw_cat "$A_OUT" "$B_OUT"
}
doc_timeout="Call timeout"
test_timeout() {
foreach_instance +A +B init_console
send_cmd "call $SIDA $DIDB $DIDA" "$B_IN"
wait_until grep "^Dialling$" "$B_OUT"
wait_until grep "^Incoming call" "$A_OUT"
wait_until grep "^Codec list" "$A_OUT"
wait_until grep "^Codec list" "$B_OUT"
wait_until grep "^Ringing$" "$B_OUT"
send_cmd "answer" "$A_IN"
wait_until grep "^Picked up$" "$B_OUT"
send_cmd "say hello" "$A_IN"
send_cmd "say hi there" "$B_IN"
wait_until grep "^hello$" "$B_OUT"
wait_until grep "^hi there$" "$A_OUT"
stop_servald_server +B
# B's console should just quit
wait_until --timeout=20 grep "^Call ended$" "$A_OUT"
send_cmd "quit" "$A_IN"
fork_wait_all
tfw_cat "$A_OUT" "$B_OUT"
}
doc_call_lifecycle="Successful call lifecycle"
test_call_lifecycle() {
foreach_instance +A +B init_console
send_cmd "call $SIDA $DIDB $DIDA" "$B_IN"
wait_until grep "^Dialling$" "$B_OUT"
wait_until grep "^Incoming call" "$A_OUT"
wait_until grep "^Codec list" "$A_OUT"
wait_until grep "^Codec list" "$B_OUT"
wait_until grep "^Ringing$" "$B_OUT"
send_cmd "answer" "$A_IN"
wait_until grep "^Picked up$" "$B_OUT"
send_cmd "say hello" "$A_IN"
send_cmd "say hi there" "$B_IN"
wait_until grep "^hello$" "$B_OUT"
wait_until grep "^hi there$" "$A_OUT"
send_cmd "hangup" "$B_IN"
wait_until grep "^Call ended$" "$A_OUT"
wait_until grep "^Call ended$" "$B_OUT"
send_cmd "quit" "$A_IN"
send_cmd "quit" "$B_IN"
2014-02-03 05:21:48 +00:00
fork_wait_all
2014-04-10 01:44:46 +00:00
tfw_cat "$A_OUT" "$B_OUT"
2014-02-03 05:21:48 +00:00
}
runTests "$@"