TDengine/source/dnode/mgmt/test/sut/src/server.cpp

49 lines
1.2 KiB
C++
Raw Normal View History

2021-12-22 07:39:32 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2022-01-04 12:36:54 +00:00
#include "sut.h"
2021-12-22 07:39:32 +00:00
void* serverLoop(void* param) {
2022-10-28 07:24:32 +00:00
TestServer* server = (TestServer*)param;
server->runnning = false;
if (dmInit() != 0) {
return NULL;
}
server->runnning = true;
if (dmRun() != 0) {
return NULL;
}
2022-05-17 08:01:06 +00:00
dmCleanup();
2022-03-17 06:33:25 +00:00
return NULL;
2021-12-22 07:39:32 +00:00
}
2022-05-17 08:01:06 +00:00
bool TestServer::Start() {
2022-03-20 02:19:14 +00:00
TdThreadAttr thAttr;
taosThreadAttrInit(&thAttr);
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
2022-10-28 07:24:32 +00:00
taosThreadCreate(&threadId, &thAttr, serverLoop, this);
2022-03-20 02:19:14 +00:00
taosThreadAttrDestroy(&thAttr);
2022-03-18 03:23:50 +00:00
taosMsleep(2100);
2022-10-28 07:24:32 +00:00
return runnning;
2021-12-22 07:39:32 +00:00
}
void TestServer::Stop() {
2022-05-16 14:34:43 +00:00
dmStop();
2022-03-20 02:19:14 +00:00
taosThreadJoin(threadId, NULL);
2021-12-22 07:39:32 +00:00
}