Added new test/filter directory with filter tests.
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 14 Jun 2005 20:03:01 +0000 (20:03 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 14 Jun 2005 20:03:01 +0000 (20:03 +0000)
configure.in
test/Makefile.am
test/filters/.cvsignore [new file with mode: 0644]
test/filters/Makefile.am [new file with mode: 0644]
test/filters/grs.marc.c [new file with mode: 0644]
test/filters/grs.xml.c [new file with mode: 0644]
test/filters/record.mrc [new file with mode: 0644]
test/filters/record.xml [new file with mode: 0644]
test/filters/text.c [new file with mode: 0644]
test/filters/zebra.cfg [new file with mode: 0644]

index 2536c3a..9927342 100644 (file)
@@ -1,5 +1,5 @@
 dnl Zebra, Index Data ApS, 1995-2005
-dnl $Id: configure.in,v 1.125 2005-06-13 10:29:20 adam Exp $
+dnl $Id: configure.in,v 1.126 2005-06-14 20:03:01 adam Exp $
 dnl
 AC_INIT(include/idzebra/version.h)
 AM_INIT_AUTOMAKE(idzebra,1.4.0)
@@ -15,7 +15,7 @@ AM_DISABLE_SHARED
 AM_PROG_LIBTOOL
 dnl
 dnl ------ headers
-AC_CHECK_HEADERS(sys/times.h unistd.h)
+AC_CHECK_HEADERS(sys/times.h sys/time.h unistd.h)
 dnl ------ crypt
 AC_CHECK_LIB(crypt, crypt)
 if test "$ac_cv_lib_crypt_crypt" = "yes"; then
@@ -348,6 +348,7 @@ AC_OUTPUT([
   test/dmoz/Makefile test/sort/Makefile test/zsh/Makefile
   test/marcxml/Makefile test/charmap/Makefile test/codec/Makefile
   test/espec/Makefile
+  test/filters/Makefile
   examples/Makefile examples/gils/Makefile examples/zthes/Makefile
   examples/marc21/Makefile
   idzebra.spec
index 49d3e4a..8a04c7a 100644 (file)
@@ -1,4 +1,4 @@
 
-SUBDIRS=codec api xslt xpath gils malxml config usmarc dmoz sort \
+SUBDIRS=codec api filters xslt xpath gils malxml config usmarc dmoz sort \
  sort2 xelm cddb rusmarc zsh marcxml charmap mbox espec
 
diff --git a/test/filters/.cvsignore b/test/filters/.cvsignore
new file mode 100644 (file)
index 0000000..4896344
--- /dev/null
@@ -0,0 +1,15 @@
+Makefile
+Makefile.in
+*.mf
+*.log
+log
+*.LCK
+shadow
+reg
+socket
+zebrasrv.pid
+.libs
+.deps
+grs.marc
+grs.xml
+text
diff --git a/test/filters/Makefile.am b/test/filters/Makefile.am
new file mode 100644 (file)
index 0000000..c312fcb
--- /dev/null
@@ -0,0 +1,30 @@
+# $Id: Makefile.am,v 1.1 2005-06-14 20:03:02 adam Exp $
+
+check_PROGRAMS = text grs.xml grs.marc
+
+TESTS = $(check_PROGRAMS)
+
+EXTRA_DIST = zebra.cfg record.xml record.mrc
+
+text_SOURCES = text.c
+grs_xml_SOURCES = grs.xml.c
+grs_marc_SOURCES = grs.marc.c
+
+AM_CPPFLAGS = -I$(top_srcdir)/include $(YAZINC)
+
+zebralibs = \
+ ../../index/libidzebra-api.la \
+ ../../rset/libidzebra-rset.la \
+ ../../recctrl/libidzebra-recctrl.la \
+ ../../dict/libidzebra-dict.la  \
+ ../../isams/libidzebra-isams.la \
+ ../../isamc/libidzebra-isamc.la \
+ ../../isamb/libidzebra-isamb.la \
+ ../../data1/libidzebra-data1.la \
+ ../../bfile/libidzebra-bfile.la \
+ ../../dfa/libidzebra-dfa.la \
+ ../../util/libidzebra-util.la
+
+LDADD = ../api/libtestlib.a $(zebralibs) $(YAZLALIB)
+
+
diff --git a/test/filters/grs.marc.c b/test/filters/grs.marc.c
new file mode 100644 (file)
index 0000000..16707af
--- /dev/null
@@ -0,0 +1,50 @@
+/* $Id: grs.marc.c,v 1.1 2005-06-14 20:03:02 adam Exp $
+   Copyright (C) 1995-2005
+   Index Data ApS
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Zebra; see the file LICENSE.zebra.  If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+*/
+
+#include "../api/testlib.h"
+
+int main(int argc, char **argv)
+{
+    ZebraService zs = start_up(0, argc, argv);
+    ZebraHandle  zh = zebra_open(zs);
+    char path[256];
+
+    check_filter(zs, "grs.marc");
+
+    zebra_select_database(zh, "Default");
+
+    zebra_set_resource(zh, "recordType", "grs.marc.usmarc");
+
+    zebra_init(zh);
+
+    zebra_begin_trans(zh, 1);
+    sprintf(path, "%.200s/record.mrc", get_srcdir());
+    zebra_repository_update(zh, path);
+    zebra_end_trans(zh);
+    zebra_commit(zh);
+
+    do_query(__LINE__, zh, "computer", 1);
+
+    do_query(__LINE__, zh, "computee", 0);
+
+    return close_down(zh, zs, 0);
+}
diff --git a/test/filters/grs.xml.c b/test/filters/grs.xml.c
new file mode 100644 (file)
index 0000000..add4249
--- /dev/null
@@ -0,0 +1,50 @@
+/* $Id: grs.xml.c,v 1.1 2005-06-14 20:03:02 adam Exp $
+   Copyright (C) 1995-2005
+   Index Data ApS
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Zebra; see the file LICENSE.zebra.  If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+*/
+
+#include "../api/testlib.h"
+
+int main(int argc, char **argv)
+{
+    ZebraService zs = start_up(0, argc, argv);
+    ZebraHandle  zh = zebra_open(zs);
+    char path[256];
+
+    check_filter(zs, "grs.xml");
+
+    zebra_select_database(zh, "Default");
+
+    zebra_set_resource(zh, "recordType", "grs.xml");
+
+    zebra_init(zh);
+
+    zebra_begin_trans(zh, 1);
+    sprintf(path, "%.200s/record.xml", get_srcdir());
+    zebra_repository_update(zh, path);
+    zebra_end_trans(zh);
+    zebra_commit(zh);
+
+    do_query(__LINE__, zh, "@attr 1=/ text", 1);
+
+    do_query(__LINE__, zh, "@attr 1=/ test", 0);
+
+    return close_down(zh, zs, 0);
+}
diff --git a/test/filters/record.mrc b/test/filters/record.mrc
new file mode 100644 (file)
index 0000000..c78fdce
--- /dev/null
@@ -0,0 +1 @@
+00366nam  22001698a 4500001001300000003000400013005001700017008004100034010001700179040001300075050001200088100001700100245003000117260001200147263000900159300001100168\1e   11224466 \1eDLC\1e00000000000000.0\1e910710c19910701nju           00010 eng  \1e  \1faDLC\1fcDLC\1e00\1fa123-xyz\1e10\1faJack Collins\1e10\1faHow to program a computer\1e\1faPenguin\1e  \1fa8710\1e  \1fap. cm.\1e  \1fa   11224466 \1e\1d
\ No newline at end of file
diff --git a/test/filters/record.xml b/test/filters/record.xml
new file mode 100644 (file)
index 0000000..13c4835
--- /dev/null
@@ -0,0 +1 @@
+<elem>some text $ text here.</elem>
diff --git a/test/filters/text.c b/test/filters/text.c
new file mode 100644 (file)
index 0000000..88a5385
--- /dev/null
@@ -0,0 +1,62 @@
+/* $Id: text.c,v 1.1 2005-06-14 20:03:02 adam Exp $
+   Copyright (C) 1995-2005
+   Index Data ApS
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Zebra; see the file LICENSE.zebra.  If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+*/
+
+#include "../api/testlib.h"
+
+int main(int argc, char **argv)
+{
+    ZebraService zs = start_up(0, argc, argv);
+    ZebraHandle  zh = zebra_open(zs);
+    char path[256];
+
+    check_filter(zs, "text");
+
+    zebra_select_database(zh, "Default");
+
+    zebra_set_resource(zh, "recordType", "text");
+
+    zebra_init(zh);
+
+    zebra_begin_trans(zh, 1);
+    sprintf(path, "%.200s/record.xml", get_srcdir());
+    zebra_repository_update(zh, path);
+    zebra_end_trans(zh);
+    zebra_commit(zh);
+
+    do_query(__LINE__, zh, "text", 1);
+
+    do_query(__LINE__, zh, "test", 0);
+
+    zebra_set_resource(zh, "recordType", "text.$");
+
+    zebra_begin_trans(zh, 1);
+    sprintf(path, "%.200s/record.xml", get_srcdir());
+    zebra_repository_update(zh, path);
+    zebra_end_trans(zh);
+    zebra_commit(zh);
+
+    do_query(__LINE__, zh, "text", 3);
+
+    do_query(__LINE__, zh, "here", 2);
+
+    return close_down(zh, zs, 0);
+}
diff --git a/test/filters/zebra.cfg b/test/filters/zebra.cfg
new file mode 100644 (file)
index 0000000..e2b4f2a
--- /dev/null
@@ -0,0 +1,17 @@
+# Simple Zebra configuration file
+# $Id: zebra.cfg,v 1.1 2005-06-14 20:03:02 adam Exp $
+#
+# Where the schema files, attribute files, etc are located.
+profilePath: ${srcdir:-.}:${srcdir:-.}/../../tab
+
+
+# Files that describe the attribute sets supported.
+attset: bib1.att
+attset: gils.att
+attset: explain.att
+
+recordtype: grs.xml
+
+isam: b
+
+modulePath: ../../recctrl/.libs