diff options
author | Volker Lendecke <vl@samba.org> | 2013-02-21 16:34:32 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-05-22 21:05:15 +0200 |
commit | bd54feab46d5dfd36c8a1729a46b59757ffe1e6a (patch) | |
tree | 2a7a95adf9205113a90fc50d42cb423ab2dac1d6 /lib/tdb | |
parent | b39e8eac2036f5aaed848d3361596984cc913083 (diff) | |
download | samba-bd54feab46d5dfd36c8a1729a46b59757ffe1e6a.tar.gz samba-bd54feab46d5dfd36c8a1729a46b59757ffe1e6a.tar.xz samba-bd54feab46d5dfd36c8a1729a46b59757ffe1e6a.zip |
tdb/tools: add -m option to tdbtorture
This allows tdbtorture to run with mutexes.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/tdb')
-rw-r--r-- | lib/tdb/tools/tdbtorture.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/lib/tdb/tools/tdbtorture.c b/lib/tdb/tools/tdbtorture.c index 5ae08f662a..3e26f65242 100644 --- a/lib/tdb/tools/tdbtorture.c +++ b/lib/tdb/tools/tdbtorture.c @@ -33,6 +33,7 @@ static int always_transaction = 0; static int hash_size = 2; static int loopnum; static int count_pipe; +static bool mutex = false; static struct tdb_logging_context log_ctx; #ifdef PRINTF_ATTRIBUTE @@ -119,6 +120,7 @@ static void addrec_db(void) #if TRANSACTION_PROB if (in_transaction == 0 && + ((tdb_get_flags(db) & TDB_MUTEX_LOCKING) == 0) && (always_transaction || random() % TRANSACTION_PROB == 0)) { if (tdb_transaction_start(db) != 0) { fatal("tdb_transaction_start failed"); @@ -216,7 +218,7 @@ static int traverse_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, static void usage(void) { - printf("Usage: tdbtorture [-t] [-k] [-n NUM_PROCS] [-l NUM_LOOPS] [-s SEED] [-H HASH_SIZE]\n"); + printf("Usage: tdbtorture [-t] [-k] [-m] [-n NUM_PROCS] [-l NUM_LOOPS] [-s SEED] [-H HASH_SIZE]\n"); exit(0); } @@ -230,7 +232,13 @@ static void send_count_and_suicide(int sig) static int run_child(const char *filename, int i, int seed, unsigned num_loops, unsigned start) { - db = tdb_open_ex(filename, hash_size, TDB_DEFAULT, + int tdb_flags = TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH; + + if (mutex) { + tdb_flags |= TDB_MUTEX_LOCKING; + } + + db = tdb_open_ex(filename, hash_size, tdb_flags, O_RDWR | O_CREAT, 0600, &log_ctx, NULL); if (!db) { fatal("db open failed"); @@ -302,7 +310,7 @@ int main(int argc, char * const *argv) log_ctx.log_fn = tdb_log; - while ((c = getopt(argc, argv, "n:l:s:H:thk")) != -1) { + while ((c = getopt(argc, argv, "n:l:s:H:thkm")) != -1) { switch (c) { case 'n': num_procs = strtol(optarg, NULL, 0); @@ -322,6 +330,13 @@ int main(int argc, char * const *argv) case 'k': kill_random = 1; break; + case 'm': + mutex = tdb_runtime_check_for_robust_mutexes(); + if (!mutex) { + printf("tdb_runtime_check_for_robust_mutexes() returned false\n"); + exit(1); + } + break; default: usage(); } @@ -443,7 +458,13 @@ int main(int argc, char * const *argv) done: if (error_count == 0) { - db = tdb_open_ex(test_tdb, hash_size, TDB_DEFAULT, + int tdb_flags = TDB_DEFAULT; + + if (mutex) { + tdb_flags |= TDB_NOLOCK; + } + + db = tdb_open_ex(test_tdb, hash_size, tdb_flags, O_RDWR, 0, &log_ctx, NULL); if (!db) { fatal("db open failed\n"); |