proc test
This commit is contained in:
parent
f84c1fd021
commit
5382648ba6
|
@ -40,9 +40,7 @@ class Testbase {
|
|||
void ServerStart();
|
||||
void ClientRestart();
|
||||
SRpcMsg* SendReq(tmsg_t msgType, void* pCont, int32_t contLen);
|
||||
|
||||
private:
|
||||
void InitLog(const char* path);
|
||||
void InitLog(const char* path);
|
||||
|
||||
private:
|
||||
TestServer server;
|
||||
|
|
|
@ -80,7 +80,7 @@ static int32_t taosProcInitMutex(SProcQueue *pQueue) {
|
|||
}
|
||||
|
||||
if (taosThreadMutexInit(&pQueue->mutex, &mattr) != 0) {
|
||||
taosThreadMutexDestroy(&pQueue->mutex);
|
||||
taosThreadMutexAttrDestroy(&mattr);
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
uError("failed to init mutex since %s", terrstr());
|
||||
return -1;
|
||||
|
@ -472,7 +472,8 @@ void taosProcPutToParentQ(SProcObj *pProc, const void *pHead, int16_t headLen, c
|
|||
ProcFuncType ftype) {
|
||||
int32_t retry = 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++;
|
||||
taosMsleep(retry);
|
||||
}
|
||||
|
|
|
@ -46,11 +46,11 @@ add_executable(encodeTest "encodeTest.cpp")
|
|||
target_link_libraries(encodeTest os util gtest gtest_main)
|
||||
|
||||
# queueTest
|
||||
add_executable(proc_test "procTest.cpp")
|
||||
target_link_libraries(proc_test os util gtest_main)
|
||||
add_executable(procTest "procTest.cpp")
|
||||
target_link_libraries(procTest os util transport sut gtest_main)
|
||||
add_test(
|
||||
NAME proc_test
|
||||
COMMAND proc_test
|
||||
NAME procTest
|
||||
COMMAND procTest
|
||||
)
|
||||
|
||||
# cfgTest
|
||||
|
|
|
@ -10,19 +10,56 @@
|
|||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "os.h"
|
||||
#include "tprocess.h"
|
||||
#include "tqueue.h"
|
||||
#include "trpc.h"
|
||||
#include "sut.h"
|
||||
|
||||
#include <sys/shm.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
class UtilTestQueue : public ::testing::Test {
|
||||
class UtilTesProc : public ::testing::Test {
|
||||
public:
|
||||
void SetUp() override {}
|
||||
void TearDown() override {}
|
||||
void SetUp() override {
|
||||
test.InitLog("/tmp/td");
|
||||
uDebugFlag = 207;
|
||||
shm.id = -1;
|
||||
}
|
||||
void TearDown() override {
|
||||
taosDropShm(&shm);
|
||||
}
|
||||
|
||||
public:
|
||||
static void SetUpTestSuite() {}
|
||||
static void TearDownTestSuite() {}
|
||||
static Testbase test;
|
||||
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