mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-19 03:06:28 +00:00
101 lines
2.9 KiB
Bash
Executable File
101 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Tests for Serval DNA server operations.
|
|
#
|
|
# Copyright 2012 Paul Gardner-Stephen
|
|
#
|
|
# 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"
|
|
|
|
setup() {
|
|
setup_servald
|
|
assert_no_servald_processes
|
|
set_instance
|
|
}
|
|
|
|
teardown() {
|
|
# TODO Disabled until stopping multiple-instances are supported
|
|
# TODO stop_all_servald_servers
|
|
kill_all_servald_processes
|
|
assert_no_servald_processes
|
|
}
|
|
|
|
setup_servald_instance() {
|
|
set_instance $1
|
|
touch "$SERVALINSTANCE_PATH/dummynet"
|
|
executeOk_servald config set interfaces "+>$2"
|
|
executeOk_servald config set monitor.socket "org.servalproject.servald.monitor.socket.$1"
|
|
executeOk_servald config set mdp.socket "org.servalproject.servald.mdp.socket.$1"
|
|
executeOk_servald keyring add
|
|
assert [ -e "$SERVALINSTANCE_PATH/serval.keyring" ]
|
|
executeOk_servald keyring list
|
|
tfw_cat --stdout
|
|
sid=$(replayStdout | sed -ne "1s/^\($rexp_sid\):.*\$/\1/p")
|
|
assert --message='main identity known' [ -n "$sid" ]
|
|
executeOk_servald set did $sid 5550001 "Agent Smith"
|
|
start_servald_server $1
|
|
executeOk_servald status
|
|
tfw_cat --stdout
|
|
}
|
|
|
|
setup_servald_instances() {
|
|
setup_servald
|
|
setup_servald_instance A dummynet
|
|
DUMMYNET=$SERVALINSTANCE_PATH/dummynet
|
|
setup_servald_instance B $DUMMYNET
|
|
|
|
# Now make sure that they can see each other
|
|
sleep 2.5 # Should be plenty of time
|
|
set_instance A
|
|
echo "Dummynet file $DUMMYNET after 5 seconds: "`ls -l $DUMMYNET`
|
|
executeOk_servald id peers
|
|
assertStdoutLineCount '==' 1
|
|
}
|
|
|
|
doc_MultipleServalDTest="Can start multiple servald instances communicating via a dummy interface"
|
|
|
|
setup_MultipleServalDTest() {
|
|
setup
|
|
}
|
|
|
|
test_MultipleServalDTest() {
|
|
setup_servald_instances
|
|
}
|
|
|
|
doc_DNAWildcardSearchFindsSelf="DNA lookup of wildcard finds self (star method)"
|
|
setup_DNAWildcardSearchFindsSelf() {
|
|
setup
|
|
}
|
|
test_DNAWildcardSearchFindsSelf() {
|
|
setup_servald_instances
|
|
executeOk_servald dna lookup "*"
|
|
assertStdoutLineCount '==' 1
|
|
}
|
|
|
|
doc_DNAWildcardSearchFindsSelfEmpty="DNA lookup of wildcard finds self (empty query method)"
|
|
setup_DNAWildcardSearchFindsSelfEmpty() {
|
|
setup
|
|
}
|
|
test_DNAWildcardSearchFindsSelfEmpty() {
|
|
setup_servald_instances
|
|
executeOk_servald dna lookup ""
|
|
assertStdoutLineCount '==' 1
|
|
}
|
|
|
|
|
|
runTests "$@"
|