From: Adam Dickmeiss Date: Fri, 31 Mar 2006 15:58:03 +0000 (+0000) Subject: Use GCC attribute warn_unsed_result for a few of the most important X-Git-Tag: before.bug.529~183 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=74fdf8a15af7bb827a256d9df3ecc34a57d2120f Use GCC attribute warn_unsed_result for a few of the most important API functions. This allows us to find places where errors are not properly dealt with. All testlib functions are prefixed with tl_.. They usually return 1 for TRUE, 0 for FALSE .. And YAZ_CHECK functions are used in virtually all tests now. --- diff --git a/include/idzebra/api.h b/include/idzebra/api.h index 88d9fec..f91ed82 100644 --- a/include/idzebra/api.h +++ b/include/idzebra/api.h @@ -1,4 +1,4 @@ -/* $Id: api.h,v 1.31 2005-12-09 11:33:32 adam Exp $ +/* $Id: api.h,v 1.32 2006-03-31 15:58:03 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -39,6 +39,19 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA YAZ_BEGIN_CDECL +/* + expand GCC_ATTRIBUTE if GCC is in use. See : + http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html +*/ + +#ifndef GCC_ATTRIBUTE +#ifdef __GNUC__ +#define GCC_ATTRIBUTE(x) __attribute__ (x) +#else +#define GCC_ATTRIBUTE(x) +#endif +#endif + typedef struct { int processed; int inserted; @@ -84,7 +97,8 @@ typedef struct zebra_service *ZebraService; This function is a simplified version of zebra_start_res. */ YAZ_EXPORT -ZebraService zebra_start(const char *configName); +ZebraService zebra_start(const char *configName + ) GCC_ATTRIBUTE((warn_unused_result)); /** \fn ZebraService zebra_start_res(const char *configName, \ Res def_res, Res over_res) @@ -98,7 +112,8 @@ ZebraService zebra_start(const char *configName); */ YAZ_EXPORT ZebraService zebra_start_res(const char *configName, - Res def_res, Res over_res); + Res def_res, Res over_res + ) GCC_ATTRIBUTE((warn_unused_result)); /** \brief stops a Zebra service. @@ -129,7 +144,8 @@ void zebra_filter_info(ZebraService zs, void *cd, one handle is sufficient */ YAZ_EXPORT -ZebraHandle zebra_open(ZebraService zs, Res res); +ZebraHandle zebra_open(ZebraService zs, Res res + ) GCC_ATTRIBUTE((warn_unused_result)); /** \brief Destroys Zebra session handle. @@ -379,10 +395,12 @@ ZEBRA_RES zebra_admin_exchange_record(ZebraHandle zh, int action); YAZ_EXPORT -ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw); +ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw + ) GCC_ATTRIBUTE((warn_unused_result)); YAZ_EXPORT -ZEBRA_RES zebra_end_trans(ZebraHandle zh); +ZEBRA_RES zebra_end_trans(ZebraHandle zh + ) GCC_ATTRIBUTE((warn_unused_result)); YAZ_EXPORT ZEBRA_RES zebra_end_transaction(ZebraHandle zh, @@ -433,14 +451,17 @@ ZEBRA_RES zebra_sort(ZebraHandle zh, ODR stream, const char **input_setnames, const char *output_setname, Z_SortKeySpecList *sort_sequence, - int *sort_status); + int *sort_status + ) GCC_ATTRIBUTE((warn_unused_result)); YAZ_EXPORT ZEBRA_RES zebra_select_databases(ZebraHandle zh, int num_bases, - const char **basenames); + const char **basenames + ) GCC_ATTRIBUTE((warn_unused_result)); YAZ_EXPORT -ZEBRA_RES zebra_select_database(ZebraHandle zh, const char *basename); +ZEBRA_RES zebra_select_database(ZebraHandle zh, const char *basename + ) GCC_ATTRIBUTE((warn_unused_result)); YAZ_EXPORT void zebra_shadow_enable(ZebraHandle zh, int value); diff --git a/index/apitest.c b/index/apitest.c index 0248f72..6c27a32 100644 --- a/index/apitest.c +++ b/index/apitest.c @@ -1,4 +1,4 @@ -/* $Id: apitest.c,v 1.23 2005-09-13 11:51:06 adam Exp $ +/* $Id: apitest.c,v 1.24 2006-03-31 15:58:04 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -152,7 +152,11 @@ int main (int argc, char **argv) printf ("zebras_open failed\n"); exit (1); } - zebra_select_databases (zh, 1, &base); + if (zebra_select_databases (zh, 1, &base) != ZEBRA_OK) + { + printf ("zebra_select_databases failed\n"); + exit (1); + } /* Each argument to main will be a query */ for (argno = 1; argno < argc; argno++) { diff --git a/index/main.c b/index/main.c index 1ced237..ae942ed 100644 --- a/index/main.c +++ b/index/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.127 2005-09-13 11:51:06 adam Exp $ +/* $Id: main.c,v 1.128 2006-03-31 15:58:04 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -279,7 +279,8 @@ int main (int argc, char **argv) } /* while arg */ if (trans_started) - zebra_end_trans (zh); + if (zebra_end_trans (zh) != ZEBRA_OK) + yaz_log (YLOG_WARN, "zebra_end_trans failed"); zebra_close (zh); zebra_stop (zs); diff --git a/index/zebraapi.c b/index/zebraapi.c index 35d02d8..b3258e3 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.209 2006-03-31 08:51:26 adam Exp $ +/* $Id: zebraapi.c,v 1.210 2006-03-31 15:58:04 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -1363,7 +1363,8 @@ ZEBRA_RES zebra_admin_exchange_record(ZebraHandle zh, { if (action == 1) /* fail if insert */ { - zebra_end_trans(zh); + if (zebra_end_trans(zh) != ZEBRA_OK) + yaz_log(YLOG_WARN, "zebra_end_trans failed"); zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED, "Cannot insert record: already exist"); return ZEBRA_FAIL; @@ -1375,7 +1376,8 @@ ZEBRA_RES zebra_admin_exchange_record(ZebraHandle zh, { if (action == 2 || action == 3) /* fail if delete or update */ { - zebra_end_trans(zh); + if (zebra_end_trans(zh) != ZEBRA_OK) + yaz_log(YLOG_WARN, "zebra_end_trans failed"); zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED, "Cannot delete/update record: does not exist"); return ZEBRA_FAIL; @@ -1406,7 +1408,11 @@ ZEBRA_RES zebra_admin_exchange_record(ZebraHandle zh, { dict_delete_ord(zh->reg->matchDict, db_ord, recid_z); } - zebra_end_trans(zh); + if (zebra_end_trans(zh) != ZEBRA_OK) + { + yaz_log(YLOG_WARN, "zebra_end_trans failed"); + res = ZEBRA_FAIL; + } return res; } @@ -1466,7 +1472,11 @@ ZEBRA_RES zebra_drop_database(ZebraHandle zh, const char *db) "drop database only supported for isam:b"); ret = ZEBRA_FAIL; } - zebra_end_trans (zh); + if (zebra_end_trans (zh) != ZEBRA_OK) + { + yaz_log(YLOG_WARN, "zebra_end_trans failed"); + ret = ZEBRA_FAIL; + } return ret; } @@ -1485,7 +1495,10 @@ ZEBRA_RES zebra_create_database (ZebraHandle zh, const char *db) if (zebraExplain_newDatabase (zh->reg->zei, db, 0 /* explainDatabase */)) { - zebra_end_trans (zh); + if (zebra_end_trans (zh) != ZEBRA_OK) + { + yaz_log(YLOG_WARN, "zebra_end_trans failed"); + } zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED, db); return ZEBRA_FAIL; } @@ -2197,7 +2210,11 @@ ZEBRA_RES zebra_insert_record (ZebraHandle zh, match, fname, 0, 0); /* allow_update */ - zebra_end_trans(zh); + if (zebra_end_trans(zh) != ZEBRA_OK) + { + yaz_log(YLOG_WARN, "zebra_end_trans failed"); + res = ZEBRA_FAIL; + } return res; } @@ -2228,7 +2245,11 @@ ZEBRA_RES zebra_update_record (ZebraHandle zh, match, fname, force_update, 1); /* allow_update */ - zebra_end_trans(zh); + if (zebra_end_trans(zh) != ZEBRA_OK) + { + yaz_log(YLOG_WARN, "zebra_end_trans failed"); + res = ZEBRA_FAIL; + } return res; } @@ -2257,7 +2278,11 @@ ZEBRA_RES zebra_delete_record (ZebraHandle zh, match,fname, force_update, 1); /* allow_update */ - zebra_end_trans(zh); + if (zebra_end_trans(zh) != ZEBRA_OK) + { + yaz_log(YLOG_WARN, "zebra_end_trans failed"); + res = ZEBRA_FAIL; + } return res; } diff --git a/index/zserver.c b/index/zserver.c index 62e3387..565e652 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -1,4 +1,4 @@ -/* $Id: zserver.c,v 1.144 2005-12-09 11:33:32 adam Exp $ +/* $Id: zserver.c,v 1.145 2006-03-31 15:58:04 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -391,10 +391,11 @@ int bend_sort (void *handle, bend_sort_rr *rr) { ZebraHandle zh = (ZebraHandle) handle; - zebra_sort (zh, rr->stream, - rr->num_input_setnames, (const char **) rr->input_setnames, - rr->output_setname, rr->sort_sequence, &rr->sort_status); - zebra_result (zh, &rr->errcode, &rr->errstring); + if (zebra_sort (zh, rr->stream, + rr->num_input_setnames, (const char **) rr->input_setnames, + rr->output_setname, rr->sort_sequence, &rr->sort_status) + != ZEBRA_OK) + zebra_result (zh, &rr->errcode, &rr->errstring); return 0; } @@ -446,7 +447,12 @@ static void es_admin_request (bend_esrequest_rr *rr, ZebraHandle zh, Z_AdminEsRe case Z_ESAdminOriginPartToKeep_commit: yaz_log(YLOG_LOG, "adm-commit"); if (r->toKeep->databaseName) - zebra_select_database(zh, r->toKeep->databaseName); + { + if (zebra_select_database(zh, r->toKeep->databaseName) != + ZEBRA_OK) + yaz_log(YLOG_WARN, "zebra_select_database failed in " + "adm-commit"); + } zebra_commit(zh); break; case Z_ESAdminOriginPartToKeep_shutdown: @@ -728,7 +734,11 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) } } } - zebra_end_trans (zh); + if (zebra_end_trans (zh) != ZEBRA_OK) + { + yaz_log(YLOG_WARN, "zebra_end_trans failed for" + " extended service operation"); + } } } } diff --git a/test/Makefile.am b/test/Makefile.am index 8a04c7a..6d3d247 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS=codec api filters xslt xpath gils malxml config usmarc dmoz sort \ - sort2 xelm cddb rusmarc zsh marcxml charmap mbox espec +SUBDIRS=codec api filters xslt xpath malxml config usmarc dmoz sort \ + sort2 xelm cddb rusmarc zsh marcxml charmap mbox espec gils diff --git a/test/api/safari1.c b/test/api/safari1.c index f702e93..f865c51 100644 --- a/test/api/safari1.c +++ b/test/api/safari1.c @@ -1,4 +1,4 @@ -/* $Id: safari1.c,v 1.9 2006-03-21 14:36:22 adam Exp $ +/* $Id: safari1.c,v 1.10 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -56,33 +56,34 @@ const char *myrec[] = 0 }; -int main(int argc, char **argv) +static void tst(int argc, char **argv) { zint ids[3]; zint limits[3]; - ZebraService zs = start_up("safari.cfg", argc, argv); + ZebraService zs = tl_start_up("safari.cfg", argc, argv); ZebraHandle zh = zebra_open(zs, 0); - init_data(zh, myrec); - do_query(__LINE__, zh, "@attr 4=3 @attr 1=any the", 3); - do_query(__LINE__, zh, "@attr 4=3 @attr 1=any @and the art", 1); - do_query(__LINE__, zh, "@attr 4=3 @attr 1=any @and den gamle", 0); - do_query(__LINE__, zh, "@attr 4=3 @attr 1=any @and the gamle", 1); - do_query(__LINE__, zh, "@attr 4=3 @attr 1=any @and the of", 0); + YAZ_CHECK(tl_init_data(zh, myrec)); + + YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any the", 3)); + YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @and the art", 1)); + YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @and den gamle", 0)); + YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @and the gamle", 1)); + YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @and the of", 0)); /* verify that we get these records exactly */ ids[0] = 24338; ids[1] = 24339; ids[2] = 24340; - meta_query(__LINE__, zh, "@attr 4=3 @attr 1=any mand", 3, ids); + YAZ_CHECK(tl_meta_query(zh, "@attr 4=3 @attr 1=any mand", 3, ids)); /* limit to 125061 */ limits[0] = 125061; limits[1] = 0; zebra_set_limit(zh, 0, limits); ids[0] = 24339; - meta_query(__LINE__, zh, "@attr 4=3 @attr 1=any mand", 1, ids); + YAZ_CHECK(tl_meta_query(zh, "@attr 4=3 @attr 1=any mand", 1, ids)); /* limit to 125060, 125061 */ limits[0] = 125061; @@ -91,7 +92,7 @@ int main(int argc, char **argv) zebra_set_limit(zh, 0, limits); ids[0] = 24338; ids[1] = 24339; - meta_query(__LINE__, zh, "@attr 4=3 @attr 1=any mand", 2, ids); + YAZ_CHECK(tl_meta_query(zh, "@attr 4=3 @attr 1=any mand", 2, ids)); /* all except 125062 */ limits[0] = 125062; @@ -100,11 +101,13 @@ int main(int argc, char **argv) ids[0] = 24338; ids[1] = 24339; - meta_query(__LINE__, zh, "@attr 4=3 @attr 1=any mand", 2, ids); + YAZ_CHECK(tl_meta_query(zh, "@attr 4=3 @attr 1=any mand", 2, ids)); /* no limit */ zebra_set_limit(zh, 1, 0); - do_query(__LINE__, zh, "@attr 4=3 @attr 1=any mand", 3); + YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any mand", 3)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/api/t0.c b/test/api/t0.c index d41cdfb..8562208 100644 --- a/test/api/t0.c +++ b/test/api/t0.c @@ -1,4 +1,4 @@ -/* $Id: t0.c,v 1.2 2006-03-25 15:33:43 adam Exp $ +/* $Id: t0.c,v 1.3 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -22,18 +22,12 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA /** t0 - test zebra_start .. */ -#include -#include -#include - -int main(int argc, char **argv) -{ - ZebraService zs; - - YAZ_CHECK_INIT(argc, argv); - - zs = zebra_start("xxxxpoiasdfasfd.cfg"); - YAZ_CHECK(!zs); +#include "testlib.h" - YAZ_CHECK_TERM; +static void tst(int argc, char **argv) +{ + tl_start_log(argc, argv); + YAZ_CHECK(!zebra_start("xxxxpoiasdfasfd.cfg")); /* should fail */ } + +TL_MAIN diff --git a/test/api/t1.c b/test/api/t1.c index 731c390..bf88e50 100644 --- a/test/api/t1.c +++ b/test/api/t1.c @@ -1,4 +1,4 @@ -/* $Id: t1.c,v 1.13 2005-09-13 11:51:07 adam Exp $ +/* $Id: t1.c,v 1.14 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -22,13 +22,16 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA /** t1 - just start and stop */ +#include #include "testlib.h" - -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN + diff --git a/test/api/t10.c b/test/api/t10.c index 97b3c67..6e53237 100644 --- a/test/api/t10.c +++ b/test/api/t10.c @@ -1,4 +1,4 @@ -/* $Id: t10.c,v 1.9 2005-09-13 11:51:07 adam Exp $ +/* $Id: t10.c,v 1.10 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -25,9 +25,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "testlib.h" #include "rankingrecords.h" -#define qry(zh,query,hits,string,score) \ - ranking_query(__LINE__,(zh),(query),(hits),(string),(score)) - struct tst { char *schema; char *hit1; @@ -38,8 +35,6 @@ struct tst { int score3; }; - - struct tst tests[] = { {"ntc-atn", "first title", 0, "first title", 1000, "first title",1000 }, {"ntc-ntn", "first title", 0, "first title", 1000, "first title",1000 }, @@ -70,31 +65,33 @@ struct tst tests[] = { {0,0,0,0,0,0,0}, }; -int main(int argc, char **argv) +static void tst(int argc, char **argv) { int i; - ZebraService zs = start_up("zebrazv.cfg", argc, argv); + ZebraService zs = tl_start_up("zebrazv.cfg", argc, argv); ZebraHandle zh = zebra_open(zs, 0); - init_data(zh, recs); + YAZ_CHECK(tl_init_data(zh, recs)); zebra_close(zh); for (i = 0; tests[i].schema; i++) { zh = zebra_open(zs, 0); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zh); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); + zebra_set_resource(zh, "zvrank.weighting-scheme", tests[i].schema); yaz_log(YLOG_LOG,"============%d: %s ===========", i, tests[i].schema); - ranking_query( __LINE__, zh, "@attr 1=1016 @attr 2=102 the", - 3, tests[i].hit1, tests[i].score1); - ranking_query( __LINE__, zh, "@attr 1=1016 @attr 2=102 @or foo bar", - 3, tests[i].hit2, tests[i].score2); - ranking_query( __LINE__, zh, - "@attr 1=1016 @attr 2=102 @or @or the foo bar", - 3, tests[i].hit3, tests[i].score3); - + YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 the", + 3, tests[i].hit1, tests[i].score1)); + YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 @or foo bar", + 3, tests[i].hit2, tests[i].score2)); + YAZ_CHECK(tl_ranking_query(zh, + "@attr 1=1016 @attr 2=102 @or @or the foo bar", + 3, tests[i].hit3, tests[i].score3)); zebra_close(zh); } - - return close_down(0,zs,0); + YAZ_CHECK(tl_close_down(0, zs)); } + +TL_MAIN diff --git a/test/api/t11.c b/test/api/t11.c index 8748ec0..cf286c6 100644 --- a/test/api/t11.c +++ b/test/api/t11.c @@ -1,4 +1,4 @@ -/* $Id: t11.c,v 1.3 2005-09-13 11:51:07 adam Exp $ +/* $Id: t11.c,v 1.4 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -29,97 +29,102 @@ const char *myrec[] = { "\ne f\n\n" , 0} ; -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - init_data(zh, myrec); + YAZ_CHECK(zh); + + YAZ_CHECK(tl_init_data(zh, myrec)); if (1) { /* scan before. nothing must be returned */ const char *ent[] = { "a", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 0", 1, 1, 1, 1, 0, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 1, 1, 1, 1, 0, ent)); } if (1) { /* scan after. nothing must be returned */ - do_scan(__LINE__, zh, "@attr 1=4 m", 1, 1, 1, 0, 1, 0); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 m", 1, 1, 1, 0, 1, 0)); } if (1) { const char *ent[] = { "a", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 a", 1, 1, 1, 1, 0, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", 1, 1, 1, 1, 0, ent)); } if (1) { const char *ent[] = { "b", "c", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent)); } if (1) { const char *ent[] = { "b", "c", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent)); } if (1) { const char *ent[] = { "e", "f", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 e", 1, 3, 1, 2, 1, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 e", 1, 3, 1, 2, 1, ent)); } if (1) { const char *ent[] = { "c", "d", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 a", -1, 2, -1, 2, 0, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -1, 2, -1, 2, 0, ent)); } if (1) { const char *ent[] = { "d", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 a", -2, 1, -2, 1, 0, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 1, -2, 1, 0, ent)); } if (1) { const char *ent[] = { "f", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 a", -4, 1, -4, 1, 0, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -4, 1, -4, 1, 0, ent)); } if (1) { const char *ent[] = { "f", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 a", -5, 1, -5, 0, 1, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -5, 1, -5, 0, 1, ent)); } if (1) { const char *ent[] = { "d", "e", "f", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 a", -2, 3, -2, 3, 0, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 3, -2, 3, 0, ent)); } if (1) { const char *ent[] = { "d", "e", "f", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 a", -2, 4, -2, 3, 1, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 4, -2, 3, 1, ent)); } if (1) { const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 0", 2, 100, 1, 6, 1, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 2, 100, 1, 6, 1, ent)); } if (1) { const char *ent[] = { "b", "c", "d", "e", "f", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 0", 0, 100, 0, 5, 1, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 0, 100, 0, 5, 1, ent)); } if (1) { const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 0", 10, 100, 1, 6, 1, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 10, 100, 1, 6, 1, ent)); } if (1) { const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 }; - do_scan(__LINE__, zh, "@attr 1=4 0", 22, 10, 1, 0, 1, ent); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 22, 10, 1, 0, 1, ent)); } if (1) { - do_scan(__LINE__, zh, "@attr 1=4 z", -22, 10, -22, 0, 1, 0); + YAZ_CHECK(tl_scan(zh, "@attr 1=4 z", -22, 10, -22, 0, 1, 0)); } - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN + diff --git a/test/api/t12.c b/test/api/t12.c index ede4022..9574044 100644 --- a/test/api/t12.c +++ b/test/api/t12.c @@ -1,4 +1,4 @@ -/* $Id: t12.c,v 1.2 2005-09-13 11:51:07 adam Exp $ +/* $Id: t12.c,v 1.3 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -24,48 +24,58 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { int i; int no_db = 140; - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - zebra_select_database(zh, "Default"); - zebra_init(zh); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); + YAZ_CHECK(zebra_init(zh) == ZEBRA_OK); zebra_close(zh); zh = zebra_open(zs, 0); + YAZ_CHECK(zh); - zebra_begin_trans (zh, 1); + YAZ_CHECK(zebra_begin_trans (zh, 1) == ZEBRA_OK); + for (i = 0; ititle %d\n", i); zebra_add_record (zh, rec_buf, strlen(rec_buf)); } - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); + zebra_close(zh); zh = zebra_open(zs, 0); + YAZ_CHECK(zh); for (i = 0; i<=no_db; i++) { char dbstr[20]; char querystr[50]; sprintf(dbstr, "%d", i); - zebra_select_database(zh, dbstr); + YAZ_CHECK(zebra_select_database(zh, dbstr) == ZEBRA_OK); sprintf(querystr, "@attr 1=4 %d", i); if (i == no_db) - do_query_x(__LINE__, zh, querystr, 0, 109); + { + YAZ_CHECK(tl_query_x(zh, querystr, 0, 109)); + } else - do_query(__LINE__, zh, querystr, 1); + { + YAZ_CHECK(tl_query(zh, querystr, 1)); + } } - - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN + diff --git a/test/api/t13.c b/test/api/t13.c index 10f11fb..551cb8c 100644 --- a/test/api/t13.c +++ b/test/api/t13.c @@ -1,4 +1,4 @@ -/* $Id: t13.c,v 1.5 2006-03-25 21:17:40 adam Exp $ +/* $Id: t13.c,v 1.6 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -23,7 +23,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA /** test resources */ #include #include -#include +#include "testlib.h" #include static void tst_res(void) @@ -49,7 +49,7 @@ static void tst_res(void) zh = zebra_open(zs, 0); YAZ_CHECK(zh); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); /* run this a few times so we can see leaks easier */ for (i = 0; i<10; i++) @@ -109,11 +109,4 @@ static void tst_no_config(void) zebra_stop(zs); } - -int main(int argc, char **argv) -{ - YAZ_CHECK_INIT(argc, argv); - tst_res(); - tst_no_config(); - YAZ_CHECK_TERM; -} +TL_MAIN diff --git a/test/api/t14.c b/test/api/t14.c index a98b175..ea51d40 100644 --- a/test/api/t14.c +++ b/test/api/t14.c @@ -1,4 +1,4 @@ -/* $Id: t14.c,v 1.2 2006-02-09 08:31:02 adam Exp $ +/* $Id: t14.c,v 1.3 2006-03-31 15:58:05 adam Exp $ Copyright (C) 2004-2005 Index Data ApS @@ -26,40 +26,34 @@ static void create_search_drop(ZebraHandle zh) { const char *rec = "some"; const char *opaque_id = "9"; - ZEBRA_RES res; - res = zebra_create_database (zh, "Default"); - TL_ASSERT(res == ZEBRA_OK); + YAZ_CHECK(zebra_create_database (zh, "Default") == ZEBRA_OK); /* bug #447 */ - res = zebra_admin_exchange_record ( - zh, rec, strlen(rec), - opaque_id, strlen(opaque_id), - 1); /* insert */ - TL_ASSERT(res == ZEBRA_OK); + YAZ_CHECK(zebra_admin_exchange_record ( + zh, rec, strlen(rec), + opaque_id, strlen(opaque_id), + 1) == ZEBRA_OK); /* insert */ - res = zebra_admin_exchange_record ( + YAZ_CHECK(zebra_admin_exchange_record ( zh, rec, strlen(rec), opaque_id, strlen(opaque_id), - 4); /* update/insert */ + 4) == ZEBRA_OK); /* update/insert */ - TL_ASSERT(res == ZEBRA_OK); - do_query(__LINE__, zh, "@attr 1=4 some", 1); + YAZ_CHECK(tl_query(zh, "@attr 1=4 some", 1)); zebra_drop_database(zh, "Default"); - do_query_x(__LINE__, zh, "@attr 1=4 some", 0, 109); + YAZ_CHECK(tl_query_x(zh, "@attr 1=4 some", 0, 109)); } -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up("zebra.cfg", argc, argv); + ZebraService zs = tl_start_up("zebra.cfg", argc, argv); ZebraHandle zh = zebra_open(zs, 0); - ZEBRA_RES res; - res = zebra_select_database(zh, "Default"); - TL_ASSERT(res == ZEBRA_OK); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); @@ -67,7 +61,7 @@ int main(int argc, char **argv) /* bug #447 */ create_search_drop(zh); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } - +TL_MAIN diff --git a/test/api/t2.c b/test/api/t2.c index 6dacdd0..fcfa4d4 100644 --- a/test/api/t2.c +++ b/test/api/t2.c @@ -1,4 +1,4 @@ -/* $Id: t2.c,v 1.17 2005-09-13 11:51:07 adam Exp $ +/* $Id: t2.c,v 1.18 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -28,13 +28,16 @@ const char *myrec[] = { "\n", 0}; -int main(int argc, char **argv) +void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - init_data(zh, myrec); - do_query(__LINE__,zh, "@attr 1=4 my", 1); + YAZ_CHECK(tl_init_data(zh, myrec)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 my", 1)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN + diff --git a/test/api/t3.c b/test/api/t3.c index 7117907..0c409c0 100644 --- a/test/api/t3.c +++ b/test/api/t3.c @@ -1,4 +1,4 @@ -/* $Id: t3.c,v 1.18 2005-09-13 11:51:07 adam Exp $ +/* $Id: t3.c,v 1.19 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -30,14 +30,13 @@ const char *myrec[] ={ "\n", 0}; - -int main(int argc, char **argv) +static void tst(int argc, char **argv) { int i; - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - init_data(zh, myrec); + YAZ_CHECK(tl_init_data(zh, myrec)); for (i = 0; i<4; i++) { @@ -50,14 +49,30 @@ int main(int argc, char **argv) Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input, "@attr 1=4 my"); zint hits; - zebra_begin_trans (zh, 1); - zebra_begin_trans (zh, 0); + if (zebra_begin_trans (zh, 1) != ZEBRA_OK) + { + fprintf(stderr, "zebra_begin_trans failed\n"); + exit(1); + } + if (zebra_begin_trans (zh, 0) != ZEBRA_OK) + { + fprintf(stderr, "zebra_begin_trans failed\n"); + exit(1); + } sprintf(setname, "s%d", i+1); zebra_search_RPN (zh, odr_input, query, setname, &hits); - zebra_end_trans (zh); - zebra_end_trans (zh); + if (zebra_end_trans (zh) != ZEBRA_OK) + { + fprintf(stderr, "zebra_end_trans failed\n"); + exit(1); + } + if (zebra_end_trans (zh) != ZEBRA_OK) + { + fprintf(stderr, "zebra_end_trans failed\n"); + exit(1); + } yaz_pqf_destroy(parser); zebra_deleteResultSet(zh, Z_DeleteRequest_list, 1, &setnamep, &status); @@ -66,5 +81,8 @@ int main(int argc, char **argv) } zebra_commit(zh); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN + diff --git a/test/api/t4.c b/test/api/t4.c index 74687a5..4055c5a 100644 --- a/test/api/t4.c +++ b/test/api/t4.c @@ -1,4 +1,4 @@ -/* $Id: t4.c,v 1.18 2005-09-13 11:51:07 adam Exp $ +/* $Id: t4.c,v 1.19 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -32,29 +32,31 @@ const char *myrec[] = { #define NUMBER_TO_FETCH_MAX 1000 -int main(int argc, char **argv) +static void tst(int argc, char **argv) { int i; int number_to_be_inserted = 5; int number_to_fetch = 5; - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - init_data(zh, myrec); + YAZ_CHECK(tl_init_data(zh, myrec)); + + YAZ_CHECK(zebra_begin_trans (zh, 1) == ZEBRA_OK); - zebra_begin_trans (zh, 1); for (i = 0; i< number_to_be_inserted-1; i++) { /* -1 since already inserted one in init_data */ zebra_add_record(zh, myrec[0], strlen(myrec[0])); } - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); + zebra_close(zh); zebra_stop(zs); - zs = start_service(""); + zs = tl_zebra_start(""); zh = zebra_open(zs, 0); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_set_resource(zh, "sortmax", "3"); /* make small sort boundary */ for (i = 0; i<2; i++) @@ -88,7 +90,7 @@ int main(int argc, char **argv) odr_destroy(odr_input); - zebra_begin_trans(zh, 1); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); for (j = 0; j < number_to_fetch; j++) retrievalRecord[j].position = j+1; @@ -119,9 +121,11 @@ int main(int argc, char **argv) } odr_destroy(odr_output); - zebra_end_trans(zh); - + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); } zebra_commit(zh); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN + diff --git a/test/api/t5.c b/test/api/t5.c index 3705efe..a8fc54b 100644 --- a/test/api/t5.c +++ b/test/api/t5.c @@ -1,4 +1,4 @@ -/* $Id: t5.c,v 1.14 2005-09-13 11:51:07 adam Exp $ +/* $Id: t5.c,v 1.15 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -21,6 +21,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA */ /** t5.c: proximity searches */ +#include #include "testlib.h" const char *myrec[] = { @@ -29,72 +30,74 @@ const char *myrec[] = { "\nMy title x\n\n" , 0} ; - -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - init_data(zh, myrec); + YAZ_CHECK(tl_init_data(zh, myrec)); /* phrase searches */ - do_query(__LINE__, zh, "@attr 1=4 my", 3); - do_query(__LINE__, zh, "@attr 1=4 {my x}", 1); - do_query(__LINE__, zh, "@attr 1=4 @attr 4=1 {my x}", 1); - do_query(__LINE__, zh, "@attr 1=4 {my x}", 1); - do_query(__LINE__, zh, "@attr 1=4 {x my}", 0); - do_query(__LINE__, zh, "@attr 1=4 {my x title}", 1); - do_query(__LINE__, zh, "@attr 1=4 {my title}", 2); + YAZ_CHECK(tl_query(zh, "@attr 1=4 my", 3)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 {my x}", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=1 {my x}", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 {my x}", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 {x my}", 0)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 {my x title}", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 {my title}", 2)); /* and-list searches */ - do_query(__LINE__, zh, "@attr 1=4 @attr 4=6 {x my}", 2); - do_query(__LINE__, zh, "@attr 1=4 @attr 4=6 {my x}", 2); - do_query(__LINE__, zh, "@attr 1=4 @attr 4=6 {my my}", 3); - do_query(__LINE__, zh, "@attr 1=4 @attr 4=6 {e x}", 0); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {x my}", 2)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {my x}", 2)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {my my}", 3)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {e x}", 0)); /* or-list searches */ - do_query(__LINE__, zh, "@attr 1=4 @attr 4=105 {x my}", 3); - do_query(__LINE__, zh, "@attr 1=4 @attr 4=105 {my x}", 3); - do_query(__LINE__, zh, "@attr 1=4 @attr 4=105 {my my}", 3); - do_query(__LINE__, zh, "@attr 1=4 @attr 4=105 {e x}", 2); - do_query(__LINE__, zh, "@attr 1=4 @attr 4=106 {e x}", 2); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {x my}", 3)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {my x}", 3)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {my my}", 3)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {e x}", 2)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=106 {e x}", 2)); - do_query(__LINE__, zh, "@attr 1=4 @and x title", 2); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @and x title", 2)); /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */ - do_query(__LINE__, zh, "@prox 0 2 1 2 k 2 my x", 2); + YAZ_CHECK(tl_query(zh, "@prox 0 2 1 2 k 2 my x", 2)); /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */ - do_query(__LINE__, zh, "@prox 0 2 1 2 k 2 x my", 0); + YAZ_CHECK(tl_query(zh, "@prox 0 2 1 2 k 2 x my", 0)); /* exl=0 distance=2 order=0 relation=2 (<=), known, unit=word */ - do_query(__LINE__, zh, "@prox 0 2 0 2 k 2 x my", 2); + YAZ_CHECK(tl_query(zh, "@prox 0 2 0 2 k 2 x my", 2)); /* exl=0 distance=2 order=0 relation=3 (=), known, unit=word */ - do_query(__LINE__, zh, "@prox 0 2 1 3 k 2 my x", 1); + YAZ_CHECK(tl_query(zh, "@prox 0 2 1 3 k 2 my x", 1)); /* exl=1 distance=2 order=0 relation=3 (=), known, unit=word */ - do_query(__LINE__, zh, "@prox 1 2 1 3 k 2 my x", 1); + YAZ_CHECK(tl_query(zh, "@prox 1 2 1 3 k 2 my x", 1)); /* provoke unsupported use attribute */ - do_query_x(__LINE__, zh, "@attr 1=999 @attr 4=1 x", 0, 114); - do_query_x(__LINE__, zh, "@attr 1=999 @attr 4=6 x", 0, 114); - do_query_x(__LINE__, zh, "@attr 1=999 @attr 4=105 x", 0, 114); - do_query_x(__LINE__, zh, "@attr 1=999 @attr 4=109 123", 0, 114); - do_query_x(__LINE__, zh, "@attrset 1.2.840.10003.3.1 @attr 1=999 x", - 0, 114); + YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=1 x", 0, 114)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=6 x", 0, 114)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=105 x", 0, 114)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=109 123", 0, 114)); + YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.840.10003.3.1 @attr 1=999 x", + 0, 114)); /* provoke unsupported attribute set */ - do_query_x(__LINE__, zh, "@attrset 1.2.8 @attr 1=999 @attr 4=1 x", 0, 121); - do_query_x(__LINE__, zh, "@attrset 1.2.8 @attr 1=999 @attr 4=6 x", 0, - 121); - do_query_x(__LINE__, zh, "@attrset 1.2.8 @attr 1=999 @attr 4=105 x", 0, - 121); - do_query_x(__LINE__, zh, "@attrset 1.2.8 @attr 1=999 @attr 4=109 123", - 0, 121); + YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=1 x", 0, 121)); + YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=6 x", 0, + 121)); + YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=105 x", 0, + 121)); + YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=109 123", + 0, 121)); /* provoke unsupported relation */ - do_query_x(__LINE__, zh, "@attr 1=1016 @attr 2=6 x", 0, 117); - do_query_x(__LINE__, zh, "@attr 1=1016 @attr 2=6 @attr 4=109 x", 0, 114); + YAZ_CHECK(tl_query_x(zh, "@attr 1=1016 @attr 2=6 x", 0, 117)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=1016 @attr 2=6 @attr 4=109 x", 0, 114)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN + diff --git a/test/api/t6.c b/test/api/t6.c index ab8b259..f94052f 100644 --- a/test/api/t6.c +++ b/test/api/t6.c @@ -1,4 +1,4 @@ -/* $Id: t6.c,v 1.11 2005-09-13 11:51:07 adam Exp $ +/* $Id: t6.c,v 1.12 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -24,15 +24,15 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { int i; - ZebraService zs = start_up("zebra6.cfg", argc, argv); + ZebraService zs = tl_start_up("zebra6.cfg", argc, argv); ZebraHandle zh = zebra_open(zs, 0); srand(17); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); zebra_close(zh); @@ -41,9 +41,11 @@ int main(int argc, char **argv) int l; zh = zebra_open (zs, 0); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zh); + + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); - zebra_begin_trans (zh, 1); + YAZ_CHECK(zebra_begin_trans (zh, 1) == ZEBRA_OK); for (l = 0; l<100; l++) { @@ -70,17 +72,20 @@ int main(int argc, char **argv) strcat(rec_buf, ""); zebra_add_record (zh, rec_buf, strlen(rec_buf)); } - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_close(zh); } zh = zebra_open(zs, 0); + YAZ_CHECK(zh); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_set_resource(zh, "trunclimit", "2"); /* check massive truncation: bug #281 */ - do_query(__LINE__, zh, "@attr 1=4 @attr 2=1 z", -1); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=1 z", -1)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/api/t7.c b/test/api/t7.c index cdae308..a57726c 100644 --- a/test/api/t7.c +++ b/test/api/t7.c @@ -1,4 +1,4 @@ -/* $Id: t7.c,v 1.10 2005-09-13 11:51:07 adam Exp $ +/* $Id: t7.c,v 1.11 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -31,15 +31,13 @@ const char *recs[] = { "\n", 0}; - -int main(int argc, char **argv) +static void tst(int argc, char **argv) { const char *setname1 = "set1"; const char *setname2 = "set2"; const char *setname3 = "set3"; int status; - ZEBRA_RES ret; - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open (zs, 0); ODR odr_input = odr_createmem (ODR_DECODE); ODR odr_output = odr_createmem (ODR_ENCODE); @@ -48,46 +46,26 @@ int main(int argc, char **argv) Z_SortKeySpecList *spec = yaz_sort_spec (odr_output, "1=4 <"); zint hits; - init_data(zh, recs); + YAZ_CHECK(tl_init_data(zh, recs)); - zebra_begin_trans(zh, 0); + YAZ_CHECK(zebra_begin_trans(zh, 0) == ZEBRA_OK); - ret = zebra_search_RPN(zh, odr_input, query, setname1, &hits); - if (ret == ZEBRA_FAIL) - { - int code = zebra_errCode(zh); - printf("search returned ERROR, OK was expected ret=%d " - "code=%d\n", ret, code); - } - - ret = zebra_sort(zh, odr_output, 1, &setname1, setname2, spec, &status); - if (ret == ZEBRA_FAIL) - { - int code = zebra_errCode(zh); - printf("sort A returned ERROR, OK was expected ret=%d status=%d " - "code=%d\n", ret, status, code); - exit(1); - } - - ret = zebra_sort(zh, odr_output, 1, &setname2, setname3, spec, &status); - if (ret == ZEBRA_FAIL) - { - int code = zebra_errCode(zh); - printf("sort B returned ERROR, OK was expected ret=%d status=%d " - "code=%d\n", ret, status, code); - exit(1); - } + YAZ_CHECK(zebra_search_RPN(zh, odr_input, query, setname1, &hits) == + ZEBRA_OK); + + YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname1, setname2, spec, + &status) + == ZEBRA_OK); + YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname2, setname3, spec, + &status) == ZEBRA_OK); spec = yaz_sort_spec(odr_output, "1=5 <"); /* invalid sort spec */ - ret = zebra_sort(zh, odr_output, 1, &setname1, setname2, spec, &status); - if (ret == ZEBRA_OK) - { - printf("sort C returned OK, ERROR was expected ret=%d status=%d\n", - ret, status); - exit(1); - } - zebra_end_trans(zh); + YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname1, setname2, spec, + &status) == ZEBRA_FAIL); + + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); + yaz_pqf_destroy(parser); /* @@ -99,5 +77,7 @@ int main(int argc, char **argv) zebra_commit(zh); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/api/t8.c b/test/api/t8.c index 2cc3c3d..484cccf 100644 --- a/test/api/t8.c +++ b/test/api/t8.c @@ -1,4 +1,4 @@ -/* $Id: t8.c,v 1.8 2005-09-13 11:51:07 adam Exp $ +/* $Id: t8.c,v 1.9 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -55,41 +55,40 @@ const char *recs[] = { 0}; - - -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up("zebra8.cfg", argc, argv); + ZebraService zs = tl_start_up("zebra8.cfg", argc, argv); ZebraHandle zh = zebra_open (zs, 0); - init_data(zh, recs); + YAZ_CHECK(tl_init_data(zh, recs)); -#define Q(q,n) do_query(__LINE__,zh,q,n) /* couple of simple queries just to see that we have indexed the stuff */ - Q( "@attr 1=4 title",2 ); - Q( "title",2 ); + YAZ_CHECK(tl_query(zh, "@attr 1=4 title", 2)); + YAZ_CHECK(tl_query(zh, "title", 2)); /* 1=2038: West-Bounding-Coordinate 2039: East: 2040: North: 2041 South*/ /* 4=109: numeric string */ /* 2=3: equal 2=1: less, 2=4: greater or equal 2=5 greater */ /* N>25, search attributes work */ - Q( "@attr 2=4 @attr gils 1=2040 @attr 4=109 25",2); + YAZ_CHECK(tl_query(zh, "@attr 2=4 @attr gils 1=2040 @attr 4=109 25", 2)); /* N=41, get rec1 only */ - Q( "@attr 2=3 @attr gils 1=2040 @attr 4=109 41",1); + YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2040 @attr 4=109 41", 1)); /* N=49, get both records */ - Q( "@attr 2=3 @attr gils 1=2040 @attr 4=109 49",2); + YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2040 @attr 4=109 49", 2)); /* W=-120 get both records */ - Q( "@attr 2=3 @attr gils 1=2038 @attr 4=109 -120",2); + YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2038 @attr 4=109 -120", 2)); /* W<-122 get only rec1 */ - Q( "@attr 2=1 @attr gils 1=2038 @attr 4=109 '-120' ",1); + YAZ_CHECK(tl_query(zh, "@attr 2=1 @attr gils 1=2038 @attr 4=109 '-120' ", 1)); /* N=41 and N=49 get only rec2 */ - Q( "@attr 2=3 @attr gils 1=2040 @attr 4=109 \"41 49\" ",1); + YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2040 @attr 4=109 \"41 49\" ", 1)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/api/t9.c b/test/api/t9.c index 3f55218..0637e2e 100644 --- a/test/api/t9.c +++ b/test/api/t9.c @@ -1,4 +1,4 @@ -/* $Id: t9.c,v 1.7 2005-09-13 11:51:07 adam Exp $ +/* $Id: t9.c,v 1.8 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -26,26 +26,25 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "rankingrecords.h" -#define qry(zh,query,hits,string,score) \ - ranking_query(__LINE__,(zh),(query),(hits),(string),(score)) - -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - init_data(zh, recs); - - qry( zh, "@attr 1=1016 @attr 2=102 the", - 3, "first title", 997 ); - - qry( zh, "@attr 1=1016 @attr 2=102 foo", - 3, "second title", 850 ); - + YAZ_CHECK(tl_init_data(zh, recs)); + + YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 the", + 3, "first title", 997 )); + + YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 foo", + 3, "second title", 850 )); + /* get the record with the most significant hit, that is the 'bar' */ /* as that is the rarest of my search words */ - qry( zh, "@attr 1=1016 @attr 2=102 @or @or the foo bar", - 3, "third title", 940 ); - - return close_down(zh, zs, 0); + YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 @or @or the foo bar", + 3, "third title", 940 )); + + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/api/testlib.c b/test/api/testlib.c index 36323da..fe1ecc1 100644 --- a/test/api/testlib.c +++ b/test/api/testlib.c @@ -1,4 +1,4 @@ -/* $Id: testlib.c,v 1.29 2005-12-15 13:28:32 adam Exp $ +/* $Id: testlib.c,v 1.30 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -42,7 +42,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA /* FIXME - parse command line arguments to set log levels etc */ int log_level=0; /* not static, t*.c may use it */ -void start_log(int argc, char **argv) +void tl_start_log(int argc, char **argv) { int cmd_level = 0; char logname[2048]; @@ -60,14 +60,14 @@ void start_log(int argc, char **argv) } /** - * start_up : do common start things, and a zebra_start + * tl_start_up : do common start things, and a zebra_start * - nmem_init * - build the name of logfile from argv[0], and open it * if no argv passed, do not open a log * - read zebra.cfg from env var srcdir if it exists; otherwise current dir * default to zebra.cfg, if no name is given */ -ZebraService start_up(char *cfgname, int argc, char **argv) +ZebraService tl_start_up(char *cfgname, int argc, char **argv) { #if HAVE_SYS_RESOURCE_H #if HAVE_SYS_TIME_H @@ -78,14 +78,14 @@ ZebraService start_up(char *cfgname, int argc, char **argv) #endif #endif nmem_init(); - start_log(argc, argv); - return start_service(cfgname); + tl_start_log(argc, argv); + return tl_zebra_start(cfgname); } /** * get_srcdir: return env srcdir or . (if does does not exist) */ -const char *get_srcdir() +const char *tl_get_srcdir() { const char *srcdir = getenv("srcdir"); if (!srcdir || ! *srcdir) @@ -93,72 +93,66 @@ const char *get_srcdir() return srcdir; } -/** start_service - do a zebra_start with a decent config name */ -ZebraService start_service(const char *cfgname) +/** tl_zebra_start - do a zebra_start with a decent config name */ +ZebraService tl_zebra_start(const char *cfgname) { char cfg[256]; - const char *srcdir = get_srcdir(); - ZebraService zs; + const char *srcdir = tl_get_srcdir(); if (!cfgname || ! *cfgname ) cfgname="zebra.cfg"; sprintf(cfg, "%.200s/%.50s", srcdir, cfgname); - zs = zebra_start(cfg); - TL_ASSERT2(zs, "zebra_start_failed. Missing config file?"); - return zs; + return zebra_start(cfg); } - -/** close_down closes down the zebra, logfile, nmem, xmalloc etc. logs an OK */ -int close_down(ZebraHandle zh, ZebraService zs, int retcode) +/** tl_close_down closes down the zebra, logfile, nmem, xmalloc etc. logs an OK */ +int tl_close_down(ZebraHandle zh, ZebraService zs) { if (zh) zebra_close(zh); if (zs) zebra_stop(zs); - if (retcode) - yaz_log(log_level,"========= Exiting with return code %d", retcode); - else - yaz_log(log_level,"========= All tests OK"); nmem_exit(); xmalloc_trav("x"); - return retcode; + return 1; } /** inits the database and inserts test data */ -void init_data(ZebraHandle zh, const char **recs) +int tl_init_data(ZebraHandle zh, const char **recs) { - int i; - char *addinfo; - assert(zh); - zebra_select_database(zh, "Default"); + ZEBRA_RES res; + + if (!zh) + return 0; + + if (zebra_select_database(zh, "Default") != ZEBRA_OK) + return 0; + yaz_log(log_level, "going to call init"); - i = zebra_init(zh); - yaz_log(log_level, "init_data returned %d", i); - if (i) + res = zebra_init(zh); + if (res == ZEBRA_FAIL) { - yaz_log(log_level, "init_data: zebra_init failed with %d", i); - printf("init_data failed with %d\n", i); - zebra_result(zh, &i, &addinfo); - yaz_log(log_level, "Error %d %s", i, addinfo); - printf(" Error %d %s\n", i, addinfo); - TL_ASSERT(i == 0); + yaz_log(log_level, "init_data: zebra_init failed with %d", res); + printf("init_data failed with %d\n", res); + return 0; } if (recs) { - zebra_begin_trans (zh, 1); + int i; + if (zebra_begin_trans (zh, 1) != ZEBRA_OK) + return 0; for (i = 0; recs[i]; i++) zebra_add_record(zh, recs[i], strlen(recs[i])); - zebra_end_trans(zh); + if (zebra_end_trans(zh) != ZEBRA_OK) + return 0; zebra_commit(zh); } - + return 1; } -int do_query_x(int lineno, ZebraHandle zh, const char *query, zint exphits, - int experror) +int tl_query_x(ZebraHandle zh, const char *query, zint exphits, int experror) { ODR odr; YAZ_PQF_Parser parser; @@ -168,13 +162,20 @@ int do_query_x(int lineno, ZebraHandle zh, const char *query, zint exphits, ZEBRA_RES rc; yaz_log(log_level, "======================================"); - yaz_log(log_level, "qry[%d]: %s", lineno, query); - odr = odr_createmem (ODR_DECODE); + yaz_log(log_level, "query: %s", query); + odr = odr_createmem (ODR_DECODE); + if (!odr) + return 0; parser = yaz_pqf_create(); rpn = yaz_pqf_parse(parser, odr, query); yaz_pqf_destroy(parser); - TL_ASSERT2(rpn, "Parse of pqf failed"); + if (!rpn) + { + odr_destroy(odr); + return 0; + } + rc = zebra_search_RPN(zh, odr, rpn, setname, &hits); if (experror) { @@ -185,7 +186,7 @@ int do_query_x(int lineno, ZebraHandle zh, const char *query, zint exphits, "expected", rc); printf("Error: search returned %d (OK), but error was expected\n" "%s\n", rc, query); - TL_ASSERT(rc == ZEBRA_FAIL); + return 0; } code = zebra_errCode(zh); if (code != experror) @@ -195,7 +196,7 @@ int do_query_x(int lineno, ZebraHandle zh, const char *query, zint exphits, printf("Error: search returned error code %d, but error %d was " "expected\n%s\n", code, experror, query); - TL_ASSERT(code == experror); + return 0; } } else @@ -206,7 +207,7 @@ int do_query_x(int lineno, ZebraHandle zh, const char *query, zint exphits, printf("Error: search returned %d. Code %d\n%s\n", rc, code, query); - exit (1); + return 0; } if (exphits != -1 && hits != exphits) { @@ -215,23 +216,23 @@ int do_query_x(int lineno, ZebraHandle zh, const char *query, zint exphits, printf("Error: search returned " ZINT_FORMAT " hits instead of " ZINT_FORMAT "\n%s\n", hits, exphits, query); - exit (1); + return 0; } } - odr_destroy (odr); - return hits; + odr_destroy(odr); + return 1; } -int do_query(int lineno, ZebraHandle zh, const char *query, zint exphits) +int tl_query(ZebraHandle zh, const char *query, zint exphits) { - return do_query_x(lineno, zh, query, exphits, 0); + return tl_query_x(zh, query, exphits, 0); } -void do_scan(int lineno, ZebraHandle zh, const char *query, - int pos, int num, - int exp_pos, int exp_num, int exp_partial, - const char **exp_entries) +int tl_scan(ZebraHandle zh, const char *query, + int pos, int num, + int exp_pos, int exp_num, int exp_partial, + const char **exp_entries) { ODR odr = odr_createmem(ODR_ENCODE); ZebraScanEntry *entries = 0; @@ -239,7 +240,7 @@ void do_scan(int lineno, ZebraHandle zh, const char *query, ZEBRA_RES res; yaz_log(log_level, "======================================"); - yaz_log(log_level, "scan[%d]: pos=%d num=%d %s", lineno, pos, num, query); + yaz_log(log_level, "scan: pos=%d num=%d %s", pos, num, query); res = zebra_scan_PQF(zh, odr, query, &pos, &num, &entries, &partial, 0 /* setname */); @@ -247,7 +248,7 @@ void do_scan(int lineno, ZebraHandle zh, const char *query, { printf("Error: scan returned %d (FAIL), but no error was expected\n" "%s\n", res, query); - exit(1); + return 0; } else { @@ -277,7 +278,7 @@ void do_scan(int lineno, ZebraHandle zh, const char *query, fails++; } if (fails) - exit(1); + return 0; fails = 0; if (exp_entries) { @@ -294,67 +295,65 @@ void do_scan(int lineno, ZebraHandle zh, const char *query, } } if (fails) - exit(0); + return 0; } odr_destroy(odr); + return 1; } /** * makes a query, checks number of hits, and for the first hit, that * it contains the given string, and that it gets the right score */ -void ranking_query(int lineno, ZebraHandle zh, char *query, - int exphits, char *firstrec, int firstscore) +int tl_ranking_query(ZebraHandle zh, char *query, + int exphits, char *firstrec, int firstscore) { ZebraRetrievalRecord retrievalRecord[10]; ODR odr_output = odr_createmem (ODR_ENCODE); const char *setname="rsetname"; - int hits; int rc; int i; - hits = do_query(lineno, zh, query, exphits); + if (!tl_query(zh, query, exphits)) + return 0; for (i = 0; i<10; i++) retrievalRecord[i].position = i+1; rc = zebra_records_retrieve (zh, odr_output, setname, 0, - VAL_TEXT_XML, hits, retrievalRecord); - - if (rc) - { - printf("Error: retrieve returned %d \n%s\n",rc,query); - exit (1); - } + VAL_TEXT_XML, exphits, retrievalRecord); + if (rc != ZEBRA_OK) + return 0; if (!strstr(retrievalRecord[0].buf, firstrec)) { printf("Error: Got the wrong record first\n"); printf("Expected '%s' but got\n", firstrec); printf("%.*s\n", retrievalRecord[0].len, retrievalRecord[0].buf); - exit(1); + return 0; } if (retrievalRecord[0].score != firstscore) { printf("Error: first rec got score %d instead of %d\n", retrievalRecord[0].score, firstscore); - exit(1); + return 0; } odr_destroy (odr_output); + return 1; } -void meta_query(int lineno, ZebraHandle zh, char *query, int exphits, - zint *ids) +int tl_meta_query(ZebraHandle zh, char *query, int exphits, + zint *ids) { ZebraMetaRecord *meta; ODR odr_output = odr_createmem (ODR_ENCODE); const char *setname="rsetname"; zint *positions = (zint *) malloc(1 + (exphits * sizeof(zint))); - int hits; int i; - hits = do_query(lineno, zh, query, exphits); + if (!tl_query(zh, query, exphits)) + return 0; for (i = 0; ioccurred = 1; } -void check_filter(ZebraService zs, const char *name) +void tl_check_filter(ZebraService zs, const char *name) { struct finfo f; diff --git a/test/api/testlib.h b/test/api/testlib.h index 298e880..0354356 100644 --- a/test/api/testlib.h +++ b/test/api/testlib.h @@ -1,4 +1,4 @@ -/* $Id: testlib.h,v 1.17 2005-12-15 13:28:32 adam Exp $ +/* $Id: testlib.h,v 1.18 2006-03-31 15:58:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -27,37 +27,37 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include #include +#include /** - * start_up : Does all the usual start functions + * tl_start_up : Does all the usual start functions * - nmem_init * - build the name of logfile from argv[0], and open it * if no argv passed, do not open a log * - read zebra.cfg from env var srcdir if it exists; otherwise current dir * default to zebra.cfg, if no name is given */ -ZebraService start_up(char *cfgname, int argc, char **argv); +ZebraService tl_start_up(char *cfgname, int argc, char **argv); /** * get_srcdir : returns the source dir. Most often ".", but when * making distcheck, some other dir */ -const char *get_srcdir(); +const char *tl_get_srcdir(); /** * start_log: open a log file */ /* FIXME - parse command line arguments to set log levels etc */ -void start_log(int argc, char **argv); +void tl_start_log(int argc, char **argv); /** - * start_service - do a zebra_start with a decent config name + * tl_zebra_start - do a zebra_start with a decent config name * Takes care of checking the environment for srcdir (as needed by distcheck) * and uses that if need be. * The name defaults to zebra.cfg, if null or emtpy */ -ZebraService start_service(const char *cfgname); - +ZebraService tl_zebra_start(const char *cfgname); /** * close_down closes it all down @@ -67,54 +67,60 @@ ZebraService start_service(const char *cfgname); * closes down nmem and xmalloc * returns the retcode, for use in return or exit in main() */ -int close_down(ZebraHandle zh, ZebraService zs, int retcode); +int tl_close_down(ZebraHandle zh, ZebraService zs + ) GCC_ATTRIBUTE((warn_unused_result)); /** inits the database and inserts test data */ -void init_data(ZebraHandle zh, const char **recs); - +int tl_init_data(ZebraHandle zh, const char **recs + ) GCC_ATTRIBUTE((warn_unused_result)); /** - * do_query does a simple query, and checks that the number of hits matches + * tl_query does a simple query, and checks that the number of hits matches */ -int do_query(int lineno, ZebraHandle zh, const char *query, zint exphits); +int tl_query(ZebraHandle zh, const char *query, zint exphits + ) GCC_ATTRIBUTE((warn_unused_result)); /** - * do_query does a simple query, and checks that error is what is expected + * tl_query does a simple query, and checks that error is what is expected */ -int do_query_x(int lineno, ZebraHandle zh, const char *query, zint exphits, - int experror); - +int tl_query_x(ZebraHandle zh, const char *query, zint exphits, + int experror + ) GCC_ATTRIBUTE((warn_unused_result)); + /** - * do_scan is a utility for scan testing + * tl_scan is a utility for scan testing */ -void do_scan(int lineno, ZebraHandle zh, const char *query, - int pos, int num, /* input params */ - int exp_pos, int exp_num, int exp_partial, /* expected result */ - const char **exp_entries /* expected entries (or NULL) */ - ); +int tl_scan(ZebraHandle zh, const char *query, + int pos, int num, /* input params */ + int exp_pos, int exp_num, int exp_partial, /* expected result */ + const char **exp_entries /* expected entries (or NULL) */ + ) GCC_ATTRIBUTE((warn_unused_result)); -void do_sort(ZebraHandle zh, const char *query, zint hits, zint *exp); +int tl_sort(ZebraHandle zh, const char *query, zint hits, zint *exp + ) GCC_ATTRIBUTE((warn_unused_result)); /** * ranking_query makes a query, checks number of hits, and for * the first hit, that it contains the given string, and that it * gets the right score */ -void ranking_query(int lineno, ZebraHandle zh, char *query, - int exphits, char *firstrec, int firstscore ); +int tl_ranking_query(ZebraHandle zh, char *query, + int exphits, char *firstrec, int firstscore + ) GCC_ATTRIBUTE((warn_unused_result)); /** * meta_query makes a query, checks number of hits, and for * checks that the all records in result set has the proper identifiers (ids) */ -void meta_query(int lineno, ZebraHandle zh, char *query, int exphits, - zint *ids); +int tl_meta_query(ZebraHandle zh, char *query, int exphits, + zint *ids + ) GCC_ATTRIBUTE((warn_unused_result)); /** * if filter given by name does not exist, exit nicely but warn in log */ -void check_filter(ZebraService zs, const char *name); +void tl_check_filter(ZebraService zs, const char *name); -#define TL_ASSERT(x) if (!(x)) { yaz_log(YLOG_FATAL, "%s:%d TL_ASSERT(%s) failed", __FILE__, __LINE__, #x); exit(1); } -#define TL_ASSERT2(x,m) if (!(x)) { yaz_log(YLOG_WARN, "%s", m); yaz_log(YLOG_FATAL, "%s:%d TL_ASSERT(%s) failed", __FILE__, __LINE__, #x); exit(1); } +#define TL_MAIN int main(int argc, char **argv) { \ + YAZ_CHECK_INIT(argc, argv); tst(argc, argv); YAZ_CHECK_TERM; } diff --git a/test/charmap/charmap1.c b/test/charmap/charmap1.c index 73afa88..e53dce6 100644 --- a/test/charmap/charmap1.c +++ b/test/charmap/charmap1.c @@ -1,4 +1,4 @@ -/* $Id: charmap1.c,v 1.8 2005-09-13 11:51:07 adam Exp $ +/* $Id: charmap1.c,v 1.9 2006-03-31 15:58:06 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -22,64 +22,67 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "../api/testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); char path[256]; - check_filter(zs, "grs.xml"); + tl_check_filter(zs, "grs.xml"); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); - zebra_begin_trans(zh, 1); - sprintf(path, "%.200s/x.xml", get_srcdir()); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); + + sprintf(path, "%.200s/x.xml", tl_get_srcdir()); zebra_repository_update(zh, path); - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - do_query(__LINE__, zh, "@term string æ", 1); + YAZ_CHECK(tl_query(zh, "@term string æ", 1)); /* search for UNICODE 1E25 - letter h with dot below */ - do_query(__LINE__, zh, "@term string ḥ", 1); + YAZ_CHECK(tl_query(zh, "@term string ḥ", 1)); /* search for UNICODE A ring */ - do_query(__LINE__, zh, "@term string lås", 1); + YAZ_CHECK(tl_query(zh, "@term string lås", 1)); /* search for aa */ - do_query(__LINE__, zh, "@term string laas", 1); + YAZ_CHECK(tl_query(zh, "@term string laas", 1)); /* search for aa regular-1 */ - do_query(__LINE__, zh, "@attr 5=102 @term string lås", 1); + YAZ_CHECK(tl_query(zh, "@attr 5=102 @term string lås", 1)); /* search for aa regular-2 */ - do_query(__LINE__, zh, "@attr 5=103 @term string lås", 1); + YAZ_CHECK(tl_query(zh, "@attr 5=103 @term string lås", 1)); /* search for aa trunc=104 */ - do_query(__LINE__, zh, "@attr 5=104 @term string laas", 1); + YAZ_CHECK(tl_query(zh, "@attr 5=104 @term string laas", 1)); /* search for aa trunc=105 */ - do_query(__LINE__, zh, "@attr 5=104 @term string laas", 1); + YAZ_CHECK(tl_query(zh, "@attr 5=104 @term string laas", 1)); /* search for aaa */ - do_query(__LINE__, zh, "@term string laaas", 0); + YAZ_CHECK(tl_query(zh, "@term string laaas", 0)); /* search ABC in title:0 . */ - do_query(__LINE__, zh, "@attr 4=3 @attr 1=4 ABC", 1); + YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 ABC", 1)); /* search DEF in title:0 . */ - do_query(__LINE__, zh, "@attr 4=3 @attr 1=4 DEF", 0); + YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 DEF", 0)); /* search [ in title:0 . */ - do_query(__LINE__, zh, "@attr 4=3 @attr 1=4 [", 1); + YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 [", 1)); /* search \ in title:0 . */ - do_query(__LINE__, zh, "@attr 4=3 @attr 1=4 \\\\\\\\", 1); + YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 \\\\\\\\", 1)); /* search { in title:0 . */ - do_query(__LINE__, zh, "@attr 4=3 @attr 1=4 \\{", 1); - - return close_down(zh, zs, 0); + YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 \\{", 1)); + + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/espec/t1.c b/test/espec/t1.c index f168a9b..3f5cf94 100644 --- a/test/espec/t1.c +++ b/test/espec/t1.c @@ -1,4 +1,4 @@ -/* $Id: t1.c,v 1.5 2005-09-13 11:51:08 adam Exp $ +/* $Id: t1.c,v 1.6 2006-03-31 15:58:06 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -22,35 +22,33 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "../api/testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); char path[256]; - int i, errs = 0; + int i; - check_filter(zs, "grs.xml"); + tl_check_filter(zs, "grs.xml"); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); - zebra_begin_trans(zh, 1); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); for (i = 1; i <= 1; i++) { - sprintf(path, "%.200s/rec%d.xml", get_srcdir(), i); + sprintf(path, "%.200s/rec%d.xml", tl_get_srcdir(), i); zebra_repository_update(zh, path); } - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - do_query(__LINE__,zh, "@attr 1=1016 X2", 1); - do_query(__LINE__,zh, "@attr 1=1016 {X2 X3}", 1); + YAZ_CHECK(tl_query(zh, "@attr 1=1016 X2", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=1016 {X2 X3}", 1)); - if (errs) - { - fprintf(stderr, "%d sysnos did not match\n", errs); - exit(1); - } - return close_down(zh, zs, 0); + + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/filters/grs.marc.c b/test/filters/grs.marc.c index ff7aac9..51e2f49 100644 --- a/test/filters/grs.marc.c +++ b/test/filters/grs.marc.c @@ -1,4 +1,4 @@ -/* $Id: grs.marc.c,v 1.2 2005-09-13 11:51:08 adam Exp $ +/* $Id: grs.marc.c,v 1.3 2006-03-31 15:58:07 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -22,29 +22,32 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "../api/testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); char path[256]; - check_filter(zs, "grs.marc"); + tl_check_filter(zs, "grs.marc"); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_set_resource(zh, "recordType", "grs.marc.usmarc"); zebra_init(zh); - zebra_begin_trans(zh, 1); - sprintf(path, "%.200s/record.mrc", get_srcdir()); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); + sprintf(path, "%.200s/record.mrc", tl_get_srcdir()); zebra_repository_update(zh, path); - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - do_query(__LINE__, zh, "computer", 1); + YAZ_CHECK(tl_query(zh, "computer", 1)); - do_query(__LINE__, zh, "computee", 0); + YAZ_CHECK(tl_query(zh, "computee", 0)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN + diff --git a/test/filters/grs.xml.c b/test/filters/grs.xml.c index 4941910..429d074 100644 --- a/test/filters/grs.xml.c +++ b/test/filters/grs.xml.c @@ -1,4 +1,4 @@ -/* $Id: grs.xml.c,v 1.2 2005-09-13 11:51:08 adam Exp $ +/* $Id: grs.xml.c,v 1.3 2006-03-31 15:58:07 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -20,31 +20,35 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include "../api/testlib.h" -int main(int argc, char **argv) +void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); char path[256]; - check_filter(zs, "grs.xml"); + tl_check_filter(zs, "grs.xml"); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_set_resource(zh, "recordType", "grs.xml"); zebra_init(zh); - zebra_begin_trans(zh, 1); - sprintf(path, "%.200s/record.xml", get_srcdir()); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); + sprintf(path, "%.200s/record.xml", tl_get_srcdir()); zebra_repository_update(zh, path); - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - do_query(__LINE__, zh, "@attr 1=/ text", 1); + YAZ_CHECK(tl_query(zh, "@attr 1=/ text", 1)); - do_query(__LINE__, zh, "@attr 1=/ test", 0); + YAZ_CHECK(tl_query(zh, "@attr 1=/ test", 0)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN + diff --git a/test/filters/text.c b/test/filters/text.c index 4880eb3..c16a859 100644 --- a/test/filters/text.c +++ b/test/filters/text.c @@ -1,4 +1,4 @@ -/* $Id: text.c,v 1.2 2005-09-13 11:51:08 adam Exp $ +/* $Id: text.c,v 1.3 2006-03-31 15:58:07 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -22,41 +22,43 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "../api/testlib.h" -int main(int argc, char **argv) +void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); char path[256]; - check_filter(zs, "text"); + tl_check_filter(zs, "text"); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_set_resource(zh, "recordType", "text"); zebra_init(zh); - zebra_begin_trans(zh, 1); - sprintf(path, "%.200s/record.xml", get_srcdir()); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); + sprintf(path, "%.200s/record.xml", tl_get_srcdir()); zebra_repository_update(zh, path); - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - do_query(__LINE__, zh, "text", 1); + YAZ_CHECK(tl_query(zh, "text", 1)); - do_query(__LINE__, zh, "test", 0); + YAZ_CHECK(tl_query(zh, "test", 0)); zebra_set_resource(zh, "recordType", "text.$"); - zebra_begin_trans(zh, 1); - sprintf(path, "%.200s/record.xml", get_srcdir()); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); + sprintf(path, "%.200s/record.xml", tl_get_srcdir()); zebra_repository_update(zh, path); - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - do_query(__LINE__, zh, "text", 3); + YAZ_CHECK(tl_query(zh, "text", 3)); - do_query(__LINE__, zh, "here", 2); + YAZ_CHECK(tl_query(zh, "here", 2)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/marcxml/t1.c b/test/marcxml/t1.c index 9b4aa64..9d096ab 100644 --- a/test/marcxml/t1.c +++ b/test/marcxml/t1.c @@ -1,4 +1,4 @@ -/* $Id: t1.c,v 1.6 2005-09-13 11:51:08 adam Exp $ +/* $Id: t1.c,v 1.7 2006-03-31 15:58:07 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -22,30 +22,32 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); char path[256]; - check_filter(zs, "grs.xml"); - zebra_select_database(zh, "Default"); + tl_check_filter(zs, "grs.xml"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); - zebra_begin_trans(zh, 1); - sprintf(path, "%.200s/m1.xml", get_srcdir()); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); + sprintf(path, "%.200s/m1.xml", tl_get_srcdir()); zebra_repository_update(zh, path); - sprintf(path, "%.200s/m2.xml", get_srcdir()); + sprintf(path, "%.200s/m2.xml", tl_get_srcdir()); zebra_repository_update(zh, path); - sprintf(path, "%.200s/m3.xml", get_srcdir()); + sprintf(path, "%.200s/m3.xml", tl_get_srcdir()); zebra_repository_update(zh, path); - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - - do_query(__LINE__,zh, "@and " + + YAZ_CHECK(tl_query(zh, "@and " "@attr 1=54 eng " - "@and @attr 1=1003 jack @attr 1=4 computer", 2); + "@and @attr 1=1003 jack @attr 1=4 computer", 2)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/marcxml/t2.c b/test/marcxml/t2.c index fc854c7..19378b4 100644 --- a/test/marcxml/t2.c +++ b/test/marcxml/t2.c @@ -1,4 +1,4 @@ -/* $Id: t2.c,v 1.5 2005-09-13 11:51:08 adam Exp $ +/* $Id: t2.c,v 1.6 2006-03-31 15:58:08 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -22,26 +22,28 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); char path[256]; - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); zebra_set_resource(zh, "recordType", "grs.marcxml.record"); - zebra_begin_trans(zh, 1); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); - sprintf(path, "%.200s/sample-marc", get_srcdir()); + sprintf(path, "%.200s/sample-marc", tl_get_srcdir()); zebra_repository_update(zh, path); - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - do_query(__LINE__,zh, "@and @attr 1=1003 jack @attr 1=4 computer", 2); + YAZ_CHECK(tl_query(zh, "@and @attr 1=1003 jack @attr 1=4 computer", 2)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/mbox/mbox1.c b/test/mbox/mbox1.c index f2d83d5..340c7b0 100644 --- a/test/mbox/mbox1.c +++ b/test/mbox/mbox1.c @@ -1,4 +1,4 @@ -/* $Id: mbox1.c,v 1.2 2005-09-13 11:51:08 adam Exp $ +/* $Id: mbox1.c,v 1.3 2006-03-31 15:58:08 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -22,23 +22,23 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { char path[256]; - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - check_filter(zs, "grs.regx"); - zebra_select_database(zh, "Default"); + tl_check_filter(zs, "grs.regx"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); - zebra_begin_trans(zh, 1); - sprintf(path, "%.200s/mail1.mbx", get_srcdir()); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); + sprintf(path, "%.200s/mail1.mbx", tl_get_srcdir()); zebra_repository_update(zh, path); - sprintf(path, "%.200s/mail3.mbx", get_srcdir()); + sprintf(path, "%.200s/mail3.mbx", tl_get_srcdir()); zebra_repository_update(zh, path); #if 0 @@ -47,8 +47,10 @@ int main(int argc, char **argv) zebra_repository_update(zh, path); #endif - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - - return close_down(zh, zs, 0); + + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/rusmarc/t1.c b/test/rusmarc/t1.c index dafda87..4ec7e21 100644 --- a/test/rusmarc/t1.c +++ b/test/rusmarc/t1.c @@ -1,4 +1,4 @@ -/* $Id: t1.c,v 1.4 2005-09-13 11:51:09 adam Exp $ +/* $Id: t1.c,v 1.5 2006-03-31 15:58:09 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -35,27 +35,28 @@ void check_koi8r() yaz_iconv_close(cd); } -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); char path[256]; check_koi8r(); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); - - zebra_begin_trans(zh, 1); - sprintf(path, "%.200s/records/simple-rusmarc", get_srcdir()); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); + sprintf(path, "%.200s/records/simple-rusmarc", tl_get_srcdir()); zebra_repository_update(zh, path); - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - do_query(__LINE__, zh, "@attr 1=21 \xfa\xc1\xcd\xd1\xd4\xc9\xce", 1); + YAZ_CHECK(tl_query(zh, "@attr 1=21 \xfa\xc1\xcd\xd1\xd4\xc9\xce", 1)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/sort/sort1.c b/test/sort/sort1.c index 2b4d8aa..b11f17a 100644 --- a/test/sort/sort1.c +++ b/test/sort/sort1.c @@ -1,4 +1,4 @@ -/* $Id: sort1.c,v 1.6 2005-09-13 11:51:09 adam Exp $ +/* $Id: sort1.c,v 1.7 2006-03-31 15:58:09 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -20,47 +20,49 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include #include "../api/testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); zint ids[5]; char path[256]; int i; - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); - zebra_begin_trans(zh, 1); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); for (i = 1; i <= 4; i++) { - sprintf(path, "%.200s/rec%d.xml", get_srcdir(), i); + sprintf(path, "%.200s/rec%d.xml", tl_get_srcdir(), i); zebra_repository_update(zh, path); } - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); ids[0] = 3; ids[1] = 2; ids[2] = 4; ids[3] = 5; - do_sort(zh, "@or computer @attr 7=1 @attr 1=30 0", 4, ids); + YAZ_CHECK(tl_sort(zh, "@or computer @attr 7=1 @attr 1=30 0", 4, ids)); ids[0] = 5; ids[1] = 4; ids[2] = 2; ids[3] = 3; - do_sort(zh, "@or computer @attr 7=1 @attr 1=1021 0", 4, ids); + YAZ_CHECK(tl_sort(zh, "@or computer @attr 7=1 @attr 1=1021 0", 4, ids)); ids[0] = 2; ids[1] = 5; ids[2] = 4; ids[3] = 3; - do_sort(zh, "@or computer @attr 7=1 @attr 1=1021 @attr 4=109 0", 4, ids); + YAZ_CHECK(tl_sort(zh, "@or computer @attr 7=1 @attr 1=1021 @attr 4=109 0", 4, ids)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + + +TL_MAIN diff --git a/test/sort2/t1.c b/test/sort2/t1.c index c69ba76..78d2b02 100644 --- a/test/sort2/t1.c +++ b/test/sort2/t1.c @@ -1,4 +1,4 @@ -/* $Id: t1.c,v 1.4 2005-09-13 11:51:10 adam Exp $ +/* $Id: t1.c,v 1.5 2006-03-31 15:58:09 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -22,32 +22,34 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "../api/testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); char path[256]; int i; zint ids[5]; - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); - zebra_begin_trans(zh, 1); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); for (i = 1; i <= 4; i++) { - sprintf(path, "%.200s/rec%d.xml", get_srcdir(), i); + sprintf(path, "%.200s/rec%d.xml", tl_get_srcdir(), i); zebra_repository_update(zh, path); } - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); ids[0] = 2; ids[1] = 5; ids[2] = 3; ids[3] = 4; - do_sort(zh, "@or computer @attr 7=1 @attr 1=4 0", 4, ids); + YAZ_CHECK(tl_sort(zh, "@or computer @attr 7=1 @attr 1=4 0", 4, ids)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/xpath/xpath1.c b/test/xpath/xpath1.c index 4a40070..2c86213 100644 --- a/test/xpath/xpath1.c +++ b/test/xpath/xpath1.c @@ -1,4 +1,4 @@ -/* $Id: xpath1.c,v 1.4 2005-09-13 11:51:10 adam Exp $ +/* $Id: xpath1.c,v 1.5 2006-03-31 15:58:10 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -24,7 +24,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA /** xpath1.c - index a simple sgml record and search in it */ -int main(int argc, char **argv) +static void tst(int argc, char **argv) { ZebraService zs; ZebraHandle zh; @@ -38,20 +38,22 @@ int main(int argc, char **argv) " \n", 0}; - zs = start_up(0, argc, argv); + zs = tl_start_up(0, argc, argv); zh = zebra_open(zs, 0); - init_data(zh, myrec); + YAZ_CHECK(tl_init_data(zh, myrec)); - do_query(__LINE__,zh, "@attr 1=/sgml/tag before", 0); - do_query(__LINE__,zh, "@attr 1=/sgml/tag inside", 1); - do_query(__LINE__,zh, "@attr 1=/sgml/tag after", 0); + YAZ_CHECK(tl_query(zh, "@attr 1=/sgml/tag before", 0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/sgml/tag inside", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/sgml/tag after", 0)); - do_query(__LINE__,zh, "@attr 1=/sgml/none after", 0); - do_query(__LINE__,zh, "@attr 1=/sgml/none inside", 0); + YAZ_CHECK(tl_query(zh, "@attr 1=/sgml/none after", 0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/sgml/none inside", 0)); - do_query(__LINE__,zh, "@attr 1=/sgml before", 1); - do_query(__LINE__,zh, "@attr 1=/sgml inside", 1); - do_query(__LINE__,zh, "@attr 1=/sgml after", 1); + YAZ_CHECK(tl_query(zh, "@attr 1=/sgml before", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/sgml inside", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/sgml after", 1)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/xpath/xpath2.c b/test/xpath/xpath2.c index a7d0b00..8ec8f35 100644 --- a/test/xpath/xpath2.c +++ b/test/xpath/xpath2.c @@ -1,4 +1,4 @@ -/* $Id: xpath2.c,v 1.4 2005-09-13 11:51:11 adam Exp $ +/* $Id: xpath2.c,v 1.5 2006-03-31 15:58:10 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -69,14 +69,17 @@ const char *myrec[] = { 0}; -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - init_data(zh, myrec); + YAZ_CHECK(tl_init_data(zh, myrec)); - do_query(__LINE__,zh, "@attr 1=/Zthes/termName Sauropoda", 1); - do_query(__LINE__,zh, "@attr 1=/Zthes/relation/termName Sauropoda",1); + YAZ_CHECK(tl_query(zh, "@attr 1=/Zthes/termName Sauropoda", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/Zthes/relation/termName Sauropoda", 1)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN + diff --git a/test/xpath/xpath3.c b/test/xpath/xpath3.c index 84311ed..6ca551d 100644 --- a/test/xpath/xpath3.c +++ b/test/xpath/xpath3.c @@ -1,5 +1,5 @@ -/* $Id: xpath3.c,v 1.5 2005-09-13 11:51:11 adam Exp $ +/* $Id: xpath3.c,v 1.6 2006-03-31 15:58:10 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -36,20 +36,20 @@ const char *myrec[] = { 0}; -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - init_data(zh, myrec); + YAZ_CHECK(tl_init_data(zh, myrec)); -#define q(qry,hits) do_query(__LINE__,zh,qry,hits) - - q("@attr 1=/root content",1); - q("@attr 1=/root/first content",1); - q("@attr {1=/root/first[@attr='danish']} content",1); - q("@attr {1=/root/second[@attr='danish lake']} content",1); - q("@attr {1=/root/third[@attr='dansk s\xc3\xb8']} content",1); + YAZ_CHECK(tl_query(zh, "@attr 1=/root content",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/root/first content",1)); + YAZ_CHECK(tl_query(zh, "@attr {1=/root/first[@attr='danish']} content",1)); + YAZ_CHECK(tl_query(zh, "@attr {1=/root/second[@attr='danish lake']} content",1)); + YAZ_CHECK(tl_query(zh, "@attr {1=/root/third[@attr='dansk s\xc3\xb8']} content",1)); /* FIXME - This triggers bug200 */ - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/xpath/xpath4.c b/test/xpath/xpath4.c index 7b50656..8c085c9 100644 --- a/test/xpath/xpath4.c +++ b/test/xpath/xpath4.c @@ -1,4 +1,4 @@ -/* $Id: xpath4.c,v 1.4 2005-09-13 11:51:11 adam Exp $ +/* $Id: xpath4.c,v 1.5 2006-03-31 15:58:10 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -83,70 +83,70 @@ const char *myrec[] = { 0}; -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); #if 0 yaz_log_init_level( yaz_log_mask_str_x("xpath4,rsbetween", LOG_DEFAULT_LEVEL)); #endif - init_data(zh, myrec); + YAZ_CHECK(tl_init_data(zh, myrec)); -#define q(qry,hits) do_query(__LINE__,zh,qry,hits) + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title foo",4)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title bar",2)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='da'] foo",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='en'] foo",1)); - q("@attr 1=/record/title foo",4); - q("@attr 1=/record/title bar",2); - q("@attr 1=/record/title[@lang='da'] foo",1); - q("@attr 1=/record/title[@lang='en'] foo",1); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='en'] english",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='da'] english",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='da'] danish",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='en'] danish",0)); - q("@attr 1=/record/title[@lang='en'] english",1); - q("@attr 1=/record/title[@lang='da'] english",0); - q("@attr 1=/record/title[@lang='da'] danish",1); - q("@attr 1=/record/title[@lang='en'] danish",0); - - q("@attr 1=/record/title @and foo bar",2); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title @and foo bar",2)); /* The previous one returns two hits, as the and applies to the whole record, so it matches foobar This might not have to be like that, but currently that is what zebra does. */ - q("@and @attr 1=/record/title foo @attr 1=/record/title bar ",2); + YAZ_CHECK(tl_query(zh, "@and @attr 1=/record/title foo @attr 1=/record/title bar ",2)); /* check we get all the occureences for 'grunt' */ /* this can only be seen in the log, with debugs on. bug #202 */ - q("@attr 1=/record/author grunt",3); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/author grunt",3)); /* check nested tags */ - q("@attr 1=/record/nested before",0); - q("@attr 1=/record/nested early",1); - q("@attr 1=/record/nested middle",1); - q("@attr 1=/record/nested late",1); - q("@attr 1=/record/nested after",0); - - q("@attr 1=/record/nested/nested before",0); - q("@attr 1=/record/nested/nested early",0); - q("@attr 1=/record/nested/nested middle",1); - q("@attr 1=/record/nested/nested late",0); - q("@attr 1=/record/nested/nested after",0); - - q("@attr 1=/record/nestattr[@level='outer'] before",0); - q("@attr 1=/record/nestattr[@level='outer'] early",1); - q("@attr 1=/record/nestattr[@level='outer'] middle",1); - q("@attr 1=/record/nestattr[@level='outer'] late",1); - q("@attr 1=/record/nestattr[@level='outer'] after",0); - - q("@attr 1=/record/nestattr[@level='inner'] before",0); - q("@attr 1=/record/nestattr[@level='inner'] early",0); - q("@attr 1=/record/nestattr[@level='inner'] middle",0); - q("@attr 1=/record/nestattr[@level='inner'] late",0); - q("@attr 1=/record/nestattr[@level='inner'] after",0); - - q("@attr 1=/record/nestattr/nestattr[@level='inner'] before",0); - q("@attr 1=/record/nestattr/nestattr[@level='inner'] early",0); - q("@attr 1=/record/nestattr/nestattr[@level='inner'] middle",1); - q("@attr 1=/record/nestattr/nestattr[@level='inner'] late",0); - q("@attr 1=/record/nestattr/nestattr[@level='inner'] after",0); - - return close_down(zh, zs, 0); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested before",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested early",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested middle",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested late",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested after",0)); + + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested/nested before",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested/nested early",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested/nested middle",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested/nested late",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested/nested after",0)); + + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='outer'] before",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='outer'] early",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='outer'] middle",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='outer'] late",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='outer'] after",0)); + + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='inner'] before",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='inner'] early",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='inner'] middle",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='inner'] late",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='inner'] after",0)); + + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr/nestattr[@level='inner'] before",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr/nestattr[@level='inner'] early",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr/nestattr[@level='inner'] middle",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr/nestattr[@level='inner'] late",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr/nestattr[@level='inner'] after",0)); + + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/xpath/xpath5.c b/test/xpath/xpath5.c index 0ffc2fd..390c21b 100644 --- a/test/xpath/xpath5.c +++ b/test/xpath/xpath5.c @@ -1,4 +1,4 @@ -/* $Id: xpath5.c,v 1.4 2005-09-13 11:51:11 adam Exp $ +/* $Id: xpath5.c,v 1.5 2006-03-31 15:58:10 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -55,27 +55,25 @@ const char *recs[] = { 0 }; -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - init_data(zh, recs); -// yaz_log_init_level(LOG_ALL); + YAZ_CHECK(tl_init_data(zh, recs)); -#define q(qry,hits,string,score) \ - ranking_query(__LINE__,zh,qry,hits,string,score) + YAZ_CHECK(tl_ranking_query(zh, "@attr 1=/record/title @attr 2=102 the", + 3,"first title", 952)); + YAZ_CHECK(tl_ranking_query(zh, "@attr 1=/ @attr 2=102 @or third foo", + 3,"third title", 802)); - q("@attr 1=/record/title @attr 2=102 the", - 3,"first title",952); - q("@attr 1=/ @attr 2=102 @or third foo", - 3,"third title",802); + YAZ_CHECK(tl_ranking_query(zh, "@attr 1=/ @attr 2=102 foo", + 3,"second title", 850)); - q("@attr 1=/ @attr 2=102 foo", - 3,"second title",850); + YAZ_CHECK(tl_ranking_query(zh, "@attr 1=/record/ @attr 2=102 foo", + 3,"second title", 927)); - q("@attr 1=/record/ @attr 2=102 foo", - 3,"second title",927); - - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/xpath/xpath6.c b/test/xpath/xpath6.c index 22878a0..79f8c61 100644 --- a/test/xpath/xpath6.c +++ b/test/xpath/xpath6.c @@ -1,4 +1,4 @@ -/* $Id: xpath6.c,v 1.7 2006-02-06 23:21:49 adam Exp $ +/* $Id: xpath6.c,v 1.8 2006-03-31 15:58:10 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -22,61 +22,63 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "../api/testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { int i; - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); char path[256]; - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); - check_filter(zs, "grs.xml"); + tl_check_filter(zs, "grs.xml"); zebra_set_resource(zh, "recordType", "grs.xml"); - zebra_begin_trans(zh, 1); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); for (i = 1; i <= 2; i++) { - sprintf(path, "%.200s/rec%d.xml", get_srcdir(), i); + sprintf(path, "%.200s/rec%d.xml", tl_get_srcdir(), i); zebra_repository_update(zh, path); } - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - do_query(__LINE__, zh, "@attr 5=1 @attr 6=3 @attr 4=1 @attr 1=/assembled/basic/names/CASno \"367-93-1\"", 2); + YAZ_CHECK(tl_query(zh, "@attr 5=1 @attr 6=3 @attr 4=1 @attr 1=/assembled/basic/names/CASno \"367-93-1\"", 2)); - do_query(__LINE__, zh, "@attr 5=1 @attr 6=3 @attr 4=1 @attr 1=18 \"367-93-1\"", 2); + YAZ_CHECK(tl_query(zh, "@attr 5=1 @attr 6=3 @attr 4=1 @attr 1=18 \"367-93-1\"", 2)); - do_query(__LINE__, zh, "@attr 1=/assembled/orgs/org 0", 1); + YAZ_CHECK(tl_query(zh, "@attr 1=/assembled/orgs/org 0", 1)); - do_query(__LINE__, zh, + YAZ_CHECK(tl_query(zh, "@and @attr 1=/assembled/orgs/org 0 @attr 5=1 @attr 6=3 @attr 4=1 " - "@attr 1=/assembled/basic/names/CASno \"367-93-1\"", 1); + "@attr 1=/assembled/basic/names/CASno \"367-93-1\"", 1)); - do_query(__LINE__, zh, + YAZ_CHECK(tl_query(zh, "@and @attr 1=/assembled/orgs/org 1 @attr 5=1 @attr 6=3 @attr 4=1 " - "@attr 1=/assembled/basic/names/CASno 367-93-1", 2); + "@attr 1=/assembled/basic/names/CASno 367-93-1", 2)); /* bug #317 */ - do_query(__LINE__, zh, "@attr 1=1010 46", 2); + YAZ_CHECK(tl_query(zh, "@attr 1=1010 46", 2)); /* bug #431 */ - do_query(__LINE__, zh, "@attr 1=1021 0", 1); + YAZ_CHECK(tl_query(zh, "@attr 1=1021 0", 1)); /* bug #431 */ - do_query(__LINE__, zh, "@attr 1=1021 46", 1); + YAZ_CHECK(tl_query(zh, "@attr 1=1021 46", 1)); /* bug #431 */ - do_query(__LINE__, zh, "@attr 1=1021 1", 0); + YAZ_CHECK(tl_query(zh, "@attr 1=1021 1", 0)); /* bug #460 */ - do_query(__LINE__, zh, "@attr 1=4 46", 0); + YAZ_CHECK(tl_query(zh, "@attr 1=4 46", 0)); /* bug #460 */ - do_query(__LINE__, zh, "@attr 1=4 beta", 1); + YAZ_CHECK(tl_query(zh, "@attr 1=4 beta", 1)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/xslt/xslt1.c b/test/xslt/xslt1.c index 70b4604..bf5986d 100644 --- a/test/xslt/xslt1.c +++ b/test/xslt/xslt1.c @@ -1,4 +1,4 @@ -/* $Id: xslt1.c,v 1.6 2006-02-23 11:26:00 adam Exp $ +/* $Id: xslt1.c,v 1.7 2006-03-31 15:58:10 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -20,34 +20,38 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include "testlib.h" - -int main(int argc, char **argv) + +void tst(int argc, char **argv) { char path[256]; - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - check_filter(zs, "xslt"); + tl_check_filter(zs, "xslt"); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); zebra_set_resource(zh, "recordType", "xslt.marcschema-col.xml"); - zebra_begin_trans(zh, 1); - sprintf(path, "%.200s/marc-col.xml", get_srcdir()); - zebra_repository_update(zh, path); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); + sprintf(path, "%.200s/marc-col.xml", tl_get_srcdir()); + YAZ_CHECK(zebra_repository_update(zh, path) == ZEBRA_OK); - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - do_query(__LINE__, zh, "@attr 1=title computer", 3); - do_query(__LINE__, zh, "@attr 1=control 11224466", 1); - do_query_x(__LINE__, zh, "@attr 1=titl computer", 0, 114); - do_query_x(__LINE__, zh, "@attr 1=4 computer", 0, 121); + YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 3)); + YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=4 computer", 0, 121)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN + diff --git a/test/xslt/xslt2.c b/test/xslt/xslt2.c index a164f86..fa7ed33 100644 --- a/test/xslt/xslt2.c +++ b/test/xslt/xslt2.c @@ -1,4 +1,4 @@ -/* $Id: xslt2.c,v 1.6 2006-02-23 11:26:00 adam Exp $ +/* $Id: xslt2.c,v 1.7 2006-03-31 15:58:10 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -23,7 +23,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include "testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { char path[256]; char record_buf[20000]; @@ -33,18 +33,18 @@ int main(int argc, char **argv) FILE *f; size_t r; - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - check_filter(zs, "xslt"); + tl_check_filter(zs, "xslt"); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); zebra_set_resource(zh, "recordType", "xslt.marcschema-col.xml"); - sprintf(path, "%.200s/marc-col.xml", get_srcdir()); + sprintf(path, "%.200s/marc-col.xml", tl_get_srcdir()); f = fopen(path, "rb"); if (!f) { @@ -63,12 +63,14 @@ int main(int argc, char **argv) /* for now only the first of the records in the collection is indexed. That can be seen as a bug */ - init_data(zh, records_array); + YAZ_CHECK(tl_init_data(zh, records_array)); /* only get hits from first record .. */ - do_query(__LINE__, zh, "@attr 1=title computer", 1); - do_query(__LINE__, zh, "@attr 1=control 11224466", 1); - do_query_x(__LINE__, zh, "@attr 1=titl computer", 0, 114); + YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114)); - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN diff --git a/test/xslt/xslt3.c b/test/xslt/xslt3.c index 8b85959..10699a3 100644 --- a/test/xslt/xslt3.c +++ b/test/xslt/xslt3.c @@ -1,4 +1,4 @@ -/* $Id: xslt3.c,v 1.5 2006-02-23 11:26:00 adam Exp $ +/* $Id: xslt3.c,v 1.6 2006-03-31 15:58:10 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -23,7 +23,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include "testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { char path[256]; char record_buf[20000]; @@ -33,18 +33,18 @@ int main(int argc, char **argv) FILE *f; size_t r; - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); - check_filter(zs, "xslt"); + tl_check_filter(zs, "xslt"); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); zebra_set_resource(zh, "recordType", "xslt.marcschema-one.xml"); - sprintf(path, "%.200s/marc-one.xml", get_srcdir()); + sprintf(path, "%.200s/marc-one.xml", tl_get_srcdir()); f = fopen(path, "rb"); if (!f) { @@ -62,12 +62,12 @@ int main(int argc, char **argv) record_buf[r] = '\0'; /* index this one record */ - init_data(zh, records_array); + YAZ_CHECK(tl_init_data(zh, records_array)); /* only get hits from first record .. */ - do_query(__LINE__, zh, "@attr 1=title computer", 1); - do_query(__LINE__, zh, "@attr 1=control 11224466", 1); - do_query_x(__LINE__, zh, "@attr 1=titl computer", 0, 114); + YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114)); /* index one more time to see that we don't get dups, since @@ -75,11 +75,12 @@ int main(int argc, char **argv) zebra_add_record(zh, record_buf, strlen(record_buf)); /* only get hits from first record .. */ - do_query(__LINE__, zh, "@attr 1=title computer", 1); - do_query(__LINE__, zh, "@attr 1=control 11224466", 1); - do_query_x(__LINE__, zh, "@attr 1=titl computer", 0, 114); + YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114)); - - - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN + diff --git a/test/xslt/xslt4.c b/test/xslt/xslt4.c index 42685db..37ba294 100644 --- a/test/xslt/xslt4.c +++ b/test/xslt/xslt4.c @@ -1,4 +1,4 @@ -/* $Id: xslt4.c,v 1.3 2006-02-23 11:26:00 adam Exp $ +/* $Id: xslt4.c,v 1.4 2006-03-31 15:58:10 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -20,35 +20,35 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include "testlib.h" -int main(int argc, char **argv) +static void tst(int argc, char **argv) { char path[256]; - ZebraService zs = start_up("zebrastaticrank.cfg", argc, argv); + ZebraService zs = tl_start_up("zebrastaticrank.cfg", argc, argv); ZebraHandle zh = zebra_open(zs, 0); - check_filter(zs, "xslt"); + tl_check_filter(zs, "xslt"); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); zebra_set_resource(zh, "recordType", "xslt.marcschema-col.xml"); zebra_set_resource(zh, "staticrank", "1"); - zebra_begin_trans(zh, 1); - sprintf(path, "%.200s/marc-col.xml", get_srcdir()); + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); + sprintf(path, "%.200s/marc-col.xml", tl_get_srcdir()); zebra_repository_update(zh, path); - zebra_end_trans(zh); + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - - do_query(__LINE__, zh, "@attr 1=title computer", 3); - do_query(__LINE__, zh, "@attr 1=control 11224466", 1); - do_query_x(__LINE__, zh, "@attr 1=titl computer", 0, 114); + YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 3)); + YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114)); if (1) { @@ -56,7 +56,10 @@ int main(int argc, char **argv) ids[0] = 2; ids[1] = 4; ids[2] = 3; - do_sort(zh, "@attr 1=title computer", 3, ids); + YAZ_CHECK(tl_sort(zh, "@attr 1=title computer", 3, ids)); } - return close_down(zh, zs, 0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN +