From ec493a5e8ba4aa2ab44a99f859cdcb4a58138631 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 25 Jun 2010 20:16:55 +0000 Subject: [PATCH] added test for extaddr finder git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3209 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/tests/pqi/Makefile | 5 ++- .../src/tests/pqi/extaddrfinder_test.cc | 37 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 libretroshare/src/tests/pqi/extaddrfinder_test.cc diff --git a/libretroshare/src/tests/pqi/Makefile b/libretroshare/src/tests/pqi/Makefile index f8e52eccb..4478d1769 100644 --- a/libretroshare/src/tests/pqi/Makefile +++ b/libretroshare/src/tests/pqi/Makefile @@ -9,9 +9,10 @@ include $(RS_TOP_DIR)/tests/scripts/config.mk TESTOBJ = net_test.o dht_test.o net_test1.o netiface_test.o dht_test.o TESTOBJ += pkt_test.o testconnect.o pqiarchive_test.o pqiperson_test.o +TESTOBJ += extaddrfinder_test.o #conn_test.o -TESTS = net_test net_test1 netiface_test pqiarchive_test pqiperson_test +TESTS = net_test net_test1 netiface_test pqiarchive_test pqiperson_test extaddrfinder_test MANUAL_TESTS = dht_test #conn_test @@ -45,6 +46,8 @@ pqiarchive_test: pqiarchive_test.o pkt_test.o pqiperson_test: pqiperson_test.o testconnect.o $(CC) $(CFLAGS) -o pqiperson_test pqiperson_test.o testconnect.o $(LIBS) +extaddrfinder_test: extaddrfinder_test.o + $(CC) $(CFLAGS) -o extaddrfinder_test extaddrfinder_test.o $(LIBS) clobber: remove_extra_files diff --git a/libretroshare/src/tests/pqi/extaddrfinder_test.cc b/libretroshare/src/tests/pqi/extaddrfinder_test.cc new file mode 100644 index 000000000..1ae234be0 --- /dev/null +++ b/libretroshare/src/tests/pqi/extaddrfinder_test.cc @@ -0,0 +1,37 @@ +#include "util/utest.h" + +#include +#include "pqi/pqinetwork.h" + +#include +#include + +INITTEST(); + +int main() +{ + std::cerr << "Testing the ext address finder service. This might take up to 10 secs..." << std::endl ; + + ExtAddrFinder fnd ; + in_addr addr ; + uint32_t tries = 0 ; + + while(! fnd.hasValidIP( &addr )) + { + sleep(1) ; + + if(++tries > 20) + { + std::cerr << "Failed !" << std::endl ; + CHECK(false) ; + } + } + + std::cerr << "Found the following IP: " << inet_ntoa(addr) << std::endl ; + + FINALREPORT("extaddrfinder_test"); + + return TESTRESULT() ; +} + +