mirror of
https://github.com/samba-team/samba.git
synced 2025-01-13 13:18:06 +03:00
lib/tdb2: adapt unit tests to SAMBA environment.
This means changing headers, implementing a simple tap-like wrapper, and also splitting out the helpers into those which are linked with the api* tests (which can't use non-public tdb2 functions) and those linked with the run* tests (which can). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
361f3ea9ee
commit
9d897b0951
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <ccan/hash/hash.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include <ccan/tdb2/private.h> // For TDB_TOPLEVEL_HASH_BITS
|
||||
#include "private.h" // For TDB_TOPLEVEL_HASH_BITS
|
||||
#include <ccan/hash/hash.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
|
||||
/* We rig the hash so adjacent-numbered records always clash. */
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <ccan/tdb2/private.h> // struct tdb_context
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "private.h" // struct tdb_context
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <ccan/tdb2/private.h> // for tdb_fcntl_unlock
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "private.h" // for tdb_fcntl_unlock
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <ccan/tdb2/private.h> // for tdb_context
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "private.h" // for tdb_context
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -10,8 +10,9 @@
|
||||
* Note that we don't hold a lock across tdb_traverse callbacks, so
|
||||
* that doesn't matter.
|
||||
*/
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include "system/wait.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* Another test revealed that we lost an entry. This reproduces it. */
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include <ccan/hash/hash.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "config.h"
|
||||
#include "tdb2.h"
|
||||
#include "tap-interface.h"
|
||||
#include <ccan/hash/hash.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -10,8 +10,7 @@
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <ccan/tdb2/tdb1_private.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@ -65,7 +64,7 @@ static enum agent_return do_operation(enum operation op, const char *name)
|
||||
switch (op) {
|
||||
case OPEN:
|
||||
if (tdb) {
|
||||
diag("Already have tdb %s open", tdb->name);
|
||||
diag("Already have tdb %s open", tdb_name(tdb));
|
||||
return OTHER_FAILURE;
|
||||
}
|
||||
tdb = tdb_open(name, TDB_DEFAULT, O_RDWR, 0, &tap_log_attr);
|
||||
@ -79,7 +78,7 @@ static enum agent_return do_operation(enum operation op, const char *name)
|
||||
break;
|
||||
case OPEN_WITH_HOOK:
|
||||
if (tdb) {
|
||||
diag("Already have tdb %s open", tdb->name);
|
||||
diag("Already have tdb %s open", tdb_name(tdb));
|
||||
return OTHER_FAILURE;
|
||||
}
|
||||
cif.openhook.base.attr = TDB_ATTRIBUTE_OPENHOOK;
|
||||
@ -118,10 +117,7 @@ static enum agent_return do_operation(enum operation op, const char *name)
|
||||
ret = tdb_transaction_commit(tdb)==0 ? SUCCESS : OTHER_FAILURE;
|
||||
break;
|
||||
case NEEDS_RECOVERY:
|
||||
if (tdb->flags & TDB_VERSION1)
|
||||
ret = tdb1_needs_recovery(tdb) ? SUCCESS : FAILED;
|
||||
else
|
||||
ret = tdb_needs_recovery(tdb) ? SUCCESS : FAILED;
|
||||
ret = external_agent_needs_rec(tdb);
|
||||
break;
|
||||
case CHECK:
|
||||
ret = tdb_check(tdb, NULL, NULL) == 0 ? SUCCESS : OTHER_FAILURE;
|
||||
|
@ -36,11 +36,16 @@ enum agent_return external_agent_operation(struct agent *handle,
|
||||
const char *name);
|
||||
|
||||
/* Hook into free() on tdb_data in external agent. */
|
||||
void (*external_agent_free)(void *);
|
||||
extern void (*external_agent_free)(void *);
|
||||
|
||||
/* Mapping enum -> string. */
|
||||
const char *agent_return_name(enum agent_return ret);
|
||||
const char *operation_name(enum operation op);
|
||||
|
||||
void free_external_agent(struct agent *agent);
|
||||
|
||||
/* Internal use: */
|
||||
struct tdb_context;
|
||||
enum agent_return external_agent_needs_rec(struct tdb_context *tdb);
|
||||
|
||||
#endif /* TDB2_TEST_EXTERNAL_AGENT_H */
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "failtest_helper.h"
|
||||
#include "logging.h"
|
||||
#include <string.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
|
||||
bool failtest_suppress = false;
|
||||
|
||||
|
8
lib/tdb2/test/helpapi-external-agent.c
Normal file
8
lib/tdb2/test/helpapi-external-agent.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include "external-agent.h"
|
||||
#include "tdb1_private.h"
|
||||
|
||||
/* This isn't possible with via the tdb2 API, but this makes it link. */
|
||||
enum agent_return external_agent_needs_rec(struct tdb_context *tdb)
|
||||
{
|
||||
return FAILED;
|
||||
}
|
10
lib/tdb2/test/helprun-external-agent.c
Normal file
10
lib/tdb2/test/helprun-external-agent.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include "external-agent.h"
|
||||
#include "tdb1_private.h"
|
||||
|
||||
enum agent_return external_agent_needs_rec(struct tdb_context *tdb)
|
||||
{
|
||||
if (tdb->flags & TDB_VERSION1)
|
||||
return tdb1_needs_recovery(tdb) ? SUCCESS : FAILED;
|
||||
else
|
||||
return tdb_needs_recovery(tdb) ? SUCCESS : FAILED;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#ifndef TDB2_TEST_LAYOUT_H
|
||||
#define TDB2_TEST_LAYOUT_H
|
||||
#include <ccan/tdb2/private.h>
|
||||
#include "private.h"
|
||||
|
||||
struct tdb_layout *new_tdb_layout(void);
|
||||
void tdb_layout_add_freetable(struct tdb_layout *layout);
|
||||
|
@ -1,10 +1,10 @@
|
||||
/* We save the locks so we can reaquire them. */
|
||||
#include <ccan/tdb2/tdb1_private.h>
|
||||
#include "tdb1_private.h" /* For TDB_HASH_LOCK_START, TDB1_FREELIST_TOP, etc. */
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "lock-tracking.h"
|
||||
|
||||
struct lock {
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
|
||||
unsigned tap_log_messages;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef TDB2_TEST_LOGGING_H
|
||||
#define TDB2_TEST_LOGGING_H
|
||||
#include <ccan/tdb2/tdb2.h>
|
||||
#include "tdb2.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
|
||||
static unsigned int dumb_fls(uint64_t num)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <ccan/failtest/failtest_override.h>
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <ccan/failtest/failtest.h>
|
||||
#include "logging.h"
|
||||
#include "failtest_helper.h"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <ccan/failtest/failtest_override.h>
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <ccan/failtest/failtest.h>
|
||||
#include "logging.h"
|
||||
#include "failtest_helper.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
#include "layout.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
|
||||
/* We rig the hash so adjacent-numbered records always clash. */
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <ccan/failtest/failtest_override.h>
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <ccan/failtest/failtest.h>
|
||||
#include "logging.h"
|
||||
#include "failtest_helper.h"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <ccan/failtest/failtest_override.h>
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <ccan/failtest/failtest.h>
|
||||
#include "logging.h"
|
||||
#include "failtest_helper.h"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <ccan/failtest/failtest_override.h>
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <ccan/failtest/failtest.h>
|
||||
#include "logging.h"
|
||||
#include "failtest_helper.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <ccan/tdb2/private.h>
|
||||
#include "private.h"
|
||||
#include <ccan/failtest/failtest_override.h>
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <ccan/failtest/failtest.h>
|
||||
#include "logging.h"
|
||||
#include "failtest_helper.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <ccan/ilog/ilog.h>
|
||||
#include "logging.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
|
||||
static uint64_t myhash(const void *key, size_t len, uint64_t seed, void *priv)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
|
||||
static uint64_t badhash(const void *key, size_t len, uint64_t seed, void *priv)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <err.h>
|
||||
#include "logging.h"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <ccan/tdb2/private.h>
|
||||
#include "private.h"
|
||||
#include <ccan/failtest/failtest_override.h>
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <ccan/failtest/failtest.h>
|
||||
#include "logging.h"
|
||||
#include "failtest_helper.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
#include "layout.h"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <ccan/tdb2/private.h>
|
||||
#include "private.h"
|
||||
#include <unistd.h>
|
||||
#include "lock-tracking.h"
|
||||
|
||||
@ -12,7 +12,7 @@ static int ftruncate_check(int fd, off_t length);
|
||||
#define ftruncate ftruncate_check
|
||||
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <ccan/tdb2/private.h>
|
||||
#include "private.h"
|
||||
#include <unistd.h>
|
||||
#include "lock-tracking.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
static ssize_t pwrite_check(int fd, const void *buf, size_t count, off_t offset);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
|
||||
static int mylock(int fd, int rw, off_t off, off_t len, bool waitflag,
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <ccan/failtest/failtest_override.h>
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
#include "layout.h"
|
||||
#include "failtest_helper.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include <ccan/tdb2/private.h>
|
||||
#include "private.h"
|
||||
#include <unistd.h>
|
||||
#include "lock-tracking.h"
|
||||
|
||||
#define fcntl fcntl_with_lockcheck
|
||||
#include "tdb2-source.h"
|
||||
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "tdb2-source.h"
|
||||
/* We had a bug where we marked the tdb read-only for a tdb_traverse_read.
|
||||
* If we then expanded the tdb, we would remap read-only, and later SEGV. */
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "external-agent.h"
|
||||
#include "logging.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
|
||||
static int log_count = 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* We need this otherwise fcntl locking fails. */
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "logging.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "logging.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "logging.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "logging.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "logging.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "logging.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <err.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "tdb1-lock-tracking.h"
|
||||
#define fcntl fcntl_with_lockcheck1
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#undef fcntl
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include <ccan/tdb2/private.h>
|
||||
#include "private.h"
|
||||
#include <unistd.h>
|
||||
#include "tdb1-lock-tracking.h"
|
||||
|
||||
#define fcntl fcntl_with_lockcheck1
|
||||
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "logging.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "logging.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* We should be able to tdb_check a O_RDONLY tdb, and we were previously allowed
|
||||
* to tdb_check() inside a transaction (though that's paranoia!). */
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "logging.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "logging.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "tdb1-lock-tracking.h"
|
||||
#define fcntl fcntl_with_lockcheck1
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#undef fcntl_with_lockcheck
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "logging.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "logging.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
|
||||
static int drop_count(struct tdb_context *tdb, unsigned int *count)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tdb2-source.h"
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "logging.h"
|
||||
|
||||
#define NUM_RECORDS 1000
|
||||
|
3
lib/tdb2/test/tap-interface.c
Normal file
3
lib/tdb2/test/tap-interface.c
Normal file
@ -0,0 +1,3 @@
|
||||
#include "tap-interface.h"
|
||||
|
||||
unsigned tap_ok_count, tap_ok_target = -1U;
|
41
lib/tdb2/test/tap-interface.h
Normal file
41
lib/tdb2/test/tap-interface.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
Simplistic implementation of tap interface.
|
||||
|
||||
Copyright (C) Rusty Russell 2012
|
||||
|
||||
** NOTE! The following LGPL license applies to the talloc
|
||||
** library. This does NOT imply that all of Samba is released
|
||||
** under the LGPL
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <err.h>
|
||||
|
||||
#ifndef __location__
|
||||
#define __TAP_STRING_LINE1__(s) #s
|
||||
#define __TAP_STRING_LINE2__(s) __TAP_STRING_LINE1__(s)
|
||||
#define __TAP_STRING_LINE3__ __TAP_STRING_LINE2__(__LINE__)
|
||||
#define __location__ __FILE__ ":" __TAP_STRING_LINE3__
|
||||
#endif
|
||||
|
||||
extern unsigned tap_ok_count, tap_ok_target;
|
||||
#define plan_tests(num) do { tap_ok_target = (num); } while(0)
|
||||
#define ok(e, ...) ((e) ? (printf("."), tap_ok_count++, true) : (warnx(__VA_ARGS__), false))
|
||||
#define ok1(e) ok((e), "%s:%s", __location__, #e)
|
||||
#define pass(...) (printf("."), tap_ok_count++)
|
||||
#define fail(...) warnx(__VA_ARGS__)
|
||||
#define diag printf
|
||||
#define exit_status() (tap_ok_count == tap_ok_target ? 0 : 1)
|
@ -10,8 +10,8 @@
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <ccan/tdb2/tdb1_private.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tdb1_private.h"
|
||||
#include "tap-interface.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@ -76,7 +76,7 @@ static enum agent_return do_operation(enum operation op, const char *name)
|
||||
ret = tdb_check(tdb, NULL, NULL) == TDB_SUCCESS ? SUCCESS : OTHER_FAILURE;
|
||||
break;
|
||||
case NEEDS_RECOVERY:
|
||||
ret = tdb1_needs_recovery(tdb) ? SUCCESS : FAILED;
|
||||
ret = external_agent_needs_rec(tdb);
|
||||
break;
|
||||
case CLOSE:
|
||||
ret = tdb_close(tdb) == 0 ? SUCCESS : OTHER_FAILURE;
|
||||
|
@ -37,4 +37,7 @@ enum agent_return external_agent_operation1(struct agent *handle,
|
||||
const char *agent_return_name1(enum agent_return ret);
|
||||
const char *operation_name1(enum operation op);
|
||||
|
||||
/* Internal use: */
|
||||
struct tdb_context;
|
||||
enum agent_return external_agent_needs_rec(struct tdb_context *tdb);
|
||||
#endif /* TDB_TEST_EXTERNAL_AGENT_H */
|
||||
|
@ -1,10 +1,10 @@
|
||||
/* We save the locks so we can reaquire them. */
|
||||
#include <ccan/tdb2/tdb1_private.h>
|
||||
#include "tdb1_private.h"
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <ccan/tap/tap.h>
|
||||
#include "tap-interface.h"
|
||||
#include "tdb1-lock-tracking.h"
|
||||
|
||||
struct lock {
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef TDB1_LOCK_TRACKING_H
|
||||
#define TDB1_LOCK_TRACKING_H
|
||||
#include <ccan/tdb2/private.h>
|
||||
#include "private.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Set this if you want a callback after fnctl unlock. */
|
||||
|
@ -1,21 +1,21 @@
|
||||
#include "config.h"
|
||||
#include <ccan/tdb2/check.c>
|
||||
#include <ccan/tdb2/free.c>
|
||||
#include <ccan/tdb2/hash.c>
|
||||
#include <ccan/tdb2/io.c>
|
||||
#include <ccan/tdb2/lock.c>
|
||||
#include <ccan/tdb2/open.c>
|
||||
#include <ccan/tdb2/summary.c>
|
||||
#include <ccan/tdb2/tdb.c>
|
||||
#include <ccan/tdb2/transaction.c>
|
||||
#include <ccan/tdb2/traverse.c>
|
||||
#include <ccan/tdb2/tdb1_check.c>
|
||||
#include <ccan/tdb2/tdb1_freelist.c>
|
||||
#include <ccan/tdb2/tdb1_hash.c>
|
||||
#include <ccan/tdb2/tdb1_io.c>
|
||||
#include <ccan/tdb2/tdb1_lock.c>
|
||||
#include <ccan/tdb2/tdb1_open.c>
|
||||
#include <ccan/tdb2/tdb1_summary.c>
|
||||
#include <ccan/tdb2/tdb1_tdb.c>
|
||||
#include <ccan/tdb2/tdb1_transaction.c>
|
||||
#include <ccan/tdb2/tdb1_traverse.c>
|
||||
#include "check.c"
|
||||
#include "free.c"
|
||||
#include "hash.c"
|
||||
#include "io.c"
|
||||
#include "lock.c"
|
||||
#include "open.c"
|
||||
#include "summary.c"
|
||||
#include "tdb.c"
|
||||
#include "transaction.c"
|
||||
#include "traverse.c"
|
||||
#include "tdb1_check.c"
|
||||
#include "tdb1_freelist.c"
|
||||
#include "tdb1_hash.c"
|
||||
#include "tdb1_io.c"
|
||||
#include "tdb1_lock.c"
|
||||
#include "tdb1_open.c"
|
||||
#include "tdb1_summary.c"
|
||||
#include "tdb1_tdb.c"
|
||||
#include "tdb1_transaction.c"
|
||||
#include "tdb1_traverse.c"
|
||||
|
Loading…
Reference in New Issue
Block a user