summaryrefslogtreecommitdiff
path: root/test/fops
diff options
context:
space:
mode:
authordaveh86 <howsdav@gmail.com>2015-04-22 17:38:11 +1000
committerDavid Hows <howsdav@gmail.com>2015-05-01 12:14:36 +1000
commit65255ea496bc8d4ff7b766b06396e5c7b1ea43ce (patch)
tree1feec748fbfec7747378f92776c11f7d7c3935d0 /test/fops
parent0e74e29eb18ef3f49107b4f1a075963927773b90 (diff)
downloadmongo-65255ea496bc8d4ff7b766b06396e5c7b1ea43ce.tar.gz
Create test utilities and modify FOPS test
Test utilities are created to separate the directory creation/cleanup utilities. These are piloted against the FOPS test
Diffstat (limited to 'test/fops')
-rw-r--r--test/fops/Makefile.am2
-rw-r--r--test/fops/t.c54
-rw-r--r--test/fops/thread.h6
3 files changed, 15 insertions, 47 deletions
diff --git a/test/fops/Makefile.am b/test/fops/Makefile.am
index e3bf05e2531..04816ee44a7 100644
--- a/test/fops/Makefile.am
+++ b/test/fops/Makefile.am
@@ -2,7 +2,7 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/src/include
noinst_PROGRAMS = t
t_LDADD = $(top_builddir)/libwiredtiger.la
-t_SOURCES = thread.h file.c fops.c t.c
+t_SOURCES = thread.h file.c fops.c t.c ../utility/util.c
t_LDFLAGS = -static
TESTS = $(noinst_PROGRAMS)
diff --git a/test/fops/t.c b/test/fops/t.c
index 4e66044996f..e5503adc92d 100644
--- a/test/fops/t.c
+++ b/test/fops/t.c
@@ -27,6 +27,7 @@
*/
#include "thread.h"
+#include "../utility/util.h"
WT_CONNECTION *conn; /* WiredTiger connection */
pthread_rwlock_t single; /* Single thread */
@@ -37,6 +38,8 @@ const char *config; /* Object config */
static char *progname; /* Program name */
static FILE *logfp; /* Log file */
+char *home;
+
static int handle_error(WT_EVENT_HANDLER *, WT_SESSION *, int, const char *);
static int handle_message(WT_EVENT_HANDLER *, WT_SESSION *, const char *);
static void onint(int);
@@ -82,11 +85,14 @@ main(int argc, char *argv[])
nthreads = 10;
runs = 1;
- while ((ch = __wt_getopt(progname, argc, argv, "C:l:n:r:t:")) != EOF)
+ while ((ch = __wt_getopt(progname, argc, argv, "C:h:l:n:r:t:")) != EOF)
switch (ch) {
case 'C': /* wiredtiger_open config */
config_open = __wt_optarg;
break;
+ case 'h':
+ home = __wt_optarg;
+ break;
case 'l': /* log */
if ((logfp = fopen(__wt_optarg, "w")) == NULL) {
fprintf(stderr,
@@ -112,6 +118,8 @@ main(int argc, char *argv[])
if (argc != 0)
return (usage());
+ home = testutil_workdir_from_path(home);
+
/* Clean up on signal. */
(void)signal(SIGINT, onint);
@@ -153,24 +161,16 @@ wt_startup(char *config_open)
int ret;
char config_buf[128];
-#undef CMD
-#ifdef _WIN32
-#define CMD "rd /s /q WT_TEST & mkdir WT_TEST"
-#else
-#define CMD "rm -rf WT_TEST && mkdir WT_TEST"
-#endif
- if ((ret = system(CMD)) != 0)
- die(ret, "directory cleanup call failed");
+ testutil_make_workdir(home);
snprintf(config_buf, sizeof(config_buf),
"create,error_prefix=\"%s\",cache_size=5MB%s%s",
progname,
config_open == NULL ? "" : ",",
config_open == NULL ? "" : config_open);
-
if ((ret = wiredtiger_open(
- "WT_TEST", &event_handler, config_buf, &conn)) != 0)
+ home, &event_handler, config_buf, &conn)) != 0)
die(ret, "wiredtiger_open");
}
@@ -192,18 +192,9 @@ wt_shutdown(void)
* Clean up from previous runs.
*/
static void
-shutdown(void)
+shutdown()
{
- int ret;
-
-#undef CMD
-#ifdef _WIN32
-#define CMD "if exist WT_TEST rd /s /q WT_TEST"
-#else
-#define CMD "rm -rf WT_TEST"
-#endif
- if ((ret = system(CMD)) != 0)
- die(ret, "directory cleanup call failed");
+ testutil_clean_workdir(home);
}
static int
@@ -254,24 +245,6 @@ onint(int signo)
exit(EXIT_FAILURE);
}
-/*
- * die --
- * Report an error and quit.
- */
-void
-die(int e, const char *fmt, ...)
-{
- va_list ap;
-
- fprintf(stderr, "%s: ", progname);
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- if (e != 0)
- fprintf(stderr, ": %s", wiredtiger_strerror(e));
- fprintf(stderr, "\n");
- exit(EXIT_FAILURE);
-}
/*
* usage --
@@ -286,6 +259,7 @@ usage(void)
progname);
fprintf(stderr, "%s",
"\t-C specify wiredtiger_open configuration arguments\n"
+ "\t-h home (default 'RUNDIR')\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 72333f5f710..ac3b1af8801 100644
--- a/test/fops/thread.h
+++ b/test/fops/thread.h
@@ -69,9 +69,3 @@ void obj_cursor(void);
void obj_drop(void);
void obj_upgrade(void);
void obj_verify(void);
-
-void die(int, const char *, ...)
-#if defined(__GNUC__)
-__attribute__((noreturn))
-#endif
-;