summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdbx/src/libmdbx/test/try.cc
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dbx_mdbx/src/libmdbx/test/try.cc')
-rw-r--r--plugins/Dbx_mdbx/src/libmdbx/test/try.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/plugins/Dbx_mdbx/src/libmdbx/test/try.cc b/plugins/Dbx_mdbx/src/libmdbx/test/try.cc
new file mode 100644
index 0000000000..1deae71d31
--- /dev/null
+++ b/plugins/Dbx_mdbx/src/libmdbx/test/try.cc
@@ -0,0 +1,37 @@
+#include "test.h"
+
+bool testcase_try::setup() {
+ log_trace(">> setup");
+ if (!inherited::setup())
+ return false;
+
+ log_trace("<< setup");
+ return true;
+}
+
+bool testcase_try::run() {
+ db_open();
+ assert(!txn_guard);
+
+ MDBX_txn *txn = nullptr;
+ MDBX_txn *txn2 = nullptr;
+ int rc = mdbx_txn_begin(db_guard.get(), nullptr, 0, &txn);
+ if (unlikely(rc != MDBX_SUCCESS))
+ failure_perror("mdbx_txn_begin(MDBX_TRYTXN)", rc);
+ else {
+ rc = mdbx_txn_begin(db_guard.get(), nullptr, MDBX_TRYTXN, &txn2);
+ if (unlikely(rc != MDBX_BUSY))
+ failure_perror("mdbx_txn_begin(MDBX_TRYTXN)", rc);
+ }
+
+ txn_guard.reset(txn);
+ return true;
+}
+
+bool testcase_try::teardown() {
+ log_trace(">> teardown");
+ cursor_guard.release();
+ txn_guard.release();
+ db_guard.release();
+ return inherited::teardown();
+}