serval-dna/tests/routing

166 lines
4.6 KiB
Plaintext
Raw Normal View History

2012-10-09 14:49:24 +10:30
#!/bin/bash
# Tests for Route discovery
# Copyright 2012 Serval Project
#
# 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"
configure_servald_server() {
executeOk_servald config \
set log.show_pid on \
set log.show_time on \
set debug.mdprequests Yes
2012-10-09 14:49:24 +10:30
}
add_interface() {
2012-12-08 15:09:41 +10:30
>$SERVALD_VAR/dummy$1
executeOk_servald config \
set interfaces.$1.dummy dummy$1 \
set interfaces.$1.dummy_address 127.0.$1.$instance_number \
set interfaces.$1.dummy_netmask 255.255.255.224
}
interface_up() {
grep "Dummy interface .* is up" $instance_servald_log || return 1
return 0
2012-10-09 14:49:24 +10:30
}
start_routing_instance() {
executeOk_servald config \
set server.dummy_interface_dir "$SERVALD_VAR" \
set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" \
set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" \
set log.show_pid on \
set log.show_time on \
set debug.mdprequests Yes
2012-10-09 14:49:24 +10:30
start_servald_server
2012-12-08 15:09:41 +10:30
wait_until interface_up
2012-10-09 14:49:24 +10:30
}
2012-11-26 14:40:22 +10:30
log_routing_table() {
executeOk_servald route print
tfw_cat --stdout --stderr
}
2012-10-09 14:49:24 +10:30
teardown() {
2012-11-26 14:40:22 +10:30
foreach_instance_with_pidfile log_routing_table
2012-10-09 14:49:24 +10:30
stop_all_servald_servers
kill_all_servald_processes
assert_no_servald_processes
2012-11-26 14:40:22 +10:30
report_all_servald_servers
2012-10-09 14:49:24 +10:30
}
setup_single_link() {
setup_servald
assert_no_servald_processes
foreach_instance +A +B create_single_identity
2012-12-08 15:09:41 +10:30
foreach_instance +A +B add_interface 1
foreach_instance +A +B start_routing_instance
2012-10-09 14:49:24 +10:30
}
doc_single_link="Start 2 instances on one link"
test_single_link() {
set_instance +A
2012-12-06 11:54:09 +10:30
executeOk_servald mdp ping $SIDB 10
tfw_cat --stdout --stderr
2012-10-09 14:49:24 +10:30
}
setup_multiple_nodes() {
setup_servald
assert_no_servald_processes
foreach_instance +A +B +C +D create_single_identity
2012-12-08 15:09:41 +10:30
foreach_instance +A +B +C +D add_interface 1
foreach_instance +A +B +C +D start_routing_instance
}
doc_multiple_nodes="Multiple nodes on one link"
test_multiple_nodes() {
set_instance +A
2012-12-06 11:54:09 +10:30
executeOk_servald mdp ping $SIDB 10
tfw_cat --stdout --stderr
executeOk_servald mdp ping $SIDC 3
tfw_cat --stdout --stderr
executeOk_servald mdp ping $SIDD 3
tfw_cat --stdout --stderr
}
2012-12-08 15:09:41 +10:30
setup_scan() {
setup_servald
assert_no_servald_processes
foreach_instance +A +B create_single_identity
foreach_instance +A +B add_interface 1
foreach_instance +A +B \
executeOk_servald config \
set interfaces.1.dummy_filter_broadcasts 1
foreach_instance +A +B start_routing_instance
}
scan_completed() {
grep "Scan completed" $LOG||return1
return 0
}
doc_scan="Simulate isolated clients"
test_scan() {
set_instance +A
executeOk_servald scan
wait_until scan_completed
executeOk_servald mdp ping $SIDB 3
}
2012-10-09 14:49:24 +10:30
setup_multihop_linear() {
setup_servald
assert_no_servald_processes
foreach_instance +A +B +C +D create_single_identity
2012-12-08 15:09:41 +10:30
foreach_instance +A +B add_interface 1
foreach_instance +B +C add_interface 2
foreach_instance +C +D add_interface 3
2012-10-09 14:49:24 +10:30
foreach_instance +A +B +C +D start_routing_instance
}
doc_multihop_linear="Start 4 instances in a linear arrangement"
test_multihop_linear() {
set_instance +A
2012-12-06 11:54:09 +10:30
executeOk_servald mdp ping $SIDD 10
tfw_cat --stdout --stderr
2012-10-09 14:49:24 +10:30
}
setup_crowded_mess() {
setup_servald
assert_no_servald_processes
# BCDE & DEFG form squares, ABC & FGH form triangles
foreach_instance +A +B +C +D +E +F +G +H create_single_identity
2012-12-08 15:09:41 +10:30
foreach_instance +A +B +C add_interface 1
foreach_instance +B +D add_interface 2
foreach_instance +C +E add_interface 3
foreach_instance +D +E add_interface 4
foreach_instance +D +F add_interface 5
foreach_instance +E +G add_interface 6
foreach_instance +F +G +H add_interface 7
foreach_instance +A +B +C +D +E +F +G +H start_routing_instance
}
doc_crowded_mess="Multiple possible paths"
test_crowded_mess() {
set_instance +A
2012-12-06 11:54:09 +10:30
executeOk_servald mdp ping $SIDH 10
tfw_cat --stdout --stderr
}
2012-10-09 14:49:24 +10:30
runTests "$@"