summaryrefslogtreecommitdiff
path: root/libs/libmdbx/src/test/test.cc
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-05-03 12:10:24 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-05-03 12:10:32 +0300
commit6e810c355d57695b420debb9a1c1508d3a4d8f88 (patch)
treefb4d4bcc6b57ce0f8320e97d60b4179e15b9b6d4 /libs/libmdbx/src/test/test.cc
parent37688aac67853dc1568182a3497be4c877e3dcdb (diff)
merge of libmdbx
Diffstat (limited to 'libs/libmdbx/src/test/test.cc')
-rw-r--r--libs/libmdbx/src/test/test.cc33
1 files changed, 31 insertions, 2 deletions
diff --git a/libs/libmdbx/src/test/test.cc b/libs/libmdbx/src/test/test.cc
index 6bba425a67..e34bd7f0e8 100644
--- a/libs/libmdbx/src/test/test.cc
+++ b/libs/libmdbx/src/test/test.cc
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-2018 Leonid Yuriev <leo@yuriev.ru>
+ * Copyright 2017-2019 Leonid Yuriev <leo@yuriev.ru>
* and other libmdbx authors: please see AUTHORS file.
* All rights reserved.
*
@@ -33,6 +33,8 @@ const char *testcase2str(const actor_testcase testcase) {
return "try";
case ac_copy:
return "copy";
+ case ac_append:
+ return "append";
}
}
@@ -185,9 +187,33 @@ void testcase::txn_end(bool abort) {
log_trace("<< txn_end(%s)", abort ? "abort" : "commit");
}
+void testcase::cursor_open(unsigned dbi) {
+ log_trace(">> cursor_open(%u)", dbi);
+ assert(!cursor_guard);
+ assert(txn_guard);
+
+ MDBX_cursor *cursor = nullptr;
+ int rc = mdbx_cursor_open(txn_guard.get(), dbi, &cursor);
+ if (unlikely(rc != MDBX_SUCCESS))
+ failure_perror("mdbx_cursor_open()", rc);
+ cursor_guard.reset(cursor);
+
+ log_trace("<< cursor_open(%u)", dbi);
+}
+
+void testcase::cursor_close() {
+ log_trace(">> cursor_close()");
+ assert(cursor_guard);
+ MDBX_cursor *cursor = cursor_guard.release();
+ mdbx_cursor_close(cursor);
+ log_trace("<< cursor_close()");
+}
+
void testcase::txn_restart(bool abort, bool readonly, unsigned flags) {
if (txn_guard)
txn_end(abort);
+ if (cursor_guard)
+ cursor_close();
txn_begin(readonly, flags);
}
@@ -396,7 +422,7 @@ void testcase::db_table_drop(MDBX_dbi handle) {
if (config.params.drop_table) {
int rc = mdbx_drop(txn_guard.get(), handle, true);
if (unlikely(rc != MDBX_SUCCESS))
- failure_perror("mdbx_drop()", rc);
+ failure_perror("mdbx_drop(delete=true)", rc);
log_trace("<< testcase::db_table_drop");
} else {
log_trace("<< testcase::db_table_drop: not needed");
@@ -458,6 +484,9 @@ bool test_execute(const actor_config &config) {
case ac_copy:
test.reset(new testcase_copy(config, pid));
break;
+ case ac_append:
+ test.reset(new testcase_append(config, pid));
+ break;
default:
test.reset(new testcase(config, pid));
break;