mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-30 23:39:19 +08:00
e7095e9ada
Change-Id: I2d0ccc9f7bbed6d57b2fe6ef156f33531a4eeb69
27 lines
748 B
C++
27 lines
748 B
C++
#include "test.h"
|
|
|
|
void testcase_copy::copy_db(const bool with_compaction) {
|
|
int err = osal_removefile(copy_pathname);
|
|
if (err != MDBX_SUCCESS && err != MDBX_ENOFILE)
|
|
failure_perror("mdbx_removefile()", err);
|
|
|
|
err = mdbx_env_copy(db_guard.get(), copy_pathname.c_str(),
|
|
with_compaction ? MDBX_CP_COMPACT : 0);
|
|
if (unlikely(err != MDBX_SUCCESS))
|
|
failure_perror(with_compaction ? "mdbx_env_copy(MDBX_CP_COMPACT)"
|
|
: "mdbx_env_copy(MDBX_CP_ASIS)",
|
|
err);
|
|
}
|
|
|
|
bool testcase_copy::run() {
|
|
jitter_delay();
|
|
db_open();
|
|
assert(!txn_guard);
|
|
const bool order = flipcoin();
|
|
jitter_delay();
|
|
copy_db(order);
|
|
jitter_delay();
|
|
copy_db(!order);
|
|
return true;
|
|
}
|