diff options
author | George Hazan <ghazan@miranda.im> | 2019-06-23 12:11:35 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-06-23 12:11:35 +0300 |
commit | ede0e5088aa37d1ef710a7bf74ccead5140c9117 (patch) | |
tree | 984ec1470c0c83653e8871953b4b39806fee2b99 /libs/libmdbx/src/test/test.cc | |
parent | 3632205b947823fa049e91b86a5611e9bbb59673 (diff) |
libmdbx: merge
Diffstat (limited to 'libs/libmdbx/src/test/test.cc')
-rw-r--r-- | libs/libmdbx/src/test/test.cc | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/libs/libmdbx/src/test/test.cc b/libs/libmdbx/src/test/test.cc index e34bd7f0e8..cf61f1eeee 100644 --- a/libs/libmdbx/src/test/test.cc +++ b/libs/libmdbx/src/test/test.cc @@ -35,6 +35,8 @@ const char *testcase2str(const actor_testcase testcase) { return "copy"; case ac_append: return "append"; + case ac_ttl: + return "ttl"; } } @@ -322,6 +324,7 @@ bool testcase::setup() { return false; start_timestamp = chrono::now_motonic(); + nops_completed = 0; return true; } @@ -429,6 +432,14 @@ void testcase::db_table_drop(MDBX_dbi handle) { } } +void testcase::db_table_clear(MDBX_dbi handle) { + log_trace(">> testcase::db_table_clear, handle %u", handle); + int rc = mdbx_drop(txn_guard.get(), handle, false); + if (unlikely(rc != MDBX_SUCCESS)) + failure_perror("mdbx_drop(delete=false)", rc); + log_trace("<< testcase::db_table_clear"); +} + void testcase::db_table_close(MDBX_dbi handle) { log_trace(">> testcase::db_table_close, handle %u", handle); assert(!txn_guard); @@ -450,8 +461,9 @@ void testcase::checkdata(const char *step, MDBX_dbi handle, MDBX_val key2check, //----------------------------------------------------------------------------- -bool test_execute(const actor_config &config) { +bool test_execute(const actor_config &config_const) { const mdbx_pid_t pid = osal_getpid(); + actor_config config = config_const; if (global::singlemode) { logging::setup(format("single_%s", testcase2str(config.testcase))); @@ -487,23 +499,40 @@ bool test_execute(const actor_config &config) { case ac_append: test.reset(new testcase_append(config, pid)); break; + case ac_ttl: + test.reset(new testcase_ttl(config, pid)); + break; default: test.reset(new testcase(config, pid)); break; } - if (!test->setup()) - log_notice("test setup failed"); - else if (!test->run()) - log_notice("test failed"); - else if (!test->teardown()) - log_notice("test teardown failed"); - else { - log_info("test successed"); - return true; - } + size_t iter = 0; + do { + iter++; + if (!test->setup()) { + log_notice("test setup failed"); + return false; + } else if (!test->run()) { + log_notice("test failed"); + return false; + } else if (!test->teardown()) { + log_notice("test teardown failed"); + return false; + } else { + if (config.params.nrepeat == 1) + log_info("test successed"); + else if (config.params.nrepeat == 1) + log_info("test successed (iteration %zi of %zi)", iter, + size_t(config.params.nrepeat)); + else + log_info("test successed (iteration %zi)", iter); + config.params.keygen.seed += INT32_C(0xA4F4D37B); + } + } while (config.params.nrepeat == 0 || iter < config.params.nrepeat); + return true; } catch (const std::exception &pipets) { failure("***** Exception: %s *****", pipets.what()); + return false; } - return false; } |