From 4a8f82f621e908fb50bc9966c2478e6645709bf3 Mon Sep 17 00:00:00 2001 From: Stephane Bortzmeyer Date: Tue, 20 Jul 2004 14:19:49 +0000 Subject: [PATCH] Test framework for plugins --- SRC/Makefile.am | 2 +- SRC/PLUGINS | 5 ++++- SRC/plugins/whois/test.sh | 6 ++++++ SRC/test-echoping-plugins | 20 ++++++++++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100755 SRC/plugins/whois/test.sh create mode 100644 SRC/test-echoping-plugins diff --git a/SRC/Makefile.am b/SRC/Makefile.am index 17d0124..20292ee 100644 --- a/SRC/Makefile.am +++ b/SRC/Makefile.am @@ -11,7 +11,7 @@ DOCS=DETAILS PLUGINS SUBDIRS=plugins TESTS=test-echoping-local test-echoping-remote -MORE_TESTS=test-echoping-proxy test-echoping-icp test-echoping-crypto test-echoping-tos test-echoping-ipv6 test-echoping-idn +MORE_TESTS=test-echoping-proxy test-echoping-icp test-echoping-crypto test-echoping-tos test-echoping-ipv6 test-echoping-idn test-echoping-plugins test: check tests: check diff --git a/SRC/PLUGINS b/SRC/PLUGINS index 3fef949..2b8e8d1 100644 --- a/SRC/PLUGINS +++ b/SRC/PLUGINS @@ -36,7 +36,7 @@ void start_raw () int execute () Connects and do whatever the protocol requires. It is called once per iteration. It returns >=0 if it succeeds, -1 if it failed - temporarily (so echoping will continue its loop) and -2 if it failes + temporarily (so echoping will continue its loop) and -2 if it failed permanently (so echoping will stop the iteration). void terminate () @@ -53,4 +53,7 @@ simplest which still does something useful. The documentation of the plugin should be in a manual page named echoping_PLUGINNAME. See the above plugins for examples. +You can write a shell script named test.sh in the plugin directory to +test the plugin. test-echoping-plugins will execute it. + $Id$ diff --git a/SRC/plugins/whois/test.sh b/SRC/plugins/whois/test.sh new file mode 100755 index 0000000..4a7ec5a --- /dev/null +++ b/SRC/plugins/whois/test.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +# $Id$ + +../../echoping -m whois -v whois.nic.fr --dump echoping.fr # Does not exist +../../echoping -m whois -v whois.nic.fr --dump nic.fr # Exists \ No newline at end of file diff --git a/SRC/test-echoping-plugins b/SRC/test-echoping-plugins new file mode 100644 index 0000000..e2f5fa1 --- /dev/null +++ b/SRC/test-echoping-plugins @@ -0,0 +1,20 @@ +#!/bin/sh + +# $Id$ + +echo "" +echo "Since this tests tries remote servers, a failure is not always " +echo " echoping's fault: it may be a network problem." +echo "" + +for plugin in `ls plugins`; do + if [ -d plugins/$plugin ]; then + cd plugins/$plugin + if [ -x test.sh ]; then + echo "Testing $plugin..." + sh ./test.sh + echo "" + fi + cd ../.. + fi +done