s3:registry: do not use regdb functions during db upgrade
[Samba/gebeck_regimport.git] / lib / tdb2 / test / api-16-wipe_all.c
blobd17eff8e6a8cac343fd584f88f368a571124b7e7
1 #include <ccan/tdb2/tdb2.h>
2 #include <ccan/tap/tap.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include "logging.h"
8 static bool add_records(struct tdb_context *tdb)
10 int i;
11 struct tdb_data key = { (unsigned char *)&i, sizeof(i) };
12 struct tdb_data data = { (unsigned char *)&i, sizeof(i) };
14 for (i = 0; i < 1000; i++) {
15 if (tdb_store(tdb, key, data, TDB_REPLACE) != 0)
16 return false;
18 return true;
22 int main(int argc, char *argv[])
24 unsigned int i;
25 struct tdb_context *tdb;
26 int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
27 TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
28 TDB_NOMMAP|TDB_CONVERT,
29 TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1,
30 TDB_NOMMAP|TDB_VERSION1,
31 TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1,
32 TDB_CONVERT|TDB_VERSION1,
33 TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 };
35 plan_tests(sizeof(flags) / sizeof(flags[0]) * 4 + 1);
36 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
37 tdb = tdb_open("run-16-wipe_all.tdb", flags[i],
38 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
39 if (ok1(tdb)) {
40 struct tdb_data key;
41 ok1(add_records(tdb));
42 ok1(tdb_wipe_all(tdb) == TDB_SUCCESS);
43 ok1(tdb_firstkey(tdb, &key) == TDB_ERR_NOEXIST);
44 tdb_close(tdb);
48 ok1(tap_log_messages == 0);
49 return exit_status();