libmdbx/test/try.c++

29 lines
724 B
C++
Raw Normal View History

#include "test.h++"
2017-10-26 08:56:12 +08:00
class testcase_try : public testcase {
public:
testcase_try(const actor_config &config, const mdbx_pid_t pid)
: testcase(config, pid) {}
bool run() override;
};
REGISTER_TESTCASE(try);
2017-10-26 08:56:12 +08:00
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, MDBX_TXN_READWRITE, &txn);
2017-10-26 08:56:12 +08:00
if (unlikely(rc != MDBX_SUCCESS))
failure_perror("mdbx_txn_begin(MDBX_TXN_TRY)", rc);
2017-10-26 08:56:12 +08:00
else {
rc = mdbx_txn_begin(db_guard.get(), nullptr, MDBX_TXN_TRY, &txn2);
2017-10-26 08:56:12 +08:00
if (unlikely(rc != MDBX_BUSY))
failure_perror("mdbx_txn_begin(MDBX_TXN_TRY)", rc);
2017-10-26 08:56:12 +08:00
}
txn_guard.reset(txn);
return true;
}