diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2015-08-05 17:54:11 +1000 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2015-08-05 17:54:11 +1000 |
commit | da99fbb759a5c30cbfa836e7996c9994d9586e86 (patch) | |
tree | 27efa6b23c604eabb6ad81fce866ca2063207050 | |
parent | a6e130f1da240de9e6a39fe088c9b3ada72903af (diff) | |
download | mongo-da99fbb759a5c30cbfa836e7996c9994d9586e86.tar.gz |
Update test/format's use of the random number generator to match develop.
-rw-r--r-- | dist/s_string.ok | 1 | ||||
-rw-r--r-- | test/format/backup.c | 2 | ||||
-rw-r--r-- | test/format/bdb.c | 4 | ||||
-rw-r--r-- | test/format/bulk.c | 6 | ||||
-rw-r--r-- | test/format/compact.c | 2 | ||||
-rw-r--r-- | test/format/config.c | 14 | ||||
-rw-r--r-- | test/format/config.h | 2 | ||||
-rw-r--r-- | test/format/format.h | 8 | ||||
-rw-r--r-- | test/format/ops.c | 87 | ||||
-rw-r--r-- | test/format/salvage.c | 2 | ||||
-rw-r--r-- | test/format/util.c | 39 | ||||
-rw-r--r-- | test/format/wts.c | 10 |
12 files changed, 90 insertions, 87 deletions
diff --git a/dist/s_string.ok b/dist/s_string.ok index a966134e5ce..2bdd1d88a54 100644 --- a/dist/s_string.ok +++ b/dist/s_string.ok @@ -809,6 +809,7 @@ minorp minprefix mkdir mmap +mmrand mnt msecs msg diff --git a/test/format/backup.c b/test/format/backup.c index d70353e282c..3b95ea92b5e 100644 --- a/test/format/backup.c +++ b/test/format/backup.c @@ -104,7 +104,7 @@ backup(void *arg) * Perform a backup at somewhere under 10 seconds (so we get at * least one done), and then at 45 second intervals. */ - for (period = MMRAND(1, 10);; period = 45) { + for (period = mmrand(NULL, 1, 10);; period = 45) { /* Sleep for short periods so we don't make the run wait. */ while (period > 0 && !g.workers_finished) { --period; diff --git a/test/format/bdb.c b/test/format/bdb.c index 254dd95e1d3..fec23112549 100644 --- a/test/format/bdb.c +++ b/test/format/bdb.c @@ -147,7 +147,7 @@ bdb_read(uint64_t keyno, void *valuep, size_t *valuesizep, int *notfoundp) size_t size; int ret; - key_gen(keybuf, &size, keyno, 0); + key_gen(keybuf, &size, keyno); key.data = keybuf; key.size = (uint32_t)size; @@ -193,7 +193,7 @@ bdb_remove(uint64_t keyno, int *notfoundp) size_t size; int ret; - key_gen(keybuf, &size, keyno, 0); + key_gen(keybuf, &size, keyno); key.data = keybuf; key.size = (uint32_t)size; diff --git a/test/format/bulk.c b/test/format/bulk.c index c91338b9ca1..ad9bc180e5e 100644 --- a/test/format/bulk.c +++ b/test/format/bulk.c @@ -60,7 +60,7 @@ wts_load(void) /* Set up the default key buffer. */ key_gen_setup(&keybuf); - val_gen_setup(&valbuf); + val_gen_setup(NULL, &valbuf); for (;;) { if (++g.key_cnt > g.c_rows) { @@ -72,9 +72,9 @@ wts_load(void) if (g.key_cnt % 100 == 0) track("bulk load", g.key_cnt, NULL); - key_gen(keybuf, &key.size, (uint64_t)g.key_cnt, 0); + key_gen(keybuf, &key.size, (uint64_t)g.key_cnt); key.data = keybuf; - value_gen(valbuf, &value.size, (uint64_t)g.key_cnt); + val_gen(NULL, valbuf, &value.size, (uint64_t)g.key_cnt); value.data = valbuf; switch (g.type) { diff --git a/test/format/compact.c b/test/format/compact.c index 60c99db13c3..ad603504023 100644 --- a/test/format/compact.c +++ b/test/format/compact.c @@ -55,7 +55,7 @@ compact(void *arg) * Perform compaction at somewhere under 15 seconds (so we get at * least one done), and then at 23 second intervals. */ - for (period = MMRAND(1, 15);; period = 23) { + for (period = mmrand(NULL, 1, 15);; period = 23) { /* Sleep for short periods so we don't make the run wait. */ while (period > 0 && !g.workers_finished) { --period; diff --git a/test/format/config.c b/test/format/config.c index 625e26422fd..84afedb0a63 100644 --- a/test/format/config.c +++ b/test/format/config.c @@ -58,7 +58,7 @@ config_setup(void) * them. */ if (!config_is_perm("data_source")) - switch (MMRAND(1, 3)) { + switch (mmrand(NULL, 1, 3)) { case 1: config_single("data_source=file", 0); break; @@ -71,7 +71,7 @@ config_setup(void) } if (!config_is_perm("file_type")) - switch (DATASOURCE("lsm") ? 5 : MMRAND(1, 10)) { + switch (DATASOURCE("lsm") ? 5 : mmrand(NULL, 1, 10)) { case 1: config_single("file_type=fix", 0); break; @@ -118,7 +118,7 @@ config_setup(void) * the min, 0 otherwise. */ if (F_ISSET(cp, C_BOOL)) - *cp->v = MMRAND(1, 100) <= cp->min ? 1 : 0; + *cp->v = mmrand(NULL, 1, 100) <= cp->min ? 1 : 0; else *cp->v = CONF_RAND(cp); } @@ -162,7 +162,7 @@ config_setup(void) g.c_cache = 30 * g.c_chunk_size; if (!config_is_perm("insert_pct")) - g.c_insert_pct = MMRAND(50, 85); + g.c_insert_pct = mmrand(NULL, 50, 85); } /* Make the default maximum-run length 20 minutes. */ @@ -200,7 +200,7 @@ config_checksum(void) { /* Choose a checksum mode if nothing was specified. */ if (!config_is_perm("checksum")) - switch (MMRAND(1, 10)) { + switch (mmrand(NULL, 1, 10)) { case 1: /* 10% */ config_single("checksum=on", 0); break; @@ -231,7 +231,7 @@ config_compression(void) */ if (!config_is_perm("compression")) { cstr = "compression=none"; - switch (MMRAND(1, 20)) { + switch (mmrand(NULL, 1, 20)) { case 1: case 2: case 3: case 4: /* 20% no compression */ break; case 5: case 6: /* 10% bzip */ @@ -272,7 +272,7 @@ config_isolation(void) */ if (!config_is_perm("isolation")) { /* Avoid "maybe uninitialized" warnings. */ - switch (MMRAND(1, 4)) { + switch (mmrand(NULL, 1, 4)) { case 1: cstr = "isolation=random"; break; diff --git a/test/format/config.h b/test/format/config.h index 3a849a36c26..2d2b4e03010 100644 --- a/test/format/config.h +++ b/test/format/config.h @@ -61,7 +61,7 @@ typedef struct { * Get a random value between a config min/max pair (inclusive for both min * and max). */ -#define CONF_RAND(cp) MMRAND((cp)->min, (cp)->maxrand) +#define CONF_RAND(cp) mmrand(NULL, (cp)->min, (cp)->maxrand) static CONFIG c[] = { { "abort", diff --git a/test/format/format.h b/test/format/format.h index a72ad6fc66e..650402ea775 100644 --- a/test/format/format.h +++ b/test/format/format.h @@ -54,8 +54,7 @@ #include "windows_shim.h" #endif -#include <wiredtiger.h> -#include <wiredtiger_ext.h> +#include <wt_internal.h> #ifdef BDB #include <db.h> @@ -103,9 +102,6 @@ extern WT_EXTENSION_API *wt_api; #define F_ISSET(p, mask) ((p)->flags & ((uint32_t)(mask))) #define F_SET(p, mask) ((p)->flags |= ((uint32_t)(mask))) -/* Get a random value between a min/max pair. */ -#define MMRAND(min, max) (rng() % (((max) + 1) - (min)) + (min)) - #define WT_NAME "wt" /* Object name */ #define DATASOURCE(v) (strcmp(v, g.c_data_source) == 0 ? 1 : 0) @@ -308,8 +304,6 @@ void key_gen(uint8_t *, size_t *, uint64_t); void key_gen_insert(WT_RAND_STATE *, uint8_t *, size_t *, uint64_t); void key_gen_setup(uint8_t **); void key_len_setup(void); -void key_gen_setup(uint8_t **); -void key_gen(uint8_t *, size_t *, uint64_t, int); void path_setup(const char *); uint32_t rng(WT_RAND_STATE *); void track(const char *, uint64_t, TINFO *); diff --git a/test/format/ops.c b/test/format/ops.c index 84ed02a8750..2a2ff91fbf0 100644 --- a/test/format/ops.c +++ b/test/format/ops.c @@ -28,17 +28,17 @@ #include "format.h" -static int col_insert(WT_CURSOR *, WT_ITEM *, WT_ITEM *, uint64_t *); +static int col_insert(TINFO *, WT_CURSOR *, WT_ITEM *, WT_ITEM *, uint64_t *); static int col_remove(WT_CURSOR *, WT_ITEM *, uint64_t, int *); -static int col_update(WT_CURSOR *, WT_ITEM *, WT_ITEM *, uint64_t); +static int col_update(TINFO *, WT_CURSOR *, WT_ITEM *, WT_ITEM *, uint64_t); static int nextprev(WT_CURSOR *, int, int *); static int notfound_chk(const char *, int, int, uint64_t); static void *ops(void *); static void print_item(const char *, WT_ITEM *); static int read_row(WT_CURSOR *, WT_ITEM *, uint64_t); -static int row_insert(WT_CURSOR *, WT_ITEM *, WT_ITEM *, uint64_t); +static int row_insert(TINFO *, WT_CURSOR *, WT_ITEM *, WT_ITEM *, uint64_t); static int row_remove(WT_CURSOR *, WT_ITEM *, uint64_t, int *); -static int row_update(WT_CURSOR *, WT_ITEM *, WT_ITEM *, uint64_t); +static int row_update(TINFO *, WT_CURSOR *, WT_ITEM *, WT_ITEM *, uint64_t); static void table_append_init(void); /* @@ -199,7 +199,7 @@ ops_session_config(WT_RAND_STATE *rnd) * The only current session configuration is the isolation level. */ if ((v = g.c_isolation_flag) == ISOLATION_RANDOM) - v = MMRAND(2, 4); + v = mmrand(rnd, 2, 4); switch (v) { case ISOLATION_READ_UNCOMMITTED: return ("isolation=read-uncommitted"); @@ -234,7 +234,7 @@ ops(void *arg) /* Set up the default key and value buffers. */ key_gen_setup(&keybuf); - val_gen_setup(&valbuf); + val_gen_setup(&tinfo->rnd, &valbuf); /* Set the first operation where we'll create sessions and cursors. */ session_op = 0; @@ -242,7 +242,7 @@ ops(void *arg) cursor = cursor_insert = NULL; /* Set the first operation where we'll perform checkpoint operations. */ - ckpt_op = g.c_checkpoints ? MMRAND(100, 10000) : 0; + ckpt_op = g.c_checkpoints ? mmrand(&tinfo->rnd, 100, 10000) : 0; ckpt_available = 0; for (intxn = 0; !tinfo->quit; ++tinfo->ops) { @@ -266,8 +266,8 @@ ops(void *arg) (ret = session->close(session, NULL)) != 0) die(ret, "session.close"); - if ((ret = conn->open_session( - conn, NULL, ops_session_config(), &session)) != 0) + if ((ret = conn->open_session(conn, NULL, + ops_session_config(&tinfo->rnd), &session)) != 0) die(ret, "connection.open_session"); /* @@ -282,7 +282,7 @@ ops(void *arg) * checkpoints. */ if (!SINGLETHREADED && !DATASOURCE("lsm") && - ckpt_available && MMRAND(1, 10) == 1) { + ckpt_available && mmrand(&tinfo->rnd, 1, 10) == 1) { if ((ret = session->open_cursor(session, g.uri, NULL, ckpt_name, &cursor)) != 0) die(ret, "session.open_cursor"); @@ -315,7 +315,7 @@ ops(void *arg) die(ret, "session.open_cursor"); /* Pick the next session/cursor close/open. */ - session_op += 100 * MMRAND(1, 50); + session_op += 100 * mmrand(&tinfo->rnd, 1, 50); /* Updates supported. */ readonly = 0; @@ -331,7 +331,8 @@ ops(void *arg) * checkpoint. */ if (DATASOURCE("helium") || DATASOURCE("kvsbdb") || - DATASOURCE("lsm") || readonly || MMRAND(1, 5) == 1) + DATASOURCE("lsm") || readonly || + mmrand(&tinfo->rnd, 1, 5) == 1) ckpt_config = NULL; else { (void)snprintf(ckpt_name, sizeof(ckpt_name), @@ -366,14 +367,15 @@ ops(void *arg) ckpt_available = 1; /* Pick the next checkpoint operation. */ - ckpt_op += 1000 * MMRAND(5, 20); + ckpt_op += 1000 * mmrand(&tinfo->rnd, 5, 20); } /* * If we're not single-threaded and we're not in a transaction, * start a transaction 20% of the time. */ - if (!SINGLETHREADED && !intxn && MMRAND(1, 10) >= 8) { + if (!SINGLETHREADED && !intxn && + mmrand(&tinfo->rnd, 1, 10) >= 8) { if ((ret = session->begin_transaction(session, NULL)) != 0) die(ret, "session.begin_transaction"); @@ -382,7 +384,7 @@ ops(void *arg) insert = notfound = 0; - keyno = MMRAND(1, g.rows); + keyno = mmrand(&tinfo->rnd, 1, g.rows); key.data = keybuf; value.data = valbuf; @@ -393,7 +395,7 @@ ops(void *arg) * of deletes will mean fewer inserts and writes. Modifications * are always followed by a read to confirm it worked. */ - op = readonly ? UINT32_MAX : (uint32_t)(rng() % 100); + op = readonly ? UINT32_MAX : (uint32_t)(rng(&tinfo->rnd) % 100); if (op < g.c_delete_pct) { ++tinfo->remove; switch (g.type) { @@ -415,7 +417,8 @@ ops(void *arg) ++tinfo->insert; switch (g.type) { case ROW: - if (row_insert(cursor, &key, &value, keyno)) + if (row_insert( + tinfo, cursor, &key, &value, keyno)) goto deadlock; insert = 1; break; @@ -430,7 +433,7 @@ ops(void *arg) goto skip_insert; /* Insert, then reset the insert cursor. */ - if (col_insert( + if (col_insert(tinfo, cursor_insert, &key, &value, &keyno)) goto deadlock; if ((ret = @@ -445,12 +448,14 @@ ops(void *arg) ++tinfo->update; switch (g.type) { case ROW: - if (row_update(cursor, &key, &value, keyno)) + if (row_update( + tinfo, cursor, &key, &value, keyno)) goto deadlock; break; case FIX: case VAR: -skip_insert: if (col_update(cursor, &key, &value, keyno)) +skip_insert: if (col_update( + tinfo, cursor, &key, &value, keyno)) goto deadlock; break; } @@ -468,8 +473,8 @@ skip_insert: if (col_update(cursor, &key, &value, keyno)) * a random direction. */ if (!insert) { - dir = (int)MMRAND(0, 1); - for (np = 0; np < MMRAND(1, 8); ++np) { + dir = (int)mmrand(&tinfo->rnd, 0, 1); + for (np = 0; np < mmrand(&tinfo->rnd, 1, 8); ++np) { if (notfound) break; if (nextprev(cursor, dir, ¬found)) @@ -491,7 +496,7 @@ skip_insert: if (col_update(cursor, &key, &value, keyno)) * rollback 10% of the time. */ if (intxn) - switch (MMRAND(1, 10)) { + switch (mmrand(&tinfo->rnd, 1, 10)) { case 1: case 2: case 3: case 4: /* 40% */ if ((ret = session->commit_transaction( session, NULL)) != 0) @@ -547,7 +552,7 @@ wts_read_scan(void) /* Open a session and cursor pair. */ if ((ret = conn->open_session( - conn, NULL, ops_session_config(), &session)) != 0) + conn, NULL, ops_session_config(NULL), &session)) != 0) die(ret, "connection.open_session"); if ((ret = session->open_cursor( session, g.uri, NULL, NULL, &cursor)) != 0) @@ -555,7 +560,7 @@ wts_read_scan(void) /* Check a random subset of the records using the key. */ for (last_cnt = cnt = 0; cnt < g.key_cnt;) { - cnt += rng() % 17 + 1; + cnt += rng(NULL) % 17 + 1; if (cnt > g.rows) cnt = g.rows; if (cnt - last_cnt > 1000) { @@ -600,7 +605,7 @@ read_row(WT_CURSOR *cursor, WT_ITEM *key, uint64_t keyno) cursor->set_key(cursor, keyno); break; case ROW: - key_gen((uint8_t *)key->data, &key->size, keyno, 0); + key_gen((uint8_t *)key->data, &key->size, keyno); cursor->set_key(cursor, key); break; } @@ -761,7 +766,7 @@ nextprev(WT_CURSOR *cursor, int next, int *notfoundp) * Update a row in a row-store file. */ static int -row_update( +row_update(TINFO *tinfo, WT_CURSOR *cursor, WT_ITEM *key, WT_ITEM *value, uint64_t keyno) { WT_SESSION *session; @@ -769,8 +774,8 @@ row_update( session = cursor->session; - key_gen((uint8_t *)key->data, &key->size, keyno, 0); - value_gen((uint8_t *)value->data, &value->size, keyno); + key_gen((uint8_t *)key->data, &key->size, keyno); + val_gen(&tinfo->rnd, (uint8_t *)value->data, &value->size, keyno); /* Log the operation */ if (g.logging == LOG_OPS) @@ -800,14 +805,15 @@ row_update( * Update a row in a column-store file. */ static int -col_update(WT_CURSOR *cursor, WT_ITEM *key, WT_ITEM *value, uint64_t keyno) +col_update(TINFO *tinfo, + WT_CURSOR *cursor, WT_ITEM *key, WT_ITEM *value, uint64_t keyno) { WT_SESSION *session; int notfound, ret; session = cursor->session; - value_gen((uint8_t *)value->data, &value->size, keyno); + val_gen(&tinfo->rnd, (uint8_t *)value->data, &value->size, keyno); /* Log the operation */ if (g.logging == LOG_OPS) { @@ -837,7 +843,7 @@ col_update(WT_CURSOR *cursor, WT_ITEM *key, WT_ITEM *value, uint64_t keyno) if (!SINGLETHREADED) return (0); - key_gen((uint8_t *)key->data, &key->size, keyno, 0); + key_gen((uint8_t *)key->data, &key->size, keyno); bdb_update(key->data, key->size, value->data, value->size, ¬found); (void)notfound_chk("col_update", ret, notfound, keyno); return (0); @@ -953,7 +959,7 @@ table_append(uint64_t keyno) * Insert a row in a row-store file. */ static int -row_insert( +row_insert(TINFO *tinfo, WT_CURSOR *cursor, WT_ITEM *key, WT_ITEM *value, uint64_t keyno) { WT_SESSION *session; @@ -961,8 +967,8 @@ row_insert( session = cursor->session; - key_gen((uint8_t *)key->data, &key->size, keyno, 1); - value_gen((uint8_t *)value->data, &value->size, keyno); + key_gen_insert(&tinfo->rnd, (uint8_t *)key->data, &key->size, keyno); + val_gen(&tinfo->rnd, (uint8_t *)value->data, &value->size, keyno); /* Log the operation */ if (g.logging == LOG_OPS) @@ -992,7 +998,8 @@ row_insert( * Insert an element in a column-store file. */ static int -col_insert(WT_CURSOR *cursor, WT_ITEM *key, WT_ITEM *value, uint64_t *keynop) +col_insert(TINFO *tinfo, + WT_CURSOR *cursor, WT_ITEM *key, WT_ITEM *value, uint64_t *keynop) { WT_SESSION *session; uint64_t keyno; @@ -1000,7 +1007,7 @@ col_insert(WT_CURSOR *cursor, WT_ITEM *key, WT_ITEM *value, uint64_t *keynop) session = cursor->session; - value_gen((uint8_t *)value->data, &value->size, g.rows + 1); + val_gen(&tinfo->rnd, (uint8_t *)value->data, &value->size, g.rows + 1); if (g.type == FIX) cursor->set_value(cursor, *(uint8_t *)value->data); @@ -1033,7 +1040,7 @@ col_insert(WT_CURSOR *cursor, WT_ITEM *key, WT_ITEM *value, uint64_t *keynop) if (!SINGLETHREADED) return (0); - key_gen((uint8_t *)key->data, &key->size, keyno, 0); + key_gen((uint8_t *)key->data, &key->size, keyno); bdb_update(key->data, key->size, value->data, value->size, ¬found); return (0); } @@ -1050,7 +1057,7 @@ row_remove(WT_CURSOR *cursor, WT_ITEM *key, uint64_t keyno, int *notfoundp) session = cursor->session; - key_gen((uint8_t *)key->data, &key->size, keyno, 0); + key_gen((uint8_t *)key->data, &key->size, keyno); /* Log the operation */ if (g.logging == LOG_OPS) @@ -1110,7 +1117,7 @@ col_remove(WT_CURSOR *cursor, WT_ITEM *key, uint64_t keyno, int *notfoundp) * do the same thing for the BDB store. */ if (g.type == FIX) { - key_gen((uint8_t *)key->data, &key->size, keyno, 0); + key_gen((uint8_t *)key->data, &key->size, keyno); bdb_update(key->data, key->size, "\0", 1, ¬found); } else bdb_remove(keyno, ¬found); diff --git a/test/format/salvage.c b/test/format/salvage.c index a715ca96d07..ca28e4b60d8 100644 --- a/test/format/salvage.c +++ b/test/format/salvage.c @@ -103,7 +103,7 @@ corrupt(void) found: if (fstat(fd, &sb) == -1) die(errno, "salvage-corrupt: fstat"); - offset = MMRAND(0, sb.st_size); + offset = mmrand(NULL, 0, sb.st_size); len = (size_t)(20 + (sb.st_size / 100) * 2); (void)snprintf(buf, sizeof(buf), "%s/slvg.corrupt", g.home); if ((fp = fopen(buf, "w")) == NULL) diff --git a/test/format/util.c b/test/format/util.c index d9bbdbe330f..ba4d92af7fe 100644 --- a/test/format/util.c +++ b/test/format/util.c @@ -47,7 +47,7 @@ kv_len(WT_RAND_STATE *rnd, uint64_t keyno, uint32_t min, uint32_t max) max = KILOBYTE(100); } else if (keyno % 20 != 0 && max > min + 20) max = min + 20; - return (MMRAND(min, max)); + return (mmrand(rnd, min, max)); } void @@ -66,7 +66,7 @@ key_len_setup(void) */ for (i = 0; i < sizeof(g.key_rand_len) / sizeof(g.key_rand_len[0]); ++i) g.key_rand_len[i] = - kv_len((uint64_t)i, g.c_key_min, g.c_key_max); + kv_len(NULL, (uint64_t)i, g.c_key_min, g.c_key_max); } void @@ -85,17 +85,16 @@ key_gen_setup(uint8_t **keyp) *keyp = key; } -void -key_gen(uint8_t *key, size_t *sizep, uint64_t keyno, int insert) +static void +key_gen_common(uint8_t *key, size_t *sizep, uint64_t keyno, int suffix) { - int len, suffix; + int len; /* * The key always starts with a 10-digit string (the specified cnt) * followed by two digits, a random number between 1 and 15 if it's * an insert, otherwise 00. */ - suffix = insert ? (int)MMRAND(1, 15) : 0; len = sprintf((char *)key, "%010" PRIu64 ".%02d", keyno, suffix); /* @@ -147,8 +146,8 @@ val_gen_setup(WT_RAND_STATE *rnd, uint8_t **valp) *valp = val; - val_dup_data_len = - kv_len((uint64_t)MMRAND(1, 20), g.c_value_min, g.c_value_max); + val_dup_data_len = kv_len(rnd, + (uint64_t)mmrand(rnd, 1, 20), g.c_value_min, g.c_value_max); } void @@ -160,13 +159,13 @@ val_gen(WT_RAND_STATE *rnd, uint8_t *val, size_t *sizep, uint64_t keyno) */ if (g.type == FIX) { switch (g.c_bitcnt) { - case 8: val[0] = MMRAND(1, 0xff); break; - case 7: val[0] = MMRAND(1, 0x7f); break; - case 6: val[0] = MMRAND(1, 0x3f); break; - case 5: val[0] = MMRAND(1, 0x1f); break; - case 4: val[0] = MMRAND(1, 0x0f); break; - case 3: val[0] = MMRAND(1, 0x07); break; - case 2: val[0] = MMRAND(1, 0x03); break; + case 8: val[0] = mmrand(rnd, 1, 0xff); break; + case 7: val[0] = mmrand(rnd, 1, 0x7f); break; + case 6: val[0] = mmrand(rnd, 1, 0x3f); break; + case 5: val[0] = mmrand(rnd, 1, 0x1f); break; + case 4: val[0] = mmrand(rnd, 1, 0x0f); break; + case 3: val[0] = mmrand(rnd, 1, 0x07); break; + case 2: val[0] = mmrand(rnd, 1, 0x03); break; case 1: val[0] = 1; break; } *sizep = 1; @@ -192,14 +191,15 @@ val_gen(WT_RAND_STATE *rnd, uint8_t *val, size_t *sizep, uint64_t keyno) * use the same data value all the time. */ if ((g.type == ROW || g.type == VAR) && - g.c_repeat_data_pct != 0 && MMRAND(1, 100) < g.c_repeat_data_pct) { + g.c_repeat_data_pct != 0 && + mmrand(rnd, 1, 100) < g.c_repeat_data_pct) { (void)strcpy((char *)val, "DUPLICATEV"); val[10] = '/'; *sizep = val_dup_data_len; } else { (void)sprintf((char *)val, "%010" PRIu64, keyno); val[10] = '/'; - *sizep = kv_len(keyno, g.c_value_min, g.c_value_max); + *sizep = kv_len(rnd, keyno, g.c_value_min, g.c_value_max); } } @@ -380,7 +380,7 @@ rng(WT_RAND_STATE *rnd) * threaded operation order can't be replayed. */ if (g.rand_log_stop) - return ((uint32_t)rand()); + return (__wt_random(rnd)); if (g.replay) { if (fgets(buf, sizeof(buf), g.rand_log) == NULL) { @@ -396,7 +396,8 @@ rng(WT_RAND_STATE *rnd) return ((uint32_t)strtoul(buf, NULL, 10)); } - r = (uint32_t)rand(); + r = __wt_random(rnd); + fprintf(g.rand_log, "%" PRIu32 "\n", r); return (r); } diff --git a/test/format/wts.c b/test/format/wts.c index aa8309d9eea..986796b2fc6 100644 --- a/test/format/wts.c +++ b/test/format/wts.c @@ -126,7 +126,7 @@ wts_open(const char *home, int set_api, WT_CONNECTION **connp) * Sometimes specify a set of sources just to exercise that code. */ if (g.c_statistics_server) { - if (MMRAND(0, 5) == 1 && + if (mmrand(NULL, 0, 5) == 1 && memcmp(g.uri, "file:", strlen("file:")) == 0) p += snprintf(p, REMAIN(p, end), ",statistics=(fast)" @@ -250,15 +250,15 @@ wts_create(void) * Configure the maximum key/value sizes, but leave it as the default * if we come up with something crazy. */ - maxintlkey = MMRAND(maxintlpage / 50, maxintlpage / 40); + maxintlkey = mmrand(NULL, maxintlpage / 50, maxintlpage / 40); if (maxintlkey > 20) p += snprintf(p, REMAIN(p, end), ",internal_key_max=%d", maxintlkey); - maxleafkey = MMRAND(maxleafpage / 50, maxleafpage / 40); + maxleafkey = mmrand(NULL, maxleafpage / 50, maxleafpage / 40); if (maxleafkey > 20) p += snprintf(p, REMAIN(p, end), ",leaf_key_max=%d", maxleafkey); - maxleafvalue = MMRAND(maxleafpage * 10, maxleafpage / 40); + maxleafvalue = mmrand(NULL, maxleafpage * 10, maxleafpage / 40); if (maxleafvalue > 40 && maxleafvalue < 100 * 1024) p += snprintf(p, REMAIN(p, end), ",leaf_value_max=%d", maxleafvalue); @@ -289,7 +289,7 @@ wts_create(void) ",huffman_value=english"); if (g.c_dictionary) p += snprintf(p, REMAIN(p, end), - ",dictionary=%d", MMRAND(123, 517)); + ",dictionary=%d", mmrand(NULL, 123, 517)); break; } |