summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2014-10-16 18:59:40 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2014-10-16 19:58:17 -0400
commit6828f17265878e40b40e2992c1791a0c6806ff8c (patch)
tree8baee85e7218dbad9725fcc8743baf4833298cb8
parent185694d3494ce6817cd854feaff7169fb41dd13d (diff)
downloadmongo-6828f17265878e40b40e2992c1791a0c6806ff8c.tar.gz
Port all examples, most tests, and wtperf to Windows
Added windows_shim to emulate most functions
-rw-r--r--SConstruct158
-rw-r--r--bench/wtperf/config.c10
-rw-r--r--bench/wtperf/misc.c2
-rw-r--r--bench/wtperf/wtperf.c39
-rw-r--r--bench/wtperf/wtperf.h15
-rw-r--r--examples/c/ex_all.c5
-rw-r--r--examples/c/ex_async.c6
-rw-r--r--examples/c/ex_extending.c4
-rw-r--r--examples/c/ex_log.c5
-rw-r--r--examples/c/ex_scope.c5
-rw-r--r--examples/c/ex_thread.c6
-rw-r--r--src/include/wt_internal.h3
-rw-r--r--test/format/format.h12
-rw-r--r--test/format/salvage.c8
-rw-r--r--test/format/t.c6
-rw-r--r--test/format/util.c17
-rw-r--r--test/format/wts.c9
-rw-r--r--test/huge/huge.c2
-rw-r--r--test/suite/run.py2
-rw-r--r--test/windows/windows_shim.c121
-rw-r--r--test/windows/windows_shim.h101
21 files changed, 493 insertions, 43 deletions
diff --git a/SConstruct b/SConstruct
index ae5a843be55..1a9b9e68f90 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1,6 +1,7 @@
# -*- mode: python; -*-
import re
import os
+import distutils.sysconfig
EnsureSConsVersion( 2, 0, 0 )
@@ -8,20 +9,67 @@ if not os.sys.platform == "win32":
print ("SConstruct is only supported for Windows, use build_posix for other platforms")
Exit(1)
+AddOption("--with-berkeley-db", dest="bdb", type="string", nargs=1, action="store",
+ help="Berkeley DB install path, ie, /usr/local")
+
AddOption("--enable-zlib", dest="zlib", type="string", nargs=1, action="store",
help="Use zlib compression")
AddOption("--enable-snappy", dest="snappy", type="string", nargs=1, action="store",
help="Use snappy compression")
+AddOption("--enable-swig", dest="swig", type="string", nargs=1, action="store",
+ help="Build python extension, specify location of swig.exe binary")
+
env = Environment(
- CPPPATH = ["#/src/include/", "#/build_win", "#/."],
- CFLAGS = ["/Z7", "/wd4090"],
- LINKFLAGS = ["/DEBUG"],
+ CPPPATH = ["#/src/include/",
+ "#/build_win",
+ "#/test/windows",
+ "#/.",
+ distutils.sysconfig.get_python_inc()
+ ],
+ CPPDEFINES = ["HAVE_DIAGNOSTIC"],
+ CFLAGS = [
+ #"/Zi",
+ "/Z7", # Generate debugging symbols
+ "/wd4090", # Ignore warning about mismatched const qualifiers
+ "/wd4996",
+ "/W3", # Warning level 3
+ "/we4013", # Error on undefined functions
+ "/TC", # Compile as C code
+ #"/Od", # Disable optimization
+ "/Ob1", # inline expansion
+ "/O2", # optimize for speed
+ "/GF", # enable string pooling
+ "/EHsc", # extern "C" does not throw
+ #"/RTC1", # enable stack checks
+ "/GS", # enable secrutiy checks
+ "/Gy", # separate functions for linker
+ "/Zc:wchar_t",
+ "/Gd",
+ "/MD",
+ ],
+ LINKFLAGS = [
+ "/DEBUG", # Generate debug symbols
+ "/INCREMENTAL:NO", # Disable incremental linking
+ "/OPT:REF", # Remove dead code
+ "/DYNAMICBASE",
+ "/NXCOMPAT",
+ ],
+ LIBPATH=[ distutils.sysconfig.PREFIX + r"\libs"],
+ tools=["default", "swig"],
+ SWIGFLAGS=['-python',
+ "-threads",
+ "-O",
+ "-nodefaultctor",
+ "-nodefaultdtor"
+ ],
+ SWIG=GetOption("swig")
)
useZlib = GetOption("zlib")
useSnappy = GetOption("snappy")
+useBdb = GetOption("bdb")
wtlibs = []
conf = Configure(env)
@@ -30,7 +78,7 @@ if not conf.CheckCHeader('stdlib.h'):
Exit(1)
if useZlib:
- conf.emv.Append(CPPPATH=[useZlib + "/include"])
+ conf.env.Append(CPPPATH=[useZlib + "/include"])
conf.env.Append(LIBPATH=[useZlib + "/lib"])
if conf.CheckCHeader('zlib.h'):
conf.env.Append(CPPDEFINES=["HAVE_BUILTIN_EXTENSION_ZLIB"])
@@ -49,6 +97,13 @@ if useSnappy:
print 'snappy-c.h must be installed!'
Exit(1)
+if useBdb:
+ conf.env.Append(CPPPATH=[useBdb+ "/include"])
+ conf.env.Append(LIBPATH=[useBdb+ "/lib"])
+ if not conf.CheckCHeader('db.h'):
+ print 'db.h must be installed!'
+ Exit(1)
+
env = conf.Finish()
def GenerateWiredTigerH(target, source, env):
@@ -128,3 +183,98 @@ env.Program("wt", [
"src/utilities/util_verify.c",
"src/utilities/util_write.c"],
LIBS=[wtlib] + wtlibs)
+
+if GetOption("swig"):
+ env.SharedLibrary('_wiredtiger',
+ [ 'lang\python\wiredtiger.i'],
+ SHLIBSUFFIX=".pyd",
+ LIBS=[wtlib])
+
+# Shim library of functions to emulate POSIX on Windows
+shim = env.Library("window_shim",
+ ["test/windows/windows_shim.c"])
+
+env.Program("t_bloom",
+ "test/bloom/test_bloom.c",
+ LIBS=[wtlib])
+
+#env.Program("t_checkpoint",
+ #["test/checkpoint/checkpointer.c",
+ #"test/checkpoint/test_checkpoint.c",
+ #"test/checkpoint/workers.c"],
+ #LIBS=[wtlib])
+
+env.Program("t_huge",
+ "test/huge/huge.c",
+ LIBS=[wtlib])
+
+#env.Program("t_fops",
+ #["test/fops/file.c",
+ #"test/fops/fops.c",
+ #"test/fops/t.c"],
+ #LIBS=[wtlib])
+
+if useBdb:
+ benv = env.Clone()
+
+ benv.Append(CPPDEFINES=['BERKELEY_DB_PATH=\\"' + useBdb.replace("\\", "\\\\") + '\\"'])
+
+ benv.Program("t_format",
+ ["test/format/backup.c",
+ "test/format/bdb.c",
+ "test/format/bulk.c",
+ "test/format/compact.c",
+ "test/format/config.c",
+ "test/format/ops.c",
+ "test/format/salvage.c",
+ "test/format/t.c",
+ "test/format/util.c",
+ "test/format/wts.c"],
+ LIBS=[wtlib, shim, "libdb61"])
+
+#env.Program("t_thread",
+ #["test/thread/file.c",
+ #"test/thread/rw.c",
+ #"test/thread/stats.c",
+ #"test/thread/t.c"],
+ #LIBS=[wtlib])
+
+#env.Program("t_salvage",
+ #["test/salvage/salvage.c"],
+ #LIBS=[wtlib])
+
+env.Program("wtperf", [
+ "bench/wtperf/config.c",
+ "bench/wtperf/misc.c",
+ "bench/wtperf/track.c",
+ "bench/wtperf/wtperf.c",
+ ],
+ LIBS=[wtlib, shim] )
+
+examples = [
+ "ex_access",
+ "ex_all",
+ "ex_async",
+ "ex_call_center",
+ "ex_config",
+ "ex_config_parse",
+ "ex_cursor",
+ "ex_data_source",
+ "ex_extending",
+ "ex_file",
+ "ex_hello",
+ "ex_log",
+ "ex_pack",
+ "ex_process",
+ "ex_schema",
+ "ex_scope",
+ "ex_stat",
+ "ex_thread",
+ ]
+
+for ex in examples:
+ if(ex in ['ex_async', 'ex_thread']):
+ env.Program(ex, "examples/c/" + ex + ".c", LIBS=[wtlib, shim])
+ else:
+ env.Program(ex, "examples/c/" + ex + ".c", LIBS=[wtlib])
+
diff --git a/bench/wtperf/config.c b/bench/wtperf/config.c
index ac36a950ad1..ff5fd777081 100644
--- a/bench/wtperf/config.c
+++ b/bench/wtperf/config.c
@@ -362,6 +362,7 @@ config_opt(CONFIG *cfg, WT_CONFIG_ITEM *k, WT_CONFIG_ITEM *v)
return (enomem(cfg));
snprintf(newstr, newlen,
"%s,%*s", *strp, (int)v->len, v->str);
+ newstr[newlen - 1] = '\0';
/* Free the old value now we've copied it. */
free(*strp);
}
@@ -428,14 +429,19 @@ config_opt_file(CONFIG *cfg, const char *filename)
goto err;
}
read_size = read(fd, file_buf, buf_size);
- if (read_size == -1 || (size_t)read_size != buf_size) {
+ if (read_size == -1
+#ifndef _WIN32
+ /* Windows automatically translates \r\n -> \n so counts will be off */
+ || (size_t)read_size != buf_size
+#endif
+ ) {
fprintf(stderr,
"wtperf: read unexpected amount from config file\n");
ret = EINVAL;
goto err;
}
/* Make sure the buffer is terminated correctly. */
- file_buf[buf_size] = '\0';
+ file_buf[read_size] = '\0';
ret = 0;
optionpos = 0;
diff --git a/bench/wtperf/misc.c b/bench/wtperf/misc.c
index 7850e8e2d80..0a9a1de73e2 100644
--- a/bench/wtperf/misc.c
+++ b/bench/wtperf/misc.c
@@ -67,7 +67,7 @@ setup_log_file(CONFIG *cfg)
return (ret);
/* Use line buffering for the log file. */
- (void)setvbuf(cfg->logf, NULL, _IOLBF, 0);
+ (void)setvbuf(cfg->logf, NULL, _IOLBF, 32);
return (0);
}
diff --git a/bench/wtperf/wtperf.c b/bench/wtperf/wtperf.c
index 83017b42fb7..2373324c9f8 100644
--- a/bench/wtperf/wtperf.c
+++ b/bench/wtperf/wtperf.c
@@ -64,17 +64,6 @@ static const CONFIG default_cfg = {
static const char * const debug_cconfig = "";
static const char * const debug_tconfig = "";
-/*
- * Atomic update where needed.
- */
-#if defined(_lint)
-#define ATOMIC_ADD(v, val) ((v) += (val), (v))
-#define ATOMIC_ADD_PTR(p, val) ((*p) += (val), (*p))
-#else
-#define ATOMIC_ADD(v, val) __sync_add_and_fetch(&(v), val)
-#define ATOMIC_ADD_PTR(p, val) __sync_add_and_fetch((p), val)
-#endif
-
static void *checkpoint_worker(void *);
static int create_tables(CONFIG *);
static int create_uris(CONFIG *);
@@ -104,7 +93,6 @@ static uint64_t wtperf_value_range(CONFIG *);
* wtperf uses internal WiredTiger library routines for timing and generating
* random numbers.
*/
-extern int __wt_epoch(void *, struct timespec *);
extern uint32_t __wt_random(uint32_t *);
extern void __wt_random_init(uint32_t *);
@@ -112,14 +100,7 @@ extern void __wt_random_init(uint32_t *);
static inline uint64_t
get_next_incr(CONFIG *cfg)
{
- return (ATOMIC_ADD(cfg->insert_key, 1));
-}
-
-/* Count number of async inserts completed. */
-static inline uint64_t
-async_next_incr(uint64_t *val)
-{
- return (ATOMIC_ADD_PTR(val, 1));
+ return (WT_ATOMIC_ADD8(cfg->insert_key, 1));
}
static inline void
@@ -179,7 +160,7 @@ cb_asyncop(WT_ASYNC_CALLBACK *cb, WT_ASYNC_OP *op, int ret, uint32_t flags)
switch (type) {
case WT_AOP_COMPACT:
tables = (uint32_t *)op->app_private;
- ATOMIC_ADD(*tables, (uint32_t)-1);
+ WT_ATOMIC_ADD4(*tables, (uint32_t)-1);
break;
case WT_AOP_INSERT:
trk = &thread->insert;
@@ -214,7 +195,7 @@ cb_asyncop(WT_ASYNC_CALLBACK *cb, WT_ASYNC_OP *op, int ret, uint32_t flags)
return (0);
if (ret == 0 || (ret == WT_NOTFOUND && type != WT_AOP_INSERT)) {
if (!cfg->in_warmup)
- (void)async_next_incr(&trk->ops);
+ (void)WT_ATOMIC_ADD8(trk->ops, 1);
return (0);
}
err:
@@ -821,7 +802,7 @@ populate_thread(void *arg)
*/
cursor = cursors[op % cfg->table_count];
generate_key(cfg, key_buf, op);
- measure_latency =
+ measure_latency =
cfg->sample_interval != 0 && trk->ops != 0 && (
trk->ops % cfg->sample_rate == 0);
if (measure_latency &&
@@ -933,7 +914,7 @@ populate_async(void *arg)
* will measure the time it takes to do all of them, including
* the time to process by workers.
*/
- measure_latency =
+ measure_latency =
cfg->sample_interval != 0 && trk->ops != 0 && (
trk->ops % cfg->sample_rate == 0);
if (measure_latency &&
@@ -1300,7 +1281,7 @@ execute_populate(CONFIG *cfg)
msecs = ns_to_ms(WT_TIMEDIFF(stop, start));
lprintf(cfg, 0, 1,
"Load time: %.2f\n" "load ops/sec: %" PRIu64,
- (double)msecs / (double)MSEC_PER_SEC,
+ (double)msecs / (double)MSEC_PER_SEC,
(uint64_t)((cfg->icount / msecs) / MSEC_PER_SEC));
/*
@@ -1404,7 +1385,7 @@ execute_workload(CONFIG *cfg)
last_ckpts = last_inserts = last_reads = last_updates = 0;
ret = 0;
-
+
if (cfg->warmup != 0)
cfg->in_warmup = 1;
@@ -1514,7 +1495,7 @@ err: cfg->stop = 1;
}
/*
- * Ensure that icount matches the number of records in the
+ * Ensure that icount matches the number of records in the
* existing table.
*/
static int
@@ -2047,7 +2028,7 @@ main(int argc, char *argv[])
cfg->table_name);
/* Make stdout line buffered, so verbose output appears quickly. */
- (void)setvbuf(stdout, NULL, _IOLBF, 0);
+ (void)setvbuf(stdout, NULL, _IOLBF, 32);
/* Concatenate non-default configuration strings. */
if (cfg->verbose > 1 || user_cconfig != NULL ||
@@ -2239,7 +2220,7 @@ worker_throttle(int64_t throttle, int64_t *ops, struct timespec *interval)
if (__wt_epoch(NULL, &now) != 0)
return;
- /*
+ /*
* If we've completed enough operations, reset the counters.
* If we did enough operations in less than a second, sleep for
* the rest of the second.
diff --git a/bench/wtperf/wtperf.h b/bench/wtperf/wtperf.h
index 9872b325fd1..f0d1081c68b 100644
--- a/bench/wtperf/wtperf.h
+++ b/bench/wtperf/wtperf.h
@@ -25,27 +25,38 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
+#ifndef _WIN32
#include <sys/time.h>
+#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <ctype.h>
+#ifndef _WIN32
#include <dirent.h>
+#endif
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
+#ifndef _WIN32
#include <pthread.h>
+#endif
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifndef _WIN32
#include <unistd.h>
+#endif
+
+#include <wt_internal.h>
-#include <wiredtiger.h>
-#include <wiredtiger_ext.h>
+#ifdef _WIN32
+#include "windows_shim.h"
+#endif
#include "config_opt.h"
diff --git a/examples/c/ex_all.c b/examples/c/ex_all.c
index 32850a59385..d4f571ccaf6 100644
--- a/examples/c/ex_all.c
+++ b/examples/c/ex_all.c
@@ -38,7 +38,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#ifndef _WIN32
#include <unistd.h>
+#else
+#include "windows_shim.h"
+#endif
#include <sys/stat.h>
#include <wiredtiger.h>
diff --git a/examples/c/ex_async.c b/examples/c/ex_async.c
index fb3c77e9a6d..0c8f83e4aac 100644
--- a/examples/c/ex_async.c
+++ b/examples/c/ex_async.c
@@ -31,12 +31,18 @@
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
+#ifndef _WIN32
#include <unistd.h>
+#else
+#include "windows_shim.h"
+#endif
#include <wiredtiger.h>
#if defined(_lint)
#define ATOMIC_ADD(v, val) ((v) += (val), (v))
+#elif defined(_WIN32)
+#define ATOMIC_ADD(v, val) (_InterlockedExchangeAdd(&(v), val) + val)
#else
#define ATOMIC_ADD(v, val) __sync_add_and_fetch(&(v), val)
#endif
diff --git a/examples/c/ex_extending.c b/examples/c/ex_extending.c
index 62abaa09bf8..f043dd5b383 100644
--- a/examples/c/ex_extending.c
+++ b/examples/c/ex_extending.c
@@ -35,6 +35,10 @@
#include <wiredtiger.h>
+#ifdef _WIN32
+#define strcasecmp stricmp
+#endif
+
static const char *home;
/*! [case insensitive comparator] */
diff --git a/examples/c/ex_log.c b/examples/c/ex_log.c
index 27e8e810252..8ac7d079da1 100644
--- a/examples/c/ex_log.c
+++ b/examples/c/ex_log.c
@@ -31,7 +31,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifndef _WIN32
#include <unistd.h>
+#else
+/* snprintf is not supported on <= VS2013 */
+#define snprintf _snprintf
+#endif
#include <wiredtiger.h>
diff --git a/examples/c/ex_scope.c b/examples/c/ex_scope.c
index 8dea4cfc772..334745f7e37 100644
--- a/examples/c/ex_scope.c
+++ b/examples/c/ex_scope.c
@@ -34,6 +34,11 @@
#include <wiredtiger.h>
+#ifdef _WIN32
+/* snprintf is not supported on <= VS2013 */
+#define snprintf _snprintf
+#endif
+
static const char *home;
static int
diff --git a/examples/c/ex_thread.c b/examples/c/ex_thread.c
index 05a1fc96d15..256449aa3dc 100644
--- a/examples/c/ex_thread.c
+++ b/examples/c/ex_thread.c
@@ -29,11 +29,17 @@
* table from multiple threads.
*/
+#ifndef _WIN32
#include <pthread.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef _WIN32
+#include "windows_shim.h"
+#endif
+
#include <wiredtiger.h>
static const char *home;
diff --git a/src/include/wt_internal.h b/src/include/wt_internal.h
index dae91144883..4fdbd5e30bb 100644
--- a/src/include/wt_internal.h
+++ b/src/include/wt_internal.h
@@ -31,6 +31,9 @@ extern "C" {
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
+#ifdef _WIN32
+#include <io.h>
+#endif
#include <limits.h>
#ifndef _WIN32
#include <pthread.h>
diff --git a/test/format/format.h b/test/format/format.h
index f92ecaa7cad..d6026962ec3 100644
--- a/test/format/format.h
+++ b/test/format/format.h
@@ -26,7 +26,9 @@
*/
#include <sys/stat.h>
+#ifndef _WIN32
#include <sys/time.h>
+#endif
#include <sys/types.h>
#include <assert.h>
@@ -35,12 +37,21 @@
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
+#ifndef _WIN32
#include <pthread.h>
+#endif
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifndef _WIN32
#include <unistd.h>
+#endif
+#include <time.h>
+
+#ifdef _WIN32
+#include "windows_shim.h"
+#endif
#ifdef BDB
#include <db.h>
@@ -48,6 +59,7 @@
#include <wiredtiger.h>
#include <wiredtiger_ext.h>
+
extern WT_EXTENSION_API *wt_api;
#define EXTPATH "../../ext/" /* Extensions path */
diff --git a/test/format/salvage.c b/test/format/salvage.c
index 59682dea10e..ff3cd00dcc0 100644
--- a/test/format/salvage.c
+++ b/test/format/salvage.c
@@ -74,14 +74,22 @@ corrupt(void)
(void)snprintf(buf, sizeof(buf), "%s/%s", g.home, WT_NAME);
if ((fd = open(buf, O_RDWR)) != -1) {
(void)snprintf(copycmd, sizeof(copycmd),
+#ifdef _WIN32
+ "copy %s\\%s %s\\slvg.copy\\%s.corrupted",
+#else
"cp %s/%s %s/slvg.copy/%s.corrupted",
+#endif
g.home, WT_NAME, g.home, WT_NAME);
goto found;
}
(void)snprintf(buf, sizeof(buf), "%s/%s.wt", g.home, WT_NAME);
if ((fd = open(buf, O_RDWR)) != -1) {
(void)snprintf(copycmd, sizeof(copycmd),
+#ifndef _WIN32
+ "copy %s\\%s.wt %s\\slvg.copy\\%s.wt.corrupted",
+#else
"cp %s/%s.wt %s/slvg.copy/%s.wt.corrupted",
+#endif
g.home, WT_NAME, g.home, WT_NAME);
goto found;
}
diff --git a/test/format/t.c b/test/format/t.c
index 0d52f326878..7f741737cfc 100644
--- a/test/format/t.c
+++ b/test/format/t.c
@@ -59,7 +59,7 @@ main(int argc, char *argv[])
#endif
/* Track progress unless we're re-directing output to a file. */
- g.track = isatty(STDOUT_FILENO) ? 1 : 0;
+ g.track = isatty(1) ? 1 : 0;
/* Set values from the command line. */
home = NULL;
@@ -151,7 +151,7 @@ main(int argc, char *argv[])
g.c_runs = 1;
/* Use line buffering on stdout so status updates aren't buffered. */
- (void)setvbuf(stdout, NULL, _IOLBF, 0);
+ (void)setvbuf(stdout, NULL, _IOLBF, 32);
/*
* Initialize locks to single-thread named checkpoints and backups, and
@@ -301,7 +301,7 @@ startup(void)
*/
if ((g.rand_log = fopen(g.home_rand, g.replay ? "r" : "w")) == NULL)
die(errno, "%s", g.home_rand);
- (void)setvbuf(g.rand_log, NULL, _IOLBF, 0);
+ (void)setvbuf(g.rand_log, NULL, _IOLBF, 32);
}
/*
diff --git a/test/format/util.c b/test/format/util.c
index e6357d7586b..847bc4d5b2d 100644
--- a/test/format/util.c
+++ b/test/format/util.c
@@ -276,7 +276,11 @@ path_setup(const char *home)
* log file.
*/
#undef CMD
+#ifdef _WIN32
+#define CMD "cd %s && del /s /q * && rd /s /q KVS"
+#else
#define CMD "cd %s && rm -rf `ls | sed /rand/d`"
+#endif
len = strlen(g.home) + strlen(CMD) + 1;
if ((g.home_init = malloc(len)) == NULL)
die(errno, "malloc");
@@ -284,7 +288,11 @@ path_setup(const char *home)
/* Backup directory initialize command, remove and re-create it. */
#undef CMD
+#ifdef _WIN32
+#define CMD "del /s && mkdir %s"
+#else
#define CMD "rm -rf %s && mkdir %s"
+#endif
len = strlen(g.home_backup) * 2 + strlen(CMD) + 1;
if ((g.home_backup_init = malloc(len)) == NULL)
die(errno, "malloc");
@@ -295,11 +303,18 @@ path_setup(const char *home)
* salvage command as necessary.
*/
#undef CMD
+#ifdef _WIN32
+#define CMD \
+ "cd %s && " \
+ "rd /q /s slvg.copy & mkdir slvg.copy && " \
+ "copy WiredTiger* slvg.copy\\ && copy wt* slvg.copy\\"
+#else
#define CMD \
"cd %s && " \
"rm -rf slvg.copy && mkdir slvg.copy && " \
"cp WiredTiger* wt* slvg.copy/"
- len = strlen(g.home) + strlen(CMD) + 1;
+#endif
+ len = strlen(g.home) + strlen(CMD) + 1;
if ((g.home_salvage_copy = malloc(len)) == NULL)
die(errno, "malloc");
snprintf(g.home_salvage_copy, len, CMD, g.home);
diff --git a/test/format/wts.c b/test/format/wts.c
index 97136be159d..2626959d9ef 100644
--- a/test/format/wts.c
+++ b/test/format/wts.c
@@ -92,7 +92,10 @@ wts_open(const char *home, int set_api, WT_CONNECTION **connp)
if (snprintf(config, sizeof(config),
"create,"
"checkpoint_sync=false,cache_size=%" PRIu32 "MB,"
- "buffer_alignment=512,lsm_manager=(worker_thread_max=%" PRIu32
+#ifndef _WIN32
+ "buffer_alignment=512"
+#endif
+ ",lsm_manager=(worker_thread_max=%" PRIu32
"),error_prefix=\"%s\","
"%s,%s,%s,%s,%s"
"extensions="
@@ -100,7 +103,11 @@ wts_open(const char *home, int set_api, WT_CONNECTION **connp)
"%s,%s",
g.c_cache,
g.c_lsm_worker_threads,
+#ifndef _WIN32
g.progname,
+#else
+ "t_format.exe",
+#endif
g.c_data_extend ? "file_extend=(data=8MB)" : "",
g.c_logging ? "log=(enabled=true)" : "",
g.c_mmap ? "mmap=true" : "mmap=false",
diff --git a/test/huge/huge.c b/test/huge/huge.c
index 810c70b2606..6ef9755a5a5 100644
--- a/test/huge/huge.c
+++ b/test/huge/huge.c
@@ -29,7 +29,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#ifndef _WIN32
#include <unistd.h>
+#endif
#include <wiredtiger.h>
diff --git a/test/suite/run.py b/test/suite/run.py
index d20d3121569..0768a57628b 100644
--- a/test/suite/run.py
+++ b/test/suite/run.py
@@ -46,6 +46,8 @@ elif os.path.isfile(os.path.join(wt_disttop, 'wt')):
wt_builddir = wt_disttop
elif os.path.isfile(os.path.join(wt_disttop, 'build_posix', 'wt')):
wt_builddir = os.path.join(wt_disttop, 'build_posix')
+elif os.path.isfile(os.path.join(wt_disttop, 'wt.exe')):
+ wt_builddir = wt_disttop
else:
print 'Unable to find useable WiredTiger build'
sys.exit(False)
diff --git a/test/windows/windows_shim.c b/test/windows/windows_shim.c
new file mode 100644
index 00000000000..2e0226268f6
--- /dev/null
+++ b/test/windows/windows_shim.c
@@ -0,0 +1,121 @@
+/*-
+ * Public Domain 2008-2014 WiredTiger, Inc.
+ *
+ * This is free and unencumbered software released into the public domain.
+ *
+ * Anyone is free to copy, modify, publish, use, compile, sell, or
+ * distribute this software, either in source code form or as a compiled
+ * binary, for any purpose, commercial or non-commercial, and by any
+ * means.
+ *
+ * In jurisdictions that recognize copyright laws, the author or authors
+ * of this software dedicate any and all copyright interest in the
+ * software to the public domain. We make this dedication for the benefit
+ * of the public at large and to the detriment of our heirs and
+ * successors. We intend this dedication to be an overt act of
+ * relinquishment in perpetuity of all present and future rights to this
+ * software under copyright law.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "windows_shim.h"
+
+int
+sched_yield(void)
+{
+ (void)SwitchToThread();
+ return (0);
+}
+
+int
+sleep(int seconds)
+{
+ Sleep(seconds * 1000);
+ return (0);
+}
+
+int
+usleep(useconds_t useconds)
+{
+ uint32_t milli;
+ milli = useconds / 1000;
+
+ if (milli == 0)
+ milli++;
+
+ Sleep(milli);
+
+ return (0);
+}
+
+int
+pthread_rwlock_destroy(pthread_rwlock_t *lock)
+{
+ return (0);
+}
+
+int
+pthread_rwlock_init(pthread_rwlock_t *rwlock,
+ const pthread_rwlockattr_t *ignored)
+{
+ InitializeSRWLock(&rwlock->rwlock);
+ rwlock->exclusive_locked = 0;
+
+ return (0);
+}
+
+int
+pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
+{
+ AcquireSRWLockShared(&rwlock->rwlock);
+ return (0);
+}
+
+int
+pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
+{
+ if (rwlock->exclusive_locked != 0) {
+ rwlock->exclusive_locked = 0;
+ ReleaseSRWLockExclusive(&rwlock->rwlock);
+ } else
+ ReleaseSRWLockShared(&rwlock->rwlock);
+
+ return (0);
+}
+
+int
+pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
+{
+ AcquireSRWLockExclusive(&rwlock->rwlock);
+
+ rwlock->exclusive_locked = GetCurrentThreadId();
+
+ return (0);
+
+}
+
+int
+pthread_create(pthread_t *tidret, const pthread_attr_t *ignored,
+ void *(*func)(void *), void * arg)
+{
+ *tidret = CreateThread(NULL, 0, func, arg, 0, NULL);
+
+ if (*tidret != NULL)
+ return (0);
+
+ return (1);
+}
+
+int
+pthread_join(pthread_t thread, void **ignored)
+{
+ WaitForSingleObject(thread, INFINITE);
+ return (0);
+}
diff --git a/test/windows/windows_shim.h b/test/windows/windows_shim.h
new file mode 100644
index 00000000000..3b09fdc6b2a
--- /dev/null
+++ b/test/windows/windows_shim.h
@@ -0,0 +1,101 @@
+/*-
+ * Public Domain 2008-2014 WiredTiger, Inc.
+ *
+ * This is free and unencumbered software released into the public domain.
+ *
+ * Anyone is free to copy, modify, publish, use, compile, sell, or
+ * distribute this software, either in source code form or as a compiled
+ * binary, for any purpose, commercial or non-commercial, and by any
+ * means.
+ *
+ * In jurisdictions that recognize copyright laws, the author or authors
+ * of this software dedicate any and all copyright interest in the
+ * software to the public domain. We make this dedication for the benefit
+ * of the public at large and to the detriment of our heirs and
+ * successors. We intend this dedication to be an overt act of
+ * relinquishment in perpetuity of all present and future rights to this
+ * software under copyright law.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef _WIN32
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <stdint.h>
+#include <direct.h>
+#include <io.h>
+
+#define inline __inline
+
+/* Define some POSIX types */
+typedef int u_int;
+
+/* Windows does not define constants for access() */
+#define R_OK 04
+#define X_OK R_OK
+
+/* snprintf does not exist on <= VS 2013 */
+#define snprintf _snprintf
+
+/*
+ * Emulate <sys/stat.h>
+ */
+#define mkdir(path, mode) _mkdir(path)
+
+/*
+ * Emulate <sched.h>
+ */
+int sched_yield(void);
+
+/*
+ * Emulate <unistd.h>
+ */
+#define getpid GetCurrentProcessId
+
+typedef uint32_t useconds_t;
+
+int
+sleep(int seconds);
+
+int
+usleep(useconds_t useconds);
+
+/*
+ * Emulate the <pthread.h> support we need for the tests
+ */
+typedef CRITICAL_SECTION pthread_mutex_t;
+typedef CONDITION_VARIABLE pthread_cond_t;
+
+struct rwlock_wrapper {
+ SRWLOCK rwlock;
+ int exclusive_locked;
+};
+
+struct rwlock_wrapper;
+typedef struct rwlock_wrapper pthread_rwlock_t;
+
+typedef HANDLE pthread_t;
+
+typedef int pthread_rwlockattr_t;
+typedef int pthread_attr_t;
+
+int pthread_rwlock_destroy(pthread_rwlock_t *);
+int pthread_rwlock_init(pthread_rwlock_t *,
+ const pthread_rwlockattr_t *);
+int pthread_rwlock_rdlock(pthread_rwlock_t *);
+int pthread_rwlock_unlock(pthread_rwlock_t *);
+int pthread_rwlock_wrlock(pthread_rwlock_t *);
+
+int pthread_create(pthread_t *, const pthread_attr_t *,
+ void *(*)(void *), void *);
+int pthread_join(pthread_t, void **);
+
+#endif