From da5e3d5133c357ea78958a79a0ce87f354a9667a Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Wed, 13 May 2015 17:54:30 +0300 Subject: [PATCH] lmdb: fix test#6 and run it by 'make test'. Change-Id: I3a5bb363368f46576a5acaf332f9fd7feb46a3e5 --- Makefile | 3 ++- lmdb.h | 2 ++ mtest6.c | 14 +++++++------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 713c55e3..f730fb94 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ IHDRS = lmdb.h ILIBS = liblmdb.a liblmdb.so IPROGS = mdb_stat mdb_copy mdb_dump mdb_load mdb_chk IDOCS = mdb_stat.1 mdb_copy.1 mdb_dump.1 mdb_load.1 -PROGS = $(IPROGS) mtest mtest2 mtest3 mtest4 mtest5 +PROGS = $(IPROGS) mtest mtest2 mtest3 mtest4 mtest5 mtest6 all: $(ILIBS) $(PROGS) install: $(ILIBS) $(IPROGS) $(IHDRS) @@ -52,6 +52,7 @@ test: all && echo "*** LMDB-TEST-3" && ./mtest3 && ./mdb_chk testdb \ && echo "*** LMDB-TEST-4" && ./mtest4 && ./mdb_chk testdb \ && echo "*** LMDB-TEST-5" && ./mtest5 && ./mdb_chk testdb \ + && echo "*** LMDB-TEST-6" && ./mtest6 && ./mdb_chk testdb \ && echo "*** LMDB-TESTs - all done" liblmdb.a: mdb.o midl.o diff --git a/lmdb.h b/lmdb.h index e994c973..dfc9958a 100644 --- a/lmdb.h +++ b/lmdb.h @@ -1639,6 +1639,8 @@ int mdb_setup_debug(int flags, MDB_debug_func* logger, long edge_txn); typedef int MDB_pgwalk_func(size_t pgno, unsigned pgnumber, void* ctx, const char* dbi, char type); int mdb_env_pgwalk(MDB_txn *txn, MDB_pgwalk_func* visitor, void* ctx); +char* mdb_dkey(MDB_val *key, char *buf); + #ifdef __cplusplus } #endif diff --git a/mtest6.c b/mtest6.c index 174f4f67..2a75abcc 100644 --- a/mtest6.c +++ b/mtest6.c @@ -28,15 +28,13 @@ char dkbuf[1024]; int main(int argc,char * argv[]) { - int i = 0, j = 0, rc; + int i = 0, rc; MDB_env *env; MDB_dbi dbi; MDB_val key, data; MDB_txn *txn; MDB_stat mst; MDB_cursor *cursor; - int count; - int *values; long kval; char *sval; @@ -61,19 +59,19 @@ int main(int argc,char * argv[]) printf("Adding 12 values, should yield 3 splits\n"); for (i=0;i<12;i++) { kval = i*5; - sprintf(sval, "%08x", kval); + sprintf(sval, "%08lx", kval); (void)RES(MDB_KEYEXIST, mdb_cursor_put(cursor, &key, &data, MDB_NOOVERWRITE)); } printf("Adding 12 more values, should yield 3 splits\n"); for (i=0;i<12;i++) { kval = i*5+4; - sprintf(sval, "%08x", kval); + sprintf(sval, "%08lx", kval); (void)RES(MDB_KEYEXIST, mdb_cursor_put(cursor, &key, &data, MDB_NOOVERWRITE)); } printf("Adding 12 more values, should yield 3 splits\n"); for (i=0;i<12;i++) { kval = i*5+1; - sprintf(sval, "%08x", kval); + sprintf(sval, "%08lx", kval); (void)RES(MDB_KEYEXIST, mdb_cursor_put(cursor, &key, &data, MDB_NOOVERWRITE)); } E(mdb_cursor_get(cursor, &key, &data, MDB_FIRST)); @@ -88,7 +86,9 @@ int main(int argc,char * argv[]) mdb_txn_commit(txn); #if 0 - j=0; + int j=0; + int count = 333; + int *values = alloca(sizeof(int) * count); for (i= count - 1; i > -1; i-= (rand()%5)) { j++;