s3/doc: document the ignore system acls option of vfs_acl_xattr and vfs_acl_tdb
[Samba/gebeck_regimport.git] / lib / tdb2 / test / run-tdb1-endian.c
blob3b91d45bdf5c807575d12f36cdd8b9a04158c24b
1 #include "tdb2-source.h"
2 #include <ccan/tap/tap.h>
3 #include <stdlib.h>
4 #include <err.h>
5 #include "logging.h"
7 int main(int argc, char *argv[])
9 struct tdb_context *tdb;
10 TDB_DATA key, data;
11 union tdb_attribute hsize;
13 hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
14 hsize.base.next = &tap_log_attr;
15 hsize.tdb1_hashsize.hsize = 1024;
17 plan_tests(14);
18 tdb = tdb_open("run-endian.tdb1",
19 TDB_VERSION1|TDB_CONVERT,
20 O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
22 ok1(tdb);
23 key.dsize = strlen("hi");
24 key.dptr = (void *)"hi";
25 data.dsize = strlen("world");
26 data.dptr = (void *)"world";
28 ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_ERR_NOEXIST);
29 ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
30 ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_ERR_EXISTS);
31 ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_SUCCESS);
33 ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS);
34 ok1(data.dsize == strlen("world"));
35 ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
36 free(data.dptr);
38 key.dsize++;
39 ok1(tdb_fetch(tdb, key, &data) == TDB_ERR_NOEXIST);
40 ok1(data.dptr == NULL);
41 tdb_close(tdb);
43 /* Reopen: should read it */
44 tdb = tdb_open("run-endian.tdb1", 0, O_RDWR, 0, NULL);
45 ok1(tdb);
47 key.dsize = strlen("hi");
48 key.dptr = (void *)"hi";
49 ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS);
50 ok1(data.dsize == strlen("world"));
51 ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
52 free(data.dptr);
53 tdb_close(tdb);
55 return exit_status();