mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 14:54:20 +01:00
Hacking makefiles. Addresses #782. Also fixes a valgrind bug in one of the recovery tests.
git-svn-id: file:///svn/tokudb@3814 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
7759603b6f
commit
dd8f0f3386
44 changed files with 183 additions and 150 deletions
|
@ -324,6 +324,7 @@ void toku_recover_addchild (LSN lsn, FILENUM filenum, DISKOFF diskoff, u_int32_t
|
|||
}
|
||||
BNC_DISKOFF(node, childnum) = child;
|
||||
BNC_SUBTREE_FINGERPRINT(node, childnum) = childfingerprint;
|
||||
BNC_SUBTREE_LEAFENTRY_ESTIMATE(node, childnum) = 0;
|
||||
//BNC_SUBTREE_LEAFENTRY_ESTIMATE(node, childnum) = 0; // This isn't right, but recovery is broken right now anyway, so just leaf it unininitalized.
|
||||
int r= toku_fifo_create(&BNC_BUFFER(node, childnum)); assert(r==0);
|
||||
BNC_NBYTESINBUF(node, childnum) = 0;
|
||||
|
|
|
@ -48,7 +48,6 @@ LIBNAME=libdb.$(LIBEXT)
|
|||
CFLAGS += -Wall -Werror $(OPTFLAGS) -g3 -ggdb3 $(GCOV_FLAGS)
|
||||
TDB_CPPFLAGS = -I../../include
|
||||
|
||||
|
||||
SRCS = $(sort $(wildcard *.c))
|
||||
|
||||
TDB_TESTS = $(patsubst %.c,%.tdb,$(SRCS))
|
||||
|
|
|
@ -19,23 +19,24 @@ SRC_TESTS_TDB_LOADLIBES = -L$(ROOT)lib -ltokudb -Wl,-rpath,.. -lpthread
|
|||
SRC_TESTS_TDB_CPPFLAGS = -I$(ROOT)include
|
||||
|
||||
foo:
|
||||
echo $(SRC_OFILES)
|
||||
echo $(ROOT)lib/libtokudb.$(LIBEXT)
|
||||
echo $(SRC_TESTS_RUN_ALL_TESTS)
|
||||
|
||||
src/tests.checkdir: $(SRC_TESTS_RUN_ALL_TESTS)
|
||||
src/tests.builddir: $(SRC_TESTS_ALL_TESTS)
|
||||
|
||||
$(SRC_TESTS_ALL_TESTS): $(SRC_TESTS_HERE)/test.h
|
||||
|
||||
.PHONY: $(SRC_TESTS_RUN_ALL_TESTS)
|
||||
%.bdbrun: %.bdb
|
||||
$(MAYBEATSIGN) $(UNSETTOKUENV) ./$< $(VERBVERBOSE)
|
||||
# %.tdbrun: %.tdb $(ROOT)lib/libtokudb.$(LIBEXT)
|
||||
%.tdbrun: %.tdb
|
||||
$(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./$< $(VERBVERBOSE) $(MAYBEINVERTERR)
|
||||
%.bdb: %.c
|
||||
$(UNSETTOKUENV) cc -DENVDIR=\"$<.bdbdir\" $(BDB_CPPFLAGS) -DUSE_BDB -DIS_TDB=0 $(CFLAGS) $< $(BDB_LDFLAGS) -ldb -o $@
|
||||
%.tdb: %.c
|
||||
%.tdb: %.c $(ROOT)lib/libtokudb.$(LIBEXT)
|
||||
$(SETTOKUENV) cc -DENVDIR=\"$<.tdbdir\" -DUSE_TDB -DIS_TDB=1 $(CFLAGS) $(CPPFLAGS) $(SRC_TESTS_TDB_CPPFLAGS) $(SRC_TESTS_TDB_LOADLIBES) $< -o $@
|
||||
%.tdbt: %.c
|
||||
$(SETTOKUENV) cc -DENVDIR=\"$<.tdbdir\" -DUSE_TDB -DIS_TDB=1 $(CFLAGS) $(CPPFLAGS) $(SRC_TESTS_TDB_CPPFLAGS) $(TDB_TRACELOADLIBES) $< -o $@
|
||||
|
||||
$(SRC_TESTS_HERE)/test_logmax.tdb: CPPFLAGS += -D_BSD_SOURCE
|
||||
$(SRC_TESTS_HERE)/test_thread_insert.tdb: CPPFLAGS += -D_GNU_SOURCE
|
||||
$(SRC_TESTS_HERE)/test_thread_stack.tdb: CPPFLAGS += -D_GNU_SOURCE
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
int verbose=0;
|
||||
|
||||
#define UU(x) x __attribute__((__unused__))
|
||||
|
||||
#define CKERR(r) ({ if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0); })
|
||||
#define CKERR2(r,r2) ({ if (r!=r2) fprintf(stderr, "%s:%d error %d %s, expected %d\n", __FILE__, __LINE__, r, db_strerror(r), r2); assert(r==r2); })
|
||||
#define CKERR2s(r,r2,r3) ({ if (r!=r2 && r!=r3) fprintf(stderr, "%s:%d error %d %s, expected %d or %d\n", __FILE__, __LINE__, r, db_strerror(r), r2,r3); assert(r==r2||r==r3); })
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// ENVDIR is defined in the Makefile
|
||||
#include "test.h"
|
||||
|
||||
#define CKERR(r) if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0);
|
||||
// ENVDIR is defined in the Makefile
|
||||
|
||||
void test_db_open_aborts (void) {
|
||||
DB_ENV *env;
|
||||
|
@ -141,7 +141,7 @@ void test_db_put_aborts (void) {
|
|||
r=env->close(env, 0); assert(r==0);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int main (int UU(argc), char UU(*argv[])) {
|
||||
test_db_open_aborts();
|
||||
test_db_put_aborts();
|
||||
return 0;
|
||||
|
|
|
@ -88,7 +88,7 @@ void test_cursor_current() {
|
|||
r = db->close(db, 0); assert(r == 0);
|
||||
}
|
||||
|
||||
void db_get(DB *db, int k, int v, int expectr) {
|
||||
void db_get(DB *db, int k, int UU(v), int expectr) {
|
||||
DBT key, val;
|
||||
int r = db->get(db, 0, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
|
||||
assert(r == expectr);
|
||||
|
|
|
@ -23,7 +23,7 @@ DB_ENV* dbenv;
|
|||
DBC* cursors[(int)256];
|
||||
DB_TXN* null_txn = NULL;
|
||||
|
||||
void put(char txn, int _key, int _data) {
|
||||
void put(int _key, int _data) {
|
||||
int r;
|
||||
DBT key;
|
||||
DBT data;
|
||||
|
@ -162,7 +162,7 @@ void test(u_int32_t dup_flags) {
|
|||
if (i & 0x2) data = -1;
|
||||
else data = 1;
|
||||
setup_dbs(dup_flags);
|
||||
put('a', key, data);
|
||||
put(key, data);
|
||||
cget(DB_SET, TRUE, 'a', key, data);
|
||||
cget(DB_CURRENT, TRUE, 'a', key, data);
|
||||
close_dbs();
|
||||
|
|
|
@ -52,7 +52,7 @@ void expect_db_get(DB *db, int k, int v) {
|
|||
free(val.data);
|
||||
}
|
||||
|
||||
int cursor_get(DBC *cursor, int *k, int *v, int op) {
|
||||
int cursor_get(DBC *cursor, unsigned int *k, unsigned int *v, int op) {
|
||||
DBT key, val;
|
||||
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), op);
|
||||
if (r == 0) {
|
||||
|
@ -64,15 +64,15 @@ int cursor_get(DBC *cursor, int *k, int *v, int op) {
|
|||
return r;
|
||||
}
|
||||
|
||||
void expect_cursor_get(DBC *cursor, int k, int v) {
|
||||
void expect_cursor_get(DBC *cursor, unsigned int k, unsigned 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;
|
||||
unsigned int kk;
|
||||
memcpy(&kk, key.data, key.size);
|
||||
assert(val.size == sizeof v);
|
||||
int vv;
|
||||
unsigned 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);
|
||||
|
@ -95,11 +95,11 @@ void expect_cursor_get_both(DBC *cursor, int k, int v) {
|
|||
assert(r == 0);
|
||||
}
|
||||
|
||||
void expect_cursor_get_current(DBC *cursor, int k, int v) {
|
||||
void expect_cursor_get_current(DBC *cursor, unsigned int k, unsigned 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;
|
||||
unsigned 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);
|
||||
|
@ -124,7 +124,7 @@ void test_cursor_sticky(int n, int dup_mode) {
|
|||
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
|
||||
|
||||
int i;
|
||||
int k, v;
|
||||
unsigned int k, v;
|
||||
for (i=0; i<n; i++) {
|
||||
db_put(db, htonl(i), htonl(i));
|
||||
}
|
||||
|
|
|
@ -81,12 +81,12 @@ void write_pd_to_dbt (DBT *dbt, const struct primary_data *pd) {
|
|||
write_name_to_dbt(dbt, &pd->name);
|
||||
}
|
||||
|
||||
void read_uchar_from_dbt (const DBT *dbt, int *off, unsigned char *uchar) {
|
||||
void read_uchar_from_dbt (const DBT *dbt, unsigned int *off, unsigned char *uchar) {
|
||||
assert(*off < dbt->size);
|
||||
*uchar = ((unsigned char *)dbt->data)[(*off)++];
|
||||
}
|
||||
|
||||
void read_uint_from_dbt (const DBT *dbt, int *off, unsigned int *uint) {
|
||||
void read_uint_from_dbt (const DBT *dbt, unsigned int *off, unsigned int *uint) {
|
||||
unsigned char a,b,c,d;
|
||||
read_uchar_from_dbt(dbt, off, &a);
|
||||
read_uchar_from_dbt(dbt, off, &b);
|
||||
|
@ -95,12 +95,12 @@ void read_uint_from_dbt (const DBT *dbt, int *off, unsigned int *uint) {
|
|||
*uint = (a<<24)+(b<<16)+(c<<8)+d;
|
||||
}
|
||||
|
||||
void read_timestamp_from_dbt (const DBT *dbt, int *off, struct timestamp *ts) {
|
||||
void read_timestamp_from_dbt (const DBT *dbt, unsigned int *off, struct timestamp *ts) {
|
||||
read_uint_from_dbt(dbt, off, &ts->tv_sec);
|
||||
read_uint_from_dbt(dbt, off, &ts->tv_usec);
|
||||
}
|
||||
|
||||
void read_name_from_dbt (const DBT *dbt, int *off, struct name_key *nk) {
|
||||
void read_name_from_dbt (const DBT *dbt, unsigned int *off, struct name_key *nk) {
|
||||
unsigned char buf[1000];
|
||||
int i;
|
||||
for (i=0; 1; i++) {
|
||||
|
@ -110,7 +110,7 @@ void read_name_from_dbt (const DBT *dbt, int *off, struct name_key *nk) {
|
|||
nk->name=(unsigned char*)(strdup((char*)buf));
|
||||
}
|
||||
|
||||
void read_pd_from_dbt (const DBT *dbt, int *off, struct primary_data *pd) {
|
||||
void read_pd_from_dbt (const DBT *dbt, unsigned int *off, struct primary_data *pd) {
|
||||
read_timestamp_from_dbt(dbt, off, &pd->expiretime);
|
||||
read_uchar_from_dbt(dbt, off, &pd->doesexpire);
|
||||
read_name_from_dbt(dbt, off, &pd->name);
|
||||
|
@ -120,9 +120,9 @@ int name_offset_in_pd_dbt (void) {
|
|||
return 9;
|
||||
}
|
||||
|
||||
int name_callback (DB *secondary __attribute__((__unused__)), const DBT *key, const DBT *data, DBT *result) {
|
||||
int name_callback (DB *UU(secondary), const DBT * UU(key), const DBT *data, DBT *result) {
|
||||
struct primary_data *pd = malloc(sizeof(*pd));
|
||||
int off=0;
|
||||
unsigned int off=0;
|
||||
read_pd_from_dbt(data, &off, pd);
|
||||
static int buf[1000];
|
||||
|
||||
|
@ -134,7 +134,7 @@ int name_callback (DB *secondary __attribute__((__unused__)), const DBT *key, co
|
|||
return 0;
|
||||
}
|
||||
|
||||
int expire_callback (DB *secondary __attribute__((__unused__)), const DBT *key, const DBT *data, DBT *result) {
|
||||
int expire_callback (DB *UU(secondary), const DBT *UU(key), const DBT *data, DBT *result) {
|
||||
struct primary_data *d = data->data;
|
||||
if (d->doesexpire) {
|
||||
result->flags=0;
|
||||
|
@ -463,6 +463,7 @@ void activity (void) {
|
|||
}
|
||||
|
||||
|
||||
void usage (const char*) __attribute__((__noreturn__));
|
||||
void usage (const char *argv1) {
|
||||
fprintf(stderr, "Usage:\n %s [ --DB-CREATE | --more ] [ --tod=N ] [ --seed=SEED ] [ --count=count ] \n", argv1);
|
||||
exit(1);
|
||||
|
@ -487,7 +488,6 @@ int main (int argc, const char *argv[]) {
|
|||
const char *progname=argv[0];
|
||||
int useseed;
|
||||
int activity_count = 100000;
|
||||
int verbose=0;
|
||||
|
||||
{
|
||||
struct timeval tv;
|
||||
|
@ -512,7 +512,10 @@ int main (int argc, const char *argv[]) {
|
|||
} else if (strcmp(argv[0], "--more")==0) {
|
||||
mode = MODE_MORE;
|
||||
} else if (strcmp(argv[0], "-v")==0) {
|
||||
verbose=1;
|
||||
verbose++;
|
||||
} else if (strcmp(argv[0], "-q")==0) {
|
||||
verbose--;
|
||||
if (verbose<0) verbose=0;
|
||||
} else if (maybe_parse_intarg(progname, argv[0], "--seed=", &useseed)
|
||||
|| maybe_parse_intarg(progname, argv[0], "--count=", &activity_count)) {
|
||||
/* nothing */
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
#include <sys/types.h>
|
||||
#include <db.h>
|
||||
|
||||
// ENVDIR is defined in the Makefile
|
||||
#include "test.h"
|
||||
|
||||
#define CKERR(r) if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0);
|
||||
// ENVDIR is defined in the Makefile
|
||||
|
||||
DB_ENV *env;
|
||||
DB *db;
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int main (int UU(argc), char UU(*argv[])) {
|
||||
int r;
|
||||
system("rm -rf " ENVDIR);
|
||||
r=mkdir(ENVDIR, 0777); assert(r==0);
|
||||
|
|
|
@ -101,12 +101,12 @@ void write_pd_to_dbt (DBT *dbt, const struct primary_data *pd) {
|
|||
write_name_to_dbt(dbt, &pd->name);
|
||||
}
|
||||
|
||||
void read_uchar_from_dbt (const DBT *dbt, int *off, unsigned char *uchar) {
|
||||
void read_uchar_from_dbt (const DBT *dbt, unsigned int *off, unsigned char *uchar) {
|
||||
assert(*off < dbt->size);
|
||||
*uchar = ((unsigned char *)dbt->data)[(*off)++];
|
||||
}
|
||||
|
||||
void read_uint_from_dbt (const DBT *dbt, int *off, unsigned int *uint) {
|
||||
void read_uint_from_dbt (const DBT *dbt, unsigned int *off, unsigned int *uint) {
|
||||
unsigned char a,b,c,d;
|
||||
read_uchar_from_dbt(dbt, off, &a);
|
||||
read_uchar_from_dbt(dbt, off, &b);
|
||||
|
@ -115,12 +115,12 @@ void read_uint_from_dbt (const DBT *dbt, int *off, unsigned int *uint) {
|
|||
*uint = (a<<24)+(b<<16)+(c<<8)+d;
|
||||
}
|
||||
|
||||
void read_timestamp_from_dbt (const DBT *dbt, int *off, struct timestamp *ts) {
|
||||
void read_timestamp_from_dbt (const DBT *dbt, unsigned int *off, struct timestamp *ts) {
|
||||
read_uint_from_dbt(dbt, off, &ts->tv_sec);
|
||||
read_uint_from_dbt(dbt, off, &ts->tv_usec);
|
||||
}
|
||||
|
||||
void read_name_from_dbt (const DBT *dbt, int *off, struct name_key *nk) {
|
||||
void read_name_from_dbt (const DBT *dbt, unsigned int *off, struct name_key *nk) {
|
||||
unsigned char buf[1000];
|
||||
int i;
|
||||
for (i=0; 1; i++) {
|
||||
|
@ -130,7 +130,7 @@ void read_name_from_dbt (const DBT *dbt, int *off, struct name_key *nk) {
|
|||
nk->name=(unsigned char*)(strdup((char*)buf));
|
||||
}
|
||||
|
||||
void read_pd_from_dbt (const DBT *dbt, int *off, struct primary_data *pd) {
|
||||
void read_pd_from_dbt (const DBT *dbt, unsigned int *off, struct primary_data *pd) {
|
||||
read_timestamp_from_dbt(dbt, off, &pd->creationtime);
|
||||
read_timestamp_from_dbt(dbt, off, &pd->expiretime);
|
||||
read_uchar_from_dbt(dbt, off, &pd->doesexpire);
|
||||
|
@ -141,9 +141,9 @@ int name_offset_in_pd_dbt (void) {
|
|||
return 17;
|
||||
}
|
||||
|
||||
int name_callback (DB *secondary __attribute__((__unused__)), const DBT *key, const DBT *data, DBT *result) {
|
||||
int name_callback (DB *secondary __attribute__((__unused__)), const DBT * UU(key), const DBT *data, DBT *result) {
|
||||
struct primary_data *pd = malloc(sizeof(*pd));
|
||||
int off=0;
|
||||
unsigned int off=0;
|
||||
read_pd_from_dbt(data, &off, pd);
|
||||
static int buf[1000];
|
||||
|
||||
|
@ -155,7 +155,7 @@ int name_callback (DB *secondary __attribute__((__unused__)), const DBT *key, co
|
|||
return 0;
|
||||
}
|
||||
|
||||
int expire_callback (DB *secondary __attribute__((__unused__)), const DBT *key, const DBT *data, DBT *result) {
|
||||
int expire_callback (DB *UU(secondary), const DBT * UU(key), const DBT *data, DBT *result) {
|
||||
struct primary_data *d = data->data;
|
||||
if (d->doesexpire) {
|
||||
result->flags=0;
|
||||
|
@ -348,7 +348,7 @@ void insert_person (void) {
|
|||
}
|
||||
|
||||
void print_dbt (DBT *dbt) {
|
||||
int i;
|
||||
unsigned int i;
|
||||
for (i=0; i<dbt->size; i++) {
|
||||
unsigned char c = ((char*)dbt->data)[i];
|
||||
if (c!='\\' && isprint(c)) printf("%c", c);
|
||||
|
@ -457,8 +457,9 @@ void activity (void) {
|
|||
}
|
||||
|
||||
|
||||
void usage (const char *argv1) __attribute__((__noreturn__));
|
||||
void usage (const char *argv1) {
|
||||
fprintf(stderr, "Usage:\n %s [ --DB-CREATE | --more ] [-v] seed\n", argv1);
|
||||
fprintf(stderr, "Usage:\n %s [ --DB-CREATE | --more ] [-v|-q] seed\n", argv1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -489,7 +490,10 @@ int main (int argc, const char *argv[]) {
|
|||
} else if (strcmp(argv[0], "--more")==0) {
|
||||
mode = MODE_MORE;
|
||||
} else if (strcmp(argv[0], "-v")==0) {
|
||||
verbose = 1;
|
||||
verbose++;
|
||||
} else if (strcmp(argv[0], "-q")==0) {
|
||||
verbose--;
|
||||
if (verbose<0) verbose = 0;
|
||||
} else {
|
||||
errno=0;
|
||||
char *endptr;
|
||||
|
|
|
@ -76,12 +76,12 @@ static void write_pd_to_dbt (DBT *dbt, const struct primary_data *pd) {
|
|||
write_name_to_dbt(dbt, &pd->name);
|
||||
}
|
||||
|
||||
static void read_uchar_from_dbt (const DBT *dbt, int *off, unsigned char *uchar) {
|
||||
static void read_uchar_from_dbt (const DBT *dbt, unsigned int *off, unsigned char *uchar) {
|
||||
assert(*off < dbt->size);
|
||||
*uchar = ((unsigned char *)dbt->data)[(*off)++];
|
||||
}
|
||||
|
||||
static void read_uint_from_dbt (const DBT *dbt, int *off, unsigned int *uint) {
|
||||
static void read_uint_from_dbt (const DBT *dbt, unsigned int *off, unsigned int *uint) {
|
||||
unsigned char a,b,c,d;
|
||||
read_uchar_from_dbt(dbt, off, &a);
|
||||
read_uchar_from_dbt(dbt, off, &b);
|
||||
|
@ -90,11 +90,11 @@ static void read_uint_from_dbt (const DBT *dbt, int *off, unsigned int *uint) {
|
|||
*uint = (a<<24)+(b<<16)+(c<<8)+d;
|
||||
}
|
||||
|
||||
static void read_timestamp_from_dbt (const DBT *dbt, int *off, timestamp *ts) {
|
||||
static void read_timestamp_from_dbt (const DBT *dbt, unsigned int *off, timestamp *ts) {
|
||||
read_uint_from_dbt(dbt, off, ts);
|
||||
}
|
||||
|
||||
static void read_name_from_dbt (const DBT *dbt, int *off, struct name_key *nk) {
|
||||
static void read_name_from_dbt (const DBT *dbt, unsigned int *off, struct name_key *nk) {
|
||||
unsigned char buf[1000];
|
||||
int i;
|
||||
for (i=0; 1; i++) {
|
||||
|
@ -104,16 +104,16 @@ static void read_name_from_dbt (const DBT *dbt, int *off, struct name_key *nk) {
|
|||
nk->name=(unsigned char*)(strdup((char*)buf));
|
||||
}
|
||||
|
||||
static void read_pd_from_dbt (const DBT *dbt, int *off, struct primary_data *pd) {
|
||||
static void read_pd_from_dbt (const DBT *dbt, unsigned int *off, struct primary_data *pd) {
|
||||
read_timestamp_from_dbt(dbt, off, &pd->creationtime);
|
||||
read_timestamp_from_dbt(dbt, off, &pd->expiretime);
|
||||
read_uchar_from_dbt(dbt, off, &pd->doesexpire);
|
||||
read_name_from_dbt(dbt, off, &pd->name);
|
||||
}
|
||||
|
||||
static int name_callback (DB *secondary __attribute__((__unused__)), const DBT *key, const DBT *data, DBT *result) {
|
||||
static int name_callback (DB *secondary __attribute__((__unused__)), const DBT * UU(key), const DBT *data, DBT *result) {
|
||||
struct primary_data *pd = malloc(sizeof(*pd));
|
||||
int off=0;
|
||||
unsigned int off=0;
|
||||
read_pd_from_dbt(data, &off, pd);
|
||||
static int buf[1000];
|
||||
|
||||
|
@ -125,7 +125,7 @@ static int name_callback (DB *secondary __attribute__((__unused__)), const DBT *
|
|||
return 0;
|
||||
}
|
||||
|
||||
int expire_callback (DB *secondary __attribute__((__unused__)), const DBT *key, const DBT *data, DBT *result) {
|
||||
int expire_callback (DB *UU(secondary), const DBT * UU(key), const DBT *data, DBT *result) {
|
||||
struct primary_data *d = data->data;
|
||||
if (d->doesexpire) {
|
||||
result->flags=0;
|
||||
|
@ -307,7 +307,7 @@ static void activity (void) {
|
|||
|
||||
|
||||
static void usage (const char *argv1) {
|
||||
fprintf(stderr, "Usage:\n %s [ --DB-CREATE | --more ] [-v] seed\n", argv1);
|
||||
fprintf(stderr, "Usage:\n %s [ --DB-CREATE | --more ] [-v|-q] seed\n", argv1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,10 @@ int main (int argc, const char *argv[]) {
|
|||
if (strcmp(argv[0], "--more")==0) {
|
||||
mode = MODE_MORE;
|
||||
} else if (strcmp(argv[0], "-v")==0) {
|
||||
verbose = 1;
|
||||
verbose++;
|
||||
} else if (strcmp(argv[0], "-q")==0) {
|
||||
verbose--;
|
||||
if (verbose<0) verbose = 0;
|
||||
} else {
|
||||
usage(progname);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ void my_free(void * p) {
|
|||
* getname -- extracts a secondary key (the last name) from a primary
|
||||
* key/data pair
|
||||
*/
|
||||
int getskey(DB *secondary, const DBT *pkey, const DBT *pdata, DBT *skey)
|
||||
int getskey(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey)
|
||||
{
|
||||
DATA* entry;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ void my_free(void * p) {
|
|||
* getname -- extracts a secondary key (the last name) from a primary
|
||||
* key/data pair
|
||||
*/
|
||||
int getskey(DB *secondary, const DBT *pkey, const DBT *pdata, DBT *skey)
|
||||
int getskey(DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey)
|
||||
{
|
||||
DATA* entry;
|
||||
|
||||
|
@ -122,7 +122,7 @@ DBT* dbt_init_malloc_and_copy(DBT* dbt, int something) {
|
|||
return dbt;
|
||||
}
|
||||
|
||||
void pget_test_set_skey_pkey(DBC* dbc, u_int32_t flag, u_int32_t expect, int set_skey, int skey_set, int set_pkey, int pkey_set) {
|
||||
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;
|
||||
DBT skey;
|
||||
DBT pkey;
|
||||
|
|
|
@ -79,7 +79,7 @@ int main(int argc, const char *argv[]) {
|
|||
if (i) set_ulen = sizeof(DATA) / 2;
|
||||
else set_ulen = sizeof(DATA);
|
||||
|
||||
int old_ulen;
|
||||
unsigned int old_ulen;
|
||||
int was_truncated = 0;
|
||||
int ulen_changed;
|
||||
int size_full;
|
||||
|
@ -114,7 +114,7 @@ int main(int argc, const char *argv[]) {
|
|||
ulen_changed = data.ulen != old_ulen;
|
||||
size_full = data.size == sizeof(DATA);
|
||||
|
||||
int min = data.ulen < data.size ? data.ulen : data.size;
|
||||
unsigned int min = data.ulen < data.size ? data.ulen : data.size;
|
||||
min = min < sizeof(DATA) ? min : sizeof(DATA);
|
||||
//assert(min == sizeof(DATA));
|
||||
r = memcmp((DATA*)data.data, &fake, min);
|
||||
|
|
|
@ -30,7 +30,7 @@ DB_ENV *dbenv = 0;
|
|||
* getname -- extracts a secondary key (the last name) from a primary
|
||||
* key/data pair
|
||||
*/
|
||||
int getskey(DB *secondary, const DBT *pkey, const DBT *pdata, DBT *skey)
|
||||
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
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
/* -*- mode: C; c-basic-offset: 4 -*- */
|
||||
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
|
||||
|
||||
// make stdlib define unsetenv()
|
||||
#define _GNU_SOURCE
|
||||
|
||||
/* Do we open directories with same priority as BDB? i.e. with home, without home, with DB_USE_ENVIRON/etc.. */
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
|
@ -72,7 +75,7 @@ int main() {
|
|||
|
||||
reinit_config(set_home, set_DB_ENVIRON, set_DB_HOME);
|
||||
r = snprintf(db_name, sizeof(db_name), "%s/%s", db_dir, DBNAME);
|
||||
assert(r < sizeof(db_name));
|
||||
assert(r < (int)sizeof(db_name));
|
||||
assert(r >= 0);
|
||||
|
||||
r = db_env_create(&env, 0);
|
||||
|
|
|
@ -8,12 +8,14 @@
|
|||
#include <errno.h>
|
||||
#include <db.h>
|
||||
|
||||
#include "test.h"
|
||||
|
||||
// ENVDIR is defined in the Makefile
|
||||
|
||||
DB_ENV *env;
|
||||
DB *db;
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int main (int UU(argc), char UU(*argv[])) {
|
||||
int r;
|
||||
r=system("rm -rf " ENVDIR); assert(r==0);
|
||||
r=mkdir(ENVDIR, 0777); assert(r==0);
|
||||
|
|
|
@ -77,14 +77,14 @@ void close_secondary() {
|
|||
r = sdbp->close(sdbp, 0); CKERR(r);
|
||||
}
|
||||
|
||||
void insert_bad_flags(DB* dbp, u_int32_t flags, int r_expect, int keyint, int dataint) {
|
||||
void insert_bad_flags(DB* db, u_int32_t flags, int r_expect, int keyint, int dataint) {
|
||||
DBT key;
|
||||
DBT data;
|
||||
int r;
|
||||
|
||||
dbt_init(&key, &keyint, sizeof(keyint));
|
||||
dbt_init(&data,&dataint,sizeof(dataint));
|
||||
r = dbp->put(dbp, null_txn, &key, &data, flags);
|
||||
r = db->put(db, null_txn, &key, &data, flags);
|
||||
CKERR2(r, r_expect);
|
||||
}
|
||||
|
||||
|
@ -99,14 +99,14 @@ void cinsert_bad_flags(DBC* dbc, u_int32_t flags, int r_expect, int keyint, int
|
|||
CKERR2(r, r_expect);
|
||||
}
|
||||
|
||||
void get_bad_flags(DB* dbp, u_int32_t flags, int r_expect, int keyint, int dataint) {
|
||||
void get_bad_flags(DB* db, u_int32_t flags, int r_expect, int keyint, int dataint) {
|
||||
DBT key;
|
||||
DBT data;
|
||||
int r;
|
||||
|
||||
dbt_init(&key, &keyint, sizeof(keyint));
|
||||
dbt_init(&data,&dataint,sizeof(dataint));
|
||||
r = dbp->get(dbp, null_txn, &key, &data, flags);
|
||||
r = db->get(db, null_txn, &key, &data, flags);
|
||||
CKERR2(r, r_expect);
|
||||
//Verify things don't change.
|
||||
assert(*(int*)key.data == keyint);
|
||||
|
@ -168,17 +168,17 @@ PUT_TEST put_tests[] = {
|
|||
const int num_put = sizeof(put_tests) / sizeof(put_tests[0]);
|
||||
|
||||
CPUT_TEST cput_tests[] = {
|
||||
{0, {{TPUT, 0, EINVAL, 0, 1}, {TGET, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, {NONE, }, }},
|
||||
{DB_DUP|DB_DUPSORT, {{TPUT, 0, EINVAL, 0, 1}, {TGET, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, {NONE, }, }},
|
||||
{0, {{TPUT, 0, EINVAL, 0, 1}, {TGET, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, {NONE, 0, 0, 0, 0}, }},
|
||||
{DB_DUP|DB_DUPSORT, {{TPUT, 0, EINVAL, 0, 1}, {TGET, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, {NONE, 0, 0, 0, 0}, }},
|
||||
{0, {{TPUT, DB_KEYFIRST, 0, 0, 1}, {TGET, DB_GET_BOTH, 0, 0, 1}, {TPUT, DB_CURRENT, 0, 0, 2}, {TGET, DB_GET_BOTH, DB_NOTFOUND, 0, 1}}},
|
||||
{DB_DUP|DB_DUPSORT, {{TPUT, DB_KEYFIRST, 0, 0, 1}, {TGET, DB_GET_BOTH, 0, 0, 1}, {TPUT, DB_CURRENT, EINVAL, 0, 2}, {TGET, DB_GET_BOTH, 0, 0, 1}}},
|
||||
{0, {{TPUT, DB_KEYLAST, 0, 0, 1}, {TGET, DB_GET_BOTH, 0, 0, 1}, {TPUT, DB_CURRENT, 0, 0, 2}, {TGET, DB_GET_BOTH, DB_NOTFOUND, 0, 1}}},
|
||||
{DB_DUP|DB_DUPSORT, {{TPUT, DB_KEYLAST, 0, 0, 1}, {TGET, DB_GET_BOTH, 0, 0, 1}, {TPUT, DB_CURRENT, EINVAL, 0, 2}, {TGET, DB_GET_BOTH, 0, 0, 1}}},
|
||||
{DB_DUP|DB_DUPSORT, {{TPUT, DB_KEYLAST, 0, 0, 1}, {TGET, DB_GET_BOTH, 0, 0, 1}, {TPUT, DB_CURRENT, 0, 1, 1}, {TGET, DB_GET_BOTH, DB_NOTFOUND, 1, 1}}},
|
||||
{DB_DUP|DB_DUPSORT, {{TPUT, DB_KEYLAST, 0, 0, 1}, {TGET, DB_GET_BOTH, 0, 0, 1}, {TPUT, DB_CURRENT, 0, 1, 1}, {TGET, DB_GET_BOTH, 0, 0, 1}}},
|
||||
{0, {{TPUT, DB_CURRENT, EINVAL, 0, 1}, {TGET, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, {NONE, }, }},
|
||||
{DB_DUP|DB_DUPSORT, {{TPUT, DB_CURRENT, EINVAL, 0, 1}, {TGET, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, {NONE, }, }},
|
||||
{0, {{TPUT, DB_NODUPDATA, EINVAL, 0, 1}, {TGET, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, {NONE, }, }},
|
||||
{0, {{TPUT, DB_CURRENT, EINVAL, 0, 1}, {TGET, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, {NONE, 0, 0, 0, 0}, }},
|
||||
{DB_DUP|DB_DUPSORT, {{TPUT, DB_CURRENT, EINVAL, 0, 1}, {TGET, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, {NONE, 0, 0, 0, 0}, }},
|
||||
{0, {{TPUT, DB_NODUPDATA, EINVAL, 0, 1}, {TGET, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, {NONE, 0, 0, 0, 0}, }},
|
||||
{DB_DUP|DB_DUPSORT, {{TPUT, DB_NODUPDATA, 0, 0, 1}, {TGET, DB_GET_BOTH, 0, 0, 1}, {TPUT, DB_NODUPDATA, 0, 0, 2}, {TGET, DB_GET_BOTH, 0, 0, 1}, }},
|
||||
{DB_DUP|DB_DUPSORT, {{TPUT, DB_NODUPDATA, 0, 0, 1}, {TGET, DB_GET_BOTH, 0, 0, 1}, {TPUT, DB_NODUPDATA, 0, 0, 2}, {TGET, DB_GET_BOTH, 0, 0, 2}, }},
|
||||
{DB_DUP|DB_DUPSORT, {{TPUT, DB_NODUPDATA, 0, 0, 1}, {TGET, DB_GET_BOTH, 0, 0, 1}, {TPUT, DB_NODUPDATA, DB_KEYEXIST, 0, 1}, {TGET, DB_GET_BOTH, 0, 0, 1}, }},
|
||||
|
@ -204,11 +204,11 @@ GET_TEST get_tests[] = {
|
|||
const int num_get = sizeof(get_tests) / sizeof(get_tests[0]);
|
||||
|
||||
STEST stests[] = {
|
||||
{0, 0, {{SGET, DB_GET_BOTH, EINVAL, 0, 1}, {NONE, }, }},
|
||||
{0, 0, {{SGET, DB_GET_BOTH, EINVAL, 0, 1}, {NONE, 0, 0, 0, 0}, }},
|
||||
};
|
||||
const int num_stests = sizeof(stests) / sizeof(stests[0]);
|
||||
|
||||
int identity_callback(DB *secondary __attribute__((__unused__)), const DBT *key, const DBT *data, DBT *result) {
|
||||
int identity_callback(DB *secondary __attribute__((__unused__)), const DBT *key, const DBT *UU(data), DBT *result) {
|
||||
memset(result, 0, sizeof(result));
|
||||
result->size = key->size;
|
||||
result->data = key->data;
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
#include <sys/types.h>
|
||||
#include <db.h>
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
#include "test.h"
|
||||
|
||||
int main (int UU(argc), char UU(*argv[])) {
|
||||
DB *db;
|
||||
int r;
|
||||
r = db_create(&db, 0, 0);
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
#include <errno.h>
|
||||
#include <db.h>
|
||||
|
||||
#include "test.h"
|
||||
|
||||
// ENVDIR is defined in the Makefile
|
||||
|
||||
DB_ENV *env;
|
||||
DB *db;
|
||||
|
||||
#define CKERR(r) if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0);
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int main (int UU(argc), char UU(*argv[])) {
|
||||
int r;
|
||||
system("rm -rf " ENVDIR);
|
||||
r=mkdir(ENVDIR, 0777); assert(r==0);
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <db.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test.h"
|
||||
|
||||
// ENVDIR is defined in the Makefile
|
||||
|
||||
DB_ENV *env;
|
||||
|
@ -16,7 +18,7 @@ DB *db;
|
|||
DBT key;
|
||||
DBT data;
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int main (int UU(argc), char UU(*argv[])) {
|
||||
int r;
|
||||
system("rm -rf " ENVDIR);
|
||||
r=mkdir(ENVDIR, 0777); assert(r==0);
|
||||
|
|
|
@ -9,15 +9,16 @@
|
|||
#include <db.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test.h"
|
||||
|
||||
// ENVDIR is defined in the Makefile
|
||||
#define CKERR(r) if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0);
|
||||
|
||||
DB_ENV *env;
|
||||
DB *db;
|
||||
DBT key;
|
||||
DBT data;
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int main (int UU(argc), char UU(*argv[])) {
|
||||
int r;
|
||||
system("rm -rf " ENVDIR);
|
||||
r=mkdir(ENVDIR, 0777); assert(r==0);
|
||||
|
|
|
@ -32,7 +32,7 @@ DB_ENV *dbenv;
|
|||
* getname -- extracts a secondary key (the last name) from a primary
|
||||
* key/data pair
|
||||
*/
|
||||
int getname(DB *secondary, const DBT *pkey, const DBT *pdata, DBT *skey)
|
||||
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
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
#include <db.h>
|
||||
#include <assert.h>
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
#include "test.h"
|
||||
|
||||
int main (int UU(argc), char UU(*argv[])) {
|
||||
const char *v;
|
||||
int major, minor, patch;
|
||||
v = db_version(0, 0, 0);
|
||||
|
|
|
@ -90,16 +90,18 @@ void test_dup_delete(int n, int dup_mode) {
|
|||
DBT key, val;
|
||||
r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
|
||||
assert(r == 0);
|
||||
int vv;
|
||||
unsigned int vv;
|
||||
assert(val.size == sizeof vv);
|
||||
memcpy(&vv, val.data, val.size);
|
||||
assert(vv == htonl(n));
|
||||
free(val.data);
|
||||
}
|
||||
|
||||
DBT key; int k = htonl(n/2);
|
||||
r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
|
||||
assert(r == 0);
|
||||
{
|
||||
DBT key; int k = htonl(n/2);
|
||||
r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
|
||||
assert(r == 0);
|
||||
}
|
||||
|
||||
/* verify lookup fails */
|
||||
{
|
||||
|
@ -261,17 +263,19 @@ void test_dup_delete_insert(int n, int dup_mode) {
|
|||
DBT key, val;
|
||||
r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
|
||||
assert(r == 0);
|
||||
int vv;
|
||||
unsigned int vv;
|
||||
assert(val.size == sizeof vv);
|
||||
memcpy(&vv, val.data, val.size);
|
||||
assert(vv == htonl(0));
|
||||
free(val.data);
|
||||
}
|
||||
|
||||
int k = htonl(n/2);
|
||||
DBT key;
|
||||
r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
|
||||
assert(r == 0);
|
||||
{
|
||||
int k = htonl(n/2);
|
||||
DBT key;
|
||||
r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
|
||||
assert(r == 0);
|
||||
}
|
||||
|
||||
/* insert n duplicates */
|
||||
for (i=0; i<n; i++) {
|
||||
|
@ -282,7 +286,7 @@ void test_dup_delete_insert(int n, int dup_mode) {
|
|||
DBT key, val;
|
||||
r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
|
||||
assert(r == 0);
|
||||
int vv;
|
||||
unsigned int vv;
|
||||
assert(val.size == sizeof vv);
|
||||
memcpy(&vv, val.data, val.size);
|
||||
assert(vv == htonl(0));
|
||||
|
@ -359,9 +363,11 @@ void test_all_dup_delete_insert(int n) {
|
|||
db_put(db, k, v);
|
||||
}
|
||||
|
||||
DBT key; int k = htonl(n/2);
|
||||
r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
|
||||
assert(r == 0);
|
||||
{
|
||||
DBT key; int k = htonl(n/2);
|
||||
r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
|
||||
assert(r == 0);
|
||||
}
|
||||
|
||||
/* insert n duplicates */
|
||||
for (i=0; i<n; i++) {
|
||||
|
@ -434,9 +440,9 @@ void test_walk_empty(int n, int dup_mode) {
|
|||
}
|
||||
|
||||
{
|
||||
DBT key; int k = htonl(n/2);
|
||||
r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
|
||||
assert(r == 0);
|
||||
DBT key; int k = htonl(n/2);
|
||||
r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
|
||||
assert(r == 0);
|
||||
}
|
||||
|
||||
DBC *cursor;
|
||||
|
@ -444,9 +450,9 @@ void test_walk_empty(int n, int dup_mode) {
|
|||
assert(r == 0);
|
||||
|
||||
{
|
||||
DBT key, val;
|
||||
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT);
|
||||
assert(r != 0);
|
||||
DBT key, val;
|
||||
r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT);
|
||||
assert(r != 0);
|
||||
}
|
||||
|
||||
r = cursor->c_close(cursor);
|
||||
|
@ -488,7 +494,7 @@ void test_icdi_search(int n, int dup_mode) {
|
|||
DBT key, val;
|
||||
r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
|
||||
assert(r == 0);
|
||||
int vv;
|
||||
unsigned int vv;
|
||||
assert(val.size == sizeof vv);
|
||||
memcpy(&vv, val.data, val.size);
|
||||
assert(vv == htonl(0));
|
||||
|
@ -507,10 +513,12 @@ void test_icdi_search(int n, int dup_mode) {
|
|||
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666);
|
||||
assert(r == 0);
|
||||
|
||||
int k = htonl(n/2);
|
||||
DBT key;
|
||||
r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
|
||||
assert(r == 0);
|
||||
{
|
||||
int k = htonl(n/2);
|
||||
DBT key;
|
||||
r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0);
|
||||
assert(r == 0);
|
||||
}
|
||||
|
||||
/* insert n duplicates */
|
||||
for (i=0; i<n; i++) {
|
||||
|
@ -521,7 +529,7 @@ void test_icdi_search(int n, int dup_mode) {
|
|||
DBT key, val;
|
||||
r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
|
||||
assert(r == 0);
|
||||
int vv;
|
||||
unsigned int vv;
|
||||
assert(val.size == sizeof vv);
|
||||
memcpy(&vv, val.data, val.size);
|
||||
assert(vv == htonl(n));
|
||||
|
@ -575,7 +583,7 @@ void test_ici_search(int n, int dup_mode) {
|
|||
DBT key, val;
|
||||
r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
|
||||
assert(r == 0);
|
||||
int vv;
|
||||
unsigned int vv;
|
||||
assert(val.size == sizeof vv);
|
||||
memcpy(&vv, val.data, val.size);
|
||||
assert(vv == htonl(0));
|
||||
|
@ -603,7 +611,7 @@ void test_ici_search(int n, int dup_mode) {
|
|||
DBT key, val;
|
||||
r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
|
||||
assert(r == 0);
|
||||
int vv;
|
||||
unsigned int vv;
|
||||
assert(val.size == sizeof vv);
|
||||
memcpy(&vv, val.data, val.size);
|
||||
assert(vv == htonl(0));
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "test.h"
|
||||
|
||||
/* verify that the dup flags are written and read from the database file correctly */
|
||||
void test_dup_flags(int dup_flags) {
|
||||
void test_dup_flags(u_int32_t dup_flags) {
|
||||
if (verbose) printf("test_dup_flags:%d\n", dup_flags);
|
||||
|
||||
DB_ENV * const null_env = 0;
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
#include <sys/types.h>
|
||||
#include <db.h>
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
#include "test.h"
|
||||
|
||||
int main (int UU(argc), char UU(*argv[])) {
|
||||
DB_ENV *env;
|
||||
DB *db;
|
||||
int r;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
char const* expect_errpfx;
|
||||
int n_handle_error=0;
|
||||
|
||||
void handle_error (const DB_ENV *dbenv, const char *errpfx, const char *msg) {
|
||||
void handle_error (const DB_ENV *UU(dbenv), const char *errpfx, const char *UU(msg)) {
|
||||
assert(errpfx==expect_errpfx);
|
||||
n_handle_error++;
|
||||
}
|
||||
|
|
|
@ -8,11 +8,13 @@
|
|||
#include <sys/types.h>
|
||||
#include <db.h>
|
||||
|
||||
#include "test.h"
|
||||
|
||||
// ENVDIR is defined in the Makefile
|
||||
|
||||
DB_ENV *env;
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int main (int UU(argc), char UU(*argv[])) {
|
||||
int r;
|
||||
system("rm -rf " ENVDIR);
|
||||
r=mkdir(ENVDIR, 0777); assert(r==0);
|
||||
|
|
|
@ -11,15 +11,15 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "test.h"
|
||||
|
||||
// ENVDIR is defined in the Makefile
|
||||
|
||||
DB_ENV *env;
|
||||
DB *db;
|
||||
DB_TXN *tid;
|
||||
|
||||
#define CKERR(r) if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0);
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int main (int UU(argc), char UU(*argv[])) {
|
||||
int r;
|
||||
system("rm -rf " ENVDIR);
|
||||
r=mkdir(ENVDIR, 0777); assert(r==0);
|
||||
|
|
|
@ -12,15 +12,15 @@
|
|||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test.h"
|
||||
|
||||
// ENVDIR is defined in the Makefile
|
||||
|
||||
DB_ENV *env;
|
||||
DB *db;
|
||||
DB_TXN *tid;
|
||||
|
||||
#define CKERR(r) if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0);
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int main (int UU(argc), char UU(*argv[])) {
|
||||
int r;
|
||||
system("rm -rf " ENVDIR);
|
||||
r=mkdir(ENVDIR, 0777); assert(r==0);
|
||||
|
|
|
@ -67,11 +67,11 @@ void insert_pending(int key, int val, DB_TXN *bookx) {
|
|||
static void put_a_random_item (DB *db, DB_TXN *tid, int i, DB_TXN *bookx) {
|
||||
char hello[30], there[30];
|
||||
DBT key,data;
|
||||
int rand = myrandom();
|
||||
random_keys_mentioned[n_keys_mentioned++] = rand;
|
||||
insert_pending(rand, i, bookx);
|
||||
//printf("Insert %u\n", rand);
|
||||
snprintf(hello, sizeof(hello), "hello%d.%d", rand, i);
|
||||
int randv = myrandom();
|
||||
random_keys_mentioned[n_keys_mentioned++] = randv;
|
||||
insert_pending(randv, i, bookx);
|
||||
//printf("Insert %u\n", randv);
|
||||
snprintf(hello, sizeof(hello), "hello%d.%d", randv, i);
|
||||
snprintf(there, sizeof(hello), "there%d", i);
|
||||
memset(&key, 0, sizeof(key));
|
||||
memset(&data, 0, sizeof(data));
|
||||
|
@ -85,23 +85,23 @@ static void put_a_random_item (DB *db, DB_TXN *tid, int i, DB_TXN *bookx) {
|
|||
static void delete_a_random_item (DB *db, DB_TXN *tid, DB_TXN *bookx) {
|
||||
if (n_keys_mentioned==0) return;
|
||||
int ridx = myrandom()%n_keys_mentioned;
|
||||
int rand = random_keys_mentioned[ridx];
|
||||
int randv = random_keys_mentioned[ridx];
|
||||
DBT keyd;
|
||||
DBT vald;
|
||||
//printf("Delete %u\n", rand);
|
||||
dbt_init(&keyd, &rand, sizeof(rand));
|
||||
dbt_init(&vald, &rand, sizeof(rand));
|
||||
//printf("Delete %u\n", randv);
|
||||
dbt_init(&keyd, &randv, sizeof(randv));
|
||||
dbt_init(&vald, &randv, sizeof(randv));
|
||||
|
||||
pending_i->del(pending_i, bookx, &keyd, 0);
|
||||
delete_in_mem(rand, &peni_count, peni_data);
|
||||
delete_in_mem(randv, &peni_count, peni_data);
|
||||
|
||||
pending_d->put(pending_d, bookx, &keyd, &vald, 0);
|
||||
insert_in_mem(rand, rand, &pend_count, pend_data);
|
||||
insert_in_mem(randv, randv, &pend_count, pend_data);
|
||||
|
||||
db->del(db, tid, &keyd, DB_DELETE_ANY);
|
||||
}
|
||||
|
||||
static void commit_items (DB_ENV *env, int i) {
|
||||
static void commit_items (DB_ENV *env, int UU(i)) {
|
||||
//printf("commit_items %d\n", i);
|
||||
DB_TXN *txn;
|
||||
int r=env->txn_begin(env, 0, &txn, 0); assert(r==0);
|
||||
|
@ -259,21 +259,21 @@ static void make_db (void) {
|
|||
r=env->txn_begin(env, 0, &bookx, 0); assert(r==0);
|
||||
|
||||
for (i=0; i<N; i++) {
|
||||
int rand = myrandom();
|
||||
if (i%10000==0) printf(".");
|
||||
if (rand%100==0) {
|
||||
int randv = myrandom();
|
||||
//if (i%10000==0) printf(".");
|
||||
if (randv%100==0) {
|
||||
r=tid->abort(tid); assert(r==0);
|
||||
r=bookx->commit(bookx, 0); assert(r==0);
|
||||
r=env->txn_begin(env, 0, &bookx, 0); assert(r==0);
|
||||
abort_items(env);
|
||||
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
|
||||
} else if (rand%1000==1) {
|
||||
} else if (randv%1000==1) {
|
||||
r=tid->commit(tid, 0); assert(r==0);
|
||||
r=bookx->commit(bookx, 0); assert(r==0);
|
||||
r=env->txn_begin(env, 0, &bookx, 0); assert(r==0);
|
||||
commit_items(env, i);
|
||||
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
|
||||
} else if (rand%3==0) {
|
||||
} else if (randv%3==0) {
|
||||
delete_a_random_item(db, tid, bookx);
|
||||
} else {
|
||||
put_a_random_item(db, tid, i, bookx);
|
||||
|
|
|
@ -32,7 +32,7 @@ int grep_for_in_logs(const char *str) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int main (int UU(argc), char UU(*argv[])) {
|
||||
int r;
|
||||
DB_ENV *env;
|
||||
DB *db;
|
||||
|
|
|
@ -50,7 +50,7 @@ void test_logmax (int logmax) {
|
|||
r=env->get_lg_max(env, &lmax);
|
||||
assert(r==0);
|
||||
if (logmax>0) {
|
||||
assert(lmax==logmax);
|
||||
assert(lmax==(u_int32_t)logmax);
|
||||
} else {
|
||||
assert(lmax>0);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ static void make_db (int n_locks) {
|
|||
assert(r == EINVAL);
|
||||
#endif
|
||||
r=env->get_lk_max_locks(env, &set_locks);
|
||||
assert(r == 0 && set_locks == n_locks);
|
||||
assert(r == 0 && set_locks == (u_int32_t)n_locks);
|
||||
}
|
||||
r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, 0777); CKERR(r);
|
||||
r=db_create(&db, env, 0); CKERR(r);
|
||||
|
|
|
@ -6,11 +6,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <db.h>
|
||||
#if defined(OSX)
|
||||
#include <sys/syscall.h>
|
||||
#else
|
||||
#include <syscall.h>
|
||||
#endif
|
||||
#include <sys/syscall.h>
|
||||
#include <pthread.h>
|
||||
#include "test.h"
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ DB_ENV *dbenv;
|
|||
* getname -- extracts a secondary key (the last name) from a primary
|
||||
* key/data pair
|
||||
*/
|
||||
int getname(DB *secondary, const DBT *pkey, const DBT *pdata, DBT *skey)
|
||||
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
|
||||
|
|
|
@ -67,7 +67,7 @@ void test_txn_abort(int n) {
|
|||
if (r!=0) break;
|
||||
if (verbose>2) printf("%d present\n", ntohl(*(int*)key.data));
|
||||
assert(key.size==4);
|
||||
assert(ntohl(*(int*)key.data)==2*i);
|
||||
assert(ntohl(*(int*)key.data)==(unsigned int)(2*i));
|
||||
}
|
||||
assert(i==n);
|
||||
r = cursor->c_close(cursor); assert(r == 0);
|
||||
|
|
|
@ -49,7 +49,7 @@ void test_abort_create(void) {
|
|||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int UU(argc), char UU(*argv[])) {
|
||||
test_abort_create();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ void test_abort_close(void) {
|
|||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int UU(argc), char UU(*argv[])) {
|
||||
test_abort_close();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ void test_abort_close(void) {
|
|||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int UU(argc), char UU(*argv[])) {
|
||||
test_abort_close();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "test.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int UU(argc), char UU(*argv[])) {
|
||||
int r;
|
||||
DB_ENV *env;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ void test_abort_close(void) {
|
|||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int UU(argc), char UU(*argv[])) {
|
||||
test_abort_close();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue