s4:scripting/python: always treat the highwatermark as opaque (bug #9508)
[Samba/gebeck_regimport.git] / lib / tdb / test / run-check.c
blob05f7aecd0839b3c842c907a9d33afbbfa809ef7d
1 #include "../common/tdb_private.h"
2 #include "../common/io.c"
3 #include "../common/tdb.c"
4 #include "../common/lock.c"
5 #include "../common/freelist.c"
6 #include "../common/traverse.c"
7 #include "../common/transaction.c"
8 #include "../common/error.c"
9 #include "../common/open.c"
10 #include "../common/check.c"
11 #include "../common/hash.c"
12 #include "tap-interface.h"
13 #include <stdlib.h>
14 #include "logging.h"
16 int main(int argc, char *argv[])
18 struct tdb_context *tdb;
19 TDB_DATA key, data;
21 plan_tests(13);
22 tdb = tdb_open_ex("run-check.tdb", 1, TDB_CLEAR_IF_FIRST,
23 O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
25 ok1(tdb);
26 ok1(tdb_check(tdb, NULL, NULL) == 0);
28 key.dsize = strlen("hi");
29 key.dptr = (void *)"hi";
30 data.dsize = strlen("world");
31 data.dptr = (void *)"world";
33 ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0);
34 ok1(tdb_check(tdb, NULL, NULL) == 0);
35 tdb_close(tdb);
37 tdb = tdb_open_ex("run-check.tdb", 1024, 0, O_RDWR, 0,
38 &taplogctx, NULL);
39 ok1(tdb);
40 ok1(tdb_check(tdb, NULL, NULL) == 0);
41 tdb_close(tdb);
43 tdb = tdb_open_ex("test/tdb.corrupt", 1024, 0, O_RDWR, 0,
44 &taplogctx, NULL);
45 ok1(tdb);
46 ok1(tdb_check(tdb, NULL, NULL) == -1);
47 ok1(tdb_error(tdb) == TDB_ERR_CORRUPT);
48 tdb_close(tdb);
50 /* Big and little endian should work! */
51 tdb = tdb_open_ex("test/old-nohash-le.tdb", 1024, 0, O_RDWR, 0,
52 &taplogctx, NULL);
53 ok1(tdb);
54 ok1(tdb_check(tdb, NULL, NULL) == 0);
55 tdb_close(tdb);
57 tdb = tdb_open_ex("test/old-nohash-be.tdb", 1024, 0, O_RDWR, 0,
58 &taplogctx, NULL);
59 ok1(tdb);
60 ok1(tdb_check(tdb, NULL, NULL) == 0);
61 tdb_close(tdb);
63 return exit_status();