X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fapi%2Ftestlib.c;h=31c921927cd195ea8e10b05557f102c9f7c2130e;hb=0ee1415968148352b07c112d0a4eb1deb4aa2322;hp=fe1ecc111879261dedb98515c13273525d36b128;hpb=74fdf8a15af7bb827a256d9df3ecc34a57d2120f;p=idzebra-moved-to-github.git diff --git a/test/api/testlib.c b/test/api/testlib.c index fe1ecc1..31c9219 100644 --- a/test/api/testlib.c +++ b/test/api/testlib.c @@ -1,5 +1,5 @@ -/* $Id: testlib.c,v 1.30 2006-03-31 15:58:05 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: testlib.c,v 1.37 2006-08-31 08:36:53 adam Exp $ + Copyright (C) 1995-2006 Index Data ApS This file is part of the Zebra server. @@ -15,9 +15,9 @@ 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. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ /** testlib - utilities for the api tests */ @@ -51,10 +51,14 @@ void tl_start_log(int argc, char **argv) if (!argv[0]) return; sprintf(logname, "%s.log", argv[0]); +#if HAVE_UNISTD_H + unlink(logname); +#endif yaz_log_init_file(logname); - log_level = yaz_log_mask_str_x(argv[0], 0); if (argc >= 2) - cmd_level |= yaz_log_mask_str_x(argv[1], 0); + log_level = yaz_log_mask_str_x(argv[1], 0); + if (argc >= 3) + yaz_log_time_format(argv[2]); yaz_log_init_level(YLOG_DEFAULT_LEVEL | log_level | cmd_level); yaz_log(log_level, "starting %s", argv[0]); } @@ -72,8 +76,8 @@ ZebraService tl_start_up(char *cfgname, int argc, char **argv) #if HAVE_SYS_RESOURCE_H #if HAVE_SYS_TIME_H struct rlimit rlim; - rlim.rlim_cur = 20; - rlim.rlim_max = 20; + rlim.rlim_cur = 60; + rlim.rlim_max = 60; setrlimit(RLIMIT_CPU, &rlim); #endif #endif @@ -172,11 +176,14 @@ int tl_query_x(ZebraHandle zh, const char *query, zint exphits, int experror) yaz_pqf_destroy(parser); if (!rpn) { + yaz_log(log_level, "could not parse pqf query %s\n", query); + printf("could not parse pqf query %s\n", query); odr_destroy(odr); return 0; } rc = zebra_search_RPN(zh, odr, rpn, setname, &hits); + odr_destroy(odr); if (experror) { int code; @@ -219,7 +226,6 @@ int tl_query_x(ZebraHandle zh, const char *query, zint exphits, int experror) return 0; } } - odr_destroy(odr); return 1; } @@ -234,6 +240,7 @@ int tl_scan(ZebraHandle zh, const char *query, int exp_pos, int exp_num, int exp_partial, const char **exp_entries) { + int ret = 1; ODR odr = odr_createmem(ODR_ENCODE); ZebraScanEntry *entries = 0; int partial = -123; @@ -244,61 +251,71 @@ int tl_scan(ZebraHandle zh, const char *query, res = zebra_scan_PQF(zh, odr, query, &pos, &num, &entries, &partial, 0 /* setname */); - if (res != ZEBRA_OK) + + if (partial == -123) { - printf("Error: scan returned %d (FAIL), but no error was expected\n" - "%s\n", res, query); - return 0; + printf("Error: scan returned OK, but partial was not set\n" + "%s\n", query); + ret = 0; + } + if (partial != exp_partial) + { + printf("Error: scan OK, with partial/expected %d/%d\n", + partial, exp_partial); + ret = 0; + } + if (res != ZEBRA_OK) /* failure */ + { + if (exp_entries) + { + printf("Error: scan failed, but no error was expected\n"); + ret = 0; + } } else { - int fails = 0; - if (partial == -123) - { - printf("Error: scan returned OK, but partial was not set\n" - "%s\n", query); - fails++; - } - if (partial != exp_partial) - { - printf("Error: scan returned OK, with partial/expected %d/%d\n" - "%s\n", partial, exp_partial, query); - fails++; - } - if (num != exp_num) - { - printf("Error: scan returned OK, with num/expected %d/%d\n" - "%s\n", num, exp_num, query); - fails++; - } - if (pos != exp_pos) - { - printf("Error: scan returned OK, with pos/expected %d/%d\n" - "%s\n", pos, exp_pos, query); - fails++; - } - if (fails) - return 0; - fails = 0; - if (exp_entries) - { - int i; - for (i = 0; i