s3:registry: do not use regdb functions during db upgrade
[Samba/gebeck_regimport.git] / lib / tdb2 / test / run-tdb1-zero-append.c
blobfdc9cdce35bb5370a5901b619cad4e81675ee713
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(5);
18 tdb = tdb_open(NULL, TDB_INTERNAL|TDB_VERSION1, O_CREAT|O_TRUNC|O_RDWR,
19 0600, &hsize);
20 ok1(tdb);
22 /* Tickle bug on appending zero length buffer to zero length buffer. */
23 key.dsize = strlen("hi");
24 key.dptr = (void *)"hi";
25 data.dptr = (void *)"world";
26 data.dsize = 0;
28 ok1(tdb_append(tdb, key, data) == TDB_SUCCESS);
29 ok1(tdb_append(tdb, key, data) == TDB_SUCCESS);
30 ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS);
31 ok1(data.dsize == 0);
32 free(data.dptr);
33 tdb_close(tdb);
35 return exit_status();