#!/bin/bash # Tests for Serval DNA Route Java API # # Copyright 2018 Flinders Univerity # # 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" source "${0%/*}/../testdefs_routing.sh" source "${0%/*}/../testdefs_rest.sh" source "${0%/*}/../testdefs_java.sh" setup() { setup_servald setup_servald_so assert_java_classes_exist assert_no_servald_processes } teardown() { stop_all_servald_servers kill_all_servald_processes assert_no_servald_processes report_all_servald_servers } configure_servald_server() { setup_route_config } doc_RouteListAll="Java API list entire routing table" setup_RouteListAll() { setup DIDA1=565656 NAMEA1="Neddy Seagoon" DIDA2=3020304 NAMEA2="Spike Milligan" foreach_instance +A +B create_identities 2 foreach_instance +A +B add_servald_interface 1 foreach_instance +A +B start_servald_server wait_until_rest_server_ready +A get_servald_primary_sid +B PRIMARY_SIDB wait_until --timeout=20 path_exists +A +B wait_until --timeout=10 path_exists +B +A set_instance +A } test_RouteListAll() { executeJavaOk org.servalproject.test.Route list-all tfw_cat --stdout --stderr assertStdoutLineCount == 4 assertStdoutGrep --matches=1 "sid=$SIDA1, did=$DIDA1, name=$NAMEA1, isSelf=true, hopCount=0" assertStdoutGrep --matches=1 "sid=$SIDA2, did=$DIDA2, name=$NAMEA2, isSelf=true, hopCount=0" assertStdoutGrep --matches=1 "sid=$PRIMARY_SIDB,.*isSelf=false, hopCount=1,.*reachableUnicast=true,.*reachableIndirect=false" for SID in "${SIDB[@]}"; do if [ "$SID" != "$PRIMARY_SIDB" ]; then assertStdoutGrep --matches=1 "sid=$SID,.*isSelf=false, hopCount=2,.*reachableUnicast=false,.*reachableIndirect=true" fi done } runTests "$@"