mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
fix unitest load config error
Former-commit-id: 8bf7417881a421bf5c28a31474743484e8fea155
This commit is contained in:
parent
688a9992be
commit
1aefac8ae0
@ -132,6 +132,21 @@ bool CommonUtil::IsFileExist(const std::string &path) {
|
||||
return (access(path.c_str(), F_OK) == 0);
|
||||
}
|
||||
|
||||
std::string CommonUtil::GetExePath() {
|
||||
const size_t bug_len = 1024;
|
||||
char exe_path[bug_len];
|
||||
size_t cnt = readlink("/proc/self/exe", exe_path, bug_len);
|
||||
if(cnt < 0|| cnt >= bug_len) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string store_path = exe_path;
|
||||
if(store_path.rfind('/') != store_path.length()){
|
||||
std::string sub_str = store_path.substr(0, store_path.rfind('/'));
|
||||
return sub_str + "/";
|
||||
}
|
||||
return store_path;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,8 @@ class CommonUtil {
|
||||
static bool IsDirectoryExit(const std::string &path);
|
||||
static ServerError CreateDirectory(const std::string &path);
|
||||
static ServerError DeleteDirectory(const std::string &path);
|
||||
|
||||
static std::string GetExePath();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -8,13 +8,18 @@
|
||||
#include <easylogging++.h>
|
||||
|
||||
#include "server/ServerConfig.h"
|
||||
#include "utils/CommonUtil.h"
|
||||
|
||||
INITIALIZE_EASYLOGGINGPP
|
||||
|
||||
using namespace zilliz::vecwise;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
std::string config_filename = "../../../conf/server_config.yaml";
|
||||
std::string exe_path = server::CommonUtil::GetExePath();
|
||||
std::string config_filename = exe_path + "../../../conf/server_config.yaml";
|
||||
zilliz::vecwise::server::ServerConfig& config = zilliz::vecwise::server::ServerConfig::GetInstance();
|
||||
config.LoadConfigFile(config_filename);
|
||||
std::cout << "Load config file form: " << config_filename << std::endl;
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user