mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-30 01:44:13 +08:00
mdbx-testing: технический возврат bool
из проверочных функций в тесте для удобства ad-hoc доработок.
This commit is contained in:
parent
d4c09f9b78
commit
a10506fb6a
@ -726,7 +726,7 @@ void testcase::verbose(const char *where, const char *stage, const MDBX_val &k,
|
|||||||
mdbx_dump_val(&v, dump_value, sizeof(dump_value)));
|
mdbx_dump_val(&v, dump_value, sizeof(dump_value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testcase::speculum_check_iterator(const char *where, const char *stage,
|
bool testcase::speculum_check_iterator(const char *where, const char *stage,
|
||||||
const testcase::SET::const_iterator &it,
|
const testcase::SET::const_iterator &it,
|
||||||
const MDBX_val &k,
|
const MDBX_val &k,
|
||||||
const MDBX_val &v) const {
|
const MDBX_val &v) const {
|
||||||
@ -737,16 +737,17 @@ void testcase::speculum_check_iterator(const char *where, const char *stage,
|
|||||||
// mdbx_dump_val(&it_key, dump_key, sizeof(dump_key)),
|
// mdbx_dump_val(&it_key, dump_key, sizeof(dump_key)),
|
||||||
// mdbx_dump_val(&it_data, dump_value, sizeof(dump_value)));
|
// mdbx_dump_val(&it_data, dump_value, sizeof(dump_value)));
|
||||||
if (!is_samedata(it_key, k))
|
if (!is_samedata(it_key, k))
|
||||||
failure("speculum-%s: %s key mismatch %s (must) != %s", where, stage,
|
return failure("speculum-%s: %s key mismatch %s (must) != %s", where, stage,
|
||||||
mdbx_dump_val(&it_key, dump_key, sizeof(dump_key)),
|
mdbx_dump_val(&it_key, dump_key, sizeof(dump_key)),
|
||||||
mdbx_dump_val(&k, dump_value, sizeof(dump_value)));
|
mdbx_dump_val(&k, dump_value, sizeof(dump_value)));
|
||||||
if (!is_samedata(it_data, v))
|
if (!is_samedata(it_data, v))
|
||||||
failure("speculum-%s: %s data mismatch %s (must) != %s", where, stage,
|
return failure("speculum-%s: %s data mismatch %s (must) != %s", where,
|
||||||
mdbx_dump_val(&it_data, dump_key, sizeof(dump_key)),
|
stage, mdbx_dump_val(&it_data, dump_key, sizeof(dump_key)),
|
||||||
mdbx_dump_val(&v, dump_value, sizeof(dump_value)));
|
mdbx_dump_val(&v, dump_value, sizeof(dump_value)));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testcase::failure(const char *fmt, ...) const {
|
bool testcase::failure(const char *fmt, ...) const {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
fflush(nullptr);
|
fflush(nullptr);
|
||||||
@ -756,10 +757,11 @@ void testcase::failure(const char *fmt, ...) const {
|
|||||||
if (txn_guard)
|
if (txn_guard)
|
||||||
mdbx_txn_commit(const_cast<testcase *>(this)->txn_guard.release());
|
mdbx_txn_commit(const_cast<testcase *>(this)->txn_guard.release());
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SPECULUM_CURSORS
|
#if SPECULUM_CURSORS
|
||||||
void testcase::speculum_check_cursor(const char *where, const char *stage,
|
bool testcase::speculum_check_cursor(const char *where, const char *stage,
|
||||||
const testcase::SET::const_iterator &it,
|
const testcase::SET::const_iterator &it,
|
||||||
int cursor_err, const MDBX_val &cursor_key,
|
int cursor_err, const MDBX_val &cursor_key,
|
||||||
const MDBX_val &cursor_data) const {
|
const MDBX_val &cursor_data) const {
|
||||||
@ -767,25 +769,29 @@ void testcase::speculum_check_cursor(const char *where, const char *stage,
|
|||||||
// 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_ENODATA)
|
cursor_err != MDBX_RESULT_TRUE && cursor_err != MDBX_ENODATA)
|
||||||
failure("speculum-%s: %s %s %d %s", where, stage, "cursor-get", cursor_err,
|
return failure("speculum-%s: %s %s %d %s", where, stage, "cursor-get",
|
||||||
mdbx_strerror(cursor_err));
|
cursor_err, mdbx_strerror(cursor_err));
|
||||||
|
|
||||||
char dump_key[32], dump_value[32];
|
char dump_key[32], dump_value[32];
|
||||||
if (it == speculum.end() && cursor_err != MDBX_NOTFOUND)
|
if (it == speculum.end() && cursor_err != MDBX_NOTFOUND)
|
||||||
failure("speculum-%s: %s extra pair {%s, %s}", where, stage,
|
return failure("speculum-%s: %s extra pair {%s, %s}", where, stage,
|
||||||
mdbx_dump_val(&cursor_key, dump_key, sizeof(dump_key)),
|
mdbx_dump_val(&cursor_key, dump_key, sizeof(dump_key)),
|
||||||
mdbx_dump_val(&cursor_data, dump_value, sizeof(dump_value)));
|
mdbx_dump_val(&cursor_data, dump_value, sizeof(dump_value)));
|
||||||
else if (it != speculum.end() && cursor_err == MDBX_NOTFOUND) {
|
else if (it != speculum.end() && cursor_err == MDBX_NOTFOUND) {
|
||||||
MDBX_val it_key = dataview2iov(it->first);
|
MDBX_val it_key = dataview2iov(it->first);
|
||||||
MDBX_val it_data = dataview2iov(it->second);
|
MDBX_val it_data = dataview2iov(it->second);
|
||||||
failure("speculum-%s: %s lack pair {%s, %s}", where, stage,
|
return failure("speculum-%s: %s lack pair {%s, %s}", where, stage,
|
||||||
mdbx_dump_val(&it_key, dump_key, sizeof(dump_key)),
|
mdbx_dump_val(&it_key, dump_key, sizeof(dump_key)),
|
||||||
mdbx_dump_val(&it_data, dump_value, sizeof(dump_value)));
|
mdbx_dump_val(&it_data, dump_value, sizeof(dump_value)));
|
||||||
} else if (cursor_err == MDBX_SUCCESS || cursor_err == MDBX_RESULT_TRUE)
|
} else if (cursor_err == MDBX_SUCCESS || cursor_err == MDBX_RESULT_TRUE)
|
||||||
speculum_check_iterator(where, stage, it, cursor_key, cursor_data);
|
return speculum_check_iterator(where, stage, it, cursor_key, cursor_data);
|
||||||
|
else {
|
||||||
|
assert(it == speculum.end() && cursor_err == MDBX_NOTFOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testcase::speculum_check_cursor(const char *where, const char *stage,
|
bool testcase::speculum_check_cursor(const char *where, const char *stage,
|
||||||
const testcase::SET::const_iterator &it,
|
const testcase::SET::const_iterator &it,
|
||||||
MDBX_cursor *cursor,
|
MDBX_cursor *cursor,
|
||||||
const MDBX_cursor_op op) const {
|
const MDBX_cursor_op op) const {
|
||||||
@ -908,11 +914,10 @@ int testcase::insert(const keygen::buffer &akey, const keygen::buffer &adata,
|
|||||||
check_seek_cursor = speculum_cursors[seek_check].get();
|
check_seek_cursor = speculum_cursors[seek_check].get();
|
||||||
seek_check_key = akey->value;
|
seek_check_key = akey->value;
|
||||||
seek_check_data = adata->value;
|
seek_check_data = adata->value;
|
||||||
seek_check_err = mdbx_cursor_get(
|
seek_check_err = mdbx_cursor_get(check_seek_cursor, &seek_check_key,
|
||||||
check_seek_cursor, &seek_check_key, &seek_check_data,
|
&seek_check_data, MDBX_SET_LOWERBOUND);
|
||||||
(config.params.table_flags & MDBX_DUPSORT) ? MDBX_GET_BOTH
|
if (seek_check_err != MDBX_SUCCESS && seek_check_err != MDBX_NOTFOUND &&
|
||||||
: MDBX_SET_KEY);
|
seek_check_err != MDBX_RESULT_TRUE)
|
||||||
if (seek_check_err != MDBX_SUCCESS && seek_check_err != MDBX_NOTFOUND)
|
|
||||||
failure("speculum-%s: %s pre-insert %d %s", "insert", "seek",
|
failure("speculum-%s: %s pre-insert %d %s", "insert", "seek",
|
||||||
seek_check_err, mdbx_strerror(seek_check_err));
|
seek_check_err, mdbx_strerror(seek_check_err));
|
||||||
#endif /* SPECULUM_CURSORS */
|
#endif /* SPECULUM_CURSORS */
|
||||||
@ -940,7 +945,7 @@ int testcase::insert(const keygen::buffer &akey, const keygen::buffer &adata,
|
|||||||
|
|
||||||
#if SPECULUM_CURSORS
|
#if SPECULUM_CURSORS
|
||||||
if (insertion_result.second) {
|
if (insertion_result.second) {
|
||||||
if (seek_check_err != MDBX_NOTFOUND) {
|
if (seek_check_err == MDBX_SUCCESS) {
|
||||||
log_error(
|
log_error(
|
||||||
"speculum.pre-insert-seek: unexpected %d {%s, %s}", seek_check_err,
|
"speculum.pre-insert-seek: unexpected %d {%s, %s}", seek_check_err,
|
||||||
mdbx_dump_val(&seek_check_key, dump_key, sizeof(dump_key)),
|
mdbx_dump_val(&seek_check_key, dump_key, sizeof(dump_key)),
|
||||||
|
@ -194,16 +194,16 @@ protected:
|
|||||||
#if SPECULUM_CURSORS
|
#if SPECULUM_CURSORS
|
||||||
scoped_cursor_guard speculum_cursors[5 + 1];
|
scoped_cursor_guard speculum_cursors[5 + 1];
|
||||||
void speculum_prepare_cursors(const Item &item);
|
void speculum_prepare_cursors(const Item &item);
|
||||||
void speculum_check_cursor(const char *where, const char *stage,
|
bool speculum_check_cursor(const char *where, const char *stage,
|
||||||
const testcase::SET::const_iterator &it,
|
const testcase::SET::const_iterator &it,
|
||||||
int cursor_err, const MDBX_val &cursor_key,
|
int cursor_err, const MDBX_val &cursor_key,
|
||||||
const MDBX_val &cursor_data) const;
|
const MDBX_val &cursor_data) const;
|
||||||
void speculum_check_cursor(const char *where, const char *stage,
|
bool speculum_check_cursor(const char *where, const char *stage,
|
||||||
const testcase::SET::const_iterator &it,
|
const testcase::SET::const_iterator &it,
|
||||||
MDBX_cursor *cursor,
|
MDBX_cursor *cursor,
|
||||||
const MDBX_cursor_op op) const;
|
const MDBX_cursor_op op) const;
|
||||||
#endif /* SPECULUM_CURSORS */
|
#endif /* SPECULUM_CURSORS */
|
||||||
void speculum_check_iterator(const char *where, const char *stage,
|
bool speculum_check_iterator(const char *where, const char *stage,
|
||||||
const testcase::SET::const_iterator &it,
|
const testcase::SET::const_iterator &it,
|
||||||
const MDBX_val &k, const MDBX_val &v) const;
|
const MDBX_val &k, const MDBX_val &v) const;
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ protected:
|
|||||||
void signal();
|
void signal();
|
||||||
bool should_continue(bool check_timeout_only = false) const;
|
bool should_continue(bool check_timeout_only = false) const;
|
||||||
|
|
||||||
void failure(const char *fmt, ...) const;
|
bool failure(const char *fmt, ...) const;
|
||||||
void generate_pair(const keygen::serial_t serial, keygen::buffer &out_key,
|
void generate_pair(const keygen::serial_t serial, keygen::buffer &out_key,
|
||||||
keygen::buffer &out_value, keygen::serial_t data_age) {
|
keygen::buffer &out_value, keygen::serial_t data_age) {
|
||||||
keyvalue_maker.pair(serial, out_key, out_value, data_age, false);
|
keyvalue_maker.pair(serial, out_key, out_value, data_age, false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user