From 86cfd86cda3fa5c65188e989962cf364f82e35bc Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Thu, 20 Jun 2019 02:41:22 +0300 Subject: [PATCH] mdbx-test: support for `repeat` parameter. Change-Id: I6de52cd21314935c123ac51537e1b893c39dd5ed --- Makefile | 4 ++-- test/main.cc | 2 +- test/test.cc | 36 +++++++++++++++++++++++++----------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 4faaaae5..145b7fad 100644 --- a/Makefile +++ b/Makefile @@ -82,11 +82,11 @@ clean: rm -rf $(TOOLS) mdbx_test @* *.[ao] *.[ls]o *~ tmp.db/* *.gcov *.log *.err src/*.o test/*.o check: all - rm -f $(TESTDB) $(TESTLOG) && (set -o pipefail; ./mdbx_test --pathname=$(TESTDB) --dont-cleanup-after basic | tee -a $(TESTLOG) | tail -n 42) \ + rm -f $(TESTDB) $(TESTLOG) && (set -o pipefail; ./mdbx_test --repeat=42 --pathname=$(TESTDB) --dont-cleanup-after basic | tee -a $(TESTLOG) | tail -n 42) \ && ./mdbx_chk -vvn $(TESTDB) && ./mdbx_chk -vvn $(TESTDB)-copy check-singleprocess: all - rm -f $(TESTDB) $(TESTLOG) && (set -o pipefail; ./mdbx_test --pathname=$(TESTDB) --dont-cleanup-after --hill --copy | tee -a $(TESTLOG) | tail -n 42) \ + rm -f $(TESTDB) $(TESTLOG) && (set -o pipefail; ./mdbx_test --repeat=42 --pathname=$(TESTDB) --dont-cleanup-after --hill --copy | tee -a $(TESTLOG) | tail -n 42) \ && ./mdbx_chk -vvn $(TESTDB) && ./mdbx_chk -vvn $(TESTDB)-copy check-fault: all diff --git a/test/main.cc b/test/main.cc index f3ee76b6..d93f0e11 100644 --- a/test/main.cc +++ b/test/main.cc @@ -37,7 +37,7 @@ void actor_params::set_defaults(const std::string &tmpdir) { table_flags = MDBX_DUPSORT; size_lower = -1; - size_now = 1024 * 1024 * ((table_flags & MDBX_DUPSORT) ? 4 : 256); + size_now = intptr_t(1024) * 1024 * ((table_flags & MDBX_DUPSORT) ? 4 : 256); size_upper = -1; shrink_threshold = -1; growth_step = -1; diff --git a/test/test.cc b/test/test.cc index e34bd7f0..bfb9341d 100644 --- a/test/test.cc +++ b/test/test.cc @@ -322,6 +322,7 @@ bool testcase::setup() { return false; start_timestamp = chrono::now_motonic(); + nops_completed = 0; return true; } @@ -492,18 +493,31 @@ bool test_execute(const actor_config &config) { 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); + } + } 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; }