mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-01 23:44:13 +08:00
mdbx-test: add SPECULUM_CURSORS
build macro/option.
Change-Id: I5dc9ccde725ce49db4fb0e94be02e9c7b48f1291
This commit is contained in:
parent
3ed99f8c20
commit
0c3fb1804e
10
test/test.cc
10
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);
|
||||
}
|
||||
|
11
test/test.h
11
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user