XPath tests
authorAdam Dickmeiss <adam@indexdata.dk>
Sat, 9 Nov 2002 22:26:19 +0000 (22:26 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Sat, 9 Nov 2002 22:26:19 +0000 (22:26 +0000)
configure.in
test/Makefile.am
test/testclient.c
test/xpath/.cvsignore [new file with mode: 0644]
test/xpath/Makefile.am [new file with mode: 0644]
test/xpath/Zthes.abs [new file with mode: 0644]
test/xpath/rec [new file with mode: 0644]
test/xpath/test1.sh [new file with mode: 0755]
test/xpath/test2.sh [new file with mode: 0755]
test/xpath/test3.sh [new file with mode: 0755]
test/xpath/zebra.cfg [new file with mode: 0644]

index b162748..58cd24b 100644 (file)
@@ -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
 ])
index a4c24e8..8ef10be 100644 (file)
@@ -1,5 +1,5 @@
 
-SUBDIRS=gils usmarc api dmoz
+SUBDIRS=gils usmarc api dmoz xpath
 
 testclient_SOURCES = testclient.c
 
index ee9363b..24509f4 100644 (file)
@@ -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 (file)
index 0000000..3689ad6
--- /dev/null
@@ -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 (file)
index 0000000..8180e73
--- /dev/null
@@ -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 (file)
index 0000000..3155f40
--- /dev/null
@@ -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 (file)
index 0000000..16afce8
--- /dev/null
@@ -0,0 +1,40 @@
+<Zthes>
+ <termId>10</termId>
+ <termName>Sauropoda</termName>
+ <termType>PT</termType>
+ <relation>
+  <relationType>BT</relationType>
+  <termId>5</termId>
+  <termName>Brontosauria</termName>
+  <termType>PT</termType>
+ </relation>
+ <relation>
+  <relationType>NT</relationType>
+  <termId>11</termId>
+  <termName>Eusauropoda</termName>
+  <termType>PT</termType>
+ </relation>
+</Zthes>
+<Zthes>
+ <termId>5</termId>
+ <termName>Brontosauria</termName>
+ <termType>PT</termType>
+ <relation>
+  <relationType>BT</relationType>
+  <termId>4</termId>
+  <termName>Sauropodomorpha</termName>
+  <termType>PT</termType>
+ </relation>
+ <relation>
+  <relationType>NT</relationType>
+  <termId>6</termId>
+  <termName>Plateosauria</termName>
+  <termType>PT</termType>
+ </relation>
+ <relation>
+  <relationType>NT</relationType>
+  <termId>10</termId>
+  <termName>Sauropoda</termName>
+  <termType>PT</termType>
+ </relation>
+</Zthes>
diff --git a/test/xpath/test1.sh b/test/xpath/test1.sh
new file mode 100755 (executable)
index 0000000..5806a0a
--- /dev/null
@@ -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 (executable)
index 0000000..d6df208
--- /dev/null
@@ -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 (executable)
index 0000000..3b0145d
--- /dev/null
@@ -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 (file)
index 0000000..3a39218
--- /dev/null
@@ -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