tdb: Fix a "increases alignment" warning
[samba.git] / lib / tdb / test / run-traverse-in-transaction.c
index d8455176a2457f28e02dced14a83da8b2e4b962c..d187b9b58b8d1f50104f965c5b466e1163563301 100644 (file)
 #include "../common/open.c"
 #include "../common/check.c"
 #include "../common/hash.c"
+#include "../common/mutex.c"
 #include "tap-interface.h"
 #undef fcntl_with_lockcheck
 #include <stdlib.h>
 #include <stdbool.h>
-#include <err.h>
 #include "external-agent.h"
 #include "logging.h"
 
@@ -48,8 +48,6 @@ int main(int argc, char *argv[])
 
        plan_tests(13);
        agent = prepare_external_agent();
-       if (!agent)
-               err(1, "preparing agent");
 
        tdb = tdb_open_ex("run-traverse-in-transaction.tdb",
                          1024, TDB_CLEAR_IF_FIRST, O_CREAT|O_TRUNC|O_RDWR,
@@ -57,15 +55,17 @@ int main(int argc, char *argv[])
        ok1(tdb);
 
        key.dsize = strlen("hi");
-       key.dptr = (void *)"hi";
-       data.dptr = (void *)"world";
+       key.dptr = discard_const_p(uint8_t, "hi");
+       data.dptr = discard_const_p(uint8_t, "world");
        data.dsize = strlen("world");
 
        ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0);
 
        ok1(external_agent_operation(agent, OPEN, tdb_name(tdb)) == SUCCESS);
 
+       ok1(tdb_transaction_active(tdb) == 0);
        ok1(tdb_transaction_start(tdb) == 0);
+       ok1(tdb_transaction_active(tdb) == 1);
        ok1(external_agent_operation(agent, TRANSACTION_START, tdb_name(tdb))
            == WOULD_HAVE_BLOCKED);
        tdb_traverse(tdb, traverse, NULL);
@@ -79,6 +79,7 @@ int main(int argc, char *argv[])
        ok1(external_agent_operation(agent, TRANSACTION_START, tdb_name(tdb))
            == WOULD_HAVE_BLOCKED);
        ok1(tdb_transaction_commit(tdb) == 0);
+       ok1(tdb_transaction_active(tdb) == 0);
        /* Now we should be fine. */
        ok1(external_agent_operation(agent, TRANSACTION_START, tdb_name(tdb))
            == SUCCESS);