From b389354c86c0562b58c638dcfe59834791c4db50 Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Mon, 11 Nov 2002 15:19:25 +0000 Subject: [PATCH] Added -e command line option to expect a given number of hits, and return with exit(3) if getting anything else. Makes test scripts nicer to write --- test/testclient.c | 14 ++++++++++++-- test/xpath/zebra.cfg | 6 +++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/test/testclient.c b/test/testclient.c index 24509f4..a074c8c 100644 --- a/test/testclient.c +++ b/test/testclient.c @@ -1,5 +1,5 @@ /* - * $Id: testclient.c,v 1.5 2002-11-09 22:26:19 adam Exp $ + * $Id: testclient.c,v 1.6 2002-11-11 15:19:25 heikki Exp $ * * Z39.50 client specifically for Zebra testing. */ @@ -22,6 +22,7 @@ int main(int argc, char **argv) char *target = 0; char *arg; int delay_sec = 0; + int expected_hits=-1; int ret; int retrieve_number = 0; int retrieve_offset = 0; @@ -30,7 +31,7 @@ int main(int argc, char **argv) int check_count = -1; int exit_code = 0; - while ((ret = options("d:n:o:f:c:", argv, argc, &arg)) != -2) + while ((ret = options("d:n:o:f:c:e:", argv, argc, &arg)) != -2) { switch (ret) { @@ -55,6 +56,9 @@ int main(int argc, char **argv) case 'c': check_count = atoi(arg); break; + case 'e': + expected_hits = atoi(arg); + break; default: printf ("%s: unknown option %s\n", prog, arg); printf ("usage:\n%s [options] target query \n", prog); @@ -96,6 +100,12 @@ int main(int argc, char **argv) printf ("Result count: %d\n", ZOOM_resultset_size(r)); if (check_count != -1 && check_count != ZOOM_resultset_size(r)) exit_code = 10; + if ((expected_hits!=-1) && (ZOOM_resultset_size(r) != expected_hits)) + { + printf("Wrong number of hits, expected %d, got %d\n", + expected_hits, ZOOM_resultset_size(r) ); + exit(3); + } } if (format) ZOOM_resultset_option_set(r, "preferredRecordSyntax", format); diff --git a/test/xpath/zebra.cfg b/test/xpath/zebra.cfg index 3a39218..9f69b93 100644 --- a/test/xpath/zebra.cfg +++ b/test/xpath/zebra.cfg @@ -1,4 +1,8 @@ -# $Id: zebra.cfg,v 1.1 2002-11-09 22:26:19 adam Exp $ +# $Id: zebra.cfg,v 1.2 2002-11-11 15:19:25 heikki Exp $ profilePath: .:../../tab recordType: grs.sgml attset: bib1.att + + + + -- 1.7.10.4