3 #include "tap-interface.h"
10 int main(int argc
, char *argv
[])
13 struct ntdb_context
*ntdb
;
14 NTDB_DATA d
= { NULL
, 0 }; /* Bogus GCC warning */
15 NTDB_DATA key
= ntdb_mkdata("key", 3);
16 NTDB_DATA data
= ntdb_mkdata("data", 4);
17 int flags
[] = { NTDB_INTERNAL
, NTDB_DEFAULT
, NTDB_NOMMAP
,
18 NTDB_INTERNAL
|NTDB_CONVERT
, NTDB_CONVERT
,
19 NTDB_NOMMAP
|NTDB_CONVERT
};
21 plan_tests(sizeof(flags
) / sizeof(flags
[0]) * 15 + 4 * 13);
22 for (i
= 0; i
< sizeof(flags
) / sizeof(flags
[0]); i
++) {
23 ntdb
= ntdb_open("api-81-seqnum.ntdb",
24 flags
[i
]|NTDB_SEQNUM
|MAYBE_NOSYNC
,
25 O_RDWR
|O_CREAT
|O_TRUNC
, 0600, &tap_log_attr
);
30 ok1(ntdb_get_seqnum(ntdb
) == seq
);
31 ok1(ntdb_store(ntdb
, key
, data
, NTDB_INSERT
) == 0);
32 ok1(ntdb_get_seqnum(ntdb
) == ++seq
);
33 /* Fetch doesn't change seqnum */
34 if (ok1(ntdb_fetch(ntdb
, key
, &d
) == NTDB_SUCCESS
))
36 ok1(ntdb_get_seqnum(ntdb
) == seq
);
37 ok1(ntdb_append(ntdb
, key
, data
) == NTDB_SUCCESS
);
38 ok1(ntdb_get_seqnum(ntdb
) == ++seq
);
40 ok1(ntdb_delete(ntdb
, key
) == NTDB_SUCCESS
);
41 ok1(ntdb_get_seqnum(ntdb
) == ++seq
);
42 /* Empty append works */
43 ok1(ntdb_append(ntdb
, key
, data
) == NTDB_SUCCESS
);
44 ok1(ntdb_get_seqnum(ntdb
) == ++seq
);
46 ok1(ntdb_wipe_all(ntdb
) == NTDB_SUCCESS
);
47 ok1(ntdb_get_seqnum(ntdb
) == ++seq
);
49 if (!(flags
[i
] & NTDB_INTERNAL
)) {
50 ok1(ntdb_transaction_start(ntdb
) == NTDB_SUCCESS
);
51 ok1(ntdb_store(ntdb
, key
, data
, NTDB_INSERT
) == 0);
52 ok1(ntdb_get_seqnum(ntdb
) == ++seq
);
53 ok1(ntdb_append(ntdb
, key
, data
) == NTDB_SUCCESS
);
54 ok1(ntdb_get_seqnum(ntdb
) == ++seq
);
55 ok1(ntdb_delete(ntdb
, key
) == NTDB_SUCCESS
);
56 ok1(ntdb_get_seqnum(ntdb
) == ++seq
);
57 ok1(ntdb_transaction_commit(ntdb
) == NTDB_SUCCESS
);
58 ok1(ntdb_get_seqnum(ntdb
) == seq
);
60 ok1(ntdb_transaction_start(ntdb
) == NTDB_SUCCESS
);
61 ok1(ntdb_store(ntdb
, key
, data
, NTDB_INSERT
) == 0);
62 ok1(ntdb_get_seqnum(ntdb
) == seq
+ 1);
63 ntdb_transaction_cancel(ntdb
);
64 ok1(ntdb_get_seqnum(ntdb
) == seq
);
67 ok1(tap_log_messages
== 0);