From 4e68a651c499e3acc77fbf2dbedd294855206f00 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sat, 9 Nov 2002 22:26:19 +0000 Subject: [PATCH] XPath tests --- configure.in | 4 ++-- test/Makefile.am | 2 +- test/testclient.c | 20 ++++++++++++++++---- test/xpath/.cvsignore | 6 ++++++ test/xpath/Makefile.am | 4 ++++ test/xpath/Zthes.abs | 5 +++++ test/xpath/rec | 40 ++++++++++++++++++++++++++++++++++++++++ test/xpath/test1.sh | 4 ++++ test/xpath/test2.sh | 16 ++++++++++++++++ test/xpath/test3.sh | 16 ++++++++++++++++ test/xpath/zebra.cfg | 4 ++++ 11 files changed, 114 insertions(+), 7 deletions(-) create mode 100644 test/xpath/.cvsignore create mode 100644 test/xpath/Makefile.am create mode 100644 test/xpath/Zthes.abs create mode 100644 test/xpath/rec create mode 100755 test/xpath/test1.sh create mode 100755 test/xpath/test2.sh create mode 100755 test/xpath/test3.sh create mode 100644 test/xpath/zebra.cfg diff --git a/configure.in b/configure.in index b162748..58cd24b 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Zebra, Index Data Aps, 1995-2002 -dnl $Id: configure.in,v 1.54 2002-11-08 19:59:52 adam Exp $ +dnl $Id: configure.in,v 1.55 2002-11-09 22:26:19 adam Exp $ dnl AC_INIT(include/zebraver.h) AM_INIT_AUTOMAKE(idzebra,1.3.3) @@ -256,6 +256,6 @@ AC_OUTPUT([ doc/zebraphp.dsl doc/tkl.xsl test/Makefile test/gils/Makefile test/usmarc/Makefile test/api/Makefile - test/dmoz/Makefile + test/dmoz/Makefile test/xpath/Makefile examples/Makefile examples/gils/Makefile ]) diff --git a/test/Makefile.am b/test/Makefile.am index a4c24e8..8ef10be 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,5 +1,5 @@ -SUBDIRS=gils usmarc api dmoz +SUBDIRS=gils usmarc api dmoz xpath testclient_SOURCES = testclient.c diff --git a/test/testclient.c b/test/testclient.c index ee9363b..24509f4 100644 --- a/test/testclient.c +++ b/test/testclient.c @@ -1,5 +1,5 @@ /* - * $Id: testclient.c,v 1.4 2002-10-23 13:55:37 adam Exp $ + * $Id: testclient.c,v 1.5 2002-11-09 22:26:19 adam Exp $ * * Z39.50 client specifically for Zebra testing. */ @@ -27,8 +27,10 @@ int main(int argc, char **argv) int retrieve_offset = 0; char *format = 0; int pos; + int check_count = -1; + int exit_code = 0; - while ((ret = options("d:n:o:f:", argv, argc, &arg)) != -2) + while ((ret = options("d:n:o:f:c:", argv, argc, &arg)) != -2) { switch (ret) { @@ -50,6 +52,9 @@ int main(int argc, char **argv) case 'f': format = xstrdup(arg); break; + case 'c': + check_count = atoi(arg); + break; default: printf ("%s: unknown option %s\n", prog, arg); printf ("usage:\n%s [options] target query \n", prog); @@ -81,10 +86,17 @@ int main(int argc, char **argv) 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); + { + printf ("Error: %s (%d) %s\n", errmsg, error, addinfo); + if (check_count != -1) + exit_code = 10; + } else + { printf ("Result count: %d\n", ZOOM_resultset_size(r)); - + if (check_count != -1 && check_count != ZOOM_resultset_size(r)) + exit_code = 10; + } if (format) ZOOM_resultset_option_set(r, "preferredRecordSyntax", format); for (pos = 0; pos < retrieve_number; pos++) diff --git a/test/xpath/.cvsignore b/test/xpath/.cvsignore new file mode 100644 index 0000000..3689ad6 --- /dev/null +++ b/test/xpath/.cvsignore @@ -0,0 +1,6 @@ +Makefile +Makefile.in +*.mf +*.log +*.tmp +*.LCK diff --git a/test/xpath/Makefile.am b/test/xpath/Makefile.am new file mode 100644 index 0000000..8180e73 --- /dev/null +++ b/test/xpath/Makefile.am @@ -0,0 +1,4 @@ +TESTS = test1.sh test2.sh test3.sh + +EXTRA_DIST = $(TESTS) zebra.cfg rec + diff --git a/test/xpath/Zthes.abs b/test/xpath/Zthes.abs new file mode 100644 index 0000000..3155f40 --- /dev/null +++ b/test/xpath/Zthes.abs @@ -0,0 +1,5 @@ +attset bib1.att +tagset tagsetg.tag +xpath enable + +# elm (2,1) title ! diff --git a/test/xpath/rec b/test/xpath/rec new file mode 100644 index 0000000..16afce8 --- /dev/null +++ b/test/xpath/rec @@ -0,0 +1,40 @@ + + 10 + Sauropoda + PT + + BT + 5 + Brontosauria + PT + + + NT + 11 + Eusauropoda + PT + + + + 5 + Brontosauria + PT + + BT + 4 + Sauropodomorpha + PT + + + NT + 6 + Plateosauria + PT + + + NT + 10 + Sauropoda + PT + + diff --git a/test/xpath/test1.sh b/test/xpath/test1.sh new file mode 100755 index 0000000..5806a0a --- /dev/null +++ b/test/xpath/test1.sh @@ -0,0 +1,4 @@ +#!/bin/sh +rm -f test1.log +../../index/zebraidx -l test1.log init || exit 1 +../../index/zebraidx -l test1.log -t grs.sgml update rec || exit 2 diff --git a/test/xpath/test2.sh b/test/xpath/test2.sh new file mode 100755 index 0000000..d6df208 --- /dev/null +++ b/test/xpath/test2.sh @@ -0,0 +1,16 @@ +#!/bin/sh +LOG=test2.log +TMP=test2.tmp +rm -f $LOG +test -f dict*.mf || exit 1 +../../index/zebrasrv -l $LOG -S unix:socket & +sleep 1 +test -f zebrasrv.pid || exit 2 +../testclient unix:socket '@attr 1=/Zthes/termName Sauropoda' >$TMP +echo 'Killing server' >>$LOG +kill `cat zebrasrv.pid` || exit 3 +cat $TMP >>$LOG +echo 'Checking that result count is 1' >>$LOG +grep "^Result count: 1$" $TMP || exit 4 +echo 'Test OK' >>$LOG + diff --git a/test/xpath/test3.sh b/test/xpath/test3.sh new file mode 100755 index 0000000..3b0145d --- /dev/null +++ b/test/xpath/test3.sh @@ -0,0 +1,16 @@ +#!/bin/sh +LOG=test3.log +TMP=test3.tmp +rm -f $LOG +test -f dict*.mf || exit 1 +../../index/zebrasrv -l $LOG -S unix:socket & +sleep 1 +test -f zebrasrv.pid || exit 2 +../testclient unix:socket '@attr 1=/Zthes/relation/termName Sauropoda' >$TMP +echo 'Killing server' >>$LOG +kill `cat zebrasrv.pid` || exit 3 +cat $TMP >>$LOG +echo 'Checking that result count is 1' >>$LOG +grep "^Result count: 1$" $TMP >/dev/null || exit 4 +echo 'Test OK' >>$LOG + diff --git a/test/xpath/zebra.cfg b/test/xpath/zebra.cfg new file mode 100644 index 0000000..3a39218 --- /dev/null +++ b/test/xpath/zebra.cfg @@ -0,0 +1,4 @@ +# $Id: zebra.cfg,v 1.1 2002-11-09 22:26:19 adam Exp $ +profilePath: .:../../tab +recordType: grs.sgml +attset: bib1.att -- 1.7.10.4