Commit 0acaed51 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

merge 1032 src/tests to 1032b. addresses #1032

git-svn-id: file:///svn/toku/tokudb.1032b@7835 c7de825b-a66e-492c-adef-691d508d4ae1
parent 1002ded5
......@@ -19,18 +19,16 @@ extern "C" {
#endif
#if defined(TOKU_WINDOWS) && TOKU_WINDOWS
#if TOKU_WINDOWS
// Windows
// ntohl and htonl are defined in winsock.h
#include <winsock.h>
#include <direct.h>
#include <sys/types.h>
#include "stdint.h"
#include "inttypes.h"
#include "toku_pthread.h"
#include <direct.h>
#include <sys/types.h>
#include "unistd.h"
#include "misc.h"
#include "toku_pthread.h"
#define UNUSED_WARNING(a) a=a /* To make up for missing attributes */
......@@ -47,7 +45,6 @@ extern "C" {
#include <inttypes.h>
#include <unistd.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/time.h>
#endif
......@@ -59,8 +56,6 @@ extern "C" {
#include <inttypes.h>
#include <unistd.h>
#include <sys/types.h>
// Define ntohl using arpa/inet.h
#include <arpa/inet.h>
#include <sys/time.h>
#else
......@@ -70,6 +65,7 @@ extern "C" {
#endif
#include "os.h"
#include "toku_htonl.h"
#define UU(x) x __attribute__((__unused__))
......
#ifndef _TOKU_HTONL_H
#define _TOKU_HTONL_H
#if !__linux__
#error
#endif
#if __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <arpa/inet.h>
static inline uint32_t toku_htonl(uint32_t i) {
return htonl(i);
}
static inline uint32_t toku_ntohl(uint32_t i) {
return ntohl(i);
}
#if __cplusplus
};
#endif
#endif
......@@ -98,7 +98,7 @@ setup (void) {
}
static void
shutdown (void) {
test_shutdown (void) {
int r;
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
......@@ -108,6 +108,6 @@ int main (int argc, const char *argv[]) {
parse_args(argc, argv);
setup();
test_abort_abort();
shutdown();
test_shutdown();
return 0;
}
......@@ -98,7 +98,7 @@ setup (void) {
}
static void
shutdown (void) {
test_shutdown (void) {
int r;
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
......@@ -108,6 +108,6 @@ int main (int argc, const char *argv[]) {
parse_args(argc, argv);
setup();
test_abort_commit();
shutdown();
test_shutdown();
return 0;
}
......@@ -94,7 +94,7 @@ setup (void) {
}
static void
shutdown (void) {
test_shutdown (void) {
int r;
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
......@@ -104,6 +104,6 @@ int main (int argc, const char *argv[]) {
parse_args(argc, argv);
setup();
test_commit_abort();
shutdown();
test_shutdown();
return 0;
}
......@@ -94,7 +94,7 @@ setup (void) {
}
static void
shutdown (void) {
test_shutdown (void) {
int r;
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
......@@ -104,6 +104,6 @@ int main (int argc, const char *argv[]) {
parse_args(argc, argv);
setup();
test_commit_commit();
shutdown();
test_shutdown();
return 0;
}
......@@ -31,7 +31,7 @@ setup (void) {
}
static void
shutdown (void) {
test_shutdown (void) {
int r;
r= db->close(db, 0); CKERR(r);
r= env->close(env, 0); CKERR(r);
......@@ -99,10 +99,10 @@ int main (int argc, const char *argv[]) {
setup();
doit(TRUE);
shutdown();
test_shutdown();
setup();
doit(FALSE);
shutdown();
test_shutdown();
return 0;
}
......
......@@ -7,7 +7,7 @@ static DB *db;
DB_TXN *txn;
static void
setup (void) {
test_setup (void) {
system("rm -rf " ENVDIR);
int r;
r=mkdir(ENVDIR, 0777); CKERR(r);
......@@ -23,7 +23,7 @@ setup (void) {
}
static void
shutdown (void) {
test_shutdown (void) {
int r;
r= db->close(db, 0); CKERR(r);
r= env->close(env, 0); CKERR(r);
......@@ -61,9 +61,9 @@ doit (void) {
int main (int argc, const char *argv[]) {
parse_args(argc, argv);
setup();
test_setup();
doit();
shutdown();
test_shutdown();
return 0;
}
......@@ -2,7 +2,6 @@
#include <db.h>
#include <sys/stat.h>
#include <sys/time.h>
#include "test.h"
#define NFILES 1000
......@@ -13,7 +12,7 @@ static DB *dbs[NFILES];
DB_TXN *txn;
static void
setup (void) {
test_setup (void) {
system("rm -rf " ENVDIR);
int r;
r=mkdir(ENVDIR, 0777); CKERR(r);
......@@ -37,7 +36,7 @@ setup (void) {
}
static void
shutdown (void) {
test_shutdown (void) {
int i;
int r;
for (i=0; i<NFILES; i++) {
......@@ -75,9 +74,9 @@ doit (void) {
int main (int argc, const char *argv[]) {
parse_args(argc, argv);
setup();
test_setup();
doit();
shutdown();
test_shutdown();
return 0;
}
......@@ -81,7 +81,7 @@ test_commit_commit (void) {
}
static void
setup (void) {
test_setup (void) {
DB_TXN *txn;
int r;
system("rm -rf " ENVDIR);
......@@ -103,7 +103,7 @@ setup (void) {
}
static void
shutdown (void) {
test_shutdown (void) {
int r;
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
......@@ -111,8 +111,8 @@ shutdown (void) {
int main (int argc, const char *argv[]) {
parse_args(argc, argv);
setup();
test_setup();
test_commit_commit();
shutdown();
test_shutdown();
return 0;
}
#include "portability.h"
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <db.h>
#include <assert.h>
#include <limits.h>
#ifndef DB_YESOVERWRITE
#define DB_YESOVERWRITE 0
......@@ -16,9 +18,9 @@ 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); })
#define CKERR(r) do { if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0); } while (0)
#define CKERR2(r,r2) do { if (r!=r2) fprintf(stderr, "%s:%d error %d %s, expected %d\n", __FILE__, __LINE__, r, db_strerror(r), r2); assert(r==r2); } while (0)
#define CKERR2s(r,r2,r3) do { 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); } while (0)
// If the error code depends on BDB vs TDB use this
#ifdef USE_TDB
......@@ -48,6 +50,7 @@ parse_args (int argc, const char *argv[]) {
argc--;
argv++;
}
os_initialize_settings(1);
}
static __attribute__((__unused__)) DBT *
......@@ -87,7 +90,9 @@ int_dbt_cmp (DB *db, const DBT *a, const DBT *b) {
return x - y;
}
#if !TOKU_WINDOWS
typedef enum __toku_bool { FALSE=0, TRUE=1} BOOL;
#endif
#ifdef USE_TDB
#define SET_TRACE_FILE(x) toku_set_trace_file(x)
......
......@@ -2,15 +2,6 @@
#include <db.h>
#include <sys/stat.h>
#include "test.h"
#include <arpa/inet.h>
unsigned char N=5;
static int
fact (int n) {
if (n<=2) return n;
else return n*fact(n-1);
}
DB_ENV *env;
DB *db;
......@@ -44,7 +35,7 @@ run (void) {
for (i=0; i<N; i++) {
r=c->c_get(c, dbt_init_malloc(&k), dbt_init_malloc(&v), DB_NEXT); CKERR(r);
assert(k.size==1); assert(v.size==4);
assert(*(char*)k.data==vN); assert(ntohl(*(int*)v.data)==i);
assert(*(char*)k.data==vN); assert((int)ntohl(*(int*)v.data)==i);
}
r=c->c_get(c, dbt_init(&k, 0, 0), dbt_init(&v, 0, 0), DB_NEXT); CKERR(r);
......@@ -76,7 +67,6 @@ int main(int argc, const char *argv[]) {
r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, 0777); CKERR(r);
r=txn->commit(txn, 0); CKERR(r);
}
//printf("fact(%d)=%d\n", N, fact(N));
run();
{
r=db->close(db, 0); CKERR(r);
......
......@@ -2,16 +2,9 @@
#include <db.h>
#include <sys/stat.h>
#include "test.h"
#include <arpa/inet.h>
unsigned char N=5;
static int
fact (int n) {
if (n<=2) return n;
else return n*fact(n-1);
}
DB_ENV *env;
DB *db;
......@@ -75,7 +68,6 @@ int main(int argc, const char *argv[]) {
r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, 0777); CKERR(r);
r=txn->commit(txn, 0); CKERR(r);
}
//printf("fact(%d)=%d\n", N, fact(N));
run();
{
r=db->close(db, 0); CKERR(r);
......
......@@ -5,7 +5,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -5,8 +5,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -26,11 +26,24 @@ test_db_open_aborts (void) {
r=db_env_create(&env, 0); assert(r==0);
r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_PRIVATE|DB_CREATE, 0777); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
#if 0
{
DB_TXN *tid;
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
r=db->open(db, tid, "foo.db", 0, DB_BTREE, DB_CREATE, 0777); CKERR(r);
r=tid->abort(tid); assert(r==0);
}
{
struct stat buf;
r=stat(ENVDIR "/foo.db", &buf);
assert(r!=0);
assert(errno==ENOENT);
}
#endif
{
DB_TXN *tid;
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
r=db->open(db, tid, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU|S_IRWXG|S_IRWXO); CKERR(r);
{
DBT key,data;
memset(&key, 0, sizeof(key));
......
......@@ -8,7 +8,6 @@
#include <db.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include "test.h"
static DB_ENV *env;
......@@ -119,9 +118,8 @@ do_abort_delete_first_or_last(int N,
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
#ifdef TOKUDB
#if defined(TOKUDB) && defined(__unix__)
r=system("../../newbrt/brtdump " ENVDIR "/foo.db > /dev/null");
assert(WIFEXITED(r) && WEXITSTATUS(r)==0);
#endif
}
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <inttypes.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <db.h>
......
......@@ -8,7 +8,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -10,7 +10,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -8,7 +8,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -8,7 +8,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -8,7 +8,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......@@ -24,7 +23,7 @@ cursor_expect (DBC *cursor, int k, int v, int op) {
assert(val.size == sizeof v);
int vv;
memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv));
assert(kk == k);
assert(vv == v);
......@@ -92,7 +91,9 @@ test_cursor_delete (int dup_mode) {
/* insert duplicate duplicates into a sorted duplicate tree */
static void
test_cursor_delete_dupsort (void) {
if (verbose) printf("test_cursor_delete_dupsort\n");
if (verbose) {
printf("test_cursor_delete_dupsort\n"); fflush(stdout);
}
int pagesize = 4096;
int elementsize = 32;
......@@ -150,11 +151,12 @@ test_cursor_delete_dupsort (void) {
}
int main(int argc, const char *argv[]) {
int r;
parse_args(argc, argv);
system("rm -rf " ENVDIR);
mkdir(ENVDIR, 0777);
r = system("rm -rf " ENVDIR); assert(r == 0);
r = os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
test_cursor_delete(0);
#ifdef USE_BDB
......
......@@ -8,7 +8,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -8,7 +8,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -8,7 +8,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -6,7 +6,6 @@
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <db.h>
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......@@ -77,12 +76,14 @@ test_cursor_sticky (int n, int dup_mode) {
int main(int argc, const char *argv[]) {
int r;
int i;
// setvbuf(stdout, NULL, _IONBF, 0);
parse_args(argc, argv);
system("rm -rf " ENVDIR);
mkdir(ENVDIR, 0777);
r = system("rm -rf " ENVDIR); assert(r == 0);
r = os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
for (i=1; i<65537; i *= 2) {
test_cursor_sticky(i, 0);
......
/* Primary with two associated things. */
#include <arpa/inet.h>
#include <assert.h>
#include <db.h>
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include "test.h"
......@@ -95,13 +93,13 @@ read_uchar_from_dbt (const DBT *dbt, unsigned int *off, unsigned char *uchar) {
}
static void
read_uint_from_dbt (const DBT *dbt, unsigned int *off, unsigned int *uint) {
read_uint_from_dbt (const DBT *dbt, unsigned int *off, unsigned int *uintptr) {
unsigned char a,b,c,d;
read_uchar_from_dbt(dbt, off, &a);
read_uchar_from_dbt(dbt, off, &b);
read_uchar_from_dbt(dbt, off, &c);
read_uchar_from_dbt(dbt, off, &d);
*uint = (a<<24)+(b<<16)+(c<<8)+d;
*uintptr = (a<<24)+(b<<16)+(c<<8)+d;
}
static void
......
/* Primary with two associated things. */
#include <arpa/inet.h>
#include <assert.h>
#include <db.h>
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include <ctype.h>
......@@ -122,13 +120,13 @@ read_uchar_from_dbt (const DBT *dbt, unsigned int *off, unsigned char *uchar) {
}
static void
read_uint_from_dbt (const DBT *dbt, unsigned int *off, unsigned int *uint) {
read_uint_from_dbt (const DBT *dbt, unsigned int *off, unsigned int *uintptr) {
unsigned char a,b,c,d;
read_uchar_from_dbt(dbt, off, &a);
read_uchar_from_dbt(dbt, off, &b);
read_uchar_from_dbt(dbt, off, &c);
read_uchar_from_dbt(dbt, off, &d);
*uint = (a<<24)+(b<<16)+(c<<8)+d;
*uintptr = (a<<24)+(b<<16)+(c<<8)+d;
}
static void
......
/* Primary with two associated things. */
#include <arpa/inet.h>
#include <assert.h>
#include <db.h>
#include <errno.h>
......@@ -81,13 +80,13 @@ static void read_uchar_from_dbt (const DBT *dbt, unsigned int *off, unsigned cha
*uchar = ((unsigned char *)dbt->data)[(*off)++];
}
static void read_uint_from_dbt (const DBT *dbt, unsigned int *off, unsigned int *uint) {
static void read_uint_from_dbt (const DBT *dbt, unsigned int *off, unsigned int *uintptr) {
unsigned char a,b,c,d;
read_uchar_from_dbt(dbt, off, &a);
read_uchar_from_dbt(dbt, off, &b);
read_uchar_from_dbt(dbt, off, &c);
read_uchar_from_dbt(dbt, off, &d);
*uint = (a<<24)+(b<<16)+(c<<8)+d;
*uintptr = (a<<24)+(b<<16)+(c<<8)+d;
}
static void read_timestamp_from_dbt (const DBT *dbt, unsigned int *off, timestamp *ts) {
......
......@@ -86,7 +86,7 @@ int main(int argc, const char *argv[]) {
int was_truncated = 0;
int ulen_changed;
int size_full;
int clone = 0;
int doclone = 0;
DATA fake;
int small_buffer = 0;
......@@ -121,7 +121,7 @@ int main(int argc, const char *argv[]) {
min = min < sizeof(DATA) ? min : sizeof(DATA);
//assert(min == sizeof(DATA));
r = memcmp((DATA*)data.data, &fake, min);
clone = r == 0;
doclone = r == 0;
if (flags[j] != 0) {
free(data.data);
......@@ -138,9 +138,9 @@ int main(int argc, const char *argv[]) {
ulen_should_change = (BOOL)(old_ulen < sizeof(DATA));
}
#endif
assert(ulen_should_change == ulen_changed);
assert(ulen_should_change == (BOOL)ulen_changed);
assert(size_full);
assert(clone == !small_buffer);
assert(doclone == !small_buffer);
}
}
oldmem = 0;
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <db.h>
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <db.h>
......
......@@ -2,7 +2,9 @@
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
// make stdlib define unsetenv()
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
/* Do we open directories with same priority as BDB? i.e. with home, without home, with DB_USE_ENVIRON/etc.. */
#include <limits.h>
......
......@@ -30,6 +30,7 @@ int main(int argc, char** argv) {
r = dbenv->open(dbenv, ENVDIR, DB_CREATE|DB_INIT_MPOOL|DB_PRIVATE, 0666);
#ifdef USE_TDB
if (verbose) printf("r=%d\n", r);
assert(r != 0);
#else
if (verbose) printf("test_db_env_open_open_close.bdb skipped. (BDB apparently does not follow the spec).\n");
......
......@@ -8,7 +8,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -674,7 +674,7 @@ static __attribute__((__unused__))
void
ignore (void *ignore __attribute__((__unused__))) {
}
#define IGNORE(x) ignore((void*)x)
#define TOKU_IGNORE(x) ignore((void*)x)
static void
cget_heavi (BOOL success, BOOL find, char txn, int _key, int _val,
......@@ -682,16 +682,16 @@ cget_heavi (BOOL success, BOOL find, char txn, int _key, int _val,
int r_h_expect,
int (*h)(const DBT*,const DBT*,void*)) {
#if defined(USE_BDB)
IGNORE(success);
IGNORE(find);
IGNORE((size_t)txn);
IGNORE((size_t)_key);
IGNORE((size_t)_val);
IGNORE((size_t)_key_expect);
IGNORE((size_t)_val_expect);
IGNORE((size_t)direction);
IGNORE(h);
IGNORE((size_t)r_h_expect);
TOKU_IGNORE(success);
TOKU_IGNORE(find);
TOKU_IGNORE((size_t)txn);
TOKU_IGNORE((size_t)_key);
TOKU_IGNORE((size_t)_val);
TOKU_IGNORE((size_t)_key_expect);
TOKU_IGNORE((size_t)_val_expect);
TOKU_IGNORE((size_t)direction);
TOKU_IGNORE(h);
TOKU_IGNORE((size_t)r_h_expect);
return;
#else
assert(txns[(int)txn] && cursors[(int)txn]);
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......@@ -31,7 +30,7 @@ expect (DBC *cursor, int k, int v) {
assert(val.size == sizeof v);
int vv;
memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv));
assert(kk == k);
assert(vv == v);
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include <errno.h>
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......@@ -31,7 +30,7 @@ expect (DBC *cursor, int k, int v) {
assert(val.size == sizeof v);
int vv;
memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv));
assert(kk == k);
assert(vv == v);
......
......@@ -10,7 +10,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......@@ -53,7 +52,7 @@ expect_cursor_get (DBC *cursor, int expectk, int expectv, int op) {
assert(val.size == sizeof expectv);
int vv;
memcpy(&vv, val.data, val.size);
if (kk != expectk || vv != expectv) printf("expect key %u got %u - %u %u\n", htonl(expectk), htonl(kk), htonl(expectv), htonl(vv));
if (kk != expectk || vv != expectv) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(expectk), (uint32_t)htonl(kk), (uint32_t)htonl(expectv), (uint32_t)htonl(vv));
assert(kk == expectk);
assert(vv == expectv);
}
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......@@ -54,7 +53,7 @@ expect_cursor_get (DBC *cursor, int k, int v) {
assert(val.size == sizeof v);
int vv;
memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv));
assert(kk == k);
assert(vv == v);
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......@@ -52,7 +51,7 @@ expect_cursor_get (DBC *cursor, int k, int v) {
assert(val.size == sizeof v);
int vv;
memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv));
assert(kk == k);
assert(vv == v);
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......@@ -52,7 +51,7 @@ expect_cursor_get (DBC *cursor, int k, int v) {
assert(val.size == sizeof v);
int vv;
memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", ntohl(k), ntohl(kk), ntohl(v), ntohl(vv));
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)ntohl(k), (uint32_t)ntohl(kk), (uint32_t)ntohl(v), (uint32_t)ntohl(vv));
assert(kk == k);
assert(vv == v);
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......@@ -52,7 +51,7 @@ expect_cursor_get (DBC *cursor, int k, int v) {
assert(val.size == sizeof v);
int vv;
memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv));
assert(kk == k);
assert(vv == v);
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......@@ -59,7 +58,7 @@ expect_cursor_get (DBC *cursor, int k, int v) {
assert(val.size == sizeof v);
int vv;
memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv));
assert(kk == k);
assert(vv == v);
......
......@@ -8,7 +8,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
#include <stdio.h>
#include <assert.h>
#include <pthread.h>
#include <toku_pthread.h>
static void *
f (void *arg) {
//pthread_exit(arg); // pthread_exit has a memoryh leak.
//toku_pthread_exit(arg); // toku_pthread_exit has a memory leak on linux
return arg;
}
int main() {
pthread_t t;
int r = pthread_create(&t, 0, f, 0); assert(r == 0);
toku_pthread_t t;
int r = toku_pthread_create(&t, 0, f, 0); assert(r == 0);
void *ret;
r = pthread_join(t, &ret); assert(r == 0);
r = toku_pthread_join(t, &ret); assert(r == 0);
return 0;
}
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -4,9 +4,8 @@
/* Test by counting the fsyncs, to see if group commit is working. */
#include <db.h>
#include <pthread.h>
#include <toku_pthread.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include "test.h"
......@@ -46,14 +45,14 @@ test_groupcommit (int nthreads) {
r=tid->commit(tid, 0); assert(r==0);
int i;
pthread_t threads[nthreads];
toku_pthread_t threads[nthreads];
int whichthread[nthreads];
for (i=0; i<nthreads; i++) {
whichthread[i]=i;
r=pthread_create(&threads[i], 0, start_a_thread, &whichthread[i]);
r=toku_pthread_create(&threads[i], 0, start_a_thread, &whichthread[i]);
}
for (i=0; i<nthreads; i++) {
pthread_join(threads[i], 0);
toku_pthread_join(threads[i], 0);
}
r=db->close(db, 0); assert(r==0);
......
......@@ -4,9 +4,8 @@
/* Test using performance metrics only, to see if group commit is working. */
#include <db.h>
#include <pthread.h>
#include <toku_pthread.h>
#include <sys/stat.h>
#include <sys/time.h>
#include "test.h"
DB_ENV *env;
......@@ -46,14 +45,14 @@ test_groupcommit (int nthreads) {
r=tid->commit(tid, 0); assert(r==0);
int i;
pthread_t threads[nthreads];
toku_pthread_t threads[nthreads];
int whichthread[nthreads];
for (i=0; i<nthreads; i++) {
whichthread[i]=i;
r=pthread_create(&threads[i], 0, start_a_thread, &whichthread[i]);
r=toku_pthread_create(&threads[i], 0, start_a_thread, &whichthread[i]);
}
for (i=0; i<nthreads; i++) {
pthread_join(threads[i], 0);
toku_pthread_join(threads[i], 0);
}
#if 0
r=env->txn_begin(env, 0, &tid, 0); CKERR(r);
......
......@@ -6,7 +6,6 @@
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <db.h>
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -6,7 +6,6 @@
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <db.h>
......
......@@ -6,7 +6,6 @@
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <db.h>
......@@ -138,7 +137,7 @@ int main(int argc, const char *argv[]) {
if (i+1 >= argc)
return 1;
lorange = strtoull(argv[++i], 0, 10);
if (lorange > UINT_MAX)
if (lorange > ULLONG_MAX)
return 2;
continue;
}
......@@ -146,7 +145,7 @@ int main(int argc, const char *argv[]) {
if (i+1 >= argc)
return 1;
hirange = strtoull(argv[++i], 0, 10);
if (hirange > UINT_MAX)
if (hirange > ULLONG_MAX)
return 2;
continue;
}
......
......@@ -4,7 +4,6 @@
#include <db.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include "test.h"
......
......@@ -3,7 +3,6 @@
#include <assert.h>
#include <sys/stat.h>
#include <time.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......@@ -65,7 +64,7 @@ int main(int argc, char *argv[]) {
int n = d + d/4;
float ps[] = { 0.0, 0.0001, 0.001, 0.01, 0.1, 0.25, 0.5, 1 };
for (i=0; i<sizeof ps / sizeof (float); i++) {
for (i=0; i<(int)(sizeof ps / sizeof (float)); i++) {
seqinsert(n, ps[i]);
}
return 0;
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......@@ -54,7 +53,7 @@ expect_cursor_get (DBC *cursor, int k, int v) {
assert(val.size == sizeof v);
int vv;
memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv));
assert(kk == k);
assert(vv == v);
......
......@@ -6,7 +6,6 @@
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <db.h>
......
......@@ -4,7 +4,6 @@
/* try a reverse compare function to verify that the database always uses the application's
compare function */
#include <arpa/inet.h>
#include <assert.h>
#include <db.h>
#include <stdio.h>
......@@ -45,7 +44,7 @@ expect (DBC *cursor, int k, int v) {
assert(val.size == sizeof v);
int vv;
memcpy(&vv, val.data, val.size);
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv));
assert(kk == k);
assert(vv == v);
......
......@@ -4,7 +4,6 @@
#include <assert.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -4,24 +4,18 @@
#include <assert.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include <sys/syscall.h>
#include <pthread.h>
#include <toku_pthread.h>
#include "test.h"
static inline unsigned int getmyid() {
#if __linux__
return syscall(__NR_gettid);
#else
return getpid();
#endif
return os_gettid();
}
typedef unsigned int my_t;
struct db_inserter {
pthread_t tid;
toku_pthread_t tid;
DB *db;
my_t startno, endno;
int do_exit;
......@@ -37,15 +31,15 @@ db_put (DB *db, my_t k, my_t v) {
static void *
do_inserts (void *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)toku_pthread_self(), getmyid(), mywork->startno, mywork->endno);
my_t i;
for (i=mywork->startno; i < mywork->endno; i++) {
int r = db_put(mywork->db, htonl(i), i); assert(r == 0);
}
if (verbose) printf("%lu:%u:do_inserts:end\n", (unsigned long)pthread_self(), getmyid());
// Don't call pthread_exit(), since it has a memory leak.
// if (mywork->do_exit) pthread_exit(arg);
if (verbose) printf("%lu:%u:do_inserts:end\n", (unsigned long)toku_pthread_self(), getmyid());
// Don't call toku_pthread_exit(), since it has a memory leak.
// if (mywork->do_exit) toku_pthread_exit(arg);
return 0;
}
......@@ -111,10 +105,10 @@ int main(int argc, char *argv[]) {
work[i].endno = n;
}
if (verbose) printf("pid:%d\n", getpid());
if (verbose) printf("pid:%d\n", os_getpid());
for (i=1; i<nthreads; i++) {
r = pthread_create(&work[i].tid, 0, do_inserts, &work[i]); assert(r == 0);
r = toku_pthread_create(&work[i].tid, 0, do_inserts, &work[i]); assert(r == 0);
}
work[0].do_exit = 0;
......@@ -122,7 +116,7 @@ int main(int argc, char *argv[]) {
for (i=1; i<nthreads; i++) {
void *ret;
r = pthread_join(work[i].tid, &ret); assert(r == 0);
r = toku_pthread_join(work[i].tid, &ret); assert(r == 0);
}
r = db->close(db, 0); assert(r == 0);
......
......@@ -4,28 +4,14 @@
#include <assert.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#if defined(OSX)
#include <sys/syscall.h>
#else
#include <syscall.h>
#endif
#include <pthread.h>
#include <toku_pthread.h>
#include "test.h"
static inline unsigned int getmyid() {
#if __linux__
return syscall(__NR_gettid);
#else
return getpid();
#endif
}
typedef unsigned int my_t;
struct db_inserter {
pthread_t tid;
toku_pthread_t tid;
DB *db;
my_t startno, endno;
int do_exit;
......@@ -41,14 +27,14 @@ db_put (DB *db, my_t k, my_t v) {
static void *
do_inserts (void *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:%d:do_inserts:start:%u-%u\n", (unsigned long)toku_pthread_self(), os_gettid(), mywork->startno, mywork->endno);
my_t i;
for (i=mywork->startno; i < mywork->endno; i++) {
int r = db_put(mywork->db, htonl(i), i); assert(r == 0);
}
if (verbose) printf("%lu:%u:do_inserts:end\n", (unsigned long)pthread_self(), getmyid());
if (mywork->do_exit) pthread_exit(arg);
if (verbose) printf("%lu:%d:do_inserts:end\n", (unsigned long)toku_pthread_self(), os_gettid());
if (mywork->do_exit) return arg;
return 0;
}
......@@ -135,15 +121,15 @@ int main(int argc, char *argv[]) {
work[i].endno = n;
}
if (verbose) printf("pid:%d\n", getpid());
if (verbose) printf("pid:%d tid:%d\n", os_getpid(), os_gettid());
for (i=all_on_threads ? 0 : 1; i<nthreads; i++) {
pthread_attr_t attr;
r = pthread_attr_init(&attr); assert(r == 0);
toku_pthread_attr_t attr;
r = toku_pthread_attr_init(&attr); assert(r == 0);
if (thread_stack) {
r = pthread_attr_setstacksize(&attr, thread_stack); assert(r == 0);
r = toku_pthread_attr_setstacksize(&attr, thread_stack); assert(r == 0);
}
r = pthread_create(&work[i].tid, &attr, do_inserts, &work[i]); assert(r == 0);
r = toku_pthread_create(&work[i].tid, &attr, do_inserts, &work[i]); assert(r == 0);
}
if (!all_on_threads) {
......@@ -153,7 +139,7 @@ int main(int argc, char *argv[]) {
for (i=all_on_threads ? 0 : 1; i<nthreads; i++) {
void *ret;
r = pthread_join(work[i].tid, &ret); assert(r == 0);
r = toku_pthread_join(work[i].tid, &ret); assert(r == 0);
}
r = db->close(db, 0); assert(r == 0);
......
......@@ -6,7 +6,6 @@
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -6,7 +6,6 @@
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -6,7 +6,6 @@
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -6,7 +6,6 @@
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -5,7 +5,6 @@
#include <string.h>
#include <sys/stat.h>
#include <db.h>
#include <arpa/inet.h>
#include "test.h"
......@@ -66,7 +65,7 @@ test_txn_abort (int n) {
for (i=0; 1; i++) {
r = cursor->c_get(cursor, &key, &val, DB_NEXT);
if (r!=0) break;
if (verbose>2) printf("%u present\n", ntohl(*(int*)key.data));
if (verbose>2) printf("%u present\n", (uint32_t)ntohl(*(int*)key.data));
assert(key.size==4);
assert(ntohl(*(int*)key.data)==(unsigned int)(2*i));
}
......
......@@ -8,7 +8,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -8,7 +8,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -43,6 +43,7 @@ close_db (void) {
static void
test_txn_abort (int insert, int secondnum) {
if (verbose) { fprintf(stderr, "%s (%s):%d [%d,%d]\n", __FILE__, __FUNCTION__, __LINE__, insert, secondnum); fflush(stderr); }
setup_db();
DBT key, val;
......@@ -99,6 +100,8 @@ test_txn_abort (int insert, int secondnum) {
r = cursor->c_close(cursor); CKERR(r);
r = txn->commit(txn, 0);
}
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
}
......
......@@ -8,7 +8,6 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
......@@ -6,7 +6,6 @@
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <db.h>
......
......@@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include "test.h"
......
#ifndef _TOKU_HTONL_H
#define _TOKU_HTONL_H
#if !defined(_WIN32)
#error
#endif
#if __cplusplus
extern "C" {
#endif
#if defined(__INTEL_COMPILER)
// assume endian == LITTLE_ENDIAN
static inline uint32_t toku_htonl(uint32_t i) {
return _bswap(i);
}
static inline uint32_t toku_ntohl(uint32_t i) {
return _bswap(i);
}
#endif
#if defined(_MSVC_VER)
#include <winsock.h>
static inline uint32_t toku_htonl(uint32_t i) {
return htonl(i);
}
static inline uint32_t toku_ntohl(uint32_t i) {
return ntonl(i);
}
#endif
#if __cplusplus
};
#endif
#endif
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