From 0c3fb1804ef99f6d6d999ea11dcbe153b9e55bd9 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sun, 28 Mar 2021 18:41:54 +0300 Subject: [PATCH] mdbx-test: add `SPECULUM_CURSORS` build macro/option. Change-Id: I5dc9ccde725ce49db4fb0e94be02e9c7b48f1291 --- test/test.cc | 10 ++++++++++ test/test.h | 11 ++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/test/test.cc b/test/test.cc index 31032bc9..42d46f9b 100644 --- a/test/test.cc +++ b/test/test.cc @@ -683,6 +683,7 @@ void testcase::speculum_check_iterator(const char *where, const char *stage, mdbx_dump_val(&data, dump_value, sizeof(dump_value))); } +#if SPECULUM_CURSORS void testcase::speculum_check_cursor(const char *where, const char *stage, const testcase::SET::const_iterator &it, int cursor_err, const MDBX_val &cursor_key, @@ -820,6 +821,7 @@ void testcase::speculum_prepare_cursors(const Item &item) { failure("speculum-%s: %s on-last %d %s", "prepare-cursors", "next-next", err, mdbx_strerror(err)); } +#endif /* SPECULUM_CURSORS */ int testcase::insert(const keygen::buffer &akey, const keygen::buffer &adata, MDBX_put_flags_t flags) { @@ -829,7 +831,9 @@ int testcase::insert(const keygen::buffer &akey, const keygen::buffer &adata, if (config.params.speculum) { item.first = iov2dataview(akey); item.second = iov2dataview(adata); +#if SPECULUM_CURSORS speculum_prepare_cursors(item); +#endif /* SPECULUM_CURSORS */ } err = mdbx_put(txn_guard.get(), dbi, &akey->value, &adata->value, flags); @@ -852,6 +856,7 @@ int testcase::insert(const keygen::buffer &akey, const keygen::buffer &adata, rc = false; } +#if SPECULUM_CURSORS if (insertion_result.first != speculum.begin()) { const auto cursor_prev = speculum_cursors[prev].get(); auto it_prev = insertion_result.first; @@ -885,6 +890,7 @@ int testcase::insert(const keygen::buffer &akey, const keygen::buffer &adata, } } } +#endif /* SPECULUM_CURSORS */ } return rc ? MDBX_SUCCESS : MDBX_RESULT_TRUE; @@ -925,7 +931,9 @@ int testcase::remove(const keygen::buffer &akey, const keygen::buffer &adata) { if (config.params.speculum) { item.first = iov2dataview(akey); item.second = iov2dataview(adata); +#if SPECULUM_CURSORS speculum_prepare_cursors(item); +#endif /* SPECULUM_CURSORS */ } err = mdbx_del(txn_guard.get(), dbi, &akey->value, &adata->value); @@ -950,6 +958,7 @@ int testcase::remove(const keygen::buffer &akey, const keygen::buffer &adata) { rc = false; } +#if SPECULUM_CURSORS if (it_found != speculum.begin()) { const auto cursor_prev = speculum_cursors[prev].get(); auto it_prev = it_found; @@ -989,6 +998,7 @@ int testcase::remove(const keygen::buffer &akey, const keygen::buffer &adata) { failure("speculum-%s: %s on-last %d %s", "after-remove", "lowerbound", err, mdbx_strerror(err)); } +#endif /* SPECULUM_CURSORS */ speculum.erase(it_found); } diff --git a/test/test.h b/test/test.h index 8724cef5..cbd3d710 100644 --- a/test/test.h +++ b/test/test.h @@ -198,11 +198,12 @@ protected: } last; SET speculum{ItemCompare(this)}, speculum_committed{ItemCompare(this)}; +#ifndef SPECULUM_CURSORS +#define SPECULUM_CURSORS 1 +#endif /* SPECULUM_CURSORS */ +#if SPECULUM_CURSORS scoped_cursor_guard speculum_cursors[5]; void speculum_prepare_cursors(const Item &item); - void speculum_check_iterator(const char *where, const char *stage, - const testcase::SET::const_iterator &it, - const MDBX_val &key, const MDBX_val &data) const; void speculum_check_cursor(const char *where, const char *stage, const testcase::SET::const_iterator &it, int cursor_err, const MDBX_val &cursor_key, @@ -211,6 +212,10 @@ protected: const testcase::SET::const_iterator &it, MDBX_cursor *cursor, const MDBX_cursor_op op) const; +#endif /* SPECULUM_CURSORS */ + void speculum_check_iterator(const char *where, const char *stage, + const testcase::SET::const_iterator &it, + const MDBX_val &key, const MDBX_val &data) const; void verbose(const char *where, const char *stage, const testcase::SET::const_iterator &it) const;