diff options
author | Alex Gorrod <alexander.gorrod@mongodb.com> | 2016-09-09 15:49:31 +1000 |
---|---|---|
committer | Alex Gorrod <alexander.gorrod@mongodb.com> | 2016-09-09 15:58:39 +1000 |
commit | 29b5a329c5c72fe87d1627bd99e682d9d5e2e34c (patch) | |
tree | 1dc8949286121eb16b472d4f5e4ea391baebc5de /src/third_party/wiredtiger/test | |
parent | bda317e9c852b27f0fe7d148e5c08499d2f8ec49 (diff) | |
download | mongo-29b5a329c5c72fe87d1627bd99e682d9d5e2e34c.tar.gz |
Import wiredtiger: 569c70d13a7b3da0fe8eb1bac06a86865cb36a7c from branch mongodb-3.4
ref: 7d3c0f9f50..569c70d13a
for: 3.3.13
SERVER-25843 Coverity analysis defect 99856: Redundant test
SERVER-25845 Coverity analysis defect 99859: Explicit null dereferenced
SERVER-25846 Coverity analysis defect 99861: Dereference after null check
WT-2221 Document which statistics are available via a "fast" configuration vs. an "all" configuration
WT-2233 Investigate changing when the eviction server switches to aggressive mode.
WT-2323 Allocate a transaction id at the beginning of join cursor iteration
WT-2555 make format run on Windows
WT-2788 Java: freed memory overwrite during handle close can cause JNI crash
WT-2816 Improve WiredTiger eviction performance
WT-2824 wtperf displays connection and table create configurations twice
WT-2842 split wtperf's configuration into per-database and per-run parts
WT-2866 Eviction server algorithm tuning
WT-2867 Review and fix barrier usage in __lsm_tree_close
WT-2870 Rename wtperf checkpoint schema jobs
WT-2871 __wt_verbose has the wrong GCC format attributes
WT-2872 Recent stuck cache test/stress failures.
WT-2873 Refactor CRC32 code
WT-2875 Test test_wt2853_perf can run too long under valgrind
WT-2876 Extend wtperf to support a log like table
WT-2878 Verbose changes affected performance
WT-2881 Add -Wpedantic to clang compiler warning flags
WT-2882 Add CRC32 hardware scons detection, disable CRC hardware support on ARM for now
WT-2883 wiredtiger_open with verbose=handleops recursive loop
WT-2885 __wt_checkpoint_signal lint
WT-2886 Decide how in-memory configuration and eviction_dirty_target interact
WT-2888 Switch functions to return void where possible
WT-2892 hot backup can race with block truncate
WT-2896 Coverity #1362535: resource leak
WT-2897 Checkpoints can become corrupted on failure
WT-2901 Add option to disable checkpoint dirty stepdown phase
Diffstat (limited to 'src/third_party/wiredtiger/test')
22 files changed, 729 insertions, 113 deletions
diff --git a/src/third_party/wiredtiger/test/bloom/test_bloom.c b/src/third_party/wiredtiger/test/bloom/test_bloom.c index 9a7584f951f..7a298f000aa 100644 --- a/src/third_party/wiredtiger/test/bloom/test_bloom.c +++ b/src/third_party/wiredtiger/test/bloom/test_bloom.c @@ -160,8 +160,7 @@ run(void) item.size = g.c_key_max; for (i = 0; i < g.c_ops; i++) { item.data = g.entries[i]; - if ((ret = __wt_bloom_insert(bloomp, &item)) != 0) - testutil_die(ret, "__wt_bloom_insert: %" PRIu32, i); + __wt_bloom_insert(bloomp, &item); } testutil_check(__wt_bloom_finalize(bloomp)); diff --git a/src/third_party/wiredtiger/test/checkpoint/test_checkpoint.c b/src/third_party/wiredtiger/test/checkpoint/test_checkpoint.c index 6293d36f916..6b2f0d4466c 100644 --- a/src/third_party/wiredtiger/test/checkpoint/test_checkpoint.c +++ b/src/third_party/wiredtiger/test/checkpoint/test_checkpoint.c @@ -34,7 +34,7 @@ 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) WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn)); -static int cleanup(void); +static void cleanup(void); static int usage(void); static int wt_connect(const char *); static int wt_shutdown(void); @@ -139,7 +139,7 @@ main(int argc, char *argv[]) printf(" %d: %d workers, %d tables\n", cnt, g.nworkers, g.ntables); - (void)cleanup(); /* Clean up previous runs */ + cleanup(); /* Clean up previous runs */ /* Setup a fresh set of cookies in the global array. */ if ((g.cookies = calloc( @@ -240,14 +240,13 @@ wt_shutdown(void) * cleanup -- * Clean up from previous runs. */ -static int +static void cleanup(void) { g.running = 0; g.ntables_created = 0; testutil_clean_work_dir(g.home); - return (0); } static int @@ -283,7 +282,7 @@ onint(int signo) { WT_UNUSED(signo); - (void)cleanup(); + cleanup(); fprintf(stderr, "\n"); exit(EXIT_FAILURE); diff --git a/src/third_party/wiredtiger/test/csuite/Makefile.am b/src/third_party/wiredtiger/test/csuite/Makefile.am index 097468f0e85..15db2fbcf46 100644 --- a/src/third_party/wiredtiger/test/csuite/Makefile.am +++ b/src/third_party/wiredtiger/test/csuite/Makefile.am @@ -1,6 +1,5 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/src/include \ - -I$(top_srcdir)/test/utility \ - -DCRC_PATH="\"$(top_srcdir)/src/checksum/x86/checksum.c\"" + -I$(top_srcdir)/test/utility LDADD = $(top_builddir)/test/utility/libtest_util.la \ $(top_builddir)/libwiredtiger.la AM_LDFLAGS = -static @@ -11,13 +10,16 @@ noinst_PROGRAMS = test_wt1965_col_efficiency test_wt2246_col_append_SOURCES = wt2246_col_append/main.c noinst_PROGRAMS += test_wt2246_col_append +test_wt2323_join_visibility_SOURCES = wt2323_join_visibility/main.c +noinst_PROGRAMS += test_wt2323_join_visibility + test_wt2535_insert_race_SOURCES = wt2535_insert_race/main.c noinst_PROGRAMS += test_wt2535_insert_race test_wt2447_join_main_table_SOURCES = wt2447_join_main_table/main.c noinst_PROGRAMS += test_wt2447_join_main_table -test_wt2695_checksum_SOURCES = wt2695_checksum/main.c wt2695_checksum/sw.c +test_wt2695_checksum_SOURCES = wt2695_checksum/main.c noinst_PROGRAMS += test_wt2695_checksum test_wt2592_join_schema_SOURCES = wt2592_join_schema/main.c diff --git a/src/third_party/wiredtiger/test/csuite/wt2323_join_visibility/main.c b/src/third_party/wiredtiger/test/csuite/wt2323_join_visibility/main.c new file mode 100644 index 00000000000..bbf1626fe82 --- /dev/null +++ b/src/third_party/wiredtiger/test/csuite/wt2323_join_visibility/main.c @@ -0,0 +1,402 @@ +/*- + * Public Domain 2014-2016 MongoDB, Inc. + * 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 "test_util.h" + +/* + * JIRA ticket reference: WT-2323 + * + * Test case description: We create two kinds of threads that race: One kind + * is populating/updating records in a table with a few indices, the other + * is reading from a join of that table. The hope in constructing this test + * was to have the updates interleaved between reads of multiple indices by + * the join, yielding an inconsistent view of the data. In the main table, + * we insert account records, with a positive or negative balance. The + * negative balance accounts always have a flag set to non-zero, positive + * balances have the flag set to zero. The join we do is: + * + * select (*) from account where account.postal_code = '54321' and + * account.balance < 0 and account.flags == 0 + * + * which should always yield no results. + * + * Failure mode: This test never actually failed with any combination of + * parameters, with N_INSERT up to 50000000. It seems that a snapshot is + * implicitly allocated in the session used by a join by the set_key calls + * that occur before the first 'next' of the join cursor is done. Despite + * that, the test seems interesting enough to keep around, with the number + * of inserts set low as a default. + */ + +void (*custom_die)(void) = NULL; + +#define N_RECORDS 10000 +#define N_INSERT 500000 +#define N_INSERT_THREAD 2 +#define N_JOIN_THREAD 2 +#define S64 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789::" +#define S1024 (S64 S64 S64 S64 S64 S64 S64 S64 S64 S64 S64 S64 S64 S64 S64 S64) + +typedef struct { + char posturi[256]; + char baluri[256]; + char flaguri[256]; + char joinuri[256]; + bool bloom; + bool remove; +} SHARED_OPTS; + +typedef struct { + TEST_OPTS *testopts; + SHARED_OPTS *sharedopts; + int threadnum; + int nthread; + int done; + int joins; + int removes; + int inserts; + int notfounds; + int rollbacks; +} THREAD_ARGS; + +static void *thread_insert(void *); +static void *thread_join(void *); +static void test_join(TEST_OPTS *, SHARED_OPTS *, bool, bool); + +int +main(int argc, char *argv[]) +{ + SHARED_OPTS *sharedopts, _sharedopts; + TEST_OPTS *opts, _opts; + const char *tablename; + + opts = &_opts; + sharedopts = &_sharedopts; + memset(opts, 0, sizeof(*opts)); + memset(sharedopts, 0, sizeof(*sharedopts)); + + testutil_check(testutil_parse_opts(argc, argv, opts)); + testutil_make_work_dir(opts->home); + + tablename = strchr(opts->uri, ':'); + testutil_assert(tablename != NULL); + tablename++; + snprintf(sharedopts->posturi, sizeof(sharedopts->posturi), + "index:%s:post", tablename); + snprintf(sharedopts->baluri, sizeof(sharedopts->baluri), + "index:%s:bal", tablename); + snprintf(sharedopts->flaguri, sizeof(sharedopts->flaguri), + "index:%s:flag", tablename); + snprintf(sharedopts->joinuri, sizeof(sharedopts->joinuri), + "join:%s", opts->uri); + + testutil_check(wiredtiger_open(opts->home, NULL, + "create,cache_size=1G", &opts->conn)); + + test_join(opts, sharedopts, true, true); + test_join(opts, sharedopts, true, false); + test_join(opts, sharedopts, false, true); + test_join(opts, sharedopts, false, false); + + testutil_cleanup(opts); + + return (0); +} + +static void +test_join(TEST_OPTS *opts, SHARED_OPTS *sharedopts, bool bloom, + bool sometimes_remove) +{ + THREAD_ARGS insert_args[N_INSERT_THREAD], join_args[N_JOIN_THREAD]; + WT_CURSOR *maincur; + WT_SESSION *session; + pthread_t insert_tid[N_INSERT_THREAD], join_tid[N_JOIN_THREAD]; + int i; + + memset(insert_args, 0, sizeof(insert_args)); + memset(join_args, 0, sizeof(join_args)); + + sharedopts->bloom = bloom; + sharedopts->remove = sometimes_remove; + + fprintf(stderr, "Running with bloom=%d, remove=%d\n", + (int)bloom, (int)sometimes_remove); + + testutil_check( + opts->conn->open_session(opts->conn, NULL, NULL, &session)); + + /* + * Note: id is repeated as id2. This makes it easier to + * identify the primary key in dumps of the index files. + */ + testutil_check(session->create(session, opts->uri, + "key_format=i,value_format=iiSii," + "columns=(id,post,bal,extra,flag,id2)")); + + testutil_check(session->create(session, sharedopts->posturi, + "columns=(post)")); + testutil_check(session->create(session, sharedopts->baluri, + "columns=(bal)")); + testutil_check(session->create(session, sharedopts->flaguri, + "columns=(flag)")); + + /* + * Insert a single record with all items we need to + * call search() on, this makes our join logic easier. + */ + testutil_check(session->open_cursor(session, opts->uri, NULL, NULL, + &maincur)); + maincur->set_key(maincur, N_RECORDS); + maincur->set_value(maincur, 54321, 0, "", 0, N_RECORDS); + testutil_check(maincur->insert(maincur)); + testutil_check(maincur->close(maincur)); + + for (i = 0; i < N_INSERT_THREAD; ++i) { + insert_args[i].threadnum = i; + insert_args[i].nthread = N_INSERT_THREAD; + insert_args[i].testopts = opts; + insert_args[i].sharedopts = sharedopts; + testutil_check(pthread_create(&insert_tid[i], NULL, + thread_insert, (void *)&insert_args[i])); + } + + for (i = 0; i < N_JOIN_THREAD; ++i) { + join_args[i].threadnum = i; + join_args[i].nthread = N_JOIN_THREAD; + join_args[i].testopts = opts; + join_args[i].sharedopts = sharedopts; + testutil_check(pthread_create(&join_tid[i], NULL, + thread_join, (void *)&join_args[i])); + } + + /* + * Wait for insert threads to finish. When they + * are done, signal join threads to complete. + */ + for (i = 0; i < N_INSERT_THREAD; ++i) + testutil_check(pthread_join(insert_tid[i], NULL)); + + for (i = 0; i < N_JOIN_THREAD; ++i) + join_args[i].done = 1; + + for (i = 0; i < N_JOIN_THREAD; ++i) + testutil_check(pthread_join(join_tid[i], NULL)); + + fprintf(stderr, "\n"); + for (i = 0; i < N_JOIN_THREAD; ++i) { + fprintf(stderr, " join thread %d did %d joins\n", + i, join_args[i].joins); + } + for (i = 0; i < N_INSERT_THREAD; ++i) + fprintf(stderr, + " insert thread %d did " + "%d inserts, %d removes, %d notfound, %d rollbacks\n", + i, insert_args[i].inserts, insert_args[i].removes, + insert_args[i].notfounds, insert_args[i].rollbacks); + + testutil_check(session->drop(session, sharedopts->posturi, NULL)); + testutil_check(session->drop(session, sharedopts->baluri, NULL)); + testutil_check(session->drop(session, sharedopts->flaguri, NULL)); + testutil_check(session->drop(session, opts->uri, NULL)); + testutil_check(session->close(session, NULL)); +} + +static void *thread_insert(void *arg) +{ + SHARED_OPTS *sharedopts; + TEST_OPTS *opts; + THREAD_ARGS *threadargs; + WT_CURSOR *maincur; + WT_RAND_STATE rnd; + WT_SESSION *session; + int bal, i, flag, key, post, ret; + const char *extra = S1024; + + threadargs = (THREAD_ARGS *)arg; + opts = threadargs->testopts; + sharedopts = threadargs->sharedopts; + testutil_check(__wt_random_init_seed(NULL, &rnd)); + + testutil_check(opts->conn->open_session( + opts->conn, NULL, NULL, &session)); + + testutil_check(session->open_cursor(session, opts->uri, NULL, NULL, + &maincur)); + + for (i = 0; i < N_INSERT; i++) { + /* + * Insert threads may stomp on each other's records; + * that's okay. + */ + key = (int)(__wt_random(&rnd) % N_RECORDS); + maincur->set_key(maincur, key); + if (sharedopts->remove) + testutil_check(session->begin_transaction(session, + "isolation=snapshot")); + if (sharedopts->remove && __wt_random(&rnd) % 5 == 0 && + maincur->search(maincur) == 0) { + /* + * Another thread can be removing at the + * same time. + */ + ret = maincur->remove(maincur); + testutil_assert(ret == 0 || + (N_INSERT_THREAD > 1 && + (ret == WT_NOTFOUND || ret == WT_ROLLBACK))); + if (ret == 0) + threadargs->removes++; + else if (ret == WT_NOTFOUND) + threadargs->notfounds++; + else if (ret == WT_ROLLBACK) + threadargs->rollbacks++; + } else { + if (__wt_random(&rnd) % 2 == 0) + post = 54321; + else + post = i % 100000; + if (__wt_random(&rnd) % 2 == 0) { + bal = -100; + flag = 1; + } else { + bal = 1 + (i % 1000) * 100; + flag = 0; + } + maincur->set_value(maincur, post, bal, extra, flag, + key); + ret = maincur->insert(maincur); + testutil_assert(ret == 0 || + (N_INSERT_THREAD > 1 && ret == WT_ROLLBACK)); + testutil_check(maincur->reset(maincur)); + if (ret == 0) + threadargs->inserts++; + else if (ret == WT_ROLLBACK) + threadargs->rollbacks++; + } + if (sharedopts->remove) + testutil_check(session->commit_transaction(session, + NULL)); + if (i % 1000 == 0 && i != 0) { + if (i % 10000 == 0) + fprintf(stderr, "*"); + else + fprintf(stderr, "."); + } + } + testutil_check(maincur->close(maincur)); + testutil_check(session->close(session, NULL)); + return (NULL); +} + +static void *thread_join(void *arg) +{ + SHARED_OPTS *sharedopts; + TEST_OPTS *opts; + THREAD_ARGS *threadargs; + WT_CURSOR *postcur, *balcur, *flagcur, *joincur; + WT_SESSION *session; + int bal, flag, key, key2, post, ret; + char cfg[128]; + char *extra; + + threadargs = (THREAD_ARGS *)arg; + opts = threadargs->testopts; + sharedopts = threadargs->sharedopts; + + testutil_check(opts->conn->open_session( + opts->conn, NULL, NULL, &session)); + + testutil_check(session->open_cursor( + session, sharedopts->posturi, NULL, NULL, &postcur)); + testutil_check(session->open_cursor( + session, sharedopts->baluri, NULL, NULL, &balcur)); + testutil_check(session->open_cursor( + session, sharedopts->flaguri, NULL, NULL, &flagcur)); + + for (threadargs->joins = 0; threadargs->done == 0; + threadargs->joins++) { + testutil_check(session->open_cursor( + session, sharedopts->joinuri, NULL, NULL, &joincur)); + postcur->set_key(postcur, 54321); + testutil_check(postcur->search(postcur)); + testutil_check(session->join(session, joincur, postcur, + "compare=eq")); + + balcur->set_key(balcur, 0); + testutil_check(balcur->search(balcur)); + if (sharedopts->bloom) + sprintf(cfg, "compare=lt,strategy=bloom,count=%d", + N_RECORDS); + else + sprintf(cfg, "compare=lt"); + testutil_check(session->join(session, joincur, balcur, cfg)); + + flagcur->set_key(flagcur, 0); + testutil_check(flagcur->search(flagcur)); + if (sharedopts->bloom) + sprintf(cfg, "compare=eq,strategy=bloom,count=%d", + N_RECORDS); + else + sprintf(cfg, "compare=eq"); + testutil_check(session->join(session, joincur, flagcur, cfg)); + + /* Expect no values returned */ + ret = joincur->next(joincur); + if (ret == 0) { + /* + * The values may already have been changed, but + * print them for informational purposes. + */ + testutil_check(joincur->get_key(joincur, &key)); + testutil_check(joincur->get_value(joincur, &post, + &bal, &extra, &flag, &key2)); + fprintf(stderr, "FAIL: iteration %d: " + "key=%d/%d, postal_code=%d, balance=%d, flag=%d\n", + threadargs->joins, key, key2, post, bal, flag); + /* Save the results. */ + testutil_check(opts->conn->close(opts->conn, NULL)); + opts->conn = NULL; + return (NULL); + } + testutil_assert(ret == WT_NOTFOUND); + testutil_check(joincur->close(joincur)); + + /* + * Reset the cursors, potentially allowing the insert + * threads to proceed. + */ + testutil_check(postcur->reset(postcur)); + testutil_check(balcur->reset(balcur)); + testutil_check(flagcur->reset(flagcur)); + if (threadargs->joins % 100 == 0) + fprintf(stderr, "J"); + } + testutil_check(postcur->close(postcur)); + testutil_check(balcur->close(balcur)); + testutil_check(flagcur->close(flagcur)); + testutil_check(session->close(session, NULL)); + return (NULL); +} diff --git a/src/third_party/wiredtiger/test/csuite/wt2695_checksum/main.c b/src/third_party/wiredtiger/test/csuite/wt2695_checksum/main.c index dc6f5b5cd87..df6f562f719 100644 --- a/src/third_party/wiredtiger/test/csuite/wt2695_checksum/main.c +++ b/src/third_party/wiredtiger/test/csuite/wt2695_checksum/main.c @@ -34,8 +34,6 @@ void (*custom_die)(void) = NULL; -uint32_t cksum_sw(const void *, size_t); - static inline void check(uint32_t hw, uint32_t sw, size_t len, const char *msg) { @@ -61,57 +59,66 @@ main(void) testutil_check(__wt_random_init_seed(NULL, &rnd)); /* Initialize the WiredTiger library checksum functions. */ - __wt_cksum_init(); + __wt_checksum_init(); /* * Some simple known checksums. */ len = 1; - hw = __wt_cksum(data, len); + hw = __wt_checksum(data, len); check(hw, (uint32_t)0x527d5351, len, "nul x1: hardware"); - sw = cksum_sw(data, len); + sw = __wt_checksum_sw(data, len); check(sw, (uint32_t)0x527d5351, len, "nul x1: software"); len = 2; - hw = __wt_cksum(data, len); + hw = __wt_checksum(data, len); check(hw, (uint32_t)0xf16177d2, len, "nul x2: hardware"); - sw = cksum_sw(data, len); + sw = __wt_checksum_sw(data, len); check(sw, (uint32_t)0xf16177d2, len, "nul x2: software"); len = 3; - hw = __wt_cksum(data, len); + hw = __wt_checksum(data, len); check(hw, (uint32_t)0x6064a37a, len, "nul x3: hardware"); - sw = cksum_sw(data, len); + sw = __wt_checksum_sw(data, len); check(sw, (uint32_t)0x6064a37a, len, "nul x3: software"); len = 4; - hw = __wt_cksum(data, len); + hw = __wt_checksum(data, len); check(hw, (uint32_t)0x48674bc7, len, "nul x4: hardware"); - sw = cksum_sw(data, len); + sw = __wt_checksum_sw(data, len); check(sw, (uint32_t)0x48674bc7, len, "nul x4: software"); len = strlen("123456789"); memcpy(data, "123456789", len); - hw = __wt_cksum(data, len); + hw = __wt_checksum(data, len); check(hw, (uint32_t)0xe3069283, len, "known string #1: hardware"); - sw = cksum_sw(data, len); + sw = __wt_checksum_sw(data, len); check(sw, (uint32_t)0xe3069283, len, "known string #1: software"); len = strlen("The quick brown fox jumps over the lazy dog"); memcpy(data, "The quick brown fox jumps over the lazy dog", len); - hw = __wt_cksum(data, len); + hw = __wt_checksum(data, len); check(hw, (uint32_t)0x22620404, len, "known string #2: hardware"); - sw = cksum_sw(data, len); + sw = __wt_checksum_sw(data, len); check(sw, (uint32_t)0x22620404, len, "known string #2: software"); /* + * Offset the string by 1 to ensure the hardware code handles unaligned + * reads. + */ + hw = __wt_checksum(data + 1, len - 1); + check(hw, (uint32_t)0xae11f7f5, len, "known string #2: hardware"); + sw = __wt_checksum_sw(data + 1, len - 1); + check(sw, (uint32_t)0xae11f7f5, len, "known string #2: software"); + + /* * Checksums of power-of-two data chunks. */ for (i = 0, len = 512; i < 1000; ++i) { for (j = 0; j < len; ++j) data[j] = __wt_random(&rnd) & 0xff; - hw = __wt_cksum(data, len); - sw = cksum_sw(data, len); + hw = __wt_checksum(data, len); + sw = __wt_checksum_sw(data, len); check(hw, sw, len, "random power-of-two"); len *= 2; @@ -126,8 +133,8 @@ main(void) len = __wt_random(&rnd) % DATASIZE; for (j = 0; j < len; ++j) data[j] = __wt_random(&rnd) & 0xff; - hw = __wt_cksum(data, len); - sw = cksum_sw(data, len); + hw = __wt_checksum(data, len); + sw = __wt_checksum_sw(data, len); check(hw, sw, len, "random"); } diff --git a/src/third_party/wiredtiger/test/csuite/wt2695_checksum/sw.c b/src/third_party/wiredtiger/test/csuite/wt2695_checksum/sw.c deleted file mode 100644 index 892d9480bf3..00000000000 --- a/src/third_party/wiredtiger/test/csuite/wt2695_checksum/sw.c +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * Public Domain 2014-2016 MongoDB, Inc. - * 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 "test_util.h" - -/* - * Build the software version of the CRC code. - */ -#define __wt_cksum __wt_cksum_notused -uint32_t __wt_cksum_notused(const void *, size_t); -#define __wt_cksum_init __wt_cksum_init_notused -void __wt_cksum_init_notused(void); - -#include CRC_PATH - -/* - * cksum_sw -- - * Checksum in software. - */ -uint32_t cksum_sw(const void *, size_t); -uint32_t -cksum_sw(const void *chunk, size_t len) -{ - return (__wt_cksum_sw(chunk, len)); -} diff --git a/src/third_party/wiredtiger/test/csuite/wt2853_perf/main.c b/src/third_party/wiredtiger/test/csuite/wt2853_perf/main.c index c57d5ba056c..67ba4a20ada 100644 --- a/src/third_party/wiredtiger/test/csuite/wt2853_perf/main.c +++ b/src/third_party/wiredtiger/test/csuite/wt2853_perf/main.c @@ -86,6 +86,9 @@ main(int argc, char *argv[]) opts = &_opts; sharedopts = &_sharedopts; + + if (testutil_disable_long_tests()) + return (0); memset(opts, 0, sizeof(*opts)); memset(sharedopts, 0, sizeof(*sharedopts)); memset(insert_args, 0, sizeof(insert_args)); @@ -183,7 +186,8 @@ main(int argc, char *argv[]) return (0); } -static void *thread_insert(void *arg) +static void * +thread_insert(void *arg) { TEST_OPTS *opts; THREAD_ARGS *threadargs; @@ -249,7 +253,8 @@ static void *thread_insert(void *arg) return (NULL); } -static void *thread_get(void *arg) +static void * +thread_get(void *arg) { SHARED_OPTS *sharedopts; TEST_OPTS *opts; diff --git a/src/third_party/wiredtiger/test/format/config.h b/src/third_party/wiredtiger/test/format/config.h index 16fffb6fafe..6e3f5473479 100644 --- a/src/third_party/wiredtiger/test/format/config.h +++ b/src/third_party/wiredtiger/test/format/config.h @@ -70,8 +70,8 @@ static CONFIG c[] = { C_BOOL, 90, 0, 0, &g.c_auto_throttle, NULL }, { "backups", - "if backups are enabled", /* 5% */ - C_BOOL, 5, 0, 0, &g.c_backups, NULL }, + "if backups are enabled", /* 20% */ + C_BOOL, 20, 0, 0, &g.c_backups, NULL }, { "bitcnt", "number of bits for fixed-length column-store files", @@ -203,8 +203,8 @@ static CONFIG c[] = { C_BOOL, 0, 0, 0, &g.c_leak_memory, NULL }, { "logging", - "if logging configured", /* 30% */ - C_BOOL, 30, 0, 0, &g.c_logging, NULL }, + "if logging configured", /* 50% */ + C_BOOL, 50, 0, 0, &g.c_logging, NULL }, { "logging_archive", "if log file archival configured", /* 50% */ diff --git a/src/third_party/wiredtiger/test/format/format.h b/src/third_party/wiredtiger/test/format/format.h index ece30601cf0..047be552308 100644 --- a/src/third_party/wiredtiger/test/format/format.h +++ b/src/third_party/wiredtiger/test/format/format.h @@ -239,7 +239,7 @@ typedef struct { } GLOBAL; extern GLOBAL g; -typedef struct { +typedef struct WT_COMPILER_TYPE_ALIGN(WT_CACHE_LINE_ALIGNMENT) { WT_RAND_STATE rnd; /* thread RNG state */ uint64_t search; /* operations */ @@ -261,7 +261,7 @@ typedef struct { #define TINFO_COMPLETE 2 /* Finished */ #define TINFO_JOINED 3 /* Resolved */ volatile int state; /* state */ -} TINFO WT_COMPILER_TYPE_ALIGN(WT_CACHE_LINE_ALIGNMENT); +} TINFO; #ifdef HAVE_BERKELEY_DB void bdb_close(void); diff --git a/src/third_party/wiredtiger/test/format/rebalance.c b/src/third_party/wiredtiger/test/format/rebalance.c index d35dcec1d53..5fd86ef3317 100644 --- a/src/third_party/wiredtiger/test/format/rebalance.c +++ b/src/third_party/wiredtiger/test/format/rebalance.c @@ -42,7 +42,8 @@ wts_rebalance(void) /* Dump the current object. */ (void)snprintf(cmd, sizeof(cmd), - "../../wt -h %s dump -f %s/rebalance.orig %s", + ".." DIR_DELIM_STR ".." DIR_DELIM_STR "wt" + " -h %s dump -f %s/rebalance.orig %s", g.home, g.home, g.uri); testutil_checkfmt(system(cmd), "command failed: %s", cmd); @@ -66,13 +67,18 @@ wts_rebalance(void) wts_close(); (void)snprintf(cmd, sizeof(cmd), - "../../wt -h %s dump -f %s/rebalance.new %s", + ".." DIR_DELIM_STR ".." DIR_DELIM_STR "wt" + " -h %s dump -f %s/rebalance.new %s", g.home, g.home, g.uri); testutil_checkfmt(system(cmd), "command failed: %s", cmd); /* Compare the old/new versions of the object. */ (void)snprintf(cmd, sizeof(cmd), +#ifdef _WIN32 + "fc /b %s\\rebalance.orig %s\\rebalance.new > NUL", +#else "cmp %s/rebalance.orig %s/rebalance.new > /dev/null", +#endif g.home, g.home); testutil_checkfmt(system(cmd), "command failed: %s", cmd); } diff --git a/src/third_party/wiredtiger/test/format/util.c b/src/third_party/wiredtiger/test/format/util.c index cebe2153b3e..667f6d6bcb1 100644 --- a/src/third_party/wiredtiger/test/format/util.c +++ b/src/third_party/wiredtiger/test/format/util.c @@ -319,17 +319,23 @@ path_setup(const char *home) */ #undef CMD #ifdef _WIN32 -#define CMD "test -e %s || mkdir %s; " \ - "cd %s && del /s /q * >:nul && rd /s /q KVS; " \ - "mkdir KVS" +#define CMD "del /q rand.copy & " \ + "(IF EXIST %s\\rand copy /y %s\\rand rand.copy) & " \ + "(IF EXIST %s rd /s /q %s) & mkdir %s & " \ + "(IF EXIST rand.copy copy rand.copy %s\\rand) & " \ + "cd %s & mkdir KVS" + len = strlen(g.home) * 7 + strlen(CMD) + 1; + g.home_init = dmalloc(len); + snprintf(g.home_init, len, CMD, + g.home, g.home, g.home, g.home, g.home, g.home, g.home); #else #define CMD "test -e %s || mkdir %s; " \ "cd %s > /dev/null && rm -rf `ls | sed /rand/d`; " \ "mkdir KVS" -#endif len = strlen(g.home) * 3 + strlen(CMD) + 1; g.home_init = dmalloc(len); snprintf(g.home_init, len, CMD, g.home, g.home, g.home); +#endif /* Primary backup directory. */ len = strlen(g.home) + strlen("BACKUP") + 2; @@ -342,7 +348,7 @@ path_setup(const char *home) */ #undef CMD #ifdef _WIN32 -#define CMD "del %s/%s %s/%s /s /q >:nul && mkdir %s/%s %s/%s" +#define CMD "rd /s /q %s\\%s %s\\%s & mkdir %s\\%s %s\\%s" #else #define CMD "rm -rf %s/%s %s/%s && mkdir %s/%s %s/%s" #endif diff --git a/src/third_party/wiredtiger/test/format/wts.c b/src/third_party/wiredtiger/test/format/wts.c index 9acca409d6e..74c4bb902b3 100644 --- a/src/third_party/wiredtiger/test/format/wts.c +++ b/src/third_party/wiredtiger/test/format/wts.c @@ -307,15 +307,16 @@ wts_init(void) /* * Ensure that we can service at least one operation per-thread - * concurrently without filling the cache with pinned pages. We - * choose a multiplier of three because the max configurations control - * on disk size and in memory pages are often significantly larger - * than their disk counterparts. + * concurrently without filling the cache with pinned pages. We choose + * a multiplier of three because the max configurations control on disk + * size and in memory pages are often significantly larger than their + * disk counterparts. We also apply the default eviction_dirty_trigger + * of 20% so that workloads don't get stuck with dirty pages in cache. */ maxintlpage = 1U << g.c_intl_page_max; maxleafpage = 1U << g.c_leaf_page_max; while (3 * g.c_threads * (maxintlpage + maxleafpage) > - g.c_cache << 20) { + (g.c_cache << 20) / 5) { if (maxleafpage <= 512 && maxintlpage <= 512) break; if (maxintlpage > 512) diff --git a/src/third_party/wiredtiger/test/java/com/wiredtiger/test/ConcurrentCloseTest.java b/src/third_party/wiredtiger/test/java/com/wiredtiger/test/ConcurrentCloseTest.java new file mode 100644 index 00000000000..fece0353bf0 --- /dev/null +++ b/src/third_party/wiredtiger/test/java/com/wiredtiger/test/ConcurrentCloseTest.java @@ -0,0 +1,179 @@ +/*- + * Public Domain 2014-2016 MongoDB, Inc. + * 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. + */ +package com.wiredtiger.test; + +import com.wiredtiger.db.Connection; +import com.wiredtiger.db.Cursor; +import com.wiredtiger.db.Session; +import com.wiredtiger.db.WiredTigerException; +import com.wiredtiger.db.wiredtiger; + +import static org.junit.Assert.assertEquals; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.junit.Assert; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/* + * Test multiple threads concurrently inserting and reading. + * Each insert thread opens and closes for each record, so the + * test stresses the concurrency of these calls in particular. + * This is a test case for a problem reported in WT-2788. + */ +class InsertThread extends Thread { + private Connection conn; + private int threadId; + + public InsertThread(Connection conn, int threadId) { + this.conn = conn; + this.threadId = threadId; + } + + public void run() + { + try { + int ret; + for (int i = 0; i < 500; i++) { + Session session = conn.open_session(null); + Cursor cursor = session.open_cursor("table:cclose", null, + "overwrite"); + cursor.putKeyString("key"+threadId + "-" + i); + cursor.putValueString("value1"); + ret = cursor.insert(); + cursor.close(); + ret = session.close(null); + } + } catch (WiredTigerException wte) { + System.err.println("Exception " + wte); + } + } +} + +class ScanThread extends Thread { + private Connection conn; + + public ScanThread(Connection conn) { + this.conn = conn; + } + + public void run() + { + try { + int ret; + + Session session = conn.open_session(null); + Cursor cursor = session.open_cursor("table:cclose", null, null); + + /* Show all records. */ + while ((ret = cursor.next()) == 0) { + String key = cursor.getKeyString(); + String value = cursor.getValueString(); + System.out.println("Got record: " + key + " : " + value); + } + if (ret != wiredtiger.WT_NOTFOUND) + System.err.println("Cursor.next: " + + wiredtiger.wiredtiger_strerror(ret)); + cursor.close(); + session.close(null); + } catch (WiredTigerException wte) { + System.err.println("Exception " + wte); + } + } +} + +public class ConcurrentCloseTest { + Connection conn; + Session session; + + public static String home; + + public static final int NUM_THREADS = 10; + + @Test + public void test_threads() + { + setup(); + try { + List<Thread> threads = new ArrayList<Thread>(); + int i, ret; + + ret = session.create("table:cclose", "key_format=S,value_format=S"); + Cursor cursor = session.open_cursor("table:cclose", null, + "overwrite"); + cursor.putKeyString("key1"); + cursor.putValueString("value1"); + ret = cursor.insert(); + cursor.close(); + ret = session.close(null); + + for (i = 0; i < NUM_THREADS; i++) { + Thread insertThread = new InsertThread(conn, i); + Thread scanThread = new InsertThread(conn, i); + insertThread.start(); + scanThread.start(); + threads.add(insertThread); + threads.add(scanThread); + } + + for (Thread thread : threads) + try { + thread.join(); + ret = -1; + } + catch (InterruptedException ie) { + } + + ret = conn.close(null); + System.exit(ret); + } + catch (WiredTigerException wte) { + System.err.println("Exception: " + wte); + wte.printStackTrace(); + System.exit(1); + } + } + + private void setup() { + conn = wiredtiger.open("WT_HOME", "create"); + session = conn.open_session(null); + } + + private void teardown() { + session.close(""); + conn.close(""); + } + + +} diff --git a/src/third_party/wiredtiger/test/manydbs/manydbs.c b/src/third_party/wiredtiger/test/manydbs/manydbs.c index e485e73067f..c5c9a9a7ccd 100644 --- a/src/third_party/wiredtiger/test/manydbs/manydbs.c +++ b/src/third_party/wiredtiger/test/manydbs/manydbs.c @@ -93,7 +93,7 @@ get_stat(WT_SESSION *stat_session, int stat_field, uint64_t *valuep) return (ret); } -static int +static void run_ops(int dbs) { WT_ITEM data; @@ -119,7 +119,6 @@ run_ops(int dbs) testutil_check(cursors[db]->insert(cursors[db])); } } - return (0); } int @@ -211,7 +210,7 @@ main(int argc, char *argv[]) WT_STAT_CONN_COND_AUTO_WAIT_RESET, &cond_reset_orig[i])); for (i = 0; i < MAX_IDLE_TIME; i += IDLE_INCR) { if (!idle) - testutil_check(run_ops(dbs)); + run_ops(dbs); printf("Sleep %d (%d of %d)\n", IDLE_INCR, i, MAX_IDLE_TIME); sleep(IDLE_INCR); } diff --git a/src/third_party/wiredtiger/test/mciproject.yml b/src/third_party/wiredtiger/test/mciproject.yml index ff58d1839cf..eb74914eb46 100644 --- a/src/third_party/wiredtiger/test/mciproject.yml +++ b/src/third_party/wiredtiger/test/mciproject.yml @@ -128,6 +128,20 @@ tasks: ./test/fops/t fi + - name: format + depends_on: + - name: compile + commands: + - func: "fetch binaries" + - command: shell.exec + params: + working_dir: "wiredtiger" + script: | + set -o errexit + set -o verbose + # format assumes we run it from the format directory + cmd.exe /c "cd test\\format && ..\\..\\t_format.exe reverse=0 encryption=none logging_compression=none runs=20" + buildvariants: - name: ubuntu1404 display_name: Ubuntu 14.04 @@ -165,6 +179,7 @@ buildvariants: - name: compile - name: compile-windows-alt - name: unit-test + #- name: format - Enable when we have a solution for hangs and crashses - name: fops - name: osx-1010 diff --git a/src/third_party/wiredtiger/test/salvage/salvage.c b/src/third_party/wiredtiger/test/salvage/salvage.c index c3349188623..bad0167ca8e 100644 --- a/src/third_party/wiredtiger/test/salvage/salvage.c +++ b/src/third_party/wiredtiger/test/salvage/salvage.c @@ -602,8 +602,8 @@ copy(u_int gen, u_int recno) dsk->recno = recno; dsk->write_gen = gen; blk = WT_BLOCK_HEADER_REF(buf); - blk->cksum = 0; - blk->cksum = __wt_cksum(dsk, PSIZE); + blk->checksum = 0; + blk->checksum = __wt_checksum(dsk, PSIZE); CHECK(fwrite(buf, 1, PSIZE, ofp) == PSIZE); } diff --git a/src/third_party/wiredtiger/test/suite/test_join06.py b/src/third_party/wiredtiger/test/suite/test_join06.py index 5fedd365712..a6681cdccd0 100644 --- a/src/third_party/wiredtiger/test/suite/test_join06.py +++ b/src/third_party/wiredtiger/test/suite/test_join06.py @@ -37,8 +37,10 @@ class test_join06(wttest.WiredTigerTestCase): nentries = 1000 isoscen = [ - ('isolation_read_uncommitted', dict(uncommitted=True)), - ('isolation_default', dict(uncommitted=False)) + ('isolation_read_uncommitted', dict(isolation='read-uncommitted')), + ('isolation_read_committed', dict(isolation='read-committed')), + ('isolation_default', dict(isolation='')), + ('isolation_snapshot', dict(isolation='snapshot')) ] bloomscen = [ @@ -79,8 +81,8 @@ class test_join06(wttest.WiredTigerTestCase): # TODO: needed? #self.reopen_conn() - if self.uncommitted: - self.session.begin_transaction('isolation=read-uncommitted') + if self.isolation != '': + self.session.begin_transaction('isolation=' + self.isolation) jc = self.session.open_cursor('join:table:join06', None, None) c0 = self.session.open_cursor('index:join06:index0', None, None) @@ -96,7 +98,7 @@ class test_join06(wttest.WiredTigerTestCase): self.assertEquals(0, c1.search()) self.session.join(jc, c1, joinconfig) - if self.uncommitted and self.bloom: + if self.isolation == 'read-uncommitted' and self.bloom: # Make sure that read-uncommitted with Bloom is not allowed. # This is detected on the first next() operation. msg = '/cannot be used with read-uncommitted/' @@ -106,7 +108,7 @@ class test_join06(wttest.WiredTigerTestCase): # Changes made in another session may or may not be visible to us, # depending on the isolation level. - if self.uncommitted: + if self.isolation == 'read-uncommitted': # isolation level is read-uncommitted, so we will see # additions deletions made in our other session. mbr = set(range(525,1000,10)) | set(range(55,100,10)) | set([520]) @@ -116,12 +118,11 @@ class test_join06(wttest.WiredTigerTestCase): mbr = set(range(520,600)) | set(range(53,60)) altered = False - while jc.next() == 0: [k] = jc.get_keys() [v0,v1] = jc.get_values() #self.tty('GOT: ' + str(k) + ': ' + str(jc.get_values())) - if altered and self.uncommitted: + if altered and self.isolation == 'read-uncommitted': self.assertEquals(self.gen_values2(k), [v0, v1]) else: self.assertEquals(self.gen_values(k), [v0, v1]) @@ -150,7 +151,7 @@ class test_join06(wttest.WiredTigerTestCase): jc.close() c1.close() c0.close() - if self.uncommitted: + if self.isolation != '': self.session.commit_transaction() self.session.drop('table:join06') diff --git a/src/third_party/wiredtiger/test/utility/misc.c b/src/third_party/wiredtiger/test/utility/misc.c index dffd29a5b6a..096bc752726 100644 --- a/src/third_party/wiredtiger/test/utility/misc.c +++ b/src/third_party/wiredtiger/test/utility/misc.c @@ -82,12 +82,22 @@ testutil_clean_work_dir(char *dir) int ret; char *buf; +#ifdef _WIN32 /* Additional bytes for the Windows rd command. */ + len = 2 * strlen(dir) + strlen(RM_COMMAND) + + strlen(DIR_EXISTS_COMMAND) + 4; + if ((buf = malloc(len)) == NULL) + testutil_die(ENOMEM, "Failed to allocate memory"); + + snprintf(buf, len, "%s %s %s %s", DIR_EXISTS_COMMAND, dir, + RM_COMMAND, dir); +#else len = strlen(dir) + strlen(RM_COMMAND) + 1; if ((buf = malloc(len)) == NULL) testutil_die(ENOMEM, "Failed to allocate memory"); snprintf(buf, len, "%s%s", RM_COMMAND, dir); +#endif if ((ret = system(buf)) != 0 && ret != ENOENT) testutil_die(ret, "%s", buf); @@ -139,6 +149,23 @@ testutil_cleanup(TEST_OPTS *opts) } /* + * testutil_disable_long_tests -- + * Return if TESTUTIL_DISABLE_LONG_TESTS is set. + */ +bool +testutil_disable_long_tests(void) +{ + const char *res; + + if (__wt_getenv(NULL, + "TESTUTIL_DISABLE_LONG_TESTS", &res) == WT_NOTFOUND) + return (false); + + free((void *)res); + return (true); +} + +/* * dcalloc -- * Call calloc, dying on failure. */ diff --git a/src/third_party/wiredtiger/test/utility/parse_opts.c b/src/third_party/wiredtiger/test/utility/parse_opts.c index 4054f318259..08aeafa9617 100644 --- a/src/third_party/wiredtiger/test/utility/parse_opts.c +++ b/src/third_party/wiredtiger/test/utility/parse_opts.c @@ -47,7 +47,7 @@ testutil_parse_opts(int argc, char * const *argv, TEST_OPTS *opts) opts->running = true; opts->verbose = false; - if ((opts->progname = strrchr(argv[0], '/')) == NULL) + if ((opts->progname = strrchr(argv[0], DIR_DELIM)) == NULL) opts->progname = argv[0]; else ++opts->progname; diff --git a/src/third_party/wiredtiger/test/utility/test_util.h b/src/third_party/wiredtiger/test/utility/test_util.h index 821e06084d2..3c1d0e2630a 100644 --- a/src/third_party/wiredtiger/test/utility/test_util.h +++ b/src/third_party/wiredtiger/test/utility/test_util.h @@ -29,9 +29,12 @@ #ifdef _WIN32 #define DIR_DELIM '\\' + #define DIR_DELIM_STR "\\" + #define DIR_EXISTS_COMMAND "IF EXIST " #define RM_COMMAND "rd /s /q " #else #define DIR_DELIM '/' + #define DIR_DELIM_STR "/" #define RM_COMMAND "rm -rf " #endif @@ -118,6 +121,7 @@ void *dstrdup(const void *); void *dstrndup(const char *, size_t); void testutil_clean_work_dir(char *); void testutil_cleanup(TEST_OPTS *); +bool testutil_disable_long_tests(void); void testutil_make_work_dir(char *); int testutil_parse_opts(int, char * const *, TEST_OPTS *); void testutil_work_dir_from_path(char *, size_t, const char *); diff --git a/src/third_party/wiredtiger/test/windows/windows_shim.c b/src/third_party/wiredtiger/test/windows/windows_shim.c index 6e8da8f86d4..b161b29c2fa 100644 --- a/src/third_party/wiredtiger/test/windows/windows_shim.c +++ b/src/third_party/wiredtiger/test/windows/windows_shim.c @@ -105,6 +105,17 @@ pthread_rwlock_unlock(pthread_rwlock_t *rwlock) } int +pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock) +{ + if (TryAcquireSRWLockExclusive(&rwlock->rwlock)) { + rwlock->exclusive_locked = GetCurrentThreadId(); + return (0); + } + + return (EBUSY); +} + +int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock) { AcquireSRWLockExclusive(&rwlock->rwlock); diff --git a/src/third_party/wiredtiger/test/windows/windows_shim.h b/src/third_party/wiredtiger/test/windows/windows_shim.h index f32edce88e7..a6050e92bca 100644 --- a/src/third_party/wiredtiger/test/windows/windows_shim.h +++ b/src/third_party/wiredtiger/test/windows/windows_shim.h @@ -30,6 +30,7 @@ #define WIN32_LEAN_AND_MEAN #include <windows.h> +#include <errno.h> #include <stdint.h> #include <direct.h> #include <io.h> @@ -109,6 +110,7 @@ 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_trywrlock(pthread_rwlock_t *); int pthread_rwlock_wrlock(pthread_rwlock_t *); int pthread_create(pthread_t *, const pthread_attr_t *, |