unix_msg: Lift sockaddr_un handling from unix_dgram_send
[Samba.git] / lib / ntdb / test / api-60-noop-transaction.c
blob5e56dbc521bcfcc30618996a9b6e5fd24fb8d1ce
1 #include "private.h" // struct ntdb_context
2 #include "ntdb.h"
3 #include "tap-interface.h"
4 #include <stdlib.h>
5 #include "logging.h"
7 int main(int argc, char *argv[])
9 unsigned int i;
10 struct ntdb_context *ntdb;
11 int flags[] = { NTDB_DEFAULT, NTDB_NOMMAP,
12 NTDB_CONVERT, NTDB_NOMMAP|NTDB_CONVERT };
13 NTDB_DATA key = ntdb_mkdata("key", 3);
14 NTDB_DATA data = ntdb_mkdata("data", 4), d;
16 plan_tests(sizeof(flags) / sizeof(flags[0]) * 12 + 1);
18 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
19 ntdb = ntdb_open("api-60-transaction.ntdb",
20 flags[i]|MAYBE_NOSYNC,
21 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
22 ok1(ntdb);
23 if (!ntdb)
24 continue;
26 ok1(ntdb_store(ntdb, key, data, NTDB_INSERT) == 0);
28 ok1(ntdb_transaction_start(ntdb) == 0);
29 /* Do an identical replace. */
30 ok1(ntdb_store(ntdb, key, data, NTDB_REPLACE) == 0);
31 ok1(ntdb_transaction_commit(ntdb) == 0);
33 ok1(ntdb_check(ntdb, NULL, NULL) == 0);
34 ok1(ntdb_fetch(ntdb, key, &d) == NTDB_SUCCESS);
35 ok1(ntdb_deq(data, d));
36 free(d.dptr);
37 ntdb_close(ntdb);
39 /* Reopen, fetch. */
40 ntdb = ntdb_open("api-60-transaction.ntdb",
41 flags[i]|MAYBE_NOSYNC,
42 O_RDWR, 0600, &tap_log_attr);
43 ok1(ntdb);
44 if (!ntdb)
45 continue;
46 ok1(ntdb_check(ntdb, NULL, NULL) == 0);
47 ok1(ntdb_fetch(ntdb, key, &d) == NTDB_SUCCESS);
48 ok1(ntdb_deq(data, d));
49 free(d.dptr);
50 ntdb_close(ntdb);
53 ok1(tap_log_messages == 0);
54 return exit_status();