X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fapi%2Ftestlib.c;h=e5a774541ff3c81431a32b26a9aae45b108d0ebd;hb=3d6d9a44b38717e7e9a2c64b68db895998d4de82;hp=c0a495b5ce1e0c25b439188da94cb86c14a89c16;hpb=86277fd5ab0909de99a3e81b92d087ae45882a4a;p=idzebra-moved-to-github.git diff --git a/test/api/testlib.c b/test/api/testlib.c index c0a495b..e5a7745 100644 --- a/test/api/testlib.c +++ b/test/api/testlib.c @@ -1,4 +1,4 @@ -/* $Id: testlib.c,v 1.20 2005-05-24 11:27:48 adam Exp $ +/* $Id: testlib.c,v 1.25 2005-08-09 12:30:47 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -22,6 +22,16 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA /** testlib - utilities for the api tests */ +#if HAVE_SYS_TIME_H +#include +#endif +#if HAVE_SYS_RESOURCE_H +#include +#endif +#if HAVE_UNISTD_H +#include +#endif + #include #include #include @@ -34,6 +44,7 @@ int log_level=0; /* not static, t*.c may use it */ void start_log(int argc, char **argv) { + int cmd_level = 0; char logname[2048]; if (!argv) return; @@ -43,8 +54,8 @@ void start_log(int argc, char **argv) yaz_log_init_file(logname); log_level = yaz_log_mask_str_x(argv[0], 0); if (argc >= 2) - log_level |= yaz_log_mask_str_x(argv[1], 0); - yaz_log_init_level(YLOG_DEFAULT_LEVEL | log_level); + cmd_level |= yaz_log_mask_str_x(argv[1], 0); + yaz_log_init_level(YLOG_DEFAULT_LEVEL | log_level | cmd_level); yaz_log(log_level, "starting %s", argv[0]); } @@ -58,6 +69,14 @@ void start_log(int argc, char **argv) */ ZebraService 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; + setrlimit(RLIMIT_CPU, &rlim); +#endif +#endif nmem_init(); start_log(argc, argv); return start_service(cfgname); @@ -219,7 +238,8 @@ void do_scan(int lineno, ZebraHandle zh, const char *query, yaz_log(log_level, "======================================"); yaz_log(log_level, "scan[%d]: pos=%d num=%d %s", lineno, pos, num, query); - res = zebra_scan_PQF(zh, odr, query, &pos, &num, &entries, &partial); + res = zebra_scan_PQF(zh, odr, query, &pos, &num, &entries, &partial, + 0 /* setname */); if (res != ZEBRA_OK) { printf("Error: scan returned %d (FAIL), but no error was expected\n" @@ -358,6 +378,51 @@ void meta_query(int lineno, ZebraHandle zh, char *query, int exphits, free(positions); } +void do_sort(ZebraHandle zh, const char *query, zint hits, zint *exp) +{ + ZebraMetaRecord *recs; + zint i; + int errs = 0; + zint min_val_recs = 0; + zint min_val_exp = 0; + + assert(query); + do_query(__LINE__, zh, query, hits); + + recs = zebra_meta_records_create_range (zh, "rsetname", 1, 4); + if (!recs) + { + fprintf(stderr, "recs==0\n"); + exit(1); + } + /* find min for each sequence to get proper base offset */ + for (i = 0; i