From ba950cd0f07c22d667375141f368490123a72127 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 14 Nov 2007 09:44:16 +0000 Subject: [PATCH] Use test facility of YAZ --- bfile/tstbfile1.c | 65 ++++++++++++++++++++++++++++------------------------- bfile/tstbfile2.c | 3 ++- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/bfile/tstbfile1.c b/bfile/tstbfile1.c index 9304abb..2576787 100644 --- a/bfile/tstbfile1.c +++ b/bfile/tstbfile1.c @@ -1,4 +1,4 @@ -/* $Id: tstbfile1.c,v 1.5 2007-01-15 15:10:14 adam Exp $ +/* $Id: tstbfile1.c,v 1.6 2007-11-14 09:44:16 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -20,10 +20,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include #include +#include void tst1(BFiles bfs) { @@ -34,18 +34,19 @@ void tst1(BFiles bfs) bf_reset(bfs); bf = bf_xopen(bfs, "tst", /* block size */ 32, /* wr */ 1, "tstmagic", &version, 0 /* more_info */); - + YAZ_CHECK(bf); + if (!bf) + return; bf_xclose(bf, version, "more info"); bf = bf_xopen(bfs, "tst", /* block size */ 32, /* wr */ 1, "tstmagic", &version, &more_info); + + YAZ_CHECK(bf); + if (!bf) + return; - if (strcmp(more_info, "more info")) - { - fprintf(stderr, "tstbfile1: more info data corrupt more_info=%s\n", - more_info); - exit(1); - } + YAZ_CHECK(strcmp(more_info, "more info") == 0); bf_xclose(bf, version, 0 /* no more info */); } @@ -59,35 +60,25 @@ void tst2(BFiles bfs) bf = bf_xopen(bfs, "tst", /* block size */ 32, /* wr */ 1, "tstmagic", &version, 0 /* more_info */); - + YAZ_CHECK(bf); + if (!bf) + return; bno = 0; for (i = 1; i<30; i++) { int j; for (j = 0; j= 0 && no_in_use <= BLOCKS); + YAZ_CHECK(no_in_use >= 0); + YAZ_CHECK(no_in_use <= BLOCKS); if (r < 5 && (BLOCKS - no_in_use) > 0) { /* alloc phase */ @@ -157,7 +151,7 @@ void tst3(BFiles bfs) j++; } } - assert(tblocks[to_free-start-1]); + YAZ_CHECK(tblocks[to_free-start-1]); bf_free(bf, to_free - start, tblocks); } else @@ -170,21 +164,30 @@ void tst3(BFiles bfs) bf_xclose(bf, version, 0); } -int main(int argc, char **argv) +static void tst(void) { BFiles bfs = bfs_create(0, /* register: current dir, no limit */ 0 /* base: current dir */ ); + YAZ_CHECK(bfs); if (!bfs) - exit(1); + return; tst1(bfs); tst2(bfs); tst3(bfs); bf_reset(bfs); bfs_destroy(bfs); - exit(0); } + +int main(int argc, char **argv) +{ + YAZ_CHECK_INIT(argc, argv); + YAZ_CHECK_LOG(); + tst(); + YAZ_CHECK_TERM; +} + /* * Local variables: * c-basic-offset: 4 diff --git a/bfile/tstbfile2.c b/bfile/tstbfile2.c index 988d352..b44f261 100644 --- a/bfile/tstbfile2.c +++ b/bfile/tstbfile2.c @@ -1,4 +1,4 @@ -/* $Id: tstbfile2.c,v 1.4 2007-01-15 15:10:14 adam Exp $ +/* $Id: tstbfile2.c,v 1.5 2007-11-14 09:44:17 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -172,6 +172,7 @@ void tst(void) int main(int argc, char **argv) { YAZ_CHECK_INIT(argc, argv); + YAZ_CHECK_LOG(); tst(); YAZ_CHECK_TERM; } -- 1.7.10.4