mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 18:24:12 +08:00
mdbx-test: add check for MDBX_ENODATA
condition.
This commit is contained in:
parent
e93d53ed92
commit
9d55d06a20
@ -73,7 +73,12 @@ bool testcase_hill::run() {
|
|||||||
uint64_t committed_serial = serial_count;
|
uint64_t committed_serial = serial_count;
|
||||||
unsigned txn_nops = 0;
|
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()) {
|
while (should_continue()) {
|
||||||
const keygen::serial_t a_serial = serial_count;
|
const keygen::serial_t a_serial = serial_count;
|
||||||
if (unlikely(!keyvalue_maker.increment(serial_count, 1))) {
|
if (unlikely(!keyvalue_maker.increment(serial_count, 1))) {
|
||||||
|
16
test/test.cc
16
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, cursor_key, cursor_data, cursor_err);
|
||||||
// verbose(where, stage, it);
|
// verbose(where, stage, it);
|
||||||
if (cursor_err != MDBX_SUCCESS && cursor_err != MDBX_NOTFOUND &&
|
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,
|
failure("speculum-%s: %s %s %d %s", where, stage, "cursor-get", cursor_err,
|
||||||
mdbx_strerror(cursor_err));
|
mdbx_strerror(cursor_err));
|
||||||
|
|
||||||
@ -1050,6 +1050,15 @@ bool testcase::speculum_verify() {
|
|||||||
MDBX_val akey, avalue;
|
MDBX_val akey, avalue;
|
||||||
MDBX_val mkey, mvalue;
|
MDBX_val mkey, mvalue;
|
||||||
err = mdbx_cursor_get(cursor, &akey, &avalue, MDBX_FIRST);
|
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;
|
unsigned extra = 0, lost = 0, n = 0;
|
||||||
assert(std::is_sorted(speculum.cbegin(), speculum.cend(), ItemCompare(this)));
|
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);
|
log_error("false-negative cursor-eof: %u, rc %i", n, eof);
|
||||||
rc = false;
|
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);
|
mdbx_cursor_close(cursor);
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user