From: Adam Dickmeiss Date: Wed, 23 Oct 2002 13:41:15 +0000 (+0000) Subject: Option -d for testclient. Typos. X-Git-Tag: ZEBRA.1.3.3.DEBIAN.5~5 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=45b4e214a010658e34d12b750fbe5ce46e6b7919 Option -d for testclient. Typos. --- diff --git a/test/gils/test01.sh b/test/gils/test01.sh index 5c9ae67..4c70b97 100755 --- a/test/gils/test01.sh +++ b/test/gils/test01.sh @@ -18,7 +18,7 @@ echo "Starting server with -1 (one shot)..." ../../index/zebrasrv -1 -c zebra1.cfg -l srv.log tcp:@:9901 & sleep 1 -echo " cheking that it runs... " +echo " checking that it runs... " test -f zebrasrv.pid || exit 1 PID=`cat zebrasrv.pid` ps -p $PID >/dev/null || exit 1 diff --git a/test/gils/test02.sh b/test/gils/test02.sh index 485cd53..996feeb 100755 --- a/test/gils/test02.sh +++ b/test/gils/test02.sh @@ -20,7 +20,7 @@ echo "Starting server with -S (static)..." ../../index/zebrasrv -S -c zebra1.cfg -l srv.log tcp:@:9901 & sleep 1 -echo " cheking that it runs... " +echo " checking that it runs... " test -f zebrasrv.pid || exit 1 PID=`cat zebrasrv.pid` ps -p $PID >/dev/null || exit 1 @@ -33,7 +33,7 @@ echo " checking that it still runs..." ps -p $PID >/dev/null || exit 1 echo " connecting again, with a delay..." -../testclient localhost:9901 utah 5 > log & +../testclient -d 5 localhost:9901 utah > log & sleep 1 # let the client connect echo " killing it..." diff --git a/test/gils/test03.sh b/test/gils/test03.sh index 03e5fa4..7668276 100755 --- a/test/gils/test03.sh +++ b/test/gils/test03.sh @@ -23,7 +23,7 @@ echo "Starting server with -T (threaded)..." )& sleep 1 -echo " cheking that it runs... " +echo " checking that it runs... " test -f zebrasrv.pid || exit 1 PID=`cat zebrasrv.pid` ps -p $PID >/dev/null || exit 1 diff --git a/test/gils/test04.sh b/test/gils/test04.sh index 30aceb4..e66991c 100755 --- a/test/gils/test04.sh +++ b/test/gils/test04.sh @@ -18,7 +18,7 @@ echo "Starting server with (forked)..." ../../index/zebrasrv -c zebra1.cfg -l srv.log tcp:@:9901 & sleep 1 -echo " cheking that it runs... " +echo " checking that it runs... " test -f zebrasrv.pid || exit 1 PID=`cat zebrasrv.pid` ps -p $PID >/dev/null || exit 1 diff --git a/test/gils/test1.sh b/test/gils/test1.sh index 95e2aee..a5230b3 100755 --- a/test/gils/test1.sh +++ b/test/gils/test1.sh @@ -18,7 +18,7 @@ echo "starting server..." ../../index/zebrasrv -S -c zebra1.cfg -l srv.log tcp:@:9901 & sleep 1 -echo "cheking it runs..." +echo "checking it runs..." test -f zebrasrv.pid || exit 1 echo "search 1..." diff --git a/test/testclient.c b/test/testclient.c index 0e7fccf..614b682 100644 --- a/test/testclient.c +++ b/test/testclient.c @@ -1,5 +1,5 @@ /* - * $Id: testclient.c,v 1.2 2002-10-23 13:25:00 heikki Exp $ + * $Id: testclient.c,v 1.3 2002-10-23 13:41:15 adam Exp $ * * Synchronous single-target client doing search (but no yet retrieval) */ @@ -7,42 +7,67 @@ #include #include #include +#include #include +char *prog = "testclient"; + int main(int argc, char **argv) { ZOOM_connection z; ZOOM_resultset r; int error; const char *errmsg, *addinfo; - int sec; + char *query = 0; + char *target = 0; + char *arg; + int delay_sec = 0; + int ret; + + while ((ret = options("d:", argv, argc, &arg)) != -2) + { + switch (ret) + { + case 0: + if (!target) + target = xstrdup(arg); + else if (!query) + query = xstrdup(arg); + break; + case 'd': + delay_sec = atoi(arg); + break; + default: + printf ("%s: unknown option %s\n", prog, arg); + printf ("usage:\n%s [options] target query \n", prog); + printf (" eg. bagel.indexdata.dk/gils computer\n"); + exit (1); + } + } - if ( (argc != 3) && (argc !=4) ) + if (!target || !target) { - fprintf (stderr, "usage:\n%s target query [delay]\n", *argv); - fprintf (stderr, " eg. bagel.indexdata.dk/gils computer\n"); - exit (1); + printf ("%s: missing target/query\n", prog); + printf ("usage:\n%s [options] target query \n", prog); + printf (" eg. bagel.indexdata.dk/gils computer\n"); + exit (3); } - z = ZOOM_connection_new (argv[1], 0); + z = ZOOM_connection_new (target, 0); if ((error = ZOOM_connection_error(z, &errmsg, &addinfo))) { - fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo); + printf ("Error: %s (%d) %s\n", errmsg, error, addinfo); exit (2); } - r = ZOOM_connection_search_pqf (z, argv[2]); + r = ZOOM_connection_search_pqf (z, query); if ((error = ZOOM_connection_error(z, &errmsg, &addinfo))) fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo); else printf ("Result count: %d\n", ZOOM_resultset_size(r)); - if (argc==4) - { - sec=atoi(argv[3]); - if (sec <= 0) - sec=3; - sleep(sec); - } + + if (delay_sec > 0) + sleep(delay_sec); ZOOM_resultset_destroy (r); ZOOM_connection_destroy (z); exit (0);