Commit d0474952 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Get rid of many icc warnings. Addresses #1185.

git-svn-id: file:///svn/tokudb.1131b+1080a+1185@6397 c7de825b-a66e-492c-adef-691d508d4ae1
parent 68753fc5
...@@ -45,13 +45,13 @@ endif ...@@ -45,13 +45,13 @@ endif
LIBNAME=libdb.$(LIBEXT) LIBNAME=libdb.$(LIBEXT)
# GCOV_FLAGS = -fprofile-arcs -ftest-coverage # GCOV_FLAGS = -fprofile-arcs -ftest-coverage
CFLAGS += -Wall $(OPTFLAGS) $(GCOV_FLAGS) CFLAGS += -Werror -Wall $(OPTFLAGS) $(GCOV_FLAGS)
ifneq ($(CC),icc) ifneq ($(CC),icc)
CFLAGS += -Werror -g3 -ggdb3 CFLAGS += -g3 -ggdb3
else else
CFLAGS += -g CFLAGS += -g
CFLAGS += -diag-disable 128 # Don't complain that loops are not reachable from preceeding code.
CFLAGS += -diag-disable 981 # Don't complain about "operands are evaluated in unspecified order". This seems to be generated whenever more than one argument to a function or operand is computed by function call. CFLAGS += -diag-disable 981 # Don't complain about "operands are evaluated in unspecified order". This seems to be generated whenever more than one argument to a function or operand is computed by function call.
endif endif
TDB_CPPFLAGS = -I../../include TDB_CPPFLAGS = -I../../include
......
...@@ -18,26 +18,28 @@ typedef struct { ...@@ -18,26 +18,28 @@ typedef struct {
char waste[10240]; char waste[10240];
} DATA; } DATA;
int callback_set_malloc; static int callback_set_malloc;
DB* db; static DB* db;
DB* sdb; static DB* sdb;
DB_TXN *const null_txn = 0; static DB_TXN *const null_txn = 0;
DB_ENV *dbenv; static DB_ENV *dbenv;
static __attribute__((__unused__)) void* lastmalloced;
static void* my_malloc(size_t size) {
void* lastmalloced;
void* my_malloc(size_t size) {
void* p = malloc(size); void* p = malloc(size);
return p; return p;
} }
void* my_realloc(void *p, size_t size) { static __attribute__((__unused__))
void*
my_realloc (void *p, size_t size) {
return realloc(p, size); return realloc(p, size);
} }
void my_free(void * p) { static __attribute__((__unused__))
void
my_free(void * p) {
if (lastmalloced == p) { if (lastmalloced == p) {
if (verbose) printf("Freeing %p.\n", p); if (verbose) printf("Freeing %p.\n", p);
lastmalloced = NULL; lastmalloced = NULL;
...@@ -49,7 +51,8 @@ void my_free(void * p) { ...@@ -49,7 +51,8 @@ void my_free(void * p) {
* getname -- extracts a secondary key (the last name) from a primary * getname -- extracts a secondary key (the last name) from a primary
* key/data pair * key/data pair
*/ */
int getskey(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey) static int
getskey (DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey)
{ {
DATA* entry; DATA* entry;
...@@ -72,7 +75,8 @@ int getskey(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey) ...@@ -72,7 +75,8 @@ int getskey(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey)
return 0; return 0;
} }
void second_setup() { static void
second_setup (void) {
int r; int r;
dbenv = 0; dbenv = 0;
...@@ -93,7 +97,8 @@ void second_setup() { ...@@ -93,7 +97,8 @@ void second_setup() {
r = db->associate(db, null_txn, sdb, getskey, 0); CKERR(r); r = db->associate(db, null_txn, sdb, getskey, 0); CKERR(r);
} }
void insert_test() { static void
insert_test (void) {
int r; int r;
static DATA entry; static DATA entry;
DBT data; DBT data;
...@@ -108,7 +113,8 @@ void insert_test() { ...@@ -108,7 +113,8 @@ void insert_test() {
r = db->put(db, null_txn, &key, &data, 0); CKERR(r); r = db->put(db, null_txn, &key, &data, 0); CKERR(r);
} }
void delete_test() { static void
delete_test (void) {
int r; int r;
static DATA entry; static DATA entry;
DBT key; DBT key;
...@@ -121,7 +127,8 @@ void delete_test() { ...@@ -121,7 +127,8 @@ void delete_test() {
r = db->del(db, null_txn, &key, 0); CKERR(r); r = db->del(db, null_txn, &key, 0); CKERR(r);
} }
void close_dbs() { static void
close_dbs(void) {
int r; int r;
r = db->close(db, 0); CKERR(r); r = db->close(db, 0); CKERR(r);
......
...@@ -24,7 +24,8 @@ DB_ENV *dbenv; ...@@ -24,7 +24,8 @@ DB_ENV *dbenv;
int nummallocced = 0; int nummallocced = 0;
void* my_malloc(size_t size) { static void *
my_malloc (size_t size) {
void* p = malloc(size); void* p = malloc(size);
if (size != 0) { if (size != 0) {
nummallocced++; nummallocced++;
...@@ -33,13 +34,16 @@ void* my_malloc(size_t size) { ...@@ -33,13 +34,16 @@ void* my_malloc(size_t size) {
return p; return p;
} }
void* my_realloc(void *p, size_t size) { static __attribute__((__unused__))
void*
my_realloc (void *p, size_t size) {
void* newp = realloc(p, size); void* newp = realloc(p, size);
// if (verbose) printf("realloc [%d] %p.\n", (int)size, newp); // if (verbose) printf("realloc [%d] %p.\n", (int)size, newp);
return newp; return newp;
} }
void my_free(void * p) { static void
my_free (void * p) {
if (p) { if (p) {
nummallocced--; nummallocced--;
// if (verbose) printf("Free %p.\n", p); // if (verbose) printf("Free %p.\n", p);
...@@ -51,7 +55,8 @@ void my_free(void * p) { ...@@ -51,7 +55,8 @@ void my_free(void * p) {
* getname -- extracts a secondary key (the last name) from a primary * getname -- extracts a secondary key (the last name) from a primary
* key/data pair * key/data pair
*/ */
int getskey(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey) static int
getskey (DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey)
{ {
DATA* entry; DATA* entry;
...@@ -73,7 +78,7 @@ int getskey(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey) ...@@ -73,7 +78,7 @@ int getskey(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey)
return 0; return 0;
} }
void second_setup(u_int32_t dupflags) { static void second_setup (u_int32_t dupflags) {
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
...@@ -99,7 +104,8 @@ void second_setup(u_int32_t dupflags) { ...@@ -99,7 +104,8 @@ void second_setup(u_int32_t dupflags) {
r = db->associate(db, null_txn, sdb, getskey, 0); CKERR(r); r = db->associate(db, null_txn, sdb, getskey, 0); CKERR(r);
} }
void insert_test(int pkey, int skey) { static void
insert_test (int pkey, int skey) {
int r; int r;
DATA entry; DATA entry;
DBT data; DBT data;
...@@ -114,7 +120,8 @@ void insert_test(int pkey, int skey) { ...@@ -114,7 +120,8 @@ void insert_test(int pkey, int skey) {
r = db->put(db, null_txn, &key, &data, 0); CKERR(r); r = db->put(db, null_txn, &key, &data, 0); CKERR(r);
} }
DBT* dbt_init_malloc_and_copy(DBT* dbt, int something) { static DBT *
dbt_init_malloc_and_copy (DBT* dbt, int something) {
dbt_init_malloc(dbt); dbt_init_malloc(dbt);
dbt->size = sizeof(something); dbt->size = sizeof(something);
dbt->data = my_malloc(dbt->size); dbt->data = my_malloc(dbt->size);
...@@ -122,7 +129,8 @@ DBT* dbt_init_malloc_and_copy(DBT* dbt, int something) { ...@@ -122,7 +129,8 @@ DBT* dbt_init_malloc_and_copy(DBT* dbt, int something) {
return dbt; return dbt;
} }
void pget_test_set_skey_pkey(DBC* dbc, u_int32_t flag, int expect, int set_skey, int skey_set, int set_pkey, int pkey_set) { static void
pget_test_set_skey_pkey (DBC* dbc, u_int32_t flag, int expect, int set_skey, int skey_set, int set_pkey, int pkey_set) {
int r; int r;
DBT skey; DBT skey;
DBT pkey; DBT pkey;
...@@ -140,11 +148,13 @@ void pget_test_set_skey_pkey(DBC* dbc, u_int32_t flag, int expect, int set_skey, ...@@ -140,11 +148,13 @@ void pget_test_set_skey_pkey(DBC* dbc, u_int32_t flag, int expect, int set_skey,
my_free(data.data); my_free(data.data);
} }
void pget_test(DBC* dbc, u_int32_t flag, u_int32_t expect) { static void
pget_test (DBC* dbc, u_int32_t flag, u_int32_t expect) {
pget_test_set_skey_pkey(dbc, flag, expect, 0, 0, 0, 0); pget_test_set_skey_pkey(dbc, flag, expect, 0, 0, 0, 0);
} }
void close_dbs() { static void
close_dbs (void) {
int r; int r;
r = db->close(db, 0); CKERR(r); r = db->close(db, 0); CKERR(r);
...@@ -152,7 +162,8 @@ void close_dbs() { ...@@ -152,7 +162,8 @@ void close_dbs() {
} }
u_int32_t get_dupflags(u_int32_t flag) { static u_int32_t
get_dupflags (u_int32_t flag) {
if (flag == DB_NEXT_DUP) { if (flag == DB_NEXT_DUP) {
return DB_DUP | DB_DUPSORT; return DB_DUP | DB_DUPSORT;
} }
...@@ -166,7 +177,8 @@ const int skeysmall = 11; ...@@ -166,7 +177,8 @@ const int skeysmall = 11;
const int skeymid = 13; const int skeymid = 13;
const int skeybig = 17; const int skeybig = 17;
void insert_setup(u_int32_t flag) { static void
insert_setup (u_int32_t flag) {
switch (flag) { switch (flag) {
case (DB_SET_RANGE): //Must be inserted in descending case (DB_SET_RANGE): //Must be inserted in descending
case (DB_SET): //Just insert any two. case (DB_SET): //Just insert any two.
...@@ -208,7 +220,8 @@ void insert_setup(u_int32_t flag) { ...@@ -208,7 +220,8 @@ void insert_setup(u_int32_t flag) {
} }
void cursor_setup(DBC* dbc, u_int32_t flag) { static void
cursor_setup (DBC* dbc, u_int32_t flag) {
switch (flag) { switch (flag) {
#ifdef DB_NEXT_NODUP #ifdef DB_NEXT_NODUP
case (DB_NEXT_NODUP): case (DB_NEXT_NODUP):
......
...@@ -22,7 +22,8 @@ DB_ENV *dbenv; ...@@ -22,7 +22,8 @@ DB_ENV *dbenv;
u_int32_t set_ulen; u_int32_t set_ulen;
int32_t key_1 = 1; int32_t key_1 = 1;
void setup(void) { static void
setup(void) {
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
...@@ -33,7 +34,8 @@ void setup(void) { ...@@ -33,7 +34,8 @@ void setup(void) {
r = db->open(db, null_txn, ENVDIR "/primary.db", NULL, DB_BTREE, DB_CREATE, 0600); CKERR(r); r = db->open(db, null_txn, ENVDIR "/primary.db", NULL, DB_BTREE, DB_CREATE, 0600); CKERR(r);
} }
void insert_test(void) { static void
insert_test (void) {
int r; int r;
DATA entry; DATA entry;
DBT data; DBT data;
...@@ -47,7 +49,8 @@ void insert_test(void) { ...@@ -47,7 +49,8 @@ void insert_test(void) {
r = db->put(db, null_txn, &key, &data, 0); CKERR(r); r = db->put(db, null_txn, &key, &data, 0); CKERR(r);
} }
void close_dbs() { static void
close_dbs (void) {
int r; int r;
r = db->close(db, 0); CKERR(r); r = db->close(db, 0); CKERR(r);
...@@ -132,7 +135,7 @@ int main(int argc, const char *argv[]) { ...@@ -132,7 +135,7 @@ int main(int argc, const char *argv[]) {
BOOL ulen_should_change = FALSE; BOOL ulen_should_change = FALSE;
#if defined(USE_TDB) #if defined(USE_TDB)
if (flags[j] == DB_DBT_REALLOC) { if (flags[j] == DB_DBT_REALLOC) {
ulen_should_change = old_ulen < sizeof(DATA); ulen_should_change = (BOOL)(old_ulen < sizeof(DATA));
} }
#endif #endif
assert(ulen_should_change == ulen_changed); assert(ulen_should_change == ulen_changed);
......
...@@ -13,9 +13,10 @@ ...@@ -13,9 +13,10 @@
#include "test.h" #include "test.h"
#if USE_TDB #ifdef USE_TDB
enum {INFLATE=128}; enum {INFLATE=128};
void db_put(DB *db, int k, int v) { static void
db_put (DB *db, int k, int v) {
DBT key, val; DBT key, val;
static int vv[INFLATE]; static int vv[INFLATE];
vv[0] = v; vv[0] = v;
...@@ -23,7 +24,8 @@ void db_put(DB *db, int k, int v) { ...@@ -23,7 +24,8 @@ void db_put(DB *db, int k, int v) {
CKERR(r); CKERR(r);
} }
void expect_db_delboth(DB *db, int k, int v, u_int32_t flags, int expectr) { static void
expect_db_delboth (DB *db, int k, int v, u_int32_t flags, int expectr) {
DBT key, val; DBT key, val;
static int vv[INFLATE]; static int vv[INFLATE];
vv[0] = v; vv[0] = v;
...@@ -31,7 +33,8 @@ void expect_db_delboth(DB *db, int k, int v, u_int32_t flags, int expectr) { ...@@ -31,7 +33,8 @@ void expect_db_delboth(DB *db, int k, int v, u_int32_t flags, int expectr) {
CKERR2(r, expectr); CKERR2(r, expectr);
} }
void expect_db_getboth(DB *db, int k, int v, int expectr) { static void
expect_db_getboth (DB *db, int k, int v, int expectr) {
DBT key, val; DBT key, val;
static int vv[INFLATE]; static int vv[INFLATE];
vv[0] = v; vv[0] = v;
...@@ -39,7 +42,8 @@ void expect_db_getboth(DB *db, int k, int v, int expectr) { ...@@ -39,7 +42,8 @@ void expect_db_getboth(DB *db, int k, int v, int expectr) {
CKERR2(r, expectr); CKERR2(r, expectr);
} }
void test_db_delboth(int n, int dup_mode) { static void
test_db_delboth (int n, int dup_mode) {
if (verbose) printf("test_db_delboth:%d %d\n", n, dup_mode); if (verbose) printf("test_db_delboth:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -162,7 +166,7 @@ int main(int argc, const char *argv[]) { ...@@ -162,7 +166,7 @@ int main(int argc, const char *argv[]) {
parse_args(argc, argv); parse_args(argc, argv);
#if USE_TDB #ifdef USE_TDB
test_db_delboth(0, 0); test_db_delboth(0, 0);
int i; int i;
......
...@@ -15,25 +15,29 @@ ...@@ -15,25 +15,29 @@
void db_put(DB *db, int k, int v) { static void
db_put (DB *db, int k, int v) {
DBT key, val; DBT key, val;
int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0); int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0);
assert(r == 0); assert(r == 0);
} }
void expect_db_del(DB *db, int k, int flags, int expectr) { static void
expect_db_del (DB *db, int k, int flags, int expectr) {
DBT key; DBT key;
int r = db->del(db, 0, dbt_init(&key, &k, sizeof k), flags); int r = db->del(db, 0, dbt_init(&key, &k, sizeof k), flags);
assert(r == expectr); assert(r == expectr);
} }
void expect_db_get(DB *db, int k, int expectr) { static void
expect_db_get (DB *db, int k, int expectr) {
DBT key, val; DBT key, val;
int r = db->get(db, 0, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); int r = db->get(db, 0, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
assert(r == expectr); assert(r == expectr);
} }
void test_db_delete(int n, int dup_mode) { static void
test_db_delete (int n, int dup_mode) {
if (verbose) printf("test_db_delete:%d %d\n", n, dup_mode); if (verbose) printf("test_db_delete:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -83,22 +87,23 @@ void test_db_delete(int n, int dup_mode) { ...@@ -83,22 +87,23 @@ void test_db_delete(int n, int dup_mode) {
} }
expect_db_del(db, htonl(n), 0, DB_NOTFOUND); expect_db_del(db, htonl(n), 0, DB_NOTFOUND);
#if USE_TDB #if defined(USE_TDB)
expect_db_del(db, htonl(n), DB_DELETE_ANY, 0); expect_db_del(db, htonl(n), DB_DELETE_ANY, 0);
#endif #endif
#if USE_BDB && defined(DB_DELETE_ANY) #if defined(USE_BDB) && defined(DB_DELETE_ANY)
#if DB_DELETE_ANY == 0 #if DB_DELETE_ANY == 0
expect_db_del(db, htonl(n), DB_DELETE_ANY, DB_NOTFOUND); expect_db_del(db, htonl(n), DB_DELETE_ANY, DB_NOTFOUND);
#else #else
expect_db_del(db, htonl(n), DB_DELETE_ANY, EINVAL); expect_db_del(db, htonl(n), DB_DELETE_ANY, EINVAL);
#endif #endif
#endif #endif
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
} }
void test_db_get_datasize0() { static void
test_db_get_datasize0 (void) {
if (verbose) printf("test_db_get_datasize0\n"); if (verbose) printf("test_db_get_datasize0\n");
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -30,7 +30,8 @@ DB_ENV *dbenv = 0; ...@@ -30,7 +30,8 @@ DB_ENV *dbenv = 0;
* getname -- extracts a secondary key (the last name) from a primary * getname -- extracts a secondary key (the last name) from a primary
* key/data pair * key/data pair
*/ */
int getskey(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey) static int
getskey (DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey)
{ {
/* /*
* Since the secondary key is a simple structure member of the * Since the secondary key is a simple structure member of the
...@@ -69,7 +70,8 @@ int getskey(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey) ...@@ -69,7 +70,8 @@ int getskey(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey)
return 0; return 0;
} }
void second_setup() { static void
second_setup (void) {
int r; int r;
/* Open/create primary */ /* Open/create primary */
...@@ -83,7 +85,8 @@ void second_setup() { ...@@ -83,7 +85,8 @@ void second_setup() {
r = db->associate(db, null_txn, sdb, getskey, 0); CKERR(r); r = db->associate(db, null_txn, sdb, getskey, 0); CKERR(r);
} }
void insert() { static void
insert (void) {
int r; int r;
DATA entry; DATA entry;
DBT data; DBT data;
...@@ -98,7 +101,8 @@ void insert() { ...@@ -98,7 +101,8 @@ void insert() {
r = db->put(db, null_txn, &key, &data, 0); CKERR(r); r = db->put(db, null_txn, &key, &data, 0); CKERR(r);
} }
void check_secondary(int expect_r) { static void
check_secondary (int expect_r) {
int r; int r;
DBC *c; DBC *c;
DBT skey; DBT skey;
...@@ -111,7 +115,8 @@ void check_secondary(int expect_r) { ...@@ -111,7 +115,8 @@ void check_secondary(int expect_r) {
r = c->c_close(c); CKERR(r); r = c->c_close(c); CKERR(r);
} }
void close_dbs() { static void
close_dbs (void) {
int r; int r;
r = db->close(db, 0); CKERR(r); r = db->close(db, 0); CKERR(r);
......
...@@ -33,7 +33,8 @@ int extra_flags; ...@@ -33,7 +33,8 @@ int extra_flags;
char* home; char* home;
void reinit_config(int set_home, int set_DB_ENVIRON, int set_DB_HOME) { static void
reinit_config (int set_home, int set_DB_ENVIRON, int set_DB_HOME) {
int r = 0; int r = 0;
//Return to base dir //Return to base dir
r = fchdir(rootfd); assert(r == 0); r = fchdir(rootfd); assert(r == 0);
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
int main(int argc, char** argv) { int main(int argc, char** argv) {
DB_ENV *dbenv; DB_ENV *dbenv;
int r; int r;
int verbose = 0; int __attribute__((__unused__)) verbose = 0;
if (argc == 2 && !strcmp(argv[1], "-v")) verbose = 1; if (argc == 2 && !strcmp(argv[1], "-v")) verbose = 1;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
......
...@@ -48,12 +48,13 @@ typedef struct { ...@@ -48,12 +48,13 @@ typedef struct {
TEST tests[4]; TEST tests[4];
} STEST; } STEST;
DB *dbp; static DB *dbp;
DB *sdbp; static DB *sdbp;
DB_TXN *const null_txn = 0; static DB_TXN *const null_txn = 0;
DB_ENV *dbenv; static DB_ENV *dbenv;
void setup(u_int32_t flags) { static void
setup (u_int32_t flags) {
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
...@@ -67,17 +68,20 @@ void setup(u_int32_t flags) { ...@@ -67,17 +68,20 @@ void setup(u_int32_t flags) {
r = dbp->open(dbp, NULL, ENVDIR "/primary.db", NULL, DB_BTREE, DB_CREATE, 0600); CKERR(r); r = dbp->open(dbp, NULL, ENVDIR "/primary.db", NULL, DB_BTREE, DB_CREATE, 0600); CKERR(r);
} }
void close_dbs() { static void
close_dbs (void) {
int r; int r;
r = dbp->close(dbp, 0); CKERR(r); r = dbp->close(dbp, 0); CKERR(r);
} }
void close_secondary() { static void
close_secondary (void) {
int r; int r;
r = sdbp->close(sdbp, 0); CKERR(r); r = sdbp->close(sdbp, 0); CKERR(r);
} }
void insert_bad_flags(DB* db, u_int32_t flags, int r_expect, int keyint, int dataint) { static void
insert_bad_flags (DB* db, u_int32_t flags, int r_expect, int keyint, int dataint) {
DBT key; DBT key;
DBT data; DBT data;
int r; int r;
...@@ -88,7 +92,8 @@ void insert_bad_flags(DB* db, u_int32_t flags, int r_expect, int keyint, int dat ...@@ -88,7 +92,8 @@ void insert_bad_flags(DB* db, u_int32_t flags, int r_expect, int keyint, int dat
CKERR2(r, r_expect); CKERR2(r, r_expect);
} }
void cinsert_bad_flags(DBC* dbc, u_int32_t flags, int r_expect, int keyint, int dataint) { static void
cinsert_bad_flags (DBC* dbc, u_int32_t flags, int r_expect, int keyint, int dataint) {
DBT key; DBT key;
DBT data; DBT data;
int r; int r;
...@@ -99,7 +104,8 @@ void cinsert_bad_flags(DBC* dbc, u_int32_t flags, int r_expect, int keyint, int ...@@ -99,7 +104,8 @@ void cinsert_bad_flags(DBC* dbc, u_int32_t flags, int r_expect, int keyint, int
CKERR2(r, r_expect); CKERR2(r, r_expect);
} }
void get_bad_flags(DB* db, u_int32_t flags, int r_expect, int keyint, int dataint) { static void
get_bad_flags (DB* db, u_int32_t flags, int r_expect, int keyint, int dataint) {
DBT key; DBT key;
DBT data; DBT data;
int r; int r;
...@@ -113,7 +119,8 @@ void get_bad_flags(DB* db, u_int32_t flags, int r_expect, int keyint, int datain ...@@ -113,7 +119,8 @@ void get_bad_flags(DB* db, u_int32_t flags, int r_expect, int keyint, int datain
assert(*(int*)data.data == dataint); assert(*(int*)data.data == dataint);
} }
void cinsert_test(TEST tests[4]) { static void
cinsert_test (TEST tests[4]) {
int r; int r;
int i; int i;
DBC *dbc; DBC *dbc;
...@@ -134,7 +141,8 @@ void cinsert_test(TEST tests[4]) { ...@@ -134,7 +141,8 @@ void cinsert_test(TEST tests[4]) {
r = dbc->c_close(dbc); CKERR(r); r = dbc->c_close(dbc); CKERR(r);
} }
void stest(TEST tests[4]) { static void
stest (TEST tests[4]) {
int i; int i;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
...@@ -206,16 +214,18 @@ const int num_get = sizeof(get_tests) / sizeof(get_tests[0]); ...@@ -206,16 +214,18 @@ const int num_get = sizeof(get_tests) / sizeof(get_tests[0]);
STEST stests[] = { STEST stests[] = {
{0, 0, {{SGET, DB_GET_BOTH, EINVAL, 0, 1}, {NONE, 0, 0, 0, 0}, }}, {0, 0, {{SGET, DB_GET_BOTH, EINVAL, 0, 1}, {NONE, 0, 0, 0, 0}, }},
}; };
const int num_stests = sizeof(stests) / sizeof(stests[0]); static const int num_stests = sizeof(stests) / sizeof(stests[0]);
int identity_callback(DB *secondary __attribute__((__unused__)), const DBT *key, const DBT *UU(data), DBT *result) { static int
identity_callback (DB *secondary __attribute__((__unused__)), const DBT *key, const DBT *UU(data), DBT *result) {
memset(result, 0, sizeof(result)); memset(result, 0, sizeof(result));
result->size = key->size; result->size = key->size;
result->data = key->data; result->data = key->data;
return 0; return 0;
} }
void setup_secondary(u_int32_t flags) { static void
setup_secondary (u_int32_t flags) {
int r; int r;
/* Open/create primary */ /* Open/create primary */
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
// ENVDIR is defined in the Makefile // ENVDIR is defined in the Makefile
int dbtcmp(DBT *dbt1, DBT *dbt2) { static int
dbtcmp (DBT *dbt1, DBT *dbt2) {
int r; int r;
r = dbt1->size - dbt2->size; if (r) return r; r = dbt1->size - dbt2->size; if (r) return r;
...@@ -32,7 +33,8 @@ DB_ENV *dbenv; ...@@ -32,7 +33,8 @@ DB_ENV *dbenv;
* getname -- extracts a secondary key (the last name) from a primary * getname -- extracts a secondary key (the last name) from a primary
* key/data pair * key/data pair
*/ */
int getname(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey) static int
getname(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey)
{ {
/* /*
* Since the secondary key is a simple structure member of the * Since the secondary key is a simple structure member of the
...@@ -49,7 +51,8 @@ int getname(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey) ...@@ -49,7 +51,8 @@ int getname(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey)
return (0); return (0);
} }
void second_setup() { static void
second_setup (void) {
int r; int r;
/* Open/create primary */ /* Open/create primary */
...@@ -71,7 +74,8 @@ void second_setup() { ...@@ -71,7 +74,8 @@ void second_setup() {
r = dbp->associate(dbp, NULL, sdbp, getname, 0); CKERR(r); r = dbp->associate(dbp, NULL, sdbp, getname, 0); CKERR(r);
} }
void setup_student(struct student_record *s) { static void
setup_student (struct student_record *s) {
memset(s, 0, sizeof(struct student_record)); memset(s, 0, sizeof(struct student_record));
memcpy(&s->student_id, "WC42" SPACES, sizeof(s->student_id)); memcpy(&s->student_id, "WC42" SPACES, sizeof(s->student_id));
//Padded with enough spaces to fill out last/first name. //Padded with enough spaces to fill out last/first name.
...@@ -79,7 +83,8 @@ void setup_student(struct student_record *s) { ...@@ -79,7 +83,8 @@ void setup_student(struct student_record *s) {
memcpy(&s->first_name, "Winston" SPACES, sizeof(s->first_name)); memcpy(&s->first_name, "Winston" SPACES, sizeof(s->first_name));
} }
void insert_test() { static void
insert_test (void) {
struct student_record s; struct student_record s;
DBT data; DBT data;
DBT key; DBT key;
...@@ -124,7 +129,8 @@ void insert_test() { ...@@ -124,7 +129,8 @@ void insert_test() {
r = dbp->pget(dbp, null_txn, &key, &testkey, &data, 0); assert(r == EINVAL); r = dbp->pget(dbp, null_txn, &key, &testkey, &data, 0); assert(r == EINVAL);
} }
void delete_from_primary() { static void
delete_from_primary (void) {
int r; int r;
DBT key; DBT key;
...@@ -134,7 +140,8 @@ void delete_from_primary() { ...@@ -134,7 +140,8 @@ void delete_from_primary() {
r = dbp->del(dbp, null_txn, &key, 0); CKERR(r); r = dbp->del(dbp, null_txn, &key, 0); CKERR(r);
} }
void delete_from_secondary() { static void
delete_from_secondary (void) {
int r; int r;
DBT skey; DBT skey;
DBT data; DBT data;
...@@ -150,7 +157,8 @@ void delete_from_secondary() { ...@@ -150,7 +157,8 @@ void delete_from_secondary() {
r = sdbp->del(sdbp, null_txn, &skey, 0); CKERR(r); r = sdbp->del(sdbp, null_txn, &skey, 0); CKERR(r);
} }
void verify_gone() { static void
verify_gone (void) {
int r; int r;
DBT key; DBT key;
DBT skey; DBT skey;
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#include "test.h" #include "test.h"
void test_db_set_flags(int flags, int expectr, int flags2, int expectr2) { static void
test_db_set_flags (int flags, int expectr, int flags2, int expectr2) {
if (verbose) printf("test_db_set_flags:%d %d %d %d\n", flags, expectr, flags2, expectr2); if (verbose) printf("test_db_set_flags:%d %d %d %d\n", flags, expectr, flags2, expectr2);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
This diff is collapsed.
...@@ -12,14 +12,16 @@ ...@@ -12,14 +12,16 @@
#include "test.h" #include "test.h"
void db_put(DB *db, int k, int v) { static void
db_put (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
assert(r == 0); assert(r == 0);
} }
void expect(DBC *cursor, int k, int v) { static void
expect (DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT);
assert(r == 0); assert(r == 0);
...@@ -29,7 +31,7 @@ void expect(DBC *cursor, int k, int v) { ...@@ -29,7 +31,7 @@ void expect(DBC *cursor, int k, int v) {
assert(val.size == sizeof v); assert(val.size == sizeof v);
int vv; int vv;
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %d got %d - %d %d\n", htonl(k), htonl(kk), htonl(v), htonl(vv)); if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
assert(kk == k); assert(kk == k);
assert(vv == v); assert(vv == v);
...@@ -38,7 +40,8 @@ void expect(DBC *cursor, int k, int v) { ...@@ -38,7 +40,8 @@ void expect(DBC *cursor, int k, int v) {
} }
/* verify dup keys delete */ /* verify dup keys delete */
void test_dup_delete(int n, int dup_mode) { static void
test_dup_delete (int n, int dup_mode) {
if (verbose) printf("test_dup_delete:%d %d\n", n, dup_mode); if (verbose) printf("test_dup_delete:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -131,7 +134,9 @@ void test_dup_delete(int n, int dup_mode) { ...@@ -131,7 +134,9 @@ void test_dup_delete(int n, int dup_mode) {
assert(r == 0); assert(r == 0);
} }
void test_dup_delete_delete(int n) { static __attribute__((__unused__))
void
test_dup_delete_delete (int n) {
if (verbose) printf("test_dup_delete_delete:%d\n", n); if (verbose) printf("test_dup_delete_delete:%d\n", n);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -211,7 +216,8 @@ void test_dup_delete_delete(int n) { ...@@ -211,7 +216,8 @@ void test_dup_delete_delete(int n) {
assert(r == 0); assert(r == 0);
} }
void test_dup_delete_insert(int n, int dup_mode) { static void
test_dup_delete_insert (int n, int dup_mode) {
if (verbose) printf("test_dup_delete_insert:%d %d\n", n, dup_mode); if (verbose) printf("test_dup_delete_insert:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -316,7 +322,9 @@ void test_dup_delete_insert(int n, int dup_mode) { ...@@ -316,7 +322,9 @@ void test_dup_delete_insert(int n, int dup_mode) {
assert(r == 0); assert(r == 0);
} }
void test_all_dup_delete_insert(int n) { static __attribute__((__unused__))
void
test_all_dup_delete_insert (int n) {
if (verbose) printf("test_all_dup_delete_insert:%d\n", n); if (verbose) printf("test_all_dup_delete_insert:%d\n", n);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -391,7 +399,8 @@ void test_all_dup_delete_insert(int n) { ...@@ -391,7 +399,8 @@ void test_all_dup_delete_insert(int n) {
assert(r == 0); assert(r == 0);
} }
void test_walk_empty(int n, int dup_mode) { static void
test_walk_empty (int n, int dup_mode) {
if (verbose) printf("test_walk_empty:%d %d\n", n, dup_mode); if (verbose) printf("test_walk_empty:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -463,7 +472,9 @@ void test_walk_empty(int n, int dup_mode) { ...@@ -463,7 +472,9 @@ void test_walk_empty(int n, int dup_mode) {
} }
/* insert, close, delete, insert, search */ /* insert, close, delete, insert, search */
void test_icdi_search(int n, int dup_mode) { static __attribute__((__unused__))
void
test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -552,7 +563,9 @@ void test_icdi_search(int n, int dup_mode) { ...@@ -552,7 +563,9 @@ void test_icdi_search(int n, int dup_mode) {
} }
/* insert, close, insert, search */ /* insert, close, insert, search */
void test_ici_search(int n, int dup_mode) { static __attribute__((__unused__))
void
test_ici_search (int n, int dup_mode) {
if (verbose) printf("test_ici_search:%d %d\n", n, dup_mode); if (verbose) printf("test_ici_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -633,7 +646,8 @@ void test_ici_search(int n, int dup_mode) { ...@@ -633,7 +646,8 @@ void test_ici_search(int n, int dup_mode) {
assert(r == 0); assert(r == 0);
} }
void expect_db_lookup(DB *db, int k, int v) { static void
expect_db_lookup (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
...@@ -646,7 +660,9 @@ void expect_db_lookup(DB *db, int k, int v) { ...@@ -646,7 +660,9 @@ void expect_db_lookup(DB *db, int k, int v) {
} }
/* insert 0, insert 1, close, insert 0, search 0 */ /* insert 0, insert 1, close, insert 0, search 0 */
void test_i0i1ci0_search(int n, int dup_mode) { static __attribute__((__unused__))
void
test_i0i1ci0_search (int n, int dup_mode) {
if (verbose) printf("test_i0i1ci0_search:%d %d\n", n, dup_mode); if (verbose) printf("test_i0i1ci0_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -709,7 +725,7 @@ int main(int argc, const char *argv[]) { ...@@ -709,7 +725,7 @@ int main(int argc, const char *argv[]) {
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
mkdir(ENVDIR, 0777); mkdir(ENVDIR, 0777);
#if USE_BDB #ifdef USE_BDB
/* dup tests */ /* dup tests */
for (i = 1; i <= (1<<16); i *= 2) { for (i = 1; i <= (1<<16); i *= 2) {
test_dup_delete(i, DB_DUP); test_dup_delete(i, DB_DUP);
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
int errors; int errors;
void db_put(DB *db, int k, int v, u_int32_t put_flags, int rexpect) { static void
db_put (DB *db, int k, int v, u_int32_t put_flags, int rexpect) {
DBT key, val; DBT key, val;
// Turn off error messages if we expect there to be an error. // Turn off error messages if we expect there to be an error.
if (rexpect!=0) { if (rexpect!=0) {
...@@ -25,35 +26,38 @@ void db_put(DB *db, int k, int v, u_int32_t put_flags, int rexpect) { ...@@ -25,35 +26,38 @@ void db_put(DB *db, int k, int v, u_int32_t put_flags, int rexpect) {
} }
int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), put_flags); int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), put_flags);
if (r != rexpect) { if (r != rexpect) {
#if USE_TDB if (IS_TDB) {
if (r == EINVAL && put_flags == DB_NODUPDATA) { if (r == EINVAL && put_flags == DB_NODUPDATA) {
static int did_warn = 0; static int did_warn = 0;
if (!did_warn) { if (!did_warn) {
if (verbose) printf("%s:%d:WARNING:tokdub does not support DB_NODUPDATA yet\n", __FILE__, __LINE__); if (verbose) printf("%s:%d:WARNING:tokdub does not support DB_NODUPDATA yet\n", __FILE__, __LINE__);
did_warn=1; did_warn=1;
}
return;
} }
return; }
}
#endif
printf("Expected %d, got %d\n", rexpect, r); printf("Expected %d, got %d\n", rexpect, r);
if (r != rexpect) errors = 1; if (r != rexpect) errors = 1;
} }
} }
int maybe_do_db_dup_warning (int r, int dup_mode) { static int
#if USE_TDB maybe_do_db_dup_warning (int r, int dup_mode) {
static int did_warn=0; if (IS_TDB) {
if (r != 0 && dup_mode == DB_DUP) { static int did_warn=0;
if (did_warn==0) { if (r != 0 && dup_mode == DB_DUP) {
did_warn=1; if (did_warn==0) {
if (verbose) printf("%s:%d:WARNING: tokudb does not support DB_DUP\n", __FILE__, __LINE__); did_warn=1;
if (verbose) printf("%s:%d:WARNING: tokudb does not support DB_DUP\n", __FILE__, __LINE__);
}
return 1;
} }
return 1;
} }
#endif
return 0; return 0;
} }
void test_dup_key(int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup) {
static void
test_dup_key (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup) {
if (verbose) printf("test_dup_key: %d, %u, %d, %d\n", dup_mode, put_flags, rexpect, rexpectdupdup); if (verbose) printf("test_dup_key: %d, %u, %d, %d\n", dup_mode, put_flags, rexpect, rexpectdupdup);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -104,7 +108,8 @@ void test_dup_key(int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdup ...@@ -104,7 +108,8 @@ void test_dup_key(int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdup
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
} }
void test_dup_dup(int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup) { static void
test_dup_dup (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup) {
if (verbose) printf("test_dup_dup: %d, %u, %d, %d\n", dup_mode, put_flags, rexpect, rexpectdupdup); if (verbose) printf("test_dup_dup: %d, %u, %d, %d\n", dup_mode, put_flags, rexpect, rexpectdupdup);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -155,7 +160,8 @@ void test_dup_dup(int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdup ...@@ -155,7 +160,8 @@ void test_dup_dup(int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdup
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
} }
void test_put_00_01_01(int dup_mode, u_int32_t put_flags) { static void
test_put_00_01_01 (int dup_mode, u_int32_t put_flags) {
if (verbose) printf("test_put_00_01_01: %d, %u\n", dup_mode, put_flags); if (verbose) printf("test_put_00_01_01: %d, %u\n", dup_mode, put_flags);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -185,9 +191,9 @@ void test_put_00_01_01(int dup_mode, u_int32_t put_flags) { ...@@ -185,9 +191,9 @@ void test_put_00_01_01(int dup_mode, u_int32_t put_flags) {
db_put(db, 0, 1, put_flags, expectr); db_put(db, 0, 1, put_flags, expectr);
expectr = (put_flags == DB_NOOVERWRITE || dup_mode & DB_DUPSORT) ? DB_KEYEXIST : 0; expectr = (put_flags == DB_NOOVERWRITE || dup_mode & DB_DUPSORT) ? DB_KEYEXIST : 0;
#if USE_TDB if (IS_TDB) {
if (put_flags == DB_YESOVERWRITE) expectr = 0; if (put_flags == DB_YESOVERWRITE) expectr = 0;
#endif }
db_put(db, 0, 1, put_flags, expectr); db_put(db, 0, 1, put_flags, expectr);
DBC *cursor; DBC *cursor;
...@@ -215,9 +221,8 @@ void test_put_00_01_01(int dup_mode, u_int32_t put_flags) { ...@@ -215,9 +221,8 @@ void test_put_00_01_01(int dup_mode, u_int32_t put_flags) {
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
int yes_overwrite=0; int yes_overwrite=0;
#ifdef USE_TDB if (IS_TDB)
yes_overwrite = DB_YESOVERWRITE; yes_overwrite = DB_YESOVERWRITE;
#endif
parse_args(argc, argv); parse_args(argc, argv);
...@@ -239,13 +244,13 @@ int main(int argc, const char *argv[]) { ...@@ -239,13 +244,13 @@ int main(int argc, const char *argv[]) {
test_dup_key(DB_DUP, DB_NODUPDATA, EINVAL, EINVAL); test_dup_key(DB_DUP, DB_NODUPDATA, EINVAL, EINVAL);
test_dup_key(DB_DUP, DB_NOOVERWRITE, 0, DB_KEYEXIST); test_dup_key(DB_DUP, DB_NOOVERWRITE, 0, DB_KEYEXIST);
#if USE_TDB if (IS_TDB) {
test_dup_key(DB_DUP | DB_DUPSORT, 0, EINVAL, EINVAL); test_dup_key(DB_DUP | DB_DUPSORT, 0, EINVAL, EINVAL);
//test_dup_key(DB_DUP | DB_DUPSORT, 0, 0, 0); //test_dup_key(DB_DUP | DB_DUPSORT, 0, 0, 0);
test_dup_key(DB_DUP | DB_DUPSORT, DB_YESOVERWRITE, 0, 0); test_dup_key(DB_DUP | DB_DUPSORT, DB_YESOVERWRITE, 0, 0);
#else } else {
test_dup_key(DB_DUP | DB_DUPSORT, 0, 0, 0); test_dup_key(DB_DUP | DB_DUPSORT, 0, 0, 0);
#endif }
test_dup_key(DB_DUP | DB_DUPSORT, DB_NODUPDATA, 0, 0); test_dup_key(DB_DUP | DB_DUPSORT, DB_NODUPDATA, 0, 0);
test_dup_key(DB_DUP | DB_DUPSORT, DB_NOOVERWRITE, 0, DB_KEYEXIST); test_dup_key(DB_DUP | DB_DUPSORT, DB_NOOVERWRITE, 0, DB_KEYEXIST);
...@@ -258,13 +263,13 @@ int main(int argc, const char *argv[]) { ...@@ -258,13 +263,13 @@ int main(int argc, const char *argv[]) {
test_dup_dup(DB_DUP, DB_NODUPDATA, EINVAL, EINVAL); test_dup_dup(DB_DUP, DB_NODUPDATA, EINVAL, EINVAL);
test_dup_dup(DB_DUP, DB_NOOVERWRITE, 0, DB_KEYEXIST); test_dup_dup(DB_DUP, DB_NOOVERWRITE, 0, DB_KEYEXIST);
#if USE_TDB if (IS_TDB) {
// test_dup_dup(DB_DUP | DB_DUPSORT, 0, EINVAL, EINVAL); // test_dup_dup(DB_DUP | DB_DUPSORT, 0, EINVAL, EINVAL);
//test_dup_dup(DB_DUP | DB_DUPSORT, 0, 0, DB_KEYEXIST); //test_dup_dup(DB_DUP | DB_DUPSORT, 0, 0, DB_KEYEXIST);
test_dup_dup(DB_DUP | DB_DUPSORT, DB_YESOVERWRITE, 0, 0); test_dup_dup(DB_DUP | DB_DUPSORT, DB_YESOVERWRITE, 0, 0);
#else } else {
test_dup_dup(DB_DUP | DB_DUPSORT, 0 , 0, DB_KEYEXIST); test_dup_dup(DB_DUP | DB_DUPSORT, 0 , 0, DB_KEYEXIST);
#endif }
test_dup_dup(DB_DUP | DB_DUPSORT, DB_NODUPDATA, 0, DB_KEYEXIST); test_dup_dup(DB_DUP | DB_DUPSORT, DB_NODUPDATA, 0, DB_KEYEXIST);
test_dup_dup(DB_DUP | DB_DUPSORT, DB_NOOVERWRITE, 0, DB_KEYEXIST); test_dup_dup(DB_DUP | DB_DUPSORT, DB_NOOVERWRITE, 0, DB_KEYEXIST);
......
...@@ -13,8 +13,9 @@ ...@@ -13,8 +13,9 @@
#include "test.h" #include "test.h"
/* verify that the dup flags are written and read from the database file correctly */ /* verify that the dup flags are written and read from the database file correctly */
void test_dup_flags(u_int32_t dup_flags) { static void
if (verbose) printf("test_dup_flags:%d\n", dup_flags); test_dup_flags (u_int32_t dup_flags) {
if (verbose) printf("test_dup_flags:%u\n", dup_flags);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
DB *db; DB *db;
...@@ -27,23 +28,23 @@ void test_dup_flags(u_int32_t dup_flags) { ...@@ -27,23 +28,23 @@ void test_dup_flags(u_int32_t dup_flags) {
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, null_env, 0); assert(r == 0);
r = db->set_flags(db, dup_flags); r = db->set_flags(db, dup_flags);
#if USE_TDB if (IS_TDB) {
if (r != 0 && dup_flags == DB_DUP) { if (r != 0 && dup_flags == DB_DUP) {
if (verbose) printf("%s:%d: WARNING: tokudb does not support DB_DUP\n", __FILE__, __LINE__); if (verbose) printf("%s:%d: WARNING: tokudb does not support DB_DUP\n", __FILE__, __LINE__);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
return; return;
}
} }
#endif
assert(r == 0); assert(r == 0);
u_int32_t flags; r = db->get_flags(db, &flags); assert(r == 0); assert(flags == dup_flags); u_int32_t flags; r = db->get_flags(db, &flags); assert(r == 0); assert(flags == dup_flags);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666);
#if USE_TDB if (IS_TDB) {
if (r != 0 && dup_flags == DB_DUP) { if (r != 0 && dup_flags == DB_DUP) {
if (verbose) printf("%s:%d: WARNING: tokudb does not support DB_DUP\n", __FILE__, __LINE__); if (verbose) printf("%s:%d: WARNING: tokudb does not support DB_DUP\n", __FILE__, __LINE__);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
return; return;
}
} }
#endif
assert(r == 0); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
...@@ -51,7 +52,7 @@ void test_dup_flags(u_int32_t dup_flags) { ...@@ -51,7 +52,7 @@ void test_dup_flags(u_int32_t dup_flags) {
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, null_env, 0); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666);
if (r == 0 && verbose) if (r == 0 && verbose)
printf("%s:%d: WARNING:open ok:dup_mode:%d\n", __FILE__, __LINE__, dup_flags); printf("%s:%d: WARNING:open ok:dup_mode:%u\n", __FILE__, __LINE__, dup_flags);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, null_env, 0); assert(r == 0);
......
...@@ -12,14 +12,16 @@ ...@@ -12,14 +12,16 @@
#include "test.h" #include "test.h"
void db_put(DB *db, int k, int v) { static void
db_put (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
assert(r == 0); assert(r == 0);
} }
void expect(DBC *cursor, int k, int v) { static void
expect (DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT);
assert(r == 0); assert(r == 0);
...@@ -29,7 +31,7 @@ void expect(DBC *cursor, int k, int v) { ...@@ -29,7 +31,7 @@ void expect(DBC *cursor, int k, int v) {
assert(val.size == sizeof v); assert(val.size == sizeof v);
int vv; int vv;
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %d got %d - %d %d\n", htonl(k), htonl(kk), htonl(v), htonl(vv)); if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
assert(kk == k); assert(kk == k);
assert(vv == v); assert(vv == v);
...@@ -42,7 +44,8 @@ static int mycmp(const void *a, const void *b) { ...@@ -42,7 +44,8 @@ static int mycmp(const void *a, const void *b) {
} }
/* verify that key insertions are stored in insert order */ /* verify that key insertions are stored in insert order */
void test_insert(int n, int dup_mode) { static void
test_insert (int n, int dup_mode) {
if (verbose) printf("test_insert:%d %d\n", n, dup_mode); if (verbose) printf("test_insert:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -138,7 +141,8 @@ void test_insert(int n, int dup_mode) { ...@@ -138,7 +141,8 @@ void test_insert(int n, int dup_mode) {
} }
/* verify dup keys are buffered in order in non-leaf nodes */ /* verify dup keys are buffered in order in non-leaf nodes */
void test_nonleaf_insert(int n, int dup_mode) { static void
test_nonleaf_insert (int n, int dup_mode) {
if (verbose) printf("test_nonleaf_insert:%d %d\n", n, dup_mode); if (verbose) printf("test_nonleaf_insert:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -260,14 +264,14 @@ int main(int argc, const char *argv[]) { ...@@ -260,14 +264,14 @@ int main(int argc, const char *argv[]) {
} }
/* dup tests */ /* dup tests */
#if USE_TDB if (IS_TDB) {
// printf("%s:%d:WARNING:tokudb does not support DB_DUP\n", __FILE__, __LINE__); // printf("%s:%d:WARNING:tokudb does not support DB_DUP\n", __FILE__, __LINE__);
#else } else {
for (i = 1; i <= (1<<16); i *= 2) { for (i = 1; i <= (1<<16); i *= 2) {
test_insert(i, DB_DUP); test_insert(i, DB_DUP);
test_nonleaf_insert(i, DB_DUP); test_nonleaf_insert(i, DB_DUP);
}
} }
#endif
/* dupsort tests */ /* dupsort tests */
for (i = 1; i <= (1<<16); i *= 2) { for (i = 1; i <= (1<<16); i *= 2) {
......
...@@ -15,52 +15,24 @@ ...@@ -15,52 +15,24 @@
#include "test.h" #include "test.h"
int testlevel = 0; static int testlevel = 0;
DBT *dbt_init_zero(DBT *dbt) { static DBT *
dbt_init_zero (DBT *dbt) {
memset(dbt, 0, sizeof *dbt); memset(dbt, 0, sizeof *dbt);
return dbt; return dbt;
} }
void db_put(DB *db, int k, int v) { static void
db_put (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
assert(r == 0); assert(r == 0);
} }
void db_get(DB *db, int k) { static void
DB_TXN * const null_txn = 0; expect_cursor_set (DBC *cursor, int k, int expectv) {
DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
assert(r == 0);
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
printf("do_search %d\n", htonl(vv));
free(val.data);
}
void db_del(DB *db, int k) {
DB_TXN * const null_txn = 0;
DBT key;
int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
assert(r == 0);
}
void expect_db_get(DB *db, int k, int v) {
DB_TXN * const null_txn = 0;
DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
assert(r == 0);
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == v);
free(val.data);
}
void expect_cursor_set(DBC *cursor, int k, int expectv) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_zero(&val), DB_SET); int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_zero(&val), DB_SET);
assert(r == 0); assert(r == 0);
...@@ -70,7 +42,8 @@ void expect_cursor_set(DBC *cursor, int k, int expectv) { ...@@ -70,7 +42,8 @@ void expect_cursor_set(DBC *cursor, int k, int expectv) {
assert(expectv == vv); assert(expectv == vv);
} }
int expect_cursor_get(DBC *cursor, int expectk, int expectv, int op) { static int
expect_cursor_get (DBC *cursor, int expectk, int expectv, int op) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_zero(&key), dbt_init_zero(&val), op); int r = cursor->c_get(cursor, dbt_init_zero(&key), dbt_init_zero(&val), op);
if (r == 0) { if (r == 0) {
...@@ -80,14 +53,15 @@ int expect_cursor_get(DBC *cursor, int expectk, int expectv, int op) { ...@@ -80,14 +53,15 @@ int expect_cursor_get(DBC *cursor, int expectk, int expectv, int op) {
assert(val.size == sizeof expectv); assert(val.size == sizeof expectv);
int vv; int vv;
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
if (kk != expectk || vv != expectv) printf("expect key %d got %d - %d %d\n", htonl(expectk), htonl(kk), htonl(expectv), htonl(vv)); if (kk != expectk || vv != expectv) printf("expect key %u got %u - %u %u\n", htonl(expectk), htonl(kk), htonl(expectv), htonl(vv));
assert(kk == expectk); assert(kk == expectk);
assert(vv == expectv); assert(vv == expectv);
} }
return r; return r;
} }
void test_dup_next(int n, int dup_mode) { static void
test_dup_next (int n, int dup_mode) {
if (verbose) printf("test_dup_next:%d %d\n", n, dup_mode); if (verbose) printf("test_dup_next:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -14,33 +14,24 @@ ...@@ -14,33 +14,24 @@
void db_put(DB *db, int k, int v) { static void
db_put (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
assert(r == 0); assert(r == 0);
} }
void db_get(DB *db, int k) { static void
DB_TXN * const null_txn = 0; db_del (DB *db, int k) {
DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
assert(r == 0);
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
printf("do_search %d\n", htonl(vv));
free(val.data);
}
void db_del(DB *db, int k) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key; DBT key;
int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
assert(r == 0); assert(r == 0);
} }
void expect_db_get(DB *db, int k, int v) { static void
expect_db_get (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
...@@ -52,7 +43,8 @@ void expect_db_get(DB *db, int k, int v) { ...@@ -52,7 +43,8 @@ void expect_db_get(DB *db, int k, int v) {
free(val.data); free(val.data);
} }
void expect_cursor_get(DBC *cursor, int k, int v) { static void
expect_cursor_get (DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT);
assert(r == 0); assert(r == 0);
...@@ -62,7 +54,7 @@ void expect_cursor_get(DBC *cursor, int k, int v) { ...@@ -62,7 +54,7 @@ void expect_cursor_get(DBC *cursor, int k, int v) {
assert(val.size == sizeof v); assert(val.size == sizeof v);
int vv; int vv;
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %d got %d - %d %d\n", htonl(k), htonl(kk), htonl(v), htonl(vv)); if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
assert(kk == k); assert(kk == k);
assert(vv == v); assert(vv == v);
...@@ -71,7 +63,8 @@ void expect_cursor_get(DBC *cursor, int k, int v) { ...@@ -71,7 +63,8 @@ void expect_cursor_get(DBC *cursor, int k, int v) {
} }
/* insert, close, delete, insert, search */ /* insert, close, delete, insert, search */
void test_icdi_search(int n, int dup_mode) { static void
test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -141,7 +134,8 @@ void test_icdi_search(int n, int dup_mode) { ...@@ -141,7 +134,8 @@ void test_icdi_search(int n, int dup_mode) {
} }
/* insert, close, insert, search */ /* insert, close, insert, search */
void test_ici_search(int n, int dup_mode) { static void
test_ici_search (int n, int dup_mode) {
if (verbose) printf("test_ici_search:%d %d\n", n, dup_mode); if (verbose) printf("test_ici_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -209,7 +203,8 @@ void test_ici_search(int n, int dup_mode) { ...@@ -209,7 +203,8 @@ void test_ici_search(int n, int dup_mode) {
} }
/* insert 0, insert 1, close, insert 0, search 0 */ /* insert 0, insert 1, close, insert 0, search 0 */
void test_i0i1ci0_search(int n, int dup_mode) { static void
test_i0i1ci0_search (int n, int dup_mode) {
if (verbose) printf("test_i0i1ci0_search:%d %d\n", n, dup_mode); if (verbose) printf("test_i0i1ci0_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -265,7 +260,8 @@ void test_i0i1ci0_search(int n, int dup_mode) { ...@@ -265,7 +260,8 @@ void test_i0i1ci0_search(int n, int dup_mode) {
} }
/* insert dup keys with data descending from n to 1 */ /* insert dup keys with data descending from n to 1 */
void test_reverse_search(int n, int dup_mode) { static void
test_reverse_search (int n, int dup_mode) {
if (verbose) printf("test_reverse_search:%d %d\n", n, dup_mode); if (verbose) printf("test_reverse_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -337,15 +333,15 @@ int main(int argc, const char *argv[]) { ...@@ -337,15 +333,15 @@ int main(int argc, const char *argv[]) {
limit = 1<<16; limit = 1<<16;
/* dup search */ /* dup search */
#if USE_TDB if (IS_TDB) {
if (verbose) printf("%s:%d:WARNING:tokudb does not support DB_DUP\n", __FILE__, __LINE__); if (verbose) printf("%s:%d:WARNING:tokudb does not support DB_DUP\n", __FILE__, __LINE__);
#else } else {
for (i = 1; i <= limit; i *= 2) { for (i = 1; i <= limit; i *= 2) {
test_ici_search(i, DB_DUP); test_ici_search(i, DB_DUP);
test_icdi_search(i, DB_DUP); test_icdi_search(i, DB_DUP);
test_i0i1ci0_search(i, DB_DUP); test_i0i1ci0_search(i, DB_DUP);
}
} }
#endif
/* dupsort search */ /* dupsort search */
for (i = 1; i <= limit; i *= 2) { for (i = 1; i <= limit; i *= 2) {
...@@ -357,7 +353,7 @@ int main(int argc, const char *argv[]) { ...@@ -357,7 +353,7 @@ int main(int argc, const char *argv[]) {
/* insert data in descending order */ /* insert data in descending order */
for (i = 1; i <= limit; i *= 2) { for (i = 1; i <= limit; i *= 2) {
test_reverse_search(i, 0); test_reverse_search(i, 0);
#if USE_BDB #ifdef USE_BDB
test_reverse_search(i, DB_DUP); test_reverse_search(i, DB_DUP);
#endif #endif
test_reverse_search(i, DB_DUP + DB_DUPSORT); test_reverse_search(i, DB_DUP + DB_DUPSORT);
......
...@@ -66,7 +66,8 @@ static void lookup (int i, int expect, int expectj) { ...@@ -66,7 +66,8 @@ static void lookup (int i, int expect, int expectj) {
} }
} }
void test_dupsort_del (void) { static void
test_dupsort_del (void) {
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
r=mkdir(ENVDIR, 0777); assert(r==0); r=mkdir(ENVDIR, 0777); assert(r==0);
......
...@@ -68,7 +68,8 @@ static void lookup (int i, int expect, int expectj) { ...@@ -68,7 +68,8 @@ static void lookup (int i, int expect, int expectj) {
} }
} }
void test_abort3 (void) { static void
test_abort3 (void) {
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
r=mkdir(ENVDIR, 0777); assert(r==0); r=mkdir(ENVDIR, 0777); assert(r==0);
......
...@@ -12,21 +12,24 @@ ...@@ -12,21 +12,24 @@
#include "test.h" #include "test.h"
void db_put(DB *db, int k, int v) { static void
db_put (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
assert(r == 0); assert(r == 0);
} }
void db_del(DB *db, int k) { static void
db_del (DB *db, int k) {
DB_TXN *const null_txn = 0; DB_TXN *const null_txn = 0;
DBT key; DBT key;
int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), DB_DELETE_ANY); int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), DB_DELETE_ANY);
assert(r == 0); assert(r == 0);
} }
void expect_cursor_get(DBC *cursor, int op, int expectr) { static void
expect_cursor_get (DBC *cursor, int op, int expectr) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), op); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), op);
assert(r == expectr); assert(r == expectr);
...@@ -36,7 +39,8 @@ static int mycmp(const void *a, const void *b) { ...@@ -36,7 +39,8 @@ static int mycmp(const void *a, const void *b) {
return memcmp(a, b, sizeof (int)); return memcmp(a, b, sizeof (int));
} }
void test_dupsort_delete(int n) { static void
test_dupsort_delete (int n) {
if (verbose) printf("test_dupsort_delete:%d\n", n); if (verbose) printf("test_dupsort_delete:%d\n", n);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -14,33 +14,24 @@ ...@@ -14,33 +14,24 @@
void db_put(DB *db, int k, int v) { static void
db_put (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
assert(r == 0); assert(r == 0);
} }
void db_get(DB *db, int k) { static void
DB_TXN * const null_txn = 0; db_del (DB *db, int k) {
DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
assert(r == 0);
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
printf("do_search %d\n", htonl(vv));
free(val.data);
}
void db_del(DB *db, int k) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key; DBT key;
int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
assert(r == 0); assert(r == 0);
} }
void expect_db_get(DB *db, int k, int v) { static void
expect_db_get (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
...@@ -52,38 +43,16 @@ void expect_db_get(DB *db, int k, int v) { ...@@ -52,38 +43,16 @@ void expect_db_get(DB *db, int k, int v) {
free(val.data); free(val.data);
} }
void expect_cursor_get(DBC *cursor, int k, int v) { static void
DBT key, val; expect_cursor_set (DBC *cursor, int k) {
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT);
assert(r == 0);
assert(key.size == sizeof k);
int kk;
memcpy(&kk, key.data, key.size);
assert(val.size == sizeof v);
int vv;
memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %d got %d - %d %d\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
assert(kk == k);
assert(vv == v);
free(key.data);
free(val.data);
}
void expect_cursor_set(DBC *cursor, int k) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET); int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET);
assert(r == 0); assert(r == 0);
free(val.data); free(val.data);
} }
void expect_cursor_get_both(DBC *cursor, int k, int v) { static void
DBT key, val; expect_cursor_get_current (DBC *cursor, int k, int v) {
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_GET_BOTH);
assert(r == 0);
}
void expect_cursor_get_current(DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT);
assert(r == 0); assert(r == 0);
...@@ -94,7 +63,8 @@ void expect_cursor_get_current(DBC *cursor, int k, int v) { ...@@ -94,7 +63,8 @@ void expect_cursor_get_current(DBC *cursor, int k, int v) {
} }
void test_dupsort_get(int n, int dup_mode) { static void
test_dupsort_get (int n, int dup_mode) {
if (verbose) printf("test_dupsort_get:%d %d\n", n, dup_mode); if (verbose) printf("test_dupsort_get:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -12,35 +12,24 @@ ...@@ -12,35 +12,24 @@
#include "test.h" #include "test.h"
static void
db_put (DB *db, int k, int v) {
void db_put(DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
assert(r == 0); assert(r == 0);
} }
void db_get(DB *db, int k) { static void
DB_TXN * const null_txn = 0; db_del (DB *db, int k) {
DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
assert(r == 0);
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
printf("do_search %d\n", htonl(vv));
free(val.data);
}
void db_del(DB *db, int k) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key; DBT key;
int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
assert(r == 0); assert(r == 0);
} }
void expect_db_get(DB *db, int k, int v) { static void
expect_db_get (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
...@@ -52,7 +41,8 @@ void expect_db_get(DB *db, int k, int v) { ...@@ -52,7 +41,8 @@ void expect_db_get(DB *db, int k, int v) {
free(val.data); free(val.data);
} }
void expect_cursor_get(DBC *cursor, int k, int v) { static void
expect_cursor_get (DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT);
assert(r == 0); assert(r == 0);
...@@ -62,7 +52,7 @@ void expect_cursor_get(DBC *cursor, int k, int v) { ...@@ -62,7 +52,7 @@ void expect_cursor_get(DBC *cursor, int k, int v) {
assert(val.size == sizeof v); assert(val.size == sizeof v);
int vv; int vv;
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %d got %d - %d %d\n", htonl(k), htonl(kk), htonl(v), htonl(vv)); if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
assert(kk == k); assert(kk == k);
assert(vv == v); assert(vv == v);
...@@ -70,20 +60,15 @@ void expect_cursor_get(DBC *cursor, int k, int v) { ...@@ -70,20 +60,15 @@ void expect_cursor_get(DBC *cursor, int k, int v) {
free(val.data); free(val.data);
} }
void expect_cursor_set(DBC *cursor, int k) { static void
DBT key, val; expect_cursor_get_both (DBC *cursor, int k, int v) {
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET);
assert(r == 0);
free(val.data);
}
void expect_cursor_get_both(DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_GET_BOTH); int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_GET_BOTH);
assert(r == 0); assert(r == 0);
} }
void expect_cursor_get_current(DBC *cursor, int k, int v) { static void
expect_cursor_get_current (DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT);
assert(r == 0); assert(r == 0);
...@@ -95,7 +80,8 @@ void expect_cursor_get_current(DBC *cursor, int k, int v) { ...@@ -95,7 +80,8 @@ void expect_cursor_get_current(DBC *cursor, int k, int v) {
/* insert, close, delete, insert, search */ /* insert, close, delete, insert, search */
void test_icdi_search(int n, int dup_mode) { static void
test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -12,33 +12,24 @@ ...@@ -12,33 +12,24 @@
#include "test.h" #include "test.h"
void db_put(DB *db, int k, int v) { static void
db_put (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
assert(r == 0); assert(r == 0);
} }
void db_get(DB *db, int k) { static void
DB_TXN * const null_txn = 0; db_del (DB *db, int k) {
DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
assert(r == 0);
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
printf("do_search %d\n", htonl(vv));
free(val.data);
}
void db_del(DB *db, int k) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key; DBT key;
int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
assert(r == 0); assert(r == 0);
} }
void expect_db_get(DB *db, int k, int v) { static void
expect_db_get (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
...@@ -50,7 +41,8 @@ void expect_db_get(DB *db, int k, int v) { ...@@ -50,7 +41,8 @@ void expect_db_get(DB *db, int k, int v) {
free(val.data); free(val.data);
} }
void expect_cursor_get(DBC *cursor, int k, int v) { static void
expect_cursor_get (DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT);
assert(r == 0); assert(r == 0);
...@@ -60,7 +52,7 @@ void expect_cursor_get(DBC *cursor, int k, int v) { ...@@ -60,7 +52,7 @@ void expect_cursor_get(DBC *cursor, int k, int v) {
assert(val.size == sizeof v); assert(val.size == sizeof v);
int vv; int vv;
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %d got %d - %d %d\n", ntohl(k), ntohl(kk), ntohl(v), ntohl(vv)); if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", ntohl(k), ntohl(kk), ntohl(v), ntohl(vv));
assert(kk == k); assert(kk == k);
assert(vv == v); assert(vv == v);
...@@ -68,20 +60,15 @@ void expect_cursor_get(DBC *cursor, int k, int v) { ...@@ -68,20 +60,15 @@ void expect_cursor_get(DBC *cursor, int k, int v) {
free(val.data); free(val.data);
} }
void expect_cursor_set(DBC *cursor, int k) { static void
DBT key, val; expect_cursor_get_both_range (DBC *cursor, int k, int v, int expectr) {
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET);
assert(r == 0);
free(val.data);
}
void expect_cursor_get_both_range(DBC *cursor, int k, int v, int expectr) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_GET_BOTH_RANGE); int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_GET_BOTH_RANGE);
assert(r == expectr); assert(r == expectr);
} }
void expect_cursor_get_current(DBC *cursor, int k, int v) { static void
expect_cursor_get_current (DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT);
assert(r == 0); assert(r == 0);
...@@ -93,7 +80,8 @@ void expect_cursor_get_current(DBC *cursor, int k, int v) { ...@@ -93,7 +80,8 @@ void expect_cursor_get_current(DBC *cursor, int k, int v) {
/* insert, close, delete, insert, search */ /* insert, close, delete, insert, search */
void test_icdi_search(int n, int dup_mode) { static void
test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -12,35 +12,24 @@ ...@@ -12,35 +12,24 @@
#include "test.h" #include "test.h"
static void
db_put (DB *db, int k, int v) {
void db_put(DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
assert(r == 0); assert(r == 0);
} }
void db_get(DB *db, int k) { static void
DB_TXN * const null_txn = 0; db_del (DB *db, int k) {
DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
assert(r == 0);
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
printf("do_search %d\n", htonl(vv));
free(val.data);
}
void db_del(DB *db, int k) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key; DBT key;
int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
assert(r == 0); assert(r == 0);
} }
void expect_db_get(DB *db, int k, int v) { static void
expect_db_get (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
...@@ -52,7 +41,8 @@ void expect_db_get(DB *db, int k, int v) { ...@@ -52,7 +41,8 @@ void expect_db_get(DB *db, int k, int v) {
free(val.data); free(val.data);
} }
void expect_cursor_get(DBC *cursor, int k, int v) { static void
expect_cursor_get (DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT);
assert(r == 0); assert(r == 0);
...@@ -62,7 +52,7 @@ void expect_cursor_get(DBC *cursor, int k, int v) { ...@@ -62,7 +52,7 @@ void expect_cursor_get(DBC *cursor, int k, int v) {
assert(val.size == sizeof v); assert(val.size == sizeof v);
int vv; int vv;
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %d got %d - %d %d\n", htonl(k), htonl(kk), htonl(v), htonl(vv)); if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
assert(kk == k); assert(kk == k);
assert(vv == v); assert(vv == v);
...@@ -70,20 +60,16 @@ void expect_cursor_get(DBC *cursor, int k, int v) { ...@@ -70,20 +60,16 @@ void expect_cursor_get(DBC *cursor, int k, int v) {
free(val.data); free(val.data);
} }
void expect_cursor_set(DBC *cursor, int k) { static void
expect_cursor_set (DBC *cursor, int k) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET); int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET);
assert(r == 0); assert(r == 0);
free(val.data); free(val.data);
} }
void expect_cursor_get_both(DBC *cursor, int k, int v) { static void
DBT key, val; expect_cursor_get_current (DBC *cursor, int k, int v) {
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_GET_BOTH);
assert(r == 0);
}
void expect_cursor_get_current(DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT);
assert(r == 0); assert(r == 0);
...@@ -95,7 +81,8 @@ void expect_cursor_get_current(DBC *cursor, int k, int v) { ...@@ -95,7 +81,8 @@ void expect_cursor_get_current(DBC *cursor, int k, int v) {
/* insert, close, delete, insert, search */ /* insert, close, delete, insert, search */
void test_icdi_search(int n, int dup_mode) { static void
test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -19,33 +19,24 @@ ...@@ -19,33 +19,24 @@
#define DB_YESOVERWRITE 0 #define DB_YESOVERWRITE 0
#endif #endif
void db_put(DB *db, int k, int v) { static void
db_put (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
assert(r == 0); assert(r == 0);
} }
void db_get(DB *db, int k) { static void
DB_TXN * const null_txn = 0; db_del (DB *db, int k) {
DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
assert(r == 0);
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
printf("do_search %d\n", htonl(vv));
free(val.data);
}
void db_del(DB *db, int k) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key; DBT key;
int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), DB_DELETE_ANY); int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), DB_DELETE_ANY);
assert(r == 0); assert(r == 0);
} }
void expect_db_get(DB *db, int k, int v) { static void
expect_db_get (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
...@@ -57,7 +48,8 @@ void expect_db_get(DB *db, int k, int v) { ...@@ -57,7 +48,8 @@ void expect_db_get(DB *db, int k, int v) {
free(val.data); free(val.data);
} }
void expect_cursor_get(DBC *cursor, int k, int v) { static void
expect_cursor_get (DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT);
assert(r == 0); assert(r == 0);
...@@ -67,7 +59,7 @@ void expect_cursor_get(DBC *cursor, int k, int v) { ...@@ -67,7 +59,7 @@ void expect_cursor_get(DBC *cursor, int k, int v) {
assert(val.size == sizeof v); assert(val.size == sizeof v);
int vv; int vv;
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %d got %d - %d %d\n", htonl(k), htonl(kk), htonl(v), htonl(vv)); if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
assert(kk == k); assert(kk == k);
assert(vv == v); assert(vv == v);
...@@ -75,27 +67,16 @@ void expect_cursor_get(DBC *cursor, int k, int v) { ...@@ -75,27 +67,16 @@ void expect_cursor_get(DBC *cursor, int k, int v) {
free(val.data); free(val.data);
} }
void expect_cursor_set(DBC *cursor, int k) { static void
DBT key, val; expect_cursor_set_range (DBC *cursor, int k) {
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET);
assert(r == 0);
free(val.data);
}
void expect_cursor_set_range(DBC *cursor, int k) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET_RANGE); int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET_RANGE);
assert(r == 0); assert(r == 0);
free(val.data); free(val.data);
} }
void expect_cursor_get_both(DBC *cursor, int k, int v) { static void
DBT key, val; expect_cursor_get_current (DBC *cursor, int k, int v) {
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_GET_BOTH);
assert(r == 0);
}
void expect_cursor_get_current(DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT);
assert(r == 0); assert(r == 0);
...@@ -107,7 +88,8 @@ void expect_cursor_get_current(DBC *cursor, int k, int v) { ...@@ -107,7 +88,8 @@ void expect_cursor_get_current(DBC *cursor, int k, int v) {
/* insert, close, delete, insert, search */ /* insert, close, delete, insert, search */
void test_icdi_search(int n, int dup_mode) { static void
test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#include "test.h" #include "test.h"
void test_env_open_flags(int env_open_flags, int expectr) { static void
test_env_open_flags (int env_open_flags, int expectr) {
if (verbose) printf("test_env_open_flags:%d\n", env_open_flags); if (verbose) printf("test_env_open_flags:%d\n", env_open_flags);
DB_ENV *env; DB_ENV *env;
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
char const* expect_errpfx; char const* expect_errpfx;
int n_handle_error=0; int n_handle_error=0;
void handle_error (const DB_ENV *UU(dbenv), const char *errpfx, const char *UU(msg)) { static void
handle_error (const DB_ENV *UU(dbenv), const char *errpfx, const char *UU(msg)) {
assert(errpfx==expect_errpfx); assert(errpfx==expect_errpfx);
n_handle_error++; n_handle_error++;
} }
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#include <assert.h> #include <assert.h>
#include <pthread.h> #include <pthread.h>
void *f(void *arg) { static void *
f (void *arg) {
//pthread_exit(arg); // pthread_exit has a memoryh leak. //pthread_exit(arg); // pthread_exit has a memoryh leak.
return arg; return arg;
} }
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
#include "test.h" #include "test.h"
DBT *dbt_init_user(DBT *d, void *uptr, int ulen) { static DBT *
dbt_init_user (DBT *d, void *uptr, int ulen) {
memset(d, 0, sizeof *d); memset(d, 0, sizeof *d);
d->data = uptr; d->data = uptr;
d->ulen = ulen; d->ulen = ulen;
...@@ -20,87 +21,17 @@ DBT *dbt_init_user(DBT *d, void *uptr, int ulen) { ...@@ -20,87 +21,17 @@ DBT *dbt_init_user(DBT *d, void *uptr, int ulen) {
return d; return d;
} }
void db_put(DB *db, int k, int v) { static void
db_put (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
assert(r == 0); assert(r == 0);
} }
void db_get(DB *db, int k) { static char annotated_envdir[]= ENVDIR " ";
DB_TXN * const null_txn = 0;
DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
assert(r == 0);
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
free(val.data);
}
void db_del(DB *db, int k) {
DB_TXN * const null_txn = 0;
DBT key;
int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
assert(r == 0);
}
void expect_db_get(DB *db, int k, int v) {
DB_TXN * const null_txn = 0;
DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
assert(r == 0);
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == v);
free(val.data);
}
void expect_cursor_get(DBC *cursor, int k, int v) {
DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT);
assert(r == 0);
assert(key.size == sizeof k);
int kk;
memcpy(&kk, key.data, key.size);
assert(val.size == sizeof v);
int vv;
memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %d got %d - %d %d\n", ntohl(k), ntohl(kk), ntohl(v), ntohl(vv));
assert(kk == k);
assert(vv == v);
free(key.data);
free(val.data);
}
void expect_cursor_set(DBC *cursor, int k) {
DBT key, val;
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET);
assert(r == 0);
free(val.data);
}
void expect_cursor_get_both_range(DBC *cursor, int k, int v, int expectr) {
DBT key, val;
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_GET_BOTH_RANGE);
assert(r == expectr);
}
void expect_cursor_get_current(DBC *cursor, int k, int v) {
DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT);
assert(r == 0);
int kk, vv;
assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k);
assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v);
free(key.data); free(val.data);
}
char annotated_envdir[]= ENVDIR " ";
void test_get_both(int n, int dup_mode, int op) { static void test_get_both(int n, int dup_mode, int op) {
if (verbose) printf("test_get_both_range:%d %d %d\n", n, dup_mode, op); if (verbose) printf("test_get_both_range:%d %d %d\n", n, dup_mode, op);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#include "test.h" #include "test.h"
void test_get (int dup_mode) { static void
test_get (int dup_mode) {
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DB *db; DB *db;
......
...@@ -15,7 +15,7 @@ DB *db; ...@@ -15,7 +15,7 @@ DB *db;
#define NITER 100 #define NITER 100
void *start_a_thread (void *i_p) { static void *start_a_thread (void *i_p) {
int *which_thread_p = i_p; int *which_thread_p = i_p;
int i,r; int i,r;
for (i=0; i<NITER; i++) { for (i=0; i<NITER; i++) {
...@@ -33,7 +33,8 @@ void *start_a_thread (void *i_p) { ...@@ -33,7 +33,8 @@ void *start_a_thread (void *i_p) {
return 0; return 0;
} }
void test_groupcommit (int nthreads) { static void
test_groupcommit (int nthreads) {
int r; int r;
DB_TXN *tid; DB_TXN *tid;
...@@ -64,25 +65,30 @@ void test_groupcommit (int nthreads) { ...@@ -64,25 +65,30 @@ void test_groupcommit (int nthreads) {
// Also, it doesn't happen every time, making helgrind unsuitable for regression tests. // Also, it doesn't happen every time, making helgrind unsuitable for regression tests.
// So we must put locks around things that are properly serialized anyway. // So we must put locks around things that are properly serialized anyway.
int fsync_count_maybe_lockprotected=0; static int fsync_count_maybe_lockprotected=0;
void inc_fsync_count(void) { static void
inc_fsync_count (void) {
fsync_count_maybe_lockprotected++; fsync_count_maybe_lockprotected++;
} }
int get_fsync_count(void) { static int
get_fsync_count (void) {
int result=fsync_count_maybe_lockprotected; int result=fsync_count_maybe_lockprotected;
return result; return result;
} }
int do_fsync (int fd) { static int
do_fsync (int fd) {
inc_fsync_count(); inc_fsync_count();
return fsync(fd); return fsync(fd);
} }
const char *progname; static const char *progname;
struct timeval prevtime; static struct timeval prevtime;
int prev_count; static int prev_count;
void printtdiff (char *str) {
static void
printtdiff (char *str) {
struct timeval thistime; struct timeval thistime;
gettimeofday(&thistime, 0); gettimeofday(&thistime, 0);
double tdiff = thistime.tv_sec-prevtime.tv_sec+1e-6*(thistime.tv_usec-prevtime.tv_usec); double tdiff = thistime.tv_sec-prevtime.tv_sec+1e-6*(thistime.tv_usec-prevtime.tv_usec);
......
...@@ -14,7 +14,8 @@ DB *db; ...@@ -14,7 +14,8 @@ DB *db;
#define NITER 100 #define NITER 100
void *start_a_thread (void *i_p) { static void *
start_a_thread (void *i_p) {
int *which_thread_p = i_p; int *which_thread_p = i_p;
int i,r; int i,r;
for (i=0; i<NITER; i++) { for (i=0; i<NITER; i++) {
...@@ -32,7 +33,8 @@ void *start_a_thread (void *i_p) { ...@@ -32,7 +33,8 @@ void *start_a_thread (void *i_p) {
return 0; return 0;
} }
void test_groupcommit (int nthreads) { static void
test_groupcommit (int nthreads) {
int r; int r;
DB_TXN *tid; DB_TXN *tid;
...@@ -82,8 +84,10 @@ void test_groupcommit (int nthreads) { ...@@ -82,8 +84,10 @@ void test_groupcommit (int nthreads) {
} }
struct timeval prevtime; static struct timeval prevtime;
void printtdiff (char *str) {
static void
printtdiff (char *str) {
struct timeval thistime; struct timeval thistime;
gettimeofday(&thistime, 0); gettimeofday(&thistime, 0);
if (verbose) printf("%10.6f %s\n", thistime.tv_sec-prevtime.tv_sec+1e-6*(thistime.tv_usec-prevtime.tv_usec), str); if (verbose) printf("%10.6f %s\n", thistime.tv_sec-prevtime.tv_sec+1e-6*(thistime.tv_usec-prevtime.tv_usec), str);
......
...@@ -12,11 +12,12 @@ ...@@ -12,11 +12,12 @@
#include "test.h" #include "test.h"
#if USE_BDB #ifdef USE_BDB
#define DB_YESOVERWRITE 0 #define DB_YESOVERWRITE 0
#endif #endif
int db_put(DB *db, DB_TXN *txn, int k, int v) { static int
db_put (DB *db, DB_TXN *txn, int k, int v) {
DBT key, val; DBT key, val;
int r = db->put(db, txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
return r; return r;
...@@ -34,7 +35,8 @@ int db_put(DB *db, DB_TXN *txn, int k, int v) { ...@@ -34,7 +35,8 @@ int db_put(DB *db, DB_TXN *txn, int k, int v) {
the magic number where found via experimentation */ the magic number where found via experimentation */
void test_hsoc(int pagesize, int dup_mode) { static void
test_hsoc (int pagesize, int dup_mode) {
if (verbose) printf("test_hsoc:%d %d\n", pagesize, dup_mode); if (verbose) printf("test_hsoc:%d %d\n", pagesize, dup_mode);
int npp = pagesize / 16; int npp = pagesize / 16;
......
...@@ -12,9 +12,8 @@ ...@@ -12,9 +12,8 @@
#include "test.h" #include "test.h"
static void
test_insert_delete_insert (int dup_mode) {
void test_insert_delete_insert(int dup_mode) {
if (verbose) printf("test_insert_delete_insert:%d\n", dup_mode); if (verbose) printf("test_insert_delete_insert:%d\n", dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -12,9 +12,8 @@ ...@@ -12,9 +12,8 @@
#include "test.h" #include "test.h"
static void
test_insert (int n, int dup_mode) {
void test_insert(int n, int dup_mode) {
if (verbose) printf("test_insert:%d %d\n", n, dup_mode); if (verbose) printf("test_insert:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
u_int64_t lorange = 0; u_int64_t lorange = 0;
u_int64_t hirange = 1<<24; u_int64_t hirange = 1<<24;
void test_key_size_limit(int dup_mode) { static void
test_key_size_limit (int dup_mode) {
if (verbose > 1) printf("%s:%d\n", __FUNCTION__, dup_mode); if (verbose > 1) printf("%s:%d\n", __FUNCTION__, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -64,13 +65,14 @@ void test_key_size_limit(int dup_mode) { ...@@ -64,13 +65,14 @@ void test_key_size_limit(int dup_mode) {
free(k); free(k);
free(v); free(v);
assert(bigest > 0); assert(bigest > 0);
if (verbose && bigest >= 0) printf("%s bigest %d\n", __FUNCTION__, bigest); if (verbose) printf("%s bigest %u\n", __FUNCTION__, bigest);
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
} }
void test_data_size_limit(int dup_mode) { static void
test_data_size_limit (int dup_mode) {
if (verbose > 1) printf("%s:%d\n", __FUNCTION__, dup_mode); if (verbose > 1) printf("%s:%d\n", __FUNCTION__, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
...@@ -118,7 +120,7 @@ void test_data_size_limit(int dup_mode) { ...@@ -118,7 +120,7 @@ void test_data_size_limit(int dup_mode) {
} }
free(k); free(k);
free(v); free(v);
if (verbose && bigest > 0) printf("%s bigest %d\n", __FUNCTION__, bigest); if (verbose && bigest > 0) printf("%s bigest %u\n", __FUNCTION__, bigest);
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
......
...@@ -23,19 +23,21 @@ ...@@ -23,19 +23,21 @@
// How many iterations are we going to do insertions and deletions. This is a bound to the number of distinct keys in the DB. // How many iterations are we going to do insertions and deletions. This is a bound to the number of distinct keys in the DB.
#define N 1000 #define N 1000
int n_keys_mentioned=0; static int n_keys_mentioned=0;
int random_keys_mentioned[N]; static int random_keys_mentioned[N];
DB *pending_i, *pending_d, *committed; static DB *pending_i, *pending_d, *committed;
// Keep track of what's in the committed database separately // Keep track of what's in the committed database separately
struct pair {int x,y;}; struct pair {int x,y;};
void insert_in_mem (int x, int y, int *count, struct pair *pairs) { static void
insert_in_mem (int x, int y, int *count, struct pair *pairs) {
assert(*count<N); assert(*count<N);
pairs[(*count)++]=(struct pair){x,y}; pairs[(*count)++]=(struct pair){x,y};
} }
void delete_in_mem (int x, int *count, struct pair *pairs) { static void
delete_in_mem (int x, int *count, struct pair *pairs) {
int i; int i;
for (i=0; i<*count; i++) { for (i=0; i<*count; i++) {
if (pairs[i].x==x) { if (pairs[i].x==x) {
...@@ -48,7 +50,8 @@ void delete_in_mem (int x, int *count, struct pair *pairs) { ...@@ -48,7 +50,8 @@ void delete_in_mem (int x, int *count, struct pair *pairs) {
static int com_count=0, pend_count=0, peni_count=0; static int com_count=0, pend_count=0, peni_count=0;
static struct pair com_data[N], pend_data[N], peni_data[N]; static struct pair com_data[N], pend_data[N], peni_data[N];
void insert_pending(int key, int val, DB_TXN *bookx) { static void
insert_pending (int key, int val, DB_TXN *bookx) {
DBT keyd,datad; DBT keyd,datad;
//printf("IP %u,%u\n", key,val); //printf("IP %u,%u\n", key,val);
...@@ -182,7 +185,8 @@ static void abort_items (DB_ENV *env) { ...@@ -182,7 +185,8 @@ static void abort_items (DB_ENV *env) {
r=txn->commit(txn, 0); assert(r==0); r=txn->commit(txn, 0); assert(r==0);
} }
int compare_pairs (const void *a, const void *b) { static int
compare_pairs (const void *a, const void *b) {
return memcmp(a,b,4); return memcmp(a,b,4);
} }
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
#include "test.h" #include "test.h"
// Return the offset // Return the offset
int grep_for_in_logs(const char *str) { static int
grep_for_in_logs (const char *str) {
#ifdef TOKUDB #ifdef TOKUDB
#define lname ENVDIR "//log000000000000.tokulog" #define lname ENVDIR "//log000000000000.tokulog"
#else #else
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
#include <sys/stat.h> #include <sys/stat.h>
#include "test.h" #include "test.h"
void check_logmax (int max) { static void
check_logmax (int max) {
int any_too_big=0; int any_too_big=0;
DIR *dir = opendir(ENVDIR); DIR *dir = opendir(ENVDIR);
struct dirent *ent; struct dirent *ent;
...@@ -31,7 +32,8 @@ void check_logmax (int max) { ...@@ -31,7 +32,8 @@ void check_logmax (int max) {
assert(r==0); assert(r==0);
} }
void test_logmax (int logmax) { static void
test_logmax (int logmax) {
int r; int r;
DB_ENV *env; DB_ENV *env;
DB *db; DB *db;
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#include <db.h> #include <db.h>
#include "test.h" #include "test.h"
void seqinsert(int n, float p) { static void
seqinsert (int n, float p) {
if (verbose) printf("%s %d %f\n", __FUNCTION__, n, p); if (verbose) printf("%s %d %f\n", __FUNCTION__, n, p);
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
......
...@@ -52,7 +52,8 @@ static void lookup (int i, DB_TXN *x, int expect) { ...@@ -52,7 +52,8 @@ static void lookup (int i, DB_TXN *x, int expect) {
static DB_TXN *txn, *txn2; static DB_TXN *txn, *txn2;
void test_nested (void) { static void
test_nested (void) {
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
r=mkdir(ENVDIR, 0777); assert(r==0); r=mkdir(ENVDIR, 0777); assert(r==0);
......
...@@ -14,33 +14,24 @@ ...@@ -14,33 +14,24 @@
void db_put(DB *db, int k, int v) { static void
db_put (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0); int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0);
assert(r == 0); assert(r == 0);
} }
void db_get(DB *db, int k) { static void
DB_TXN * const null_txn = 0; db_del (DB *db, int k) {
DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
assert(r == 0);
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
printf("do_search %d\n", htonl(vv));
free(val.data);
}
void db_del(DB *db, int k) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key; DBT key;
int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
assert(r == 0); assert(r == 0);
} }
void expect_db_get(DB *db, int k, int v) { static void
expect_db_get (DB *db, int k, int v) {
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DBT key, val; DBT key, val;
int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
...@@ -52,7 +43,8 @@ void expect_db_get(DB *db, int k, int v) { ...@@ -52,7 +43,8 @@ void expect_db_get(DB *db, int k, int v) {
free(val.data); free(val.data);
} }
void expect_cursor_get(DBC *cursor, int k, int v) { static void
expect_cursor_get (DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT);
assert(r == 0); assert(r == 0);
...@@ -62,7 +54,7 @@ void expect_cursor_get(DBC *cursor, int k, int v) { ...@@ -62,7 +54,7 @@ void expect_cursor_get(DBC *cursor, int k, int v) {
assert(val.size == sizeof v); assert(val.size == sizeof v);
int vv; int vv;
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %d got %d - %d %d\n", htonl(k), htonl(kk), htonl(v), htonl(vv)); if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
assert(kk == k); assert(kk == k);
assert(vv == v); assert(vv == v);
...@@ -70,20 +62,16 @@ void expect_cursor_get(DBC *cursor, int k, int v) { ...@@ -70,20 +62,16 @@ void expect_cursor_get(DBC *cursor, int k, int v) {
free(val.data); free(val.data);
} }
void expect_cursor_set(DBC *cursor, int k, int expectr) { static void
expect_cursor_set (DBC *cursor, int k, int expectr) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET); int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET);
assert(r == expectr); assert(r == expectr);
if (val.data) free(val.data); if (val.data) free(val.data);
} }
void expect_cursor_get_both(DBC *cursor, int k, int v) { static void
DBT key, val; expect_cursor_get_current (DBC *cursor, int k, int v) {
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_GET_BOTH);
assert(r == 0);
}
void expect_cursor_get_current(DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT);
assert(r == 0); assert(r == 0);
...@@ -95,7 +83,8 @@ void expect_cursor_get_current(DBC *cursor, int k, int v) { ...@@ -95,7 +83,8 @@ void expect_cursor_get_current(DBC *cursor, int k, int v) {
/* insert, close, delete, insert, search */ /* insert, close, delete, insert, search */
void test_icdi_search(int n, int dup_mode) { static void
test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -12,9 +12,8 @@ ...@@ -12,9 +12,8 @@
#include "test.h" #include "test.h"
static void
test_rand_insert (int n, int dup_mode) {
void test_rand_insert(int n, int dup_mode) {
if (verbose) printf("test_rand_insert:%d %d\n", n, dup_mode); if (verbose) printf("test_rand_insert:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -16,9 +16,8 @@ ...@@ -16,9 +16,8 @@
#include "test.h" #include "test.h"
static int
keycompare (const void *key1, unsigned int key1len, const void *key2, unsigned int key2len) {
int keycompare (const void *key1, unsigned int key1len, const void *key2, unsigned int key2len) {
if (key1len==key2len) { if (key1len==key2len) {
return memcmp(key1,key2,key1len); return memcmp(key1,key2,key1len);
} else if (key1len<key2len) { } else if (key1len<key2len) {
...@@ -30,11 +29,13 @@ int keycompare (const void *key1, unsigned int key1len, const void *key2, unsign ...@@ -30,11 +29,13 @@ int keycompare (const void *key1, unsigned int key1len, const void *key2, unsign
} }
} }
int reverse_compare(DB *db __attribute__((__unused__)), const DBT *a, const DBT*b) { static int
reverse_compare (DB *db __attribute__((__unused__)), const DBT *a, const DBT*b) {
return -keycompare(a->data, a->size, b->data, b->size); return -keycompare(a->data, a->size, b->data, b->size);
} }
void expect(DBC *cursor, int k, int v) { static void
expect (DBC *cursor, int k, int v) {
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT);
CKERR(r); CKERR(r);
...@@ -44,7 +45,7 @@ void expect(DBC *cursor, int k, int v) { ...@@ -44,7 +45,7 @@ void expect(DBC *cursor, int k, int v) {
assert(val.size == sizeof v); assert(val.size == sizeof v);
int vv; int vv;
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %d got %d - %d %d\n", htonl(k), htonl(kk), htonl(v), htonl(vv)); if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
assert(kk == k); assert(kk == k);
assert(vv == v); assert(vv == v);
...@@ -52,7 +53,8 @@ void expect(DBC *cursor, int k, int v) { ...@@ -52,7 +53,8 @@ void expect(DBC *cursor, int k, int v) {
free(val.data); free(val.data);
} }
void test_reverse_compare(int n, int dup_flags) { static void
test_reverse_compare (int n, int dup_flags) {
if (verbose) printf("test_reverse_compare:%d %d\n", n, dup_flags); if (verbose) printf("test_reverse_compare:%d %d\n", n, dup_flags);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -59,7 +59,7 @@ static void make_db (int n_locks) { ...@@ -59,7 +59,7 @@ static void make_db (int n_locks) {
char hello[30], there[datasize+30]; char hello[30], there[datasize+30];
DBT key,data; DBT key,data;
snprintf(hello, sizeof(hello), "hello%09d", 2*i); snprintf(hello, sizeof(hello), "hello%09d", 2*i);
snprintf(there, sizeof(there), "there%d%0*d", 2*i, datasize, 2*i); // For BDB this is chosen so that different locks are on different pages snprintf(there, sizeof(there), "there%d%0*d", 2*i, (int)datasize, 2*i); // For BDB this is chosen so that different locks are on different pages
memset(&key, 0, sizeof(key)); memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data)); memset(&data, 0, sizeof(data));
key.data = hello; key.size=strlen(hello)+1; key.data = hello; key.size=strlen(hello)+1;
...@@ -88,7 +88,7 @@ static void make_db (int n_locks) { ...@@ -88,7 +88,7 @@ static void make_db (int n_locks) {
DBT key,data; DBT key,data;
int num = 16*i+8*j+1; int num = 16*i+8*j+1;
snprintf(hello, sizeof(hello), "hello%09d", num); snprintf(hello, sizeof(hello), "hello%09d", num);
snprintf(there, sizeof(there), "there%d%*d", num, datasize, num); // For BDB this is chosen so that different locks are on different pages snprintf(there, sizeof(there), "there%d%*d", num, (int)datasize, num); // For BDB this is chosen so that different locks are on different pages
memset(&key, 0, sizeof(key)); memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data)); memset(&data, 0, sizeof(data));
//printf("Writing %s in %d\n", hello, j); //printf("Writing %s in %d\n", hello, j);
...@@ -118,8 +118,10 @@ static void make_db (int n_locks) { ...@@ -118,8 +118,10 @@ static void make_db (int n_locks) {
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
make_db(-1); make_db(-1);
make_db(100); return 0; make_db(100);
make_db(1000); if (0) {
make_db(2000); make_db(1000);
make_db(2000);
}
return 0; return 0;
} }
...@@ -11,13 +11,15 @@ ...@@ -11,13 +11,15 @@
const char *dbfile = ENVDIR "/" "test.db"; const char *dbfile = ENVDIR "/" "test.db";
const char *dbname = 0; const char *dbname = 0;
int db_put(DB *db, int k, int v) { static int
db_put (DB *db, int k, int v) {
DBT key, val; DBT key, val;
int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0); int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0);
return r; return r;
} }
int db_get(DB *db, int k, int expectv, int val_flags) { static int
db_get (DB *db, int k, int expectv, int val_flags) {
int v; int v;
DBT key, val; DBT key, val;
memset(&val, 0, sizeof val); val.flags = val_flags; memset(&val, 0, sizeof val); val.flags = val_flags;
...@@ -37,7 +39,8 @@ int db_get(DB *db, int k, int expectv, int val_flags) { ...@@ -37,7 +39,8 @@ int db_get(DB *db, int k, int expectv, int val_flags) {
return r; return r;
} }
void test_db_create() { static void
test_db_create (void) {
int r; int r;
DB *db; DB *db;
...@@ -51,7 +54,8 @@ void test_db_create() { ...@@ -51,7 +54,8 @@ void test_db_create() {
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
} }
void test_db_thread() { static void
test_db_thread (void) {
int r; int r;
DB *db; DB *db;
......
...@@ -27,13 +27,15 @@ struct db_inserter { ...@@ -27,13 +27,15 @@ struct db_inserter {
int do_exit; int do_exit;
}; };
int db_put(DB *db, my_t k, my_t v) { static int
db_put (DB *db, my_t k, my_t v) {
DBT key, val; DBT key, val;
int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
return r; return r;
} }
void *do_inserts(void *arg) { static void *
do_inserts (void *arg) {
struct db_inserter *mywork = (struct db_inserter *) arg; struct db_inserter *mywork = (struct db_inserter *) arg;
if (verbose) printf("%lu:%u:do_inserts:start:%u-%u\n", (unsigned long)pthread_self(), getmyid(), mywork->startno, mywork->endno); if (verbose) printf("%lu:%u:do_inserts:start:%u-%u\n", (unsigned long)pthread_self(), getmyid(), mywork->startno, mywork->endno);
my_t i; my_t i;
...@@ -47,7 +49,8 @@ void *do_inserts(void *arg) { ...@@ -47,7 +49,8 @@ void *do_inserts(void *arg) {
return 0; return 0;
} }
int usage() { static int
usage (void) {
fprintf(stderr, "test [-n NTUPLES] [-p NTHREADS]\n"); fprintf(stderr, "test [-n NTUPLES] [-p NTHREADS]\n");
fprintf(stderr, "default NTUPLES=1000000\n"); fprintf(stderr, "default NTUPLES=1000000\n");
fprintf(stderr, "default NTHREADS=2\n"); fprintf(stderr, "default NTHREADS=2\n");
...@@ -108,7 +111,7 @@ int main(int argc, char *argv[]) { ...@@ -108,7 +111,7 @@ int main(int argc, char *argv[]) {
work[i].endno = n; work[i].endno = n;
} }
if (verbose) printf("pid:%u\n", getpid()); if (verbose) printf("pid:%d\n", getpid());
for (i=1; i<nthreads; i++) { for (i=1; i<nthreads; i++) {
r = pthread_create(&work[i].tid, 0, do_inserts, &work[i]); assert(r == 0); r = pthread_create(&work[i].tid, 0, do_inserts, &work[i]); assert(r == 0);
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
// ENVDIR is defined in the Makefile // ENVDIR is defined in the Makefile
int dbtcmp(DBT *dbt1, DBT *dbt2) { static int
dbtcmp (DBT *dbt1, DBT *dbt2) {
int r; int r;
r = dbt1->size - dbt2->size; if (r) return r; r = dbt1->size - dbt2->size; if (r) return r;
...@@ -24,15 +25,16 @@ struct student_record { ...@@ -24,15 +25,16 @@ struct student_record {
char first_name[15]; char first_name[15];
}; };
#define SPACES " " #define SPACES " "
DB *dbp; static DB *dbp;
DB *sdbp; static DB *sdbp;
DB_TXN *const null_txn = 0; static DB_TXN *const null_txn = 0;
DB_ENV *dbenv; static DB_ENV *dbenv;
/* /*
* getname -- extracts a secondary key (the last name) from a primary * getname -- extracts a secondary key (the last name) from a primary
* key/data pair * key/data pair
*/ */
int getname(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey) static int
getname(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey)
{ {
/* /*
* Since the secondary key is a simple structure member of the * Since the secondary key is a simple structure member of the
...@@ -49,7 +51,8 @@ int getname(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey) ...@@ -49,7 +51,8 @@ int getname(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey)
return (0); return (0);
} }
void second_setup() { static void
second_setup (void) {
int r; int r;
/* Open/create primary */ /* Open/create primary */
...@@ -71,7 +74,8 @@ void second_setup() { ...@@ -71,7 +74,8 @@ void second_setup() {
r = dbp->associate(dbp, NULL, sdbp, getname, 0); CKERR(r); r = dbp->associate(dbp, NULL, sdbp, getname, 0); CKERR(r);
} }
void setup_student(struct student_record *s) { static void
setup_student (struct student_record *s) {
memset(s, 0, sizeof(struct student_record)); memset(s, 0, sizeof(struct student_record));
memcpy(&s->student_id, "WC42" SPACES, sizeof(s->student_id)); memcpy(&s->student_id, "WC42" SPACES, sizeof(s->student_id));
//Padded with enough spaces to fill out last/first name. //Padded with enough spaces to fill out last/first name.
...@@ -79,7 +83,8 @@ void setup_student(struct student_record *s) { ...@@ -79,7 +83,8 @@ void setup_student(struct student_record *s) {
memcpy(&s->first_name, "Winston" SPACES, sizeof(s->first_name)); memcpy(&s->first_name, "Winston" SPACES, sizeof(s->first_name));
} }
void insert_test() { static void
insert_test (void) {
struct student_record s; struct student_record s;
DBT data; DBT data;
DBT key; DBT key;
...@@ -132,7 +137,8 @@ void insert_test() { ...@@ -132,7 +137,8 @@ void insert_test() {
r = dbp->pget(dbp, null_txn, &key, &testkey, &data, 0); assert(r == EINVAL); r = dbp->pget(dbp, null_txn, &key, &testkey, &data, 0); assert(r == EINVAL);
} }
void delete_from_primary() { static void
delete_from_primary (void) {
int r; int r;
DBT key; DBT key;
...@@ -142,7 +148,8 @@ void delete_from_primary() { ...@@ -142,7 +148,8 @@ void delete_from_primary() {
r = dbp->del(dbp, null_txn, &key, 0); CKERR(r); r = dbp->del(dbp, null_txn, &key, 0); CKERR(r);
} }
void delete_from_secondary() { static void
delete_from_secondary (void) {
int r; int r;
DBT skey; DBT skey;
DBT data; DBT data;
...@@ -158,7 +165,8 @@ void delete_from_secondary() { ...@@ -158,7 +165,8 @@ void delete_from_secondary() {
r = sdbp->del(sdbp, null_txn, &skey, 0); CKERR(r); r = sdbp->del(sdbp, null_txn, &skey, 0); CKERR(r);
} }
void verify_gone() { static void
verify_gone (void) {
int r; int r;
DBT key; DBT key;
DBT skey; DBT skey;
......
...@@ -31,13 +31,15 @@ struct db_inserter { ...@@ -31,13 +31,15 @@ struct db_inserter {
int do_exit; int do_exit;
}; };
int db_put(DB *db, my_t k, my_t v) { static int
db_put (DB *db, my_t k, my_t v) {
DBT key, val; DBT key, val;
int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
return r; return r;
} }
void *do_inserts(void *arg) { static void *
do_inserts (void *arg) {
struct db_inserter *mywork = (struct db_inserter *) arg; struct db_inserter *mywork = (struct db_inserter *) arg;
if (verbose) printf("%lu:%u:do_inserts:start:%u-%u\n", (unsigned long)pthread_self(), getmyid(), mywork->startno, mywork->endno); if (verbose) printf("%lu:%u:do_inserts:start:%u-%u\n", (unsigned long)pthread_self(), getmyid(), mywork->startno, mywork->endno);
my_t i; my_t i;
...@@ -50,7 +52,8 @@ void *do_inserts(void *arg) { ...@@ -50,7 +52,8 @@ void *do_inserts(void *arg) {
return 0; return 0;
} }
int usage() { static int
usage (void) {
fprintf(stderr, "test OPTIONS\n"); fprintf(stderr, "test OPTIONS\n");
fprintf(stderr, "[-n NTUPLES] (default:1000000)\n"); fprintf(stderr, "[-n NTUPLES] (default:1000000)\n");
fprintf(stderr, "[-p NTHREADS] (default:1)\n"); fprintf(stderr, "[-p NTHREADS] (default:1)\n");
...@@ -132,7 +135,7 @@ int main(int argc, char *argv[]) { ...@@ -132,7 +135,7 @@ int main(int argc, char *argv[]) {
work[i].endno = n; work[i].endno = n;
} }
if (verbose) printf("pid:%u\n", getpid()); if (verbose) printf("pid:%d\n", getpid());
for (i=all_on_threads ? 0 : 1; i<nthreads; i++) { for (i=all_on_threads ? 0 : 1; i<nthreads; i++) {
pthread_attr_t attr; pthread_attr_t attr;
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
#include <db.h> #include <db.h>
#include "test.h" #include "test.h"
int test_truncate(int n) { static int
test_truncate (int n) {
int r; int r;
DB_ENV *env; DB_ENV *env;
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
#include <db.h> #include <db.h>
#include "test.h" #include "test.h"
int test_truncate_subdb(int n) { static int
test_truncate_subdb (int n) {
int r; int r;
DB_ENV *env; DB_ENV *env;
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
#include <db.h> #include <db.h>
#include "test.h" #include "test.h"
int test_truncate_txn_abort(int n) { static int
test_truncate_txn_abort (int n) {
int r; int r;
DB_ENV *env; DB_ENV *env;
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
#include <db.h> #include <db.h>
#include "test.h" #include "test.h"
int test_truncate_txn_commit(int n) { static int
test_truncate_txn_commit (int n) {
int r; int r;
DB_ENV *env; DB_ENV *env;
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
#include <db.h> #include <db.h>
#include "test.h" #include "test.h"
int test_truncate_txn_commit2(int n) { static int
test_truncate_txn_commit2 (int n) {
int r; int r;
DB_ENV *env; DB_ENV *env;
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
#include <db.h> #include <db.h>
#include "test.h" #include "test.h"
int test_truncate_txn_commit2(int n) { static int
test_truncate_txn_commit2 (int n) {
int r; int r;
DB_ENV *env; DB_ENV *env;
......
...@@ -11,10 +11,11 @@ ...@@ -11,10 +11,11 @@
#include <db.h> #include <db.h>
#include "test.h" #include "test.h"
#if USE_BDB #ifdef USE_BDB
int test_errors = 0; int test_errors = 0;
void test_errcall(const DB_ENV *emv, const char *errpfx, const char *msg) { static void
test_errcall (const DB_ENV *env __attribute__((__unused__)), const char *errpfx, const char *msg) {
if (verbose) fprintf(stderr, "%s %s\n", errpfx, msg); if (verbose) fprintf(stderr, "%s %s\n", errpfx, msg);
test_errors++; test_errors++;
} }
...@@ -22,7 +23,8 @@ void test_errcall(const DB_ENV *emv, const char *errpfx, const char *msg) { ...@@ -22,7 +23,8 @@ void test_errcall(const DB_ENV *emv, const char *errpfx, const char *msg) {
#endif #endif
// try to truncate with cursors active // try to truncate with cursors active
int test_truncate_with_cursors(int n) { static int
test_truncate_with_cursors (int n) {
int r; int r;
DB_ENV *env; DB_ENV *env;
...@@ -64,13 +66,13 @@ int test_truncate_with_cursors(int n) { ...@@ -64,13 +66,13 @@ int test_truncate_with_cursors(int n) {
assert(i == n); assert(i == n);
// try to truncate with an active cursor // try to truncate with an active cursor
#if USE_BDB #ifdef USE_BDB
db->set_errcall(db, test_errcall); db->set_errcall(db, test_errcall);
assert(test_errors == 0); assert(test_errors == 0);
#endif #endif
u_int32_t row_count = 0; u_int32_t row_count = 0;
r = db->truncate(db, 0, &row_count, 0); r = db->truncate(db, 0, &row_count, 0);
#if USE_BDB #ifdef USE_BDB
// It looks like for 4.6 there's no error code, even though the documentation says "it is an error to truncate with open cursors". // It looks like for 4.6 there's no error code, even though the documentation says "it is an error to truncate with open cursors".
// For 4.3 the error code is EINVAL // For 4.3 the error code is EINVAL
// I don't know where the boundary really is: Is it an error in 4.5 or 4.4? // I don't know where the boundary really is: Is it an error in 4.5 or 4.4?
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#include <db.h> #include <db.h>
#include "test.h" #include "test.h"
void test_txn_abort(int n) { static void
test_txn_abort (int n) {
if (verbose) printf("test_txn_abort:%d\n", n); if (verbose) printf("test_txn_abort:%d\n", n);
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#include "test.h" #include "test.h"
void test_txn_abort(int n) { static void
test_txn_abort (int n) {
if (verbose>1) printf("%s %s:%d\n", __FILE__, __FUNCTION__, n); if (verbose>1) printf("%s %s:%d\n", __FILE__, __FUNCTION__, n);
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
...@@ -65,7 +66,7 @@ void test_txn_abort(int n) { ...@@ -65,7 +66,7 @@ void test_txn_abort(int n) {
for (i=0; 1; i++) { for (i=0; 1; i++) {
r = cursor->c_get(cursor, &key, &val, DB_NEXT); r = cursor->c_get(cursor, &key, &val, DB_NEXT);
if (r!=0) break; if (r!=0) break;
if (verbose>2) printf("%d present\n", ntohl(*(int*)key.data)); if (verbose>2) printf("%u present\n", ntohl(*(int*)key.data));
assert(key.size==4); assert(key.size==4);
assert(ntohl(*(int*)key.data)==(unsigned int)(2*i)); assert(ntohl(*(int*)key.data)==(unsigned int)(2*i));
} }
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#define N_TXNS 4 #define N_TXNS 4
void test_txn_abort(int n, int which_guys_to_abort) { static void
test_txn_abort (int n, int which_guys_to_abort) {
if (verbose>1) printf("test_txn_abort(%d,%x)\n", n, which_guys_to_abort); if (verbose>1) printf("test_txn_abort(%d,%x)\n", n, which_guys_to_abort);
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
...@@ -106,9 +107,9 @@ void test_txn_abort(int n, int which_guys_to_abort) { ...@@ -106,9 +107,9 @@ void test_txn_abort(int n, int which_guys_to_abort) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int i,j; int i,j;
#ifndef TOKUDB if (!IS_TDB) {
return 0; // This test is inappropriate for BDB. It requires finer grained locking that BDB supports. return 0; // This test is inappropriate for BDB. It requires finer grained locking that BDB supports.
#endif }
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
char *arg = argv[i]; char *arg = argv[i];
if (strcmp(arg, "-v") == 0 || strcmp(arg, "--verbose") == 0) { if (strcmp(arg, "-v") == 0 || strcmp(arg, "--verbose") == 0) {
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#include <db.h> #include <db.h>
#include "test.h" #include "test.h"
void test_abort_create(void) { static void
test_abort_create (void) {
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
mkdir(ENVDIR, 0777); mkdir(ENVDIR, 0777);
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#include "test.h" #include "test.h"
// //
void test_abort_close(void) { static void
test_abort_close (void) {
#ifndef USE_TDB #ifndef USE_TDB
#if DB_VERSION_MAJOR==4 && DB_VERSION_MINOR==3 #if DB_VERSION_MAJOR==4 && DB_VERSION_MINOR==3
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#include "test.h" #include "test.h"
// //
void test_abort_close(void) { static void
test_abort_close (void) {
#ifndef USE_TDB #ifndef USE_TDB
#if DB_VERSION_MAJOR==4 && DB_VERSION_MINOR==3 #if DB_VERSION_MAJOR==4 && DB_VERSION_MINOR==3
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
// Recreate a mysqld crash by closing and opening a db within a transaction. // Recreate a mysqld crash by closing and opening a db within a transaction.
// The crash occurs when writing a dirty cachetable pair, so we insert one // The crash occurs when writing a dirty cachetable pair, so we insert one
// row. // row.
void test_txn_close_open_commit(void) { static void
test_txn_close_open_commit (void) {
#ifndef USE_TDB #ifndef USE_TDB
#if DB_VERSION_MAJOR==4 && DB_VERSION_MINOR==3 #if DB_VERSION_MAJOR==4 && DB_VERSION_MINOR==3
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#include "test.h" #include "test.h"
// like test_txn_abort8.c except commit // like test_txn_abort8.c except commit
void test_abort_close(void) { static void
test_abort_close (void) {
#ifndef USE_TDB #ifndef USE_TDB
#if DB_VERSION_MAJOR==4 && DB_VERSION_MINOR==3 #if DB_VERSION_MAJOR==4 && DB_VERSION_MINOR==3
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#include "test.h" #include "test.h"
int db_put(DB *db, DB_TXN *txn, int k, int v) { static int
db_put (DB *db, DB_TXN *txn, int k, int v) {
DBT key, val; DBT key, val;
return db->put(db, txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_NOOVERWRITE); return db->put(db, txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_NOOVERWRITE);
} }
...@@ -32,7 +33,8 @@ static char *db_error(int error) { ...@@ -32,7 +33,8 @@ static char *db_error(int error) {
} }
/* t1 t2 l1 l2 p1 p2 c1 c2 */ /* t1 t2 l1 l2 p1 p2 c1 c2 */
void test_txn_cursor_last_1(int nrows) { static void
test_txn_cursor_last_1 (int nrows) {
if (verbose) printf("test_txn_cursor_last_1:%d\n", nrows); if (verbose) printf("test_txn_cursor_last_1:%d\n", nrows);
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
...@@ -115,7 +117,8 @@ void test_txn_cursor_last_1(int nrows) { ...@@ -115,7 +117,8 @@ void test_txn_cursor_last_1(int nrows) {
} }
/* t1 t2 l1 p1 l2 c1 p2 c2 */ /* t1 t2 l1 p1 l2 c1 p2 c2 */
void test_txn_cursor_last_2(int nrows) { static void
test_txn_cursor_last_2 (int nrows) {
if (verbose) printf("test_txn_cursor_last_2:%d\n", nrows); if (verbose) printf("test_txn_cursor_last_2:%d\n", nrows);
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
...@@ -201,12 +204,12 @@ int main(int argc, const char *argv[]) { ...@@ -201,12 +204,12 @@ int main(int argc, const char *argv[]) {
parse_args(argc, argv); parse_args(argc, argv);
#if USE_TDB if (IS_TDB) {
test_txn_cursor_last_1(0); test_txn_cursor_last_1(0);
test_txn_cursor_last_1(1); test_txn_cursor_last_1(1);
test_txn_cursor_last_2(0); test_txn_cursor_last_2(0);
test_txn_cursor_last_2(1); test_txn_cursor_last_2(1);
#endif }
return 0; return 0;
} }
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#include "test.h" #include "test.h"
int db_put(DB *db, DB_TXN *txn, int k, int v) { static int
db_put (DB *db, DB_TXN *txn, int k, int v) {
DBT key, val; DBT key, val;
return db->put(db, txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_NOOVERWRITE); return db->put(db, txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_NOOVERWRITE);
} }
...@@ -31,7 +32,8 @@ static char *db_error(int error) { ...@@ -31,7 +32,8 @@ static char *db_error(int error) {
} }
} }
void test_txn_nested(int do_commit) { static void
test_txn_nested(int do_commit) {
if (verbose) printf("test_txn_nested:%d\n", do_commit); if (verbose) printf("test_txn_nested:%d\n", do_commit);
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#include <db.h> #include <db.h>
#include "test.h" #include "test.h"
void test_txn_abort() { static void
test_txn_abort (void) {
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
mkdir(ENVDIR, 0777); mkdir(ENVDIR, 0777);
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#include <db.h> #include <db.h>
#include "test.h" #include "test.h"
void test_txn_abort() { static void
test_txn_abort (void) {
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
mkdir(ENVDIR, 0777); mkdir(ENVDIR, 0777);
......
...@@ -7,9 +7,11 @@ ...@@ -7,9 +7,11 @@
#include <db.h> #include <db.h>
#include "test.h" #include "test.h"
DB *db; static DB *db;
DB_ENV *env; static DB_ENV *env;
void setup_db(void) {
static void
setup_db (void) {
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
mkdir(ENVDIR, 0777); mkdir(ENVDIR, 0777);
...@@ -30,13 +32,17 @@ void setup_db(void) { ...@@ -30,13 +32,17 @@ void setup_db(void) {
} }
} }
void close_db(void) { #if 0
static void
close_db (void) {
int r; int r;
r = db->close(db, 0); CKERR(r); r = db->close(db, 0); CKERR(r);
r = env->close(env, 0); CKERR(r); r = env->close(env, 0); CKERR(r);
} }
#endif
void test_txn_abort(int insert, int secondnum) { static void
test_txn_abort (int insert, int secondnum) {
setup_db(); setup_db();
DBT key, val; DBT key, val;
...@@ -66,11 +72,11 @@ void test_txn_abort(int insert, int secondnum) { ...@@ -66,11 +72,11 @@ void test_txn_abort(int insert, int secondnum) {
} }
else { // delete else { // delete
r = db->del(db, child, dbt_init(&key, &i, sizeof i), DB_DELETE_ANY); r = db->del(db, child, dbt_init(&key, &i, sizeof i), DB_DELETE_ANY);
#if USE_TDB if (IS_TDB) {
CKERR(r); CKERR(r);
#else } else {
CKERR2(r, (secondnum==1 ? 0 : DB_NOTFOUND)); CKERR2(r, (secondnum==1 ? 0 : DB_NOTFOUND));
#endif }
} }
r = child->commit(child,DB_TXN_NOSYNC); r = child->commit(child,DB_TXN_NOSYNC);
child = NULL; child = NULL;
......
...@@ -13,12 +13,8 @@ ...@@ -13,12 +13,8 @@
#include "test.h" #include "test.h"
int db_put(DB *db, DB_TXN *txn, int k, int v) { static void
DBT key, val; test_txn_recover3 (int nrows) {
return db->put(db, txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_NOOVERWRITE);
}
void test_txn_recover3(int nrows) {
if (verbose) printf("test_txn_recover1:%d\n", nrows); if (verbose) printf("test_txn_recover1:%d\n", nrows);
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
......
...@@ -12,9 +12,8 @@ ...@@ -12,9 +12,8 @@
#include "test.h" #include "test.h"
static void
expect_cursor_get (DBC *cursor, int k, int v, int op) {
void expect_cursor_get(DBC *cursor, int k, int v, int op) {
int kk, vv; int kk, vv;
DBT key, val; DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), op); int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), op);
...@@ -23,7 +22,8 @@ void expect_cursor_get(DBC *cursor, int k, int v, int op) { ...@@ -23,7 +22,8 @@ void expect_cursor_get(DBC *cursor, int k, int v, int op) {
assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v); free(val.data); assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v); free(val.data);
} }
DBC *new_cursor(DB *db, int k, int v, int op) { static DBC *
new_cursor (DB *db, int k, int v, int op) {
DBC *cursor; DBC *cursor;
int r; int r;
r = db->cursor(db, 0, &cursor, 0); assert(r == 0); r = db->cursor(db, 0, &cursor, 0); assert(r == 0);
...@@ -31,13 +31,15 @@ DBC *new_cursor(DB *db, int k, int v, int op) { ...@@ -31,13 +31,15 @@ DBC *new_cursor(DB *db, int k, int v, int op) {
return cursor; return cursor;
} }
int db_put(DB *db, int k, int v) { static int
db_put (DB *db, int k, int v) {
DBT key, val; DBT key, val;
int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0); int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0);
return r; return r;
} }
void test_cursor_nonleaf_expand(int n, int reverse) { static void
test_cursor_nonleaf_expand (int n, int reverse) {
if (verbose) printf("test_cursor_nonleaf_expand:%d %d\n", n, reverse); if (verbose) printf("test_cursor_nonleaf_expand:%d %d\n", n, reverse);
DB_ENV * const null_env = 0; DB_ENV * const null_env = 0;
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
#include <sys/stat.h> #include <sys/stat.h>
#include "test.h" #include "test.h"
void test_autotxn(u_int32_t env_flags, u_int32_t db_flags) { static void
test_autotxn (u_int32_t env_flags, u_int32_t db_flags) {
DB_ENV *env; DB_ENV *env;
DB *db; DB *db;
int r; int r;
......
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