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:
bool Start();
void Stop();
bool runnning;
private:
TdThread threadId;
};

View File

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

View File

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