1 /* $Id: testlib.h,v 1.10 2005-01-15 19:38:35 adam Exp $
2 Copyright (C) 1995-2005
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /** testlib - utilities for the api tests */
26 #include <yaz/yconfig.h>
27 #include <yaz/pquery.h>
29 #include <idzebra/api.h>
35 * start_up : Does all the usual start functions
37 * - build the name of logfile from argv[0], and open it
38 * if no argv passed, do not open a log
39 * - read zebra.cfg from env var srcdir if it exists; otherwise current dir
40 * default to zebra.cfg, if no name is given
42 ZebraService start_up(char *cfgname, int argc, char **argv);
45 * get_srcdir : returns the source dir. Most often ".", but when
46 * making distcheck, some other dir
48 const char *get_srcdir();
51 * start_log: open a log file
53 /* FIXME - parse command line arguments to set log levels etc */
54 void start_log(int argc, char **argv);
57 * start_service - do a zebra_start with a decent config name
58 * Takes care of checking the environment for srcdir (as needed by distcheck)
59 * and uses that if need be.
60 * The name defaults to zebra.cfg, if null or emtpy
62 ZebraService start_service(char *cfgname);
66 * close_down closes it all down
67 * Does a zebra_close on zh, if not null.
68 * Does a zebra_stop on zs, if not null
69 * Writes a log message, OK if retcode is zero, error if not
70 * closes down nmem and xmalloc
71 * returns the retcode, for use in return or exit in main()
73 int close_down(ZebraHandle zh, ZebraService zs, int retcode);
75 /** inits the database and inserts test data */
76 void init_data( ZebraHandle zh, const char **recs);
80 * do_query does a simple query, and checks that the number of hits matches
82 int do_query(int lineno, ZebraHandle zh, char *query, int exphits);
86 * ranking_query makes a query, checks number of hits, and for
87 * the first hit, that it contains the given string, and that it
88 * gets the right score
90 void ranking_query(int lineno, ZebraHandle zh, char *query,
91 int exphits, char *firstrec, int firstscore );
94 * meta_query makes a query, checks number of hits, and for
95 * checks that the all records in result set has the proper identifiers (ids)
97 void meta_query(int lineno, ZebraHandle zh, char *query, int exphits,
101 * if filter given by name does not exist, exit nicely but warn in log
103 void check_filter(ZebraService zs, const char *name);