From 9d55d06a20e0f25055f3c35cf40d6ed07b0ae133 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Mon, 22 Nov 2021 13:08:22 +0300 Subject: [PATCH] mdbx-test: add check for `MDBX_ENODATA` condition. --- test/hill.cc | 7 ++++++- test/test.cc | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/test/hill.cc b/test/hill.cc index 58b2271b..edd1fc3e 100644 --- a/test/hill.cc +++ b/test/hill.cc @@ -73,7 +73,12 @@ bool testcase_hill::run() { uint64_t committed_serial = serial_count; unsigned txn_nops = 0; - bool rc = false; + bool rc = speculum_verify(); + if (!rc) { + log_notice("uphill: bailout before main loop"); + goto bailout; + } + while (should_continue()) { const keygen::serial_t a_serial = serial_count; if (unlikely(!keyvalue_maker.increment(serial_count, 1))) { diff --git a/test/test.cc b/test/test.cc index d13b7973..9263c1f5 100644 --- a/test/test.cc +++ b/test/test.cc @@ -715,7 +715,7 @@ void testcase::speculum_check_cursor(const char *where, const char *stage, // verbose(where, stage, cursor_key, cursor_data, cursor_err); // verbose(where, stage, it); if (cursor_err != MDBX_SUCCESS && cursor_err != MDBX_NOTFOUND && - cursor_err != MDBX_RESULT_TRUE) + cursor_err != MDBX_RESULT_TRUE && cursor_err != MDBX_ENODATA) failure("speculum-%s: %s %s %d %s", where, stage, "cursor-get", cursor_err, mdbx_strerror(cursor_err)); @@ -1050,6 +1050,15 @@ bool testcase::speculum_verify() { MDBX_val akey, avalue; MDBX_val mkey, mvalue; err = mdbx_cursor_get(cursor, &akey, &avalue, MDBX_FIRST); + if (err == MDBX_NOTFOUND) { + err = mdbx_cursor_get(cursor, &akey, &avalue, MDBX_GET_CURRENT); + if (err == MDBX_ENODATA) + err = MDBX_NOTFOUND; + else { + log_error("unexpected %d for MDBX_GET_CURRENT on empty DB", err); + rc = false; + } + } unsigned extra = 0, lost = 0, n = 0; assert(std::is_sorted(speculum.cbegin(), speculum.cend(), ItemCompare(this))); @@ -1128,6 +1137,11 @@ bool testcase::speculum_verify() { log_error("false-negative cursor-eof: %u, rc %i", n, eof); rc = false; } + err = mdbx_cursor_get(cursor, &akey, &avalue, MDBX_GET_CURRENT); + if (err != MDBX_ENODATA) { + log_error("unexpected %d for MDBX_GET_CURRENT at EOF", err); + rc = false; + } } mdbx_cursor_close(cursor); return rc;