From 21ac4591a8f74b9de5030532d18d962bbe72b3d3 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 14 Jun 2005 20:03:01 +0000 Subject: [PATCH] Added new test/filter directory with filter tests. --- configure.in | 5 ++-- test/Makefile.am | 2 +- test/filters/.cvsignore | 15 +++++++++++ test/filters/Makefile.am | 30 ++++++++++++++++++++++ test/filters/grs.marc.c | 50 +++++++++++++++++++++++++++++++++++++ test/filters/grs.xml.c | 50 +++++++++++++++++++++++++++++++++++++ test/filters/record.mrc | 1 + test/filters/record.xml | 1 + test/filters/text.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++ test/filters/zebra.cfg | 17 +++++++++++++ 10 files changed, 230 insertions(+), 3 deletions(-) create mode 100644 test/filters/.cvsignore create mode 100644 test/filters/Makefile.am create mode 100644 test/filters/grs.marc.c create mode 100644 test/filters/grs.xml.c create mode 100644 test/filters/record.mrc create mode 100644 test/filters/record.xml create mode 100644 test/filters/text.c create mode 100644 test/filters/zebra.cfg diff --git a/configure.in b/configure.in index 2536c3a..9927342 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/test/Makefile.am b/test/Makefile.am index 49d3e4a..8a04c7a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -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 index 0000000..4896344 --- /dev/null +++ b/test/filters/.cvsignore @@ -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 index 0000000..c312fcb --- /dev/null +++ b/test/filters/Makefile.am @@ -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 index 0000000..16707af --- /dev/null +++ b/test/filters/grs.marc.c @@ -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 index 0000000..add4249 --- /dev/null +++ b/test/filters/grs.xml.c @@ -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 index 0000000..c78fdce --- /dev/null +++ b/test/filters/record.mrc @@ -0,0 +1 @@ +00366nam 22001698a 4500001001300000003000400013005001700017008004100034010001700179040001300075050001200088100001700100245003000117260001200147263000900159300001100168 11224466 DLC00000000000000.0910710c19910701nju 00010 eng  aDLCcDLC00a123-xyz10aJack Collins10aHow to program a computer1 aPenguin a8710 ap. cm. a 11224466  \ No newline at end of file diff --git a/test/filters/record.xml b/test/filters/record.xml new file mode 100644 index 0000000..13c4835 --- /dev/null +++ b/test/filters/record.xml @@ -0,0 +1 @@ +some text $ text here. diff --git a/test/filters/text.c b/test/filters/text.c new file mode 100644 index 0000000..88a5385 --- /dev/null +++ b/test/filters/text.c @@ -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 index 0000000..e2b4f2a --- /dev/null +++ b/test/filters/zebra.cfg @@ -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 -- 1.7.10.4