diff options
author | David Hows <howsdav@gmail.com> | 2015-05-01 12:24:27 +1000 |
---|---|---|
committer | David Hows <howsdav@gmail.com> | 2015-05-01 17:29:04 +1000 |
commit | 9925a414cd4af10c7533aa53e288c0b418c5e50e (patch) | |
tree | 68502f391d228cac75f149c1cb2aabb806de9971 | |
parent | 809859d07c16dc6cde215c7d23628af903f4b942 (diff) | |
download | mongo-9925a414cd4af10c7533aa53e288c0b418c5e50e.tar.gz |
Code review Changes
-rw-r--r-- | SConstruct | 24 | ||||
-rw-r--r-- | test/fops/file.c | 77 | ||||
-rw-r--r-- | test/fops/fops.c | 5 | ||||
-rw-r--r-- | test/fops/t.c | 14 | ||||
-rw-r--r-- | test/fops/thread.h | 5 | ||||
-rw-r--r-- | test/utility/test_util.i | 35 | ||||
-rw-r--r-- | test/windows/windows_shim.h | 6 |
7 files changed, 75 insertions, 91 deletions
diff --git a/SConstruct b/SConstruct index f1f6a48f6cf..ffb59b5e523 100644 --- a/SConstruct +++ b/SConstruct @@ -389,12 +389,12 @@ env.Append(BUILDERS={'SmokeTest' : Builder(action = builder_smoke_test)}) #Build the tests and setup the "scons test" target -#Don't build bloom on Windows, its broken -#t = env.Program("t_bloom", -# "test/bloom/test_bloom.c", -# LIBS=[wtlib] + wtlibs) -#env.Alias("test", env.SmokeTest(t)) -#Default(t) +#Don't test bloom on Windows, its broken +t = env.Program("t_bloom", + "test/bloom/test_bloom.c", + LIBS=[wtlib] + wtlibs) +#env.Alias("check", env.SmokeTest(t)) +Default(t) #env.Program("t_checkpoint", #["test/checkpoint/checkpointer.c", @@ -402,11 +402,11 @@ env.Append(BUILDERS={'SmokeTest' : Builder(action = builder_smoke_test)}) #"test/checkpoint/workers.c"], #LIBS=[wtlib]) -#t = env.Program("t_huge", -# "test/huge/huge.c", -# LIBS=[wtlib] + wtlibs) -#env.Alias("test", env.SmokeTest(t)) -#Default(t) +t = env.Program("t_huge", + "test/huge/huge.c", + LIBS=[wtlib] + wtlibs) +#env.Alias("check", env.SmokeTest(t)) +Default(t) t = env.Program("t_fops", ["test/fops/file.c", @@ -414,7 +414,7 @@ t = env.Program("t_fops", "test/fops/t.c"], LIBS=[wtlib, shim] + wtlibs) env.Append(CPPPATH=["test/utility"]) -env.Alias("test", env.SmokeTest(t)) +env.Alias("check", env.SmokeTest(t)) Default(t) if useBdb: diff --git a/test/fops/file.c b/test/fops/file.c index f98b4547e6a..7453b81860d 100644 --- a/test/fops/file.c +++ b/test/fops/file.c @@ -27,7 +27,6 @@ */ #include "thread.h" -#include "test_util.i" static u_int uid = 1; @@ -39,23 +38,23 @@ obj_bulk(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die(ret, "conn.session"); + testutil_die(ret, "conn.session"); if ((ret = session->create(session, uri, config)) != 0) if (ret != EEXIST && ret != EBUSY) - die(ret, "session.create"); + testutil_die(ret, "session.create"); if (ret == 0) { sched_yield(); if ((ret = session->open_cursor( session, uri, NULL, "bulk", &c)) == 0) { if ((ret = c->close(c)) != 0) - die(ret, "cursor.close"); + testutil_die(ret, "cursor.close"); } else if (ret != ENOENT && ret != EBUSY && ret != EINVAL) - die(ret, "session.open_cursor"); + testutil_die(ret, "session.open_cursor"); } if ((ret = session->close(session, NULL)) != 0) - die(ret, "session.close"); + testutil_die(ret, "session.close"); } void @@ -67,32 +66,32 @@ obj_bulk_unique(void) char new_uri[64]; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die(ret, "conn.session"); + testutil_die(ret, "conn.session"); /* Generate a unique object name. */ if ((ret = pthread_rwlock_wrlock(&single)) != 0) - die(ret, "pthread_rwlock_wrlock single"); + testutil_die(ret, "pthread_rwlock_wrlock single"); (void)snprintf(new_uri, sizeof(new_uri), "%s.%u", uri, ++uid); if ((ret = pthread_rwlock_unlock(&single)) != 0) - die(ret, "pthread_rwlock_unlock single"); + testutil_die(ret, "pthread_rwlock_unlock single"); if ((ret = session->create(session, new_uri, config)) != 0) - die(ret, "session.create: %s", new_uri); + testutil_die(ret, "session.create: %s", new_uri); sched_yield(); if ((ret = session->open_cursor(session, new_uri, NULL, "bulk", &c)) != 0) - die(ret, "session.open_cursor: %s", new_uri); + testutil_die(ret, "session.open_cursor: %s", new_uri); if ((ret = c->close(c)) != 0) - die(ret, "cursor.close"); + testutil_die(ret, "cursor.close"); while ((ret = session->drop(session, new_uri, NULL)) != 0) if (ret != EBUSY) - die(ret, "session.drop: %s", new_uri); + testutil_die(ret, "session.drop: %s", new_uri); if ((ret = session->close(session, NULL)) != 0) - die(ret, "session.close"); + testutil_die(ret, "session.close"); } void @@ -103,18 +102,18 @@ obj_cursor(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die(ret, "conn.session"); + testutil_die(ret, "conn.session"); if ((ret = session->open_cursor(session, uri, NULL, NULL, &cursor)) != 0) { if (ret != ENOENT && ret != EBUSY) - die(ret, "session.open_cursor"); + testutil_die(ret, "session.open_cursor"); } else { if ((ret = cursor->close(cursor)) != 0) - die(ret, "cursor.close"); + testutil_die(ret, "cursor.close"); } if ((ret = session->close(session, NULL)) != 0) - die(ret, "session.close"); + testutil_die(ret, "session.close"); } void @@ -124,14 +123,14 @@ obj_create(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die(ret, "conn.session"); + testutil_die(ret, "conn.session"); if ((ret = session->create(session, uri, config)) != 0) if (ret != EEXIST && ret != EBUSY) - die(ret, "session.create"); + testutil_die(ret, "session.create"); if ((ret = session->close(session, NULL)) != 0) - die(ret, "session.close"); + testutil_die(ret, "session.close"); } void @@ -142,25 +141,25 @@ obj_create_unique(void) char new_uri[64]; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die(ret, "conn.session"); + testutil_die(ret, "conn.session"); /* Generate a unique object name. */ if ((ret = pthread_rwlock_wrlock(&single)) != 0) - die(ret, "pthread_rwlock_wrlock single"); + testutil_die(ret, "pthread_rwlock_wrlock single"); (void)snprintf(new_uri, sizeof(new_uri), "%s.%d", uri, ++uid); if ((ret = pthread_rwlock_unlock(&single)) != 0) - die(ret, "pthread_rwlock_unlock single"); + testutil_die(ret, "pthread_rwlock_unlock single"); if ((ret = session->create(session, new_uri, config)) != 0) - die(ret, "session.create"); + testutil_die(ret, "session.create"); sched_yield(); while ((ret = session->drop(session, new_uri, NULL)) != 0) if (ret != EBUSY) - die(ret, "session.drop: %s", new_uri); + testutil_die(ret, "session.drop: %s", new_uri); if ((ret = session->close(session, NULL)) != 0) - die(ret, "session.close"); + testutil_die(ret, "session.close"); } void @@ -170,14 +169,14 @@ obj_drop(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die(ret, "conn.session"); + testutil_die(ret, "conn.session"); if ((ret = session->drop(session, uri, NULL)) != 0) if (ret != ENOENT && ret != EBUSY) - die(ret, "session.drop"); + testutil_die(ret, "session.drop"); if ((ret = session->close(session, NULL)) != 0) - die(ret, "session.close"); + testutil_die(ret, "session.close"); } void @@ -187,15 +186,15 @@ obj_checkpoint(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die(ret, "conn.session"); + testutil_die(ret, "conn.session"); /* Force the checkpoint so it has to be taken. */ if ((ret = session->checkpoint(session, "force")) != 0) if (ret != ENOENT) - die(ret, "session.checkpoint"); + testutil_die(ret, "session.checkpoint"); if ((ret = session->close(session, NULL)) != 0) - die(ret, "session.close"); + testutil_die(ret, "session.close"); } void @@ -205,14 +204,14 @@ obj_upgrade(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die(ret, "conn.session"); + testutil_die(ret, "conn.session"); if ((ret = session->upgrade(session, uri, NULL)) != 0) if (ret != ENOENT && ret != EBUSY) - die(ret, "session.upgrade"); + testutil_die(ret, "session.upgrade"); if ((ret = session->close(session, NULL)) != 0) - die(ret, "session.close"); + testutil_die(ret, "session.close"); } void @@ -222,12 +221,12 @@ obj_verify(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die(ret, "conn.session"); + testutil_die(ret, "conn.session"); if ((ret = session->verify(session, uri, NULL)) != 0) if (ret != ENOENT && ret != EBUSY) - die(ret, "session.verify"); + testutil_die(ret, "session.verify"); if ((ret = session->close(session, NULL)) != 0) - die(ret, "session.close"); + testutil_die(ret, "session.close"); } diff --git a/test/fops/fops.c b/test/fops/fops.c index afedfaac0f1..170b63f3d36 100644 --- a/test/fops/fops.c +++ b/test/fops/fops.c @@ -27,7 +27,6 @@ */ #include "thread.h" -#include "test_util.i" static void *fop(void *); static void print_stats(u_int); @@ -85,7 +84,7 @@ fop_start(u_int nthreads) if ((run_stats = calloc( (size_t)(nthreads), sizeof(*run_stats))) == NULL || (tids = calloc((size_t)(nthreads), sizeof(*tids))) == NULL) - die(errno, "calloc"); + testutil_die(errno, "calloc"); (void)gettimeofday(&start, NULL); @@ -93,7 +92,7 @@ fop_start(u_int nthreads) for (i = 0; i < nthreads; ++i) if ((ret = pthread_create( &tids[i], NULL, fop, (void *)(uintptr_t)i)) != 0) - die(ret, "pthread_create"); + testutil_die(ret, "pthread_create"); /* Wait for the threads. */ for (i = 0; i < nthreads; ++i) diff --git a/test/fops/t.c b/test/fops/t.c index 15a3a542635..ac2011203bf 100644 --- a/test/fops/t.c +++ b/test/fops/t.c @@ -27,7 +27,6 @@ */ #include "thread.h" -#include "test_util.i" WT_CONNECTION *conn; /* WiredTiger connection */ pthread_rwlock_t single; /* Single thread */ @@ -71,16 +70,17 @@ main(int argc, char *argv[]) u_int nthreads; int ch, cnt, ret, runs; char *config_open, *working_dir; + working_dir = NULL; - //Remove directories + /* Remove directories */ if ((progname = strrchr(argv[0], DIR_DELIM)) == NULL) progname = argv[0]; else ++progname; if ((ret = pthread_rwlock_init(&single, NULL)) != 0) - die(ret, "pthread_rwlock_init: single"); + testutil_die(ret, "pthread_rwlock_init: single"); config_open = NULL; nops = 1000; @@ -121,7 +121,7 @@ main(int argc, char *argv[]) return (usage()); if ((ret = testutil_work_dir_from_path(home, 512, working_dir)) != 0) - die(ret, "provided directory name is too long"); + testutil_die(ret, "provided directory name is too long"); /* Clean up on signal. */ (void)signal(SIGINT, onint); @@ -173,7 +173,7 @@ wt_startup(char *config_open) config_open == NULL ? "" : config_open); if ((ret = wiredtiger_open( home, &event_handler, config_buf, &conn)) != 0) - die(ret, "wiredtiger_open"); + testutil_die(ret, "wiredtiger_open"); } /* @@ -186,7 +186,7 @@ wt_shutdown(void) int ret; if ((ret = conn->close(conn, NULL)) != 0) - die(ret, "conn.close"); + testutil_die(ret, "conn.close"); } /* @@ -260,7 +260,7 @@ usage(void) progname); fprintf(stderr, "%s", "\t-C specify wiredtiger_open configuration arguments\n" - "\t-h home (default 'RUNDIR')\n" + "\t-h home (default 'WT_TEST')\n" "\t-l specify a log file\n" "\t-n set number of operations each thread does\n" "\t-r set number of runs\n" diff --git a/test/fops/thread.h b/test/fops/thread.h index ac3b1af8801..4ae896902ec 100644 --- a/test/fops/thread.h +++ b/test/fops/thread.h @@ -44,10 +44,7 @@ #include <unistd.h> #endif -#ifdef _WIN32 -#include "windows_shim.h" -#endif - +#include "test_util.i" #include <wiredtiger.h> extern WT_CONNECTION *conn; /* WiredTiger connection */ diff --git a/test/utility/test_util.i b/test/utility/test_util.i index c2d521a2135..5b3ed2c78eb 100644 --- a/test/utility/test_util.i +++ b/test/utility/test_util.i @@ -36,16 +36,19 @@ #ifdef _WIN32 #define DIR_DELIM '\\' + #define RM_COMMAND "rd /s /q " #else #define DIR_DELIM '/' + #define RM_COMMAND "rm -rf " #endif - +#define DEFAULT_DIR "WT_TEST" +#define MKDIR_COMMAND "mkdir " /* * die -- * Report an error and quit. */ static inline void -die(int e, const char *fmt, ...) +testutil_die(int e, const char *fmt, ...) { va_list ap; @@ -68,22 +71,17 @@ testutil_work_dir_from_path(char *buffer, size_t inputSize, char *dir) { /* If no directory is provided, use the default. */ if (dir == NULL) { - if (inputSize < 9) + if (inputSize < sizeof(DEFAULT_DIR)) return (1); - snprintf(buffer, inputSize, "WT_TEST"); + snprintf(buffer, inputSize, DEFAULT_DIR); return (0); } /* 9 bytes for the directory and WT_TEST */ - if (inputSize < strlen(dir) + 9) + if (inputSize < strlen(dir) + sizeof(DEFAULT_DIR)) return (1); - /* Is this windows or *nix? */ -#ifdef _WIN32 - snprintf(buffer, inputSize, "%s\\WT_TEST", dir); -#else - snprintf(buffer, inputSize, "%s/WT_TEST", dir); -#endif + snprintf(buffer, inputSize, "%s%c%s", dir, DIR_DELIM, DEFAULT_DIR); return (0); } @@ -98,14 +96,10 @@ testutil_clean_work_dir(char *dir) size_t inputSize; /* 10 bytes for the Windows rd command */ - inputSize = strlen(dir) + 19; + inputSize = strlen(dir) + sizeof(RM_COMMAND); buffer = (char*) malloc (inputSize); -#ifdef _WIN32 - snprintf(buffer, inputSize, "rd /s /q %s", dir); -#else - snprintf(buffer, inputSize, "rm -rf %s", dir); -#endif + snprintf(buffer, inputSize, "%s%s", RM_COMMAND, dir); return system(buffer); } @@ -123,11 +117,12 @@ testutil_make_work_dir(char *dir) testutil_clean_work_dir(dir); /* 7 bytes for the mkdir command */ - inputSize = strlen(dir) + 7; + inputSize = strlen(dir) + sizeof(MKDIR_COMMAND); buffer = (char*) malloc (inputSize); /* mkdir shares syntax between Windows and Linux */ - snprintf(buffer, inputSize, "mkdir %s", dir); + snprintf(buffer, inputSize, "%s%s", MKDIR_COMMAND, dir); if ((ret = system(buffer)) != 0) - die(ret, "directory create call failed"); + testutil_die(ret, "directory create call of '%s%s' failed", + MKDIR_COMMAND, dir); } diff --git a/test/windows/windows_shim.h b/test/windows/windows_shim.h index 5ce41a4a15c..c124cda6092 100644 --- a/test/windows/windows_shim.h +++ b/test/windows/windows_shim.h @@ -62,13 +62,10 @@ _Check_return_opt_ int __cdecl _wt_snprintf( /* * Emulate <sys/time.h> */ -#ifndef WINSHIM_TIMEVAL -#define WINSHIM_TIMEVAL struct timeval { time_t tv_sec; int64_t tv_usec; }; -#endif int gettimeofday(struct timeval* tp, void* tzp); @@ -94,13 +91,10 @@ usleep(useconds_t useconds); typedef CRITICAL_SECTION pthread_mutex_t; typedef CONDITION_VARIABLE pthread_cond_t; -#ifndef WINSHIM_RWLOCK -#define WINSHIM_RWLOCK struct rwlock_wrapper { SRWLOCK rwlock; int exclusive_locked; }; -#endif struct rwlock_wrapper; typedef struct rwlock_wrapper pthread_rwlock_t; |