X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fapi%2Ftestlib.c;h=18f3cd9ea496dbca32e8b748fb4c6eb9e70b7299;hb=c401b3a1421e31b3d6b77bc7bac6ffb934207df1;hp=4edb448ce0bb01b24447abe42342b11af184a0cb;hpb=b61682c79e8311e1ec73d22872a56ff934c9b249;p=idzebra-moved-to-github.git diff --git a/test/api/testlib.c b/test/api/testlib.c index 4edb448..18f3cd9 100644 --- a/test/api/testlib.c +++ b/test/api/testlib.c @@ -1,5 +1,5 @@ -/* $Id: testlib.c,v 1.33 2006-06-28 09:38:17 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: testlib.c,v 1.39 2006-10-29 17:20:01 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 */ @@ -44,7 +44,6 @@ int log_level=0; /* not static, t*.c may use it */ void tl_start_log(int argc, char **argv) { - int cmd_level = 0; char logname[2048]; if (!argv) return; @@ -59,7 +58,8 @@ void tl_start_log(int argc, char **argv) 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); + if (log_level) + yaz_log_init_level(log_level); yaz_log(log_level, "starting %s", argv[0]); } @@ -76,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 @@ -89,7 +89,7 @@ ZebraService tl_start_up(char *cfgname, int argc, char **argv) /** * get_srcdir: return env srcdir or . (if does does not exist) */ -const char *tl_get_srcdir() +const char *tl_get_srcdir(void) { const char *srcdir = getenv("srcdir"); if (!srcdir || ! *srcdir) @@ -183,6 +183,7 @@ int tl_query_x(ZebraHandle zh, const char *query, zint exphits, int experror) } rc = zebra_search_RPN(zh, odr, rpn, setname, &hits); + odr_destroy(odr); if (experror) { int code; @@ -225,7 +226,6 @@ int tl_query_x(ZebraHandle zh, const char *query, zint exphits, int experror) return 0; } } - odr_destroy(odr); return 1; } @@ -240,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; @@ -250,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