mdbx-test: add nested testcase.

Related to https://github.com/leo-yuriev/libmdbx/issues/62

Change-Id: I5fee861582987cc11a648a3365b19c28e493317d
This commit is contained in:
Leonid Yuriev
2019-10-09 23:38:44 +03:00
parent 66430fd10d
commit 0f8b2ff399
11 changed files with 358 additions and 29 deletions

View File

@@ -37,6 +37,8 @@ const char *testcase2str(const actor_testcase testcase) {
return "append";
case ac_ttl:
return "ttl";
case ac_nested:
return "nested";
}
}
@@ -197,6 +199,20 @@ int testcase::breakable_commit() {
return rc;
}
unsigned testcase::txn_underutilization_x256(MDBX_txn *txn) const {
if (txn) {
MDBX_txn_info info;
int err = mdbx_txn_info(txn, &info, false);
if (unlikely(err != MDBX_SUCCESS))
failure_perror("mdbx_txn_info()", err);
const size_t left = size_t(info.txn_space_leftover);
const size_t total =
size_t(info.txn_space_leftover) + size_t(info.txn_space_dirty);
return (unsigned)(left / (total >> 8));
}
return 0;
}
void testcase::txn_end(bool abort) {
log_trace(">> txn_end(%s)", abort ? "abort" : "commit");
assert(txn_guard);
@@ -479,9 +495,9 @@ void testcase::db_table_drop(MDBX_dbi handle) {
}
}
void testcase::db_table_clear(MDBX_dbi handle) {
void testcase::db_table_clear(MDBX_dbi handle, MDBX_txn *txn) {
log_trace(">> testcase::db_table_clear, handle %u", handle);
int rc = mdbx_drop(txn_guard.get(), handle, false);
int rc = mdbx_drop(txn ? txn : txn_guard.get(), handle, false);
if (unlikely(rc != MDBX_SUCCESS))
failure_perror("mdbx_drop(delete=false)", rc);
log_trace("<< testcase::db_table_clear");
@@ -549,6 +565,9 @@ bool test_execute(const actor_config &config_const) {
case ac_ttl:
test.reset(new testcase_ttl(config, pid));
break;
case ac_nested:
test.reset(new testcase_nested(config, pid));
break;
default:
test.reset(new testcase(config, pid));
break;