2012-10-09 04:19:24 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Tests for Route discovery
|
2013-02-06 08:25:31 +00:00
|
|
|
#
|
|
|
|
# Copyright 2012 Serval Project, Inc.
|
2012-10-09 04:19:24 +00:00
|
|
|
#
|
|
|
|
# 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"
|
|
|
|
|
|
|
|
add_interface() {
|
2012-12-08 04:39:41 +00:00
|
|
|
>$SERVALD_VAR/dummy$1
|
|
|
|
executeOk_servald config \
|
2013-02-14 03:48:56 +00:00
|
|
|
set interfaces.$1.file dummy$1 \
|
2012-12-08 04:39:41 +00:00
|
|
|
set interfaces.$1.dummy_address 127.0.$1.$instance_number \
|
|
|
|
set interfaces.$1.dummy_netmask 255.255.255.224
|
|
|
|
}
|
|
|
|
|
|
|
|
interface_up() {
|
2013-02-14 03:48:56 +00:00
|
|
|
grep "Interface .* is up" $instance_servald_log || return 1
|
2012-12-08 04:39:41 +00:00
|
|
|
return 0
|
2012-10-09 04:19:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
start_routing_instance() {
|
2012-12-06 02:01:19 +00:00
|
|
|
executeOk_servald config \
|
2013-02-14 03:48:56 +00:00
|
|
|
set server.interface_path "$SERVALD_VAR" \
|
2012-12-06 02:01:19 +00:00
|
|
|
set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" \
|
|
|
|
set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" \
|
2013-04-12 07:48:25 +00:00
|
|
|
set log.console.level debug \
|
2013-04-05 06:25:14 +00:00
|
|
|
set log.console.show_pid on \
|
|
|
|
set log.console.show_time on \
|
2013-04-12 07:48:25 +00:00
|
|
|
set debug.mdprequests yes \
|
|
|
|
set debug.verbose yes \
|
2012-12-10 23:26:21 +00:00
|
|
|
set rhizome.enable no
|
2012-10-09 04:19:24 +00:00
|
|
|
start_servald_server
|
2012-12-08 04:39:41 +00:00
|
|
|
wait_until interface_up
|
2012-10-09 04:19:24 +00:00
|
|
|
}
|
|
|
|
|
2012-11-26 04:10:22 +00:00
|
|
|
log_routing_table() {
|
|
|
|
executeOk_servald route print
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
}
|
|
|
|
|
2012-10-09 04:19:24 +00:00
|
|
|
teardown() {
|
2012-11-26 04:10:22 +00:00
|
|
|
foreach_instance_with_pidfile log_routing_table
|
2012-10-09 04:19:24 +00:00
|
|
|
stop_all_servald_servers
|
|
|
|
kill_all_servald_processes
|
|
|
|
assert_no_servald_processes
|
2012-11-26 04:10:22 +00:00
|
|
|
report_all_servald_servers
|
2012-10-09 04:19:24 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 05:32:09 +00:00
|
|
|
doc_single_link="Start 2 instances on one link"
|
2012-10-09 04:19:24 +00:00
|
|
|
setup_single_link() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
foreach_instance +A +B create_single_identity
|
2012-12-08 04:39:41 +00:00
|
|
|
foreach_instance +A +B add_interface 1
|
2012-11-30 03:15:08 +00:00
|
|
|
foreach_instance +A +B start_routing_instance
|
2012-10-09 04:19:24 +00:00
|
|
|
}
|
|
|
|
test_single_link() {
|
2012-12-10 23:26:21 +00:00
|
|
|
foreach_instance +A +B \
|
|
|
|
wait_until has_seen_instances +A +B
|
2012-10-09 04:19:24 +00:00
|
|
|
set_instance +A
|
2013-04-26 07:23:04 +00:00
|
|
|
executeOk_servald mdp ping --timeout=3 $SIDB 1
|
2012-10-09 05:39:33 +00:00
|
|
|
tfw_cat --stdout --stderr
|
2012-12-10 23:26:21 +00:00
|
|
|
executeOk_servald route print
|
2013-01-29 00:57:13 +00:00
|
|
|
assertStdoutGrep --matches=1 "^$SIDB:BROADCAST UNICAST :"
|
2012-10-09 04:19:24 +00:00
|
|
|
}
|
|
|
|
|
2013-04-08 00:33:25 +00:00
|
|
|
doc_multiple_ids="Route between multiple identities"
|
|
|
|
setup_multiple_ids() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
foreach_instance +A +B create_identities 2
|
|
|
|
foreach_instance +A +B add_interface 1
|
|
|
|
foreach_instance +A +B start_routing_instance
|
|
|
|
}
|
|
|
|
test_multiple_ids() {
|
|
|
|
foreach_instance +A +B \
|
|
|
|
wait_until has_seen_instances +A +B
|
|
|
|
set_instance +A
|
2013-04-26 07:23:04 +00:00
|
|
|
executeOk_servald mdp ping --timeout=3 $SIDB2 1
|
2013-04-08 00:33:25 +00:00
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
executeOk_servald route print
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDB1:BROADCAST UNICAST :dummy.*:0*"
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDB2:INDIRECT ::$SIDB1"
|
|
|
|
set_instance +B
|
2013-04-26 07:23:04 +00:00
|
|
|
executeOk_servald mdp ping --timeout=3 $SIDA2 1
|
2013-04-08 00:33:25 +00:00
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
executeOk_servald route print
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDA1:BROADCAST UNICAST :dummy.*:0*"
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDA2:INDIRECT ::$SIDA1"
|
|
|
|
}
|
|
|
|
|
2013-02-14 03:48:56 +00:00
|
|
|
doc_single_mdp="Use single MDP per packet encapsulation"
|
|
|
|
setup_single_mdp() {
|
|
|
|
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.encapsulation single
|
|
|
|
foreach_instance +A +B start_routing_instance
|
|
|
|
}
|
|
|
|
test_single_mdp() {
|
|
|
|
foreach_instance +A +B \
|
|
|
|
wait_until has_seen_instances +A +B
|
|
|
|
set_instance +A
|
2013-04-26 07:23:04 +00:00
|
|
|
executeOk_servald mdp ping --timeout=3 $SIDB 1
|
2013-02-14 03:48:56 +00:00
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
executeOk_servald route print
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDB:BROADCAST UNICAST :"
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_mismatched_encap="Mismatched MDP packet encapsulation"
|
|
|
|
setup_mismatched_encap() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
foreach_instance +A +B create_single_identity
|
|
|
|
foreach_instance +A +B add_interface 1
|
|
|
|
foreach_instance +A executeOk_servald config set interfaces.1.encapsulation single
|
|
|
|
foreach_instance +A +B start_routing_instance
|
|
|
|
}
|
|
|
|
test_mismatched_encap() {
|
|
|
|
foreach_instance +A +B \
|
|
|
|
wait_until has_seen_instances +A +B
|
|
|
|
set_instance +A
|
2013-04-26 07:23:04 +00:00
|
|
|
executeOk_servald mdp ping --timeout=3 $SIDB 1
|
2013-02-14 03:48:56 +00:00
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
executeOk_servald route print
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDB:BROADCAST UNICAST :"
|
|
|
|
}
|
|
|
|
|
2013-02-19 23:51:56 +00:00
|
|
|
doc_slip_encoding="Test slip encoding and decoding"
|
|
|
|
setup_slip_encoding() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
}
|
|
|
|
test_slip_encoding() {
|
2013-04-22 06:31:38 +00:00
|
|
|
executeOk_servald test slip --seed=1 --iterations=2000
|
2013-02-19 23:51:56 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 05:32:09 +00:00
|
|
|
doc_multiple_nodes="Multiple nodes on one link"
|
2012-11-30 03:15:08 +00:00
|
|
|
setup_multiple_nodes() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
foreach_instance +A +B +C +D create_single_identity
|
2012-12-08 04:39:41 +00:00
|
|
|
foreach_instance +A +B +C +D add_interface 1
|
2012-11-30 03:15:08 +00:00
|
|
|
foreach_instance +A +B +C +D start_routing_instance
|
|
|
|
}
|
|
|
|
test_multiple_nodes() {
|
2012-12-10 23:26:21 +00:00
|
|
|
foreach +A +B +C +D \
|
|
|
|
wait_until has_seen_instances +A +B +C +D
|
2012-11-30 03:15:08 +00:00
|
|
|
set_instance +A
|
2013-04-26 07:23:04 +00:00
|
|
|
executeOk_servald mdp ping --timeout=3 $SIDB 1
|
2012-11-30 03:15:08 +00:00
|
|
|
tfw_cat --stdout --stderr
|
2013-04-26 07:23:04 +00:00
|
|
|
executeOk_servald mdp ping --timeout=3 $SIDC 1
|
2012-11-30 03:15:08 +00:00
|
|
|
tfw_cat --stdout --stderr
|
2013-04-26 07:23:04 +00:00
|
|
|
executeOk_servald mdp ping --timeout=3 $SIDD 1
|
2012-11-30 03:15:08 +00:00
|
|
|
tfw_cat --stdout --stderr
|
2012-12-10 23:26:21 +00:00
|
|
|
executeOk_servald route print
|
2013-01-29 00:57:13 +00:00
|
|
|
assertStdoutGrep --matches=1 "^$SIDB:BROADCAST "
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDC:BROADCAST "
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDD:BROADCAST "
|
2012-11-30 03:15:08 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 05:32:09 +00:00
|
|
|
doc_scan="Simulate isolated clients"
|
2012-12-08 04:39:41 +00:00
|
|
|
setup_scan() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
foreach_instance +A +B create_single_identity
|
|
|
|
foreach_instance +A +B add_interface 1
|
2012-12-11 03:02:02 +00:00
|
|
|
set_instance +B
|
|
|
|
executeOk_servald config \
|
|
|
|
set interfaces.1.dummy_address 127.0.1.11
|
2012-12-08 04:39:41 +00:00
|
|
|
foreach_instance +A +B \
|
|
|
|
executeOk_servald config \
|
2013-02-14 03:48:56 +00:00
|
|
|
set interfaces.1.drop_broadcasts 1
|
2012-12-08 04:39:41 +00:00
|
|
|
foreach_instance +A +B start_routing_instance
|
|
|
|
}
|
|
|
|
test_scan() {
|
2012-12-10 23:26:21 +00:00
|
|
|
set_instance +A
|
|
|
|
executeOk_servald scan
|
|
|
|
wait_until scan_completed
|
|
|
|
wait_until has_seen_instances +B
|
2013-04-26 07:23:04 +00:00
|
|
|
executeOk_servald mdp ping --timeout=3 $SIDB 1
|
2012-12-14 01:44:55 +00:00
|
|
|
tfw_cat --stdout --stderr
|
2012-12-10 23:26:21 +00:00
|
|
|
executeOk_servald route print
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDB:UNICAST :"
|
2012-12-08 04:39:41 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 05:32:09 +00:00
|
|
|
scan_completed() {
|
|
|
|
grep "Scan completed" $LOG||return1
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_broadcast_only="Broadcast packets only"
|
2013-01-29 00:57:13 +00:00
|
|
|
setup_broadcast_only() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
foreach_instance +A +B create_single_identity
|
|
|
|
foreach_instance +A +B add_interface 1
|
2013-02-14 03:48:56 +00:00
|
|
|
foreach_instance +A +B \
|
|
|
|
executeOk_servald config set interfaces.1.drop_unicasts 1
|
2013-01-29 00:57:13 +00:00
|
|
|
foreach_instance +A +B start_routing_instance
|
|
|
|
}
|
|
|
|
test_broadcast_only() {
|
|
|
|
foreach_instance +A +B \
|
|
|
|
wait_until has_seen_instances +A +B
|
|
|
|
set_instance +A
|
2013-04-26 07:23:04 +00:00
|
|
|
executeOk_servald mdp ping --timeout=3 $SIDB 1
|
2013-01-29 00:57:13 +00:00
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
executeOk_servald route print
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDB:BROADCAST :"
|
|
|
|
}
|
|
|
|
|
2013-02-14 05:32:09 +00:00
|
|
|
doc_prefer_unicast="Prefer unicast packets"
|
2013-01-29 00:57:13 +00:00
|
|
|
setup_prefer_unicast() {
|
|
|
|
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.prefer_unicast 1 \
|
|
|
|
set debug.overlayframes 1
|
|
|
|
foreach_instance +A +B start_routing_instance
|
|
|
|
}
|
|
|
|
test_prefer_unicast() {
|
|
|
|
foreach_instance +A +B \
|
|
|
|
wait_until has_seen_instances +A +B
|
|
|
|
set_instance +A
|
2013-04-26 07:23:04 +00:00
|
|
|
executeOk_servald mdp ping --timeout=3 $SIDB 1
|
2013-01-29 00:57:13 +00:00
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
executeOk_servald route print
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDB:BROADCAST UNICAST :"
|
|
|
|
assertGrep "$instance_servald_log" 'Choosing to send via unicast'
|
|
|
|
}
|
|
|
|
|
2013-02-14 05:32:09 +00:00
|
|
|
doc_multihop_linear="Start 4 instances in a linear arrangement"
|
2012-10-09 04:19:24 +00:00
|
|
|
setup_multihop_linear() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
foreach_instance +A +B +C +D create_single_identity
|
2012-12-08 04:39:41 +00:00
|
|
|
foreach_instance +A +B add_interface 1
|
|
|
|
foreach_instance +B +C add_interface 2
|
|
|
|
foreach_instance +C +D add_interface 3
|
2012-10-09 04:19:24 +00:00
|
|
|
foreach_instance +A +B +C +D start_routing_instance
|
|
|
|
}
|
|
|
|
test_multihop_linear() {
|
2012-12-10 23:26:21 +00:00
|
|
|
foreach_instance +A +B +C +D \
|
|
|
|
wait_until has_seen_instances +A +B +C +D
|
2012-10-09 04:19:24 +00:00
|
|
|
set_instance +A
|
2013-04-26 07:23:04 +00:00
|
|
|
executeOk_servald --stdout --stderr mdp ping --timeout=3 $SIDD 1
|
2012-10-09 05:39:33 +00:00
|
|
|
tfw_cat --stdout --stderr
|
2013-02-18 04:01:01 +00:00
|
|
|
executeOk_servald mdp trace $SIDD
|
|
|
|
tfw_cat --stdout --stderr
|
2012-12-10 23:26:21 +00:00
|
|
|
executeOk_servald route print
|
2013-01-29 00:57:13 +00:00
|
|
|
assertStdoutGrep --matches=1 "^$SIDB:BROADCAST UNICAST :"
|
2012-12-10 23:26:21 +00:00
|
|
|
assertStdoutGrep --matches=1 "^$SIDC:INDIRECT :"
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDD:INDIRECT :"
|
2012-10-09 04:19:24 +00:00
|
|
|
}
|
|
|
|
|
2012-10-10 05:52:31 +00:00
|
|
|
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 04:39:41 +00:00
|
|
|
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
|
2012-10-10 05:52:31 +00:00
|
|
|
foreach_instance +A +B +C +D +E +F +G +H start_routing_instance
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_crowded_mess="Multiple possible paths"
|
|
|
|
test_crowded_mess() {
|
2012-12-10 23:26:21 +00:00
|
|
|
foreach_instance +A +H \
|
|
|
|
wait_until has_seen_instances +A +H
|
2012-10-10 05:52:31 +00:00
|
|
|
set_instance +A
|
2013-04-26 07:23:04 +00:00
|
|
|
executeOk_servald mdp ping --timeout=3 $SIDH 1
|
2012-10-10 05:52:31 +00:00
|
|
|
tfw_cat --stdout --stderr
|
2012-12-10 23:26:21 +00:00
|
|
|
executeOk_servald route print
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDH:INDIRECT :"
|
2012-10-10 05:52:31 +00:00
|
|
|
}
|
|
|
|
|
2012-10-09 04:19:24 +00:00
|
|
|
runTests "$@"
|