From 9842e2235306f94fd2ef168f4ae9cfd768a0e4e8 Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Tue, 9 Oct 2012 14:49:24 +1030 Subject: [PATCH] Add multi-hop routing test --- testdefs.sh | 3 +- tests/dnaprotocol | 11 ------- tests/routing | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 13 deletions(-) create mode 100755 tests/routing diff --git a/testdefs.sh b/testdefs.sh index ade3ac28..487435b2 100644 --- a/testdefs.sh +++ b/testdefs.sh @@ -630,13 +630,12 @@ assert_peers_are_instances() { # selfannounce mechanism has_seen_instances() { local I N - local logvar=LOG$instance_name for I; do [ $I = $instance_arg ] && continue for ((N=1; 1; ++N)); do local sidvar=SID${I#+}$N [ -n "${!sidvar}" ] || break - if ! grep "ADD OVERLAY NODE sid=${!sidvar}" "${!logvar}"; then + if ! grep "ADD OVERLAY NODE sid=${!sidvar}" $instance_servald_log; then return 1 fi done diff --git a/tests/dnaprotocol b/tests/dnaprotocol index 50dc9cbd..84c02e71 100755 --- a/tests/dnaprotocol +++ b/tests/dnaprotocol @@ -67,17 +67,6 @@ set_server_vars() { executeOk_servald config set debug.keyring Yes } -doc_MultiServer="Start three servald servers with dummy interfaces" -setup_MultiServer() { - setup_servald - assert_no_servald_processes - foreach_instance +A +B +C create_single_identity - configure_servald_server() { set_server_vars; } -} -test_MultiServer() { - start_servald_instances +A +B +C -} - doc_LookupWildcard="Lookup by wildcard" test_LookupWildcard() { executeOk_servald dna lookup "*" diff --git a/tests/routing b/tests/routing new file mode 100755 index 00000000..f5fd20a6 --- /dev/null +++ b/tests/routing @@ -0,0 +1,82 @@ +#!/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 + executeOk_servald config set log.show_time on + executeOk_servald config set debug.mdprequests Yes +} + +add_interface() { + >$SERVALD_VAR/$1 + executeOk_servald config get interfaces + extract_stdout_keyvalue_optional EXISTING 'interfaces' '=' '.*' + executeOk_servald config set interfaces "+>$1,$EXISTING" +} + +start_routing_instance() { + executeOk_servald config set interface.folder "$SERVALD_VAR" + executeOk_servald config set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" + executeOk_servald config set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" + executeOk_servald config set log.show_pid on + executeOk_servald config set log.show_time on + executeOk_servald config set debug.mdprequests Yes + start_servald_server +} + +teardown() { + stop_all_servald_servers + kill_all_servald_processes + assert_no_servald_processes +} + +setup_single_link() { + setup_servald + assert_no_servald_processes + foreach_instance +A +B create_single_identity + start_servald_instances +A +B +} + +doc_single_link="Start 2 instances on one link" +test_single_link() { + set_instance +A + executeOk_servald mdp ping $SIDB 3 +} + +setup_multihop_linear() { + setup_servald + assert_no_servald_processes + foreach_instance +A +B +C +D create_single_identity + foreach_instance +A +B add_interface dummy1 + foreach_instance +B +C add_interface dummy2 + foreach_instance +C +D add_interface dummy3 + foreach_instance +A +B +C +D start_routing_instance +} + +doc_multihop_linear="Start 4 instances in a linear arrangement" +test_multihop_linear() { + wait_until --sleep=0.25 instances_see_each_other +A +B +C +D + set_instance +A + executeOk_servald mdp ping $SIDD 3 +} + +runTests "$@"