proc test
This commit is contained in:
parent
f84c1fd021
commit
5382648ba6
|
@ -40,9 +40,7 @@ class Testbase {
|
||||||
void ServerStart();
|
void ServerStart();
|
||||||
void ClientRestart();
|
void ClientRestart();
|
||||||
SRpcMsg* SendReq(tmsg_t msgType, void* pCont, int32_t contLen);
|
SRpcMsg* SendReq(tmsg_t msgType, void* pCont, int32_t contLen);
|
||||||
|
void InitLog(const char* path);
|
||||||
private:
|
|
||||||
void InitLog(const char* path);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestServer server;
|
TestServer server;
|
||||||
|
|
|
@ -80,7 +80,7 @@ static int32_t taosProcInitMutex(SProcQueue *pQueue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosThreadMutexInit(&pQueue->mutex, &mattr) != 0) {
|
if (taosThreadMutexInit(&pQueue->mutex, &mattr) != 0) {
|
||||||
taosThreadMutexDestroy(&pQueue->mutex);
|
taosThreadMutexAttrDestroy(&mattr);
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
uError("failed to init mutex since %s", terrstr());
|
uError("failed to init mutex since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -472,7 +472,8 @@ void taosProcPutToParentQ(SProcObj *pProc, const void *pHead, int16_t headLen, c
|
||||||
ProcFuncType ftype) {
|
ProcFuncType ftype) {
|
||||||
int32_t retry = 0;
|
int32_t retry = 0;
|
||||||
while (taosProcQueuePush(pProc, pProc->pParentQueue, pHead, headLen, pBody, bodyLen, 0, ftype) != 0) {
|
while (taosProcQueuePush(pProc, pProc->pParentQueue, pHead, headLen, pBody, bodyLen, 0, ftype) != 0) {
|
||||||
uInfo("proc:%s, failed to put msg to queue:%p since %s, retry:%d", pProc->name, pProc->pParentQueue, terrstr(), retry);
|
uInfo("proc:%s, failed to put msg to queue:%p since %s, retry:%d", pProc->name, pProc->pParentQueue, terrstr(),
|
||||||
|
retry);
|
||||||
retry++;
|
retry++;
|
||||||
taosMsleep(retry);
|
taosMsleep(retry);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,11 +46,11 @@ add_executable(encodeTest "encodeTest.cpp")
|
||||||
target_link_libraries(encodeTest os util gtest gtest_main)
|
target_link_libraries(encodeTest os util gtest gtest_main)
|
||||||
|
|
||||||
# queueTest
|
# queueTest
|
||||||
add_executable(proc_test "procTest.cpp")
|
add_executable(procTest "procTest.cpp")
|
||||||
target_link_libraries(proc_test os util gtest_main)
|
target_link_libraries(procTest os util transport sut gtest_main)
|
||||||
add_test(
|
add_test(
|
||||||
NAME proc_test
|
NAME procTest
|
||||||
COMMAND proc_test
|
COMMAND procTest
|
||||||
)
|
)
|
||||||
|
|
||||||
# cfgTest
|
# cfgTest
|
||||||
|
|
|
@ -10,19 +10,56 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
#include "tprocess.h"
|
||||||
#include "os.h"
|
|
||||||
#include "tqueue.h"
|
#include "tqueue.h"
|
||||||
|
#include "trpc.h"
|
||||||
|
#include "sut.h"
|
||||||
|
|
||||||
#include <sys/shm.h>
|
class UtilTesProc : public ::testing::Test {
|
||||||
#include <sys/wait.h>
|
|
||||||
|
|
||||||
class UtilTestQueue : public ::testing::Test {
|
|
||||||
public:
|
public:
|
||||||
void SetUp() override {}
|
void SetUp() override {
|
||||||
void TearDown() override {}
|
test.InitLog("/tmp/td");
|
||||||
|
uDebugFlag = 207;
|
||||||
|
shm.id = -1;
|
||||||
|
}
|
||||||
|
void TearDown() override {
|
||||||
|
taosDropShm(&shm);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void SetUpTestSuite() {}
|
static Testbase test;
|
||||||
static void TearDownTestSuite() {}
|
static SShm shm;
|
||||||
|
static void SetUpTestSuite() {}
|
||||||
|
static void TearDownTestSuite() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Testbase UtilTesProc::test;
|
||||||
|
SShm UtilTesProc::shm;
|
||||||
|
|
||||||
|
TEST_F(UtilTesProc, 01_Create_Drop_Proc) {
|
||||||
|
ASSERT_EQ(taosCreateShm(&shm, 1234, 1024 * 1024 * 2), 0);
|
||||||
|
|
||||||
|
shm.size = 1023;
|
||||||
|
SProcCfg cfg = {.childConsumeFp = (ProcConsumeFp)NULL,
|
||||||
|
.childMallocHeadFp = (ProcMallocFp)taosAllocateQitem,
|
||||||
|
.childFreeHeadFp = (ProcFreeFp)taosFreeQitem,
|
||||||
|
.childMallocBodyFp = (ProcMallocFp)rpcMallocCont,
|
||||||
|
.childFreeBodyFp = (ProcFreeFp)rpcFreeCont,
|
||||||
|
.parentConsumeFp = (ProcConsumeFp)NULL,
|
||||||
|
.parentMallocHeadFp = (ProcMallocFp)taosMemoryMalloc,
|
||||||
|
.parentFreeHeadFp = (ProcFreeFp)taosMemoryFree,
|
||||||
|
.parentMallocBodyFp = (ProcMallocFp)rpcMallocCont,
|
||||||
|
.parentFreeBodyFp = (ProcFreeFp)rpcFreeCont,
|
||||||
|
.shm = shm,
|
||||||
|
.parent = &shm,
|
||||||
|
.name = "1234"};
|
||||||
|
SProcObj *proc = taosProcInit(&cfg);
|
||||||
|
ASSERT_EQ(proc, nullptr);
|
||||||
|
|
||||||
|
shm.size = 2468;
|
||||||
|
cfg.shm = shm;
|
||||||
|
proc = taosProcInit(&cfg);
|
||||||
|
ASSERT_NE(proc, nullptr);
|
||||||
|
|
||||||
|
taosDropShm(&shm);
|
||||||
|
}
|
Loading…
Reference in New Issue