mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 16:34:14 +08:00
mdbx-test: cleanup for without MDBX_NOSUBDIR case.
Change-Id: I50d6640108ca229e4919ea96469152d2533f9cab
This commit is contained in:
parent
5627521f16
commit
12770cae88
3
.github/actions/spelling/expect.txt
vendored
3
.github/actions/spelling/expect.txt
vendored
@ -367,6 +367,7 @@ EIDRM
|
|||||||
EINTR
|
EINTR
|
||||||
EINVAL
|
EINVAL
|
||||||
EIO
|
EIO
|
||||||
|
EISDIR
|
||||||
ejdb
|
ejdb
|
||||||
EKEYMISMATCH
|
EKEYMISMATCH
|
||||||
elbrus
|
elbrus
|
||||||
@ -1315,6 +1316,7 @@ rej
|
|||||||
relpath
|
relpath
|
||||||
relro
|
relro
|
||||||
RELWITHDEBINFO
|
RELWITHDEBINFO
|
||||||
|
removedirectory
|
||||||
removefile
|
removefile
|
||||||
Rescure
|
Rescure
|
||||||
resizable
|
resizable
|
||||||
@ -1333,6 +1335,7 @@ riverbankcomputing
|
|||||||
rkey
|
rkey
|
||||||
rlock
|
rlock
|
||||||
rlt
|
rlt
|
||||||
|
rmdir
|
||||||
RMID
|
RMID
|
||||||
rocksdb
|
rocksdb
|
||||||
rolledback
|
rolledback
|
||||||
|
15
test/main.cc
15
test/main.cc
@ -212,8 +212,23 @@ std::string thunk_param(const actor_config &config) {
|
|||||||
|
|
||||||
void cleanup() {
|
void cleanup() {
|
||||||
log_trace(">> cleanup");
|
log_trace(">> cleanup");
|
||||||
|
const int is_dir =
|
||||||
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
ERROR_ACCESS_DENIED /* Windows API is mad */;
|
||||||
|
#else
|
||||||
|
EISDIR;
|
||||||
|
#endif
|
||||||
for (const auto &db_path : global::databases) {
|
for (const auto &db_path : global::databases) {
|
||||||
int err = osal_removefile(db_path);
|
int err = osal_removefile(db_path);
|
||||||
|
if (err == is_dir) {
|
||||||
|
err = osal_removefile(db_path + MDBX_LOCKNAME);
|
||||||
|
if (err == MDBX_SUCCESS || err == MDBX_ENOFILE)
|
||||||
|
err = osal_removefile(db_path + MDBX_DATANAME);
|
||||||
|
if (err == MDBX_SUCCESS || err == MDBX_ENOFILE)
|
||||||
|
err = osal_removedirectory(db_path);
|
||||||
|
} else if (err == MDBX_SUCCESS || err == MDBX_ENOFILE)
|
||||||
|
err = osal_removefile(db_path + MDBX_LOCK_SUFFIX);
|
||||||
|
|
||||||
if (err != MDBX_SUCCESS && err != MDBX_ENOFILE)
|
if (err != MDBX_SUCCESS && err != MDBX_ENOFILE)
|
||||||
failure_perror(db_path.c_str(), err);
|
failure_perror(db_path.c_str(), err);
|
||||||
}
|
}
|
||||||
|
@ -535,4 +535,8 @@ int osal_removefile(const std::string &pathname) {
|
|||||||
return unlink(pathname.c_str()) ? errno : MDBX_SUCCESS;
|
return unlink(pathname.c_str()) ? errno : MDBX_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int osal_removedirectory(const std::string &pathname) {
|
||||||
|
return rmdir(pathname.c_str()) ? errno : MDBX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* !Windows */
|
#endif /* !Windows */
|
||||||
|
@ -456,4 +456,8 @@ int osal_removefile(const std::string &pathname) {
|
|||||||
return DeleteFileA(pathname.c_str()) ? MDBX_SUCCESS : GetLastError();
|
return DeleteFileA(pathname.c_str()) ? MDBX_SUCCESS : GetLastError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int osal_removedirectory(const std::string &pathname) {
|
||||||
|
return RemoveDirectoryA(pathname.c_str()) ? MDBX_SUCCESS : GetLastError();
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* Windows */
|
#endif /* Windows */
|
||||||
|
@ -35,6 +35,7 @@ void osal_yield(void);
|
|||||||
bool osal_istty(int fd);
|
bool osal_istty(int fd);
|
||||||
std::string osal_tempdir(void);
|
std::string osal_tempdir(void);
|
||||||
int osal_removefile(const std::string &pathname);
|
int osal_removefile(const std::string &pathname);
|
||||||
|
int osal_removedirectory(const std::string &pathname);
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#ifndef STDIN_FILENO
|
#ifndef STDIN_FILENO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user