Commit c4ca9f54 authored by Rusty Russell's avatar Rusty Russell

tdb2: test: convert (non-invasive) run tests to api tests.

This reduces compilation time, since these are merely linked with the
pre-built module, rather than recompiling it into the test (which
allows for fancy things like failtest).

This reduces the test compile time down from about 62 seconds to 45
seconds.  Since ccanlint compiles tests three times (once normally,
once with coverage, and once with reduced config.h) this makes a
difference: we go from 780 seconds to 729 seconds.
parent d9cbd7d4
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <ccan/hash/hash.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "logging.h"
/* We use the same seed which we saw a failure on. */
......@@ -49,5 +54,3 @@ int main(int argc, char *argv[])
ok1(tap_log_messages == 0);
return exit_status();
}
#include "tdb2-source.h"
#include <ccan/tdb2/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 "logging.h"
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "logging.h"
static bool test_records(struct tdb_context *tdb)
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "logging.h"
static bool add_records(struct tdb_context *tdb)
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "logging.h"
static enum TDB_ERROR parse(TDB_DATA key, TDB_DATA data, TDB_DATA *expected)
......
#include "tdb2-source.h"
#include <ccan/tdb2/private.h> // struct tdb_context
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include "logging.h"
int main(int argc, char *argv[])
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "logging.h"
int main(int argc, char *argv[])
......@@ -7,7 +10,7 @@ int main(int argc, char *argv[])
unsigned int i;
struct tdb_context *tdb;
int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
TDB_NOMMAP|TDB_CONVERT,
TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1,
TDB_NOMMAP|TDB_VERSION1,
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include "logging.h"
int main(int argc, char *argv[])
......@@ -24,7 +28,7 @@ int main(int argc, char *argv[])
O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
if (!ok1(tdb))
continue;
seq = 0;
ok1(tdb_get_seqnum(tdb) == seq);
ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0);
......
#include "tdb2-source.h"
#include <ccan/tdb2/private.h> // for tdb_fcntl_unlock
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include "logging.h"
static int mylock(int fd, int rw, off_t off, off_t len, bool waitflag,
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdarg.h>
#include <err.h>
#include <unistd.h>
#include "external-agent.h"
#include "logging.h"
......@@ -93,4 +97,3 @@ int main(int argc, char *argv[])
free_external_agent(agent);
return exit_status();
}
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stddef.h>
#include "logging.h"
int main(int argc, char *argv[])
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "logging.h"
int main(int argc, char *argv[])
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "logging.h"
#define NUM_TESTS 50000
......
#include "tdb2-source.h"
#include <ccan/tdb2/private.h> // for tdb_context
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "logging.h"
int main(int argc, char *argv[])
......@@ -7,7 +11,7 @@ int main(int argc, char *argv[])
unsigned int i;
struct tdb_context *tdb;
int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
TDB_NOMMAP|TDB_CONVERT,
TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1,
TDB_NOMMAP|TDB_VERSION1,
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "logging.h"
#define NUM_RECORDS 1000
......@@ -53,7 +56,7 @@ int main(int argc, char *argv[])
unsigned int i, j;
struct tdb_context *tdb;
int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
TDB_NOMMAP|TDB_CONVERT,
TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1,
TDB_NOMMAP|TDB_VERSION1,
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include "logging.h"
#define NUM_RECORDS 1000
......@@ -50,7 +54,7 @@ int main(int argc, char *argv[])
union tdb_attribute seed_attr;
enum TDB_ERROR ecode;
int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
TDB_NOMMAP|TDB_CONVERT,
TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1,
TDB_NOMMAP|TDB_VERSION1,
......
......@@ -10,10 +10,15 @@
* Note that we don't hold a lock across tdb_traverse callbacks, so
* that doesn't matter.
*/
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include "logging.h"
static enum TDB_ERROR fork_in_parse(TDB_DATA key, TDB_DATA data,
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <limits.h>
#include <errno.h>
#include "logging.h"
#include "external-agent.h"
......@@ -142,7 +148,7 @@ int main(int argc, char *argv[])
if (!ok1(tdb))
break;
/* Simple cases: should succeed. */
/* Simple cases: should succeed. */
ecode = tdb_chainlock_with_timeout_internal(tdb, key, 20,
F_RDLCK);
ok1(ecode == TDB_SUCCESS);
......@@ -162,7 +168,7 @@ int main(int argc, char *argv[])
/* OK, get agent to start transaction, then we should time out. */
ok1(external_agent_operation(agent, OPEN, "run-locktimeout.tdb")
== SUCCESS);
ok1(external_agent_operation(agent, TRANSACTION_START, "")
ok1(external_agent_operation(agent, TRANSACTION_START, "")
== SUCCESS);
ecode = tdb_chainlock_with_timeout_internal(tdb, key, 20,
F_WRLCK);
......
#include "tdb2-source.h"
/* Another test revealed that we lost an entry. This reproduces it. */
#include <ccan/tdb2/tdb2.h>
#include <ccan/hash/hash.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "logging.h"
#define NUM_RECORDS 1189
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include "logging.h"
int main(int argc, char *argv[])
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include "logging.h"
#define MAX_SIZE 10000
......@@ -10,7 +14,7 @@ int main(int argc, char *argv[])
unsigned int i;
struct tdb_context *tdb;
int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
TDB_NOMMAP|TDB_CONVERT,
TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1,
TDB_NOMMAP|TDB_VERSION1,
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "logging.h"
int main(int argc, char *argv[])
......@@ -7,7 +10,7 @@ int main(int argc, char *argv[])
unsigned int i;
struct tdb_context *tdb;
int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
TDB_NOMMAP|TDB_CONVERT,
TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1,
TDB_NOMMAP|TDB_VERSION1,
......
#include "tdb2-source.h"
#include <ccan/tdb2/tdb2.h>
#include <ccan/tap/tap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include "logging.h"
int main(int argc, char *argv[])
......@@ -57,5 +61,3 @@ int main(int argc, char *argv[])
ok1(tap_log_messages == 0);
return exit_status();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment