s3:smb2_break: make use of file_fsp_smb2()
[Samba/gebeck_regimport.git] / lib / tdb / test / run-check.c
blob455731db944138b457c0ee1bc32d61110483d293
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 <err.h>
15 #include "logging.h"
17 int main(int argc, char *argv[])
19 struct tdb_context *tdb;
20 TDB_DATA key, data;
22 plan_tests(13);
23 tdb = tdb_open_ex("run-check.tdb", 1, TDB_CLEAR_IF_FIRST,
24 O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
26 ok1(tdb);
27 ok1(tdb_check(tdb, NULL, NULL) == 0);
29 key.dsize = strlen("hi");
30 key.dptr = (void *)"hi";
31 data.dsize = strlen("world");
32 data.dptr = (void *)"world";
34 ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0);
35 ok1(tdb_check(tdb, NULL, NULL) == 0);
36 tdb_close(tdb);
38 tdb = tdb_open_ex("run-check.tdb", 1024, 0, O_RDWR, 0,
39 &taplogctx, NULL);
40 ok1(tdb);
41 ok1(tdb_check(tdb, NULL, NULL) == 0);
42 tdb_close(tdb);
44 tdb = tdb_open_ex("test/tdb.corrupt", 1024, 0, O_RDWR, 0,
45 &taplogctx, NULL);
46 ok1(tdb);
47 ok1(tdb_check(tdb, NULL, NULL) == -1);
48 ok1(tdb_error(tdb) == TDB_ERR_CORRUPT);
49 tdb_close(tdb);
51 /* Big and little endian should work! */
52 tdb = tdb_open_ex("test/old-nohash-le.tdb", 1024, 0, O_RDWR, 0,
53 &taplogctx, NULL);
54 ok1(tdb);
55 ok1(tdb_check(tdb, NULL, NULL) == 0);
56 tdb_close(tdb);
58 tdb = tdb_open_ex("test/old-nohash-be.tdb", 1024, 0, O_RDWR, 0,
59 &taplogctx, NULL);
60 ok1(tdb);
61 ok1(tdb_check(tdb, NULL, NULL) == 0);
62 tdb_close(tdb);
64 return exit_status();