fix: failed to start unitest in mac

This commit is contained in:
Shengliang Guan 2022-10-28 15:24:32 +08:00
parent 820de25e97
commit 57960661d4
3 changed files with 20 additions and 6 deletions

View File

@ -20,7 +20,8 @@ class TestServer {
public: public:
bool Start(); bool Start();
void Stop(); void Stop();
bool runnning;
private: private:
TdThread threadId; TdThread threadId;
}; };

View File

@ -16,8 +16,18 @@
#include "sut.h" #include "sut.h"
void* serverLoop(void* param) { void* serverLoop(void* param) {
dmInit(); TestServer* server = (TestServer*)param;
dmRun(); server->runnning = false;
if (dmInit() != 0) {
return NULL;
}
server->runnning = true;
if (dmRun() != 0) {
return NULL;
}
dmCleanup(); dmCleanup();
return NULL; return NULL;
} }
@ -26,10 +36,10 @@ bool TestServer::Start() {
TdThreadAttr thAttr; TdThreadAttr thAttr;
taosThreadAttrInit(&thAttr); taosThreadAttrInit(&thAttr);
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
taosThreadCreate(&threadId, &thAttr, serverLoop, NULL); taosThreadCreate(&threadId, &thAttr, serverLoop, this);
taosThreadAttrDestroy(&thAttr); taosThreadAttrDestroy(&thAttr);
taosMsleep(2100); taosMsleep(2100);
return true; return runnning;
} }
void TestServer::Stop() { void TestServer::Stop() {

View File

@ -53,7 +53,10 @@ void Testbase::Init(const char* path, int16_t port) {
taosMkDir(path); taosMkDir(path);
InitLog(TD_TMP_DIR_PATH "td"); InitLog(TD_TMP_DIR_PATH "td");
server.Start(); if (!server.Start()) {
printf("failed to start server, exit\n");
exit(0);
};
client.Init("root", "taosdata"); client.Init("root", "taosdata");
showRsp = NULL; showRsp = NULL;
} }