projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove Ubuntu Saucy
[idzebra-moved-to-github.git]
/
bfile
/
tstbfile1.c
diff --git
a/bfile/tstbfile1.c
b/bfile/tstbfile1.c
index
c0da22e
..
067b4bd
100644
(file)
--- a/
bfile/tstbfile1.c
+++ b/
bfile/tstbfile1.c
@@
-1,8
+1,5
@@
-/* $Id: tstbfile1.c,v 1.4 2006-08-14 10:40:05 adam Exp $
- Copyright (C) 1995-2006
- Index Data ApS
-
-This file is part of the Zebra server.
+/* This file is part of the Zebra server.
+ Copyright (C) Index Data
Zebra is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Zebra is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
@@
-20,10
+17,13
@@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
-#include <assert.h>
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <idzebra/bfile.h>
#include <stdlib.h>
#include <string.h>
#include <idzebra/bfile.h>
+#include <yaz/test.h>
void tst1(BFiles bfs)
{
void tst1(BFiles bfs)
{
@@
-32,20
+32,21
@@
void tst1(BFiles bfs)
const char *more_info = 0;
bf_reset(bfs);
const char *more_info = 0;
bf_reset(bfs);
- bf = bf_xopen(bfs, "tst", /* block size */ 32,
+ bf = bf_xopen(bfs, "tst", /* block size */ 32,
/* wr */ 1, "tstmagic", &version, 0 /* more_info */);
/* wr */ 1, "tstmagic", &version, 0 /* more_info */);
-
+ YAZ_CHECK(bf);
+ if (!bf)
+ return;
bf_xclose(bf, version, "more info");
bf_xclose(bf, version, "more info");
-
- bf = bf_xopen(bfs, "tst", /* block size */ 32,
+
+ bf = bf_xopen(bfs, "tst", /* block size */ 32,
/* wr */ 1, "tstmagic", &version, &more_info);
/* wr */ 1, "tstmagic", &version, &more_info);
- if (strcmp(more_info, "more info"))
- {
- fprintf(stderr, "tstbfile1: more info data corrupt more_info=%s\n",
- more_info);
- exit(1);
- }
+ YAZ_CHECK(bf);
+ if (!bf)
+ return;
+
+ YAZ_CHECK(strcmp(more_info, "more info") == 0);
bf_xclose(bf, version, 0 /* no more info */);
}
bf_xclose(bf, version, 0 /* no more info */);
}
@@
-57,37
+58,27
@@
void tst2(BFiles bfs)
BFile bf;
bf_reset(bfs);
BFile bf;
bf_reset(bfs);
- bf = bf_xopen(bfs, "tst", /* block size */ 32,
+ bf = bf_xopen(bfs, "tst", /* block size */ 32,
/* wr */ 1, "tstmagic", &version, 0 /* more_info */);
/* 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<i; j++)
blocks[bno + j] = 0;
bno = 0;
for (i = 1; i<30; i++)
{
int j;
for (j = 0; j<i; j++)
blocks[bno + j] = 0;
- if (bf_alloc(bf, i, blocks + bno))
- {
- fprintf(stderr, "bf_alloc failed i=%d bno=%d\n", i, bno);
- exit(1);
- }
+ YAZ_CHECK_EQ(bf_alloc(bf, i, blocks + bno), 0);
for (j = 0; j < i; j++)
{
for (j = 0; j < i; j++)
{
- if (!blocks[bno + j])
- {
- fprintf(stderr, "zero block i=%d bno=%d j=%d\n", i, bno, j);
- exit(1);
- }
+ YAZ_CHECK(blocks[bno + j]);
}
bno += i;
}
for (i = 0; i<bno; i++)
{
}
bno += i;
}
for (i = 0; i<bno; i++)
{
- if (bf_free(bf, 1, blocks + i))
- {
- fprintf(stderr, "bf_freec failed i=%d\n", i);
- exit(1);
- }
+ YAZ_CHECK_EQ(bf_free(bf, 1, blocks + i), 0);
}
bf_xclose(bf, version, 0);
}
}
bf_xclose(bf, version, 0);
}
@@
-107,15
+98,18
@@
void tst3(BFiles bfs)
for(i = 0; i<BLOCKS; i++)
blocks[i] = 0;
for(i = 0; i<BLOCKS; i++)
blocks[i] = 0;
- bf = bf_xopen(bfs, "tst", /* block size */ 32,
+ bf = bf_xopen(bfs, "tst", /* block size */ 32,
/* wr */ 1, "tstmagic", &version, 0 /* more_info */);
/* wr */ 1, "tstmagic", &version, 0 /* more_info */);
-
+ YAZ_CHECK(bf);
+ if (!bf)
+ return;
no_in_use = 0;
for (pass = 0; pass < 100; pass++)
{
int r = random() % 9;
no_in_use = 0;
for (pass = 0; pass < 100; pass++)
{
int r = random() % 9;
- assert (no_in_use >= 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 */
if (r < 5 && (BLOCKS - no_in_use) > 0)
{
/* alloc phase */
@@
-157,37
+151,47
@@
void tst3(BFiles bfs)
j++;
}
}
j++;
}
}
- assert(tblocks[to_free-start-1]);
+ YAZ_CHECK(tblocks[to_free-start-1]);
bf_free(bf, to_free - start, tblocks);
}
else
{
bf_xclose(bf, version, 0);
bf_free(bf, to_free - start, tblocks);
}
else
{
bf_xclose(bf, version, 0);
- bf = bf_xopen(bfs, "tst", /* block size */ 32,
+ bf = bf_xopen(bfs, "tst", /* block size */ 32,
/* wr */ 1, "tstmagic", &version, 0 /* more_info */);
}
}
bf_xclose(bf, version, 0);
}
/* wr */ 1, "tstmagic", &version, 0 /* more_info */);
}
}
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 */
);
{
BFiles bfs = bfs_create(0, /* register: current dir, no limit */
0 /* base: current dir */
);
+ YAZ_CHECK(bfs);
if (!bfs)
if (!bfs)
- exit(1);
+ return;
tst1(bfs);
tst2(bfs);
tst3(bfs);
bf_reset(bfs);
bfs_destroy(bfs);
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
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab