mdbx-test: add check for MDBX_ENODATA condition.

This commit is contained in:
Leonid Yuriev 2021-11-22 13:08:22 +03:00
parent e93d53ed92
commit 9d55d06a20
2 changed files with 21 additions and 2 deletions

View File

@ -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))) {

View File

@ -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;