-/* $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
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;
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)
*/
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.
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.
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,
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);
-/* $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
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++)
{
-/* $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
} /* 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);
-/* $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
{
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;
{
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;
{
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;
}
"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;
}
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;
}
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;
}
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;
}
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;
}
-/* $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
{
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;
}
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:
}
}
}
- zebra_end_trans (zh);
+ if (zebra_end_trans (zh) != ZEBRA_OK)
+ {
+ yaz_log(YLOG_WARN, "zebra_end_trans failed for"
+ " extended service operation");
+ }
}
}
}
-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
-/* $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
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;
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;
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
-/* $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
/** t0 - test zebra_start .. */
-#include <stdlib.h>
-#include <idzebra/api.h>
-#include <yaz/test.h>
-
-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
-/* $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
/** t1 - just start and stop */
+#include <yaz/test.h>
#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
+
-/* $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
#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;
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 },
{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
-/* $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
"<gils>\n<title>e f</title>\n</gils>\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
+
-/* $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
#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; i<no_db; i++)
{
char dbstr[20];
char rec_buf[100];
sprintf(dbstr, "%d", i);
- zebra_select_database(zh, dbstr);
+ YAZ_CHECK(zebra_select_database(zh, dbstr) == ZEBRA_OK);
sprintf(rec_buf, "<gils><title>title %d</title></gils>\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
+
-/* $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
/** test resources */
#include <stdlib.h>
#include <string.h>
-#include <yaz/test.h>
+#include "testlib.h"
#include <idzebra/api.h>
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++)
zebra_stop(zs);
}
-
-int main(int argc, char **argv)
-{
- YAZ_CHECK_INIT(argc, argv);
- tst_res();
- tst_no_config();
- YAZ_CHECK_TERM;
-}
+TL_MAIN
-/* $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
{
const char *rec = "<gils><title>some</title></gils>";
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);
/* bug #447 */
create_search_drop(zh);
- return close_down(zh, zs, 0);
+ YAZ_CHECK(tl_close_down(zh, zs));
}
-
+TL_MAIN
-/* $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
"</gils>\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
+
-/* $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
"</gils>\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++)
{
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);
}
zebra_commit(zh);
- return close_down(zh, zs, 0);
+ YAZ_CHECK(tl_close_down(zh, zs));
}
+
+TL_MAIN
+
-/* $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
#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++)
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;
}
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
+
-/* $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
*/
/** t5.c: proximity searches */
+#include <yaz/test.h>
#include "testlib.h"
const char *myrec[] = {
"<gils>\n<title>My title x</title>\n</gils>\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
+
-/* $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
#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);
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++)
{
strcat(rec_buf, "</Control-Identifier></gils>");
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
-/* $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
"</gils>\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);
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);
/*
zebra_commit(zh);
- return close_down(zh, zs, 0);
+ YAZ_CHECK(tl_close_down(zh, zs));
}
+
+TL_MAIN
-/* $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
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
-/* $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
#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
-/* $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
/* 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];
}
/**
- * 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
#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)
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;
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)
{
"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)
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
printf("Error: search returned %d. Code %d\n%s\n", rc,
code, query);
- exit (1);
+ return 0;
}
if (exphits != -1 && hits != 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;
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 */);
{
printf("Error: scan returned %d (FAIL), but no error was expected\n"
"%s\n", res, query);
- exit(1);
+ return 0;
}
else
{
fails++;
}
if (fails)
- exit(1);
+ return 0;
fails = 0;
if (exp_entries)
{
}
}
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; i<exphits; i++)
positions[i] = i+1;
if (!meta)
{
printf("Error: retrieve returned error\n%s\n", query);
- exit (1);
+ return 0;
}
for (i = 0; i<exphits; i++)
{
printf("Expected id=" ZINT_FORMAT " but got id=" ZINT_FORMAT "\n",
ids[i], meta[i].sysno);
- exit(1);
+ return 0;
}
}
zebra_meta_records_destroy(zh, meta, exphits);
odr_destroy (odr_output);
free(positions);
+ return 1;
}
-void do_sort(ZebraHandle zh, const char *query, zint hits, zint *exp)
+int tl_sort(ZebraHandle zh, const char *query, zint hits, zint *exp)
{
ZebraMetaRecord *recs;
zint i;
zint min_val_exp = 0;
assert(query);
- do_query(__LINE__, zh, query, hits);
+ if (!tl_query(zh, query, hits))
+ return 0;
recs = zebra_meta_records_create_range (zh, "rsetname", 1, 4);
if (!recs)
- {
- fprintf(stderr, "recs==0\n");
- exit(1);
- }
+ return 0;
+
/* find min for each sequence to get proper base offset */
for (i = 0; i<hits; i++)
{
zebra_meta_records_destroy (zh, recs, 4);
if (errs)
- exit(1);
+ return 0;
+ return 1;
}
f->occurred = 1;
}
-void check_filter(ZebraService zs, const char *name)
+void tl_check_filter(ZebraService zs, const char *name)
{
struct finfo f;
-/* $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
#include <yaz/pquery.h>
#include <yaz/log.h>
#include <idzebra/api.h>
+#include <yaz/test.h>
/**
- * 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
* 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; }
-/* $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
#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
-/* $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
#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
-/* $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
#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
+
-/* $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
02111-1307, USA.
*/
+#include <yaz/test.h>
#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
+
-/* $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
#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
-/* $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
#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
-/* $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
#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
-/* $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
#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
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
-/* $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
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
-/* $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
02111-1307, USA.
*/
-#include <assert.h>
#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
-/* $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
#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
-/* $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
/** 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;
"</sgml> \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
-/* $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
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
+
-/* $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
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
-/* $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
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 <title>foo</title><title>bar</title>
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
-/* $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
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
-/* $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
#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
-/* $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
02111-1307, USA.
*/
+#include <yaz/test.h>
#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
+
-/* $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
#include <stdio.h>
#include "testlib.h"
-int main(int argc, char **argv)
+static void tst(int argc, char **argv)
{
char path[256];
char record_buf[20000];
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)
{
/* 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
-/* $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
#include <stdio.h>
#include "testlib.h"
-int main(int argc, char **argv)
+static void tst(int argc, char **argv)
{
char path[256];
char record_buf[20000];
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)
{
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
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
+
-/* $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
02111-1307, USA.
*/
+#include <yaz/test.h>
#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)
{
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
+