Merge branch '3.0' of https://github.com/taosdata/TDengine into enh/TS-5445-3.0
This commit is contained in:
commit
df96529e0d
|
@ -47,8 +47,10 @@ int32_t taosGetProcMemory(int64_t *usedKB);
|
|||
int32_t taosGetSysMemory(int64_t *usedKB);
|
||||
int32_t taosGetSysAvailMemory(int64_t *availSize);
|
||||
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize);
|
||||
int32_t taosGetProcIO(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int64_t *write_bytes);
|
||||
int32_t taosGetProcIODelta(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int64_t *write_bytes);
|
||||
void taosSetDefaultProcIODelta(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int64_t *write_bytes);
|
||||
int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes);
|
||||
int32_t taosGetCardInfoDelta(int64_t *receive_bytes, int64_t *transmit_bytes);
|
||||
void taosSetDefaultCardInfoDelta(int64_t *receive_bytes, int64_t *transmit_bytes);
|
||||
|
||||
|
|
|
@ -751,7 +751,7 @@ static int32_t smlFindNearestPowerOf2(int32_t length, uint8_t type) {
|
|||
}
|
||||
|
||||
static int32_t smlProcessSchemaAction(SSmlHandle *info, SSchema *schemaField, SHashObj *schemaHash, SArray *cols,
|
||||
SArray *checkDumplicateCols, ESchemaAction *action, bool isTag) {
|
||||
SHashObj *schemaHashCheck, ESchemaAction *action, bool isTag) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
for (int j = 0; j < taosArrayGetSize(cols); ++j) {
|
||||
|
@ -759,15 +759,11 @@ static int32_t smlProcessSchemaAction(SSmlHandle *info, SSchema *schemaField, SH
|
|||
SSmlKv *kv = (SSmlKv *)taosArrayGet(cols, j);
|
||||
SML_CHECK_NULL(kv);
|
||||
SML_CHECK_CODE(smlGenerateSchemaAction(schemaField, schemaHash, kv, isTag, action, info));
|
||||
}
|
||||
|
||||
for (int j = 0; j < taosArrayGetSize(checkDumplicateCols); ++j) {
|
||||
SSmlKv *kv = (SSmlKv *)taosArrayGet(checkDumplicateCols, j);
|
||||
SML_CHECK_NULL(kv);
|
||||
if (taosHashGet(schemaHash, kv->key, kv->keyLen) != NULL) {
|
||||
if (taosHashGet(schemaHashCheck, kv->key, kv->keyLen) != NULL) {
|
||||
SML_CHECK_CODE(TSDB_CODE_PAR_DUPLICATED_COLUMN);
|
||||
}
|
||||
}
|
||||
|
||||
END:
|
||||
RETURN
|
||||
}
|
||||
|
@ -998,14 +994,14 @@ static int32_t smlBuildFields(SArray **pColumns, SArray **pTags, STableMeta *pTa
|
|||
END:
|
||||
RETURN
|
||||
}
|
||||
static int32_t smlModifyTag(SSmlHandle *info, SHashObj* hashTmp, SRequestConnInfo *conn,
|
||||
static int32_t smlModifyTag(SSmlHandle *info, SHashObj* hashTmpCheck, SHashObj* hashTmp, SRequestConnInfo *conn,
|
||||
SSmlSTableMeta *sTableData, SName *pName, STableMeta **pTableMeta){
|
||||
ESchemaAction action = SCHEMA_ACTION_NULL;
|
||||
SArray *pColumns = NULL;
|
||||
SArray *pTags = NULL;
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
SML_CHECK_CODE(smlProcessSchemaAction(info, (*pTableMeta)->schema, hashTmp, sTableData->tags, sTableData->cols, &action, true));
|
||||
SML_CHECK_CODE(smlProcessSchemaAction(info, (*pTableMeta)->schema, hashTmp, sTableData->tags, hashTmpCheck, &action, true));
|
||||
|
||||
if (action != SCHEMA_ACTION_NULL) {
|
||||
SML_CHECK_CODE(smlCheckAuth(info, conn, pName->tname, AUTH_TYPE_WRITE));
|
||||
|
@ -1029,14 +1025,14 @@ END:
|
|||
RETURN
|
||||
}
|
||||
|
||||
static int32_t smlModifyCols(SSmlHandle *info, SHashObj* hashTmp, SRequestConnInfo *conn,
|
||||
static int32_t smlModifyCols(SSmlHandle *info, SHashObj* hashTmpCheck, SHashObj* hashTmp, SRequestConnInfo *conn,
|
||||
SSmlSTableMeta *sTableData, SName *pName, STableMeta **pTableMeta){
|
||||
ESchemaAction action = SCHEMA_ACTION_NULL;
|
||||
SArray *pColumns = NULL;
|
||||
SArray *pTags = NULL;
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
SML_CHECK_CODE(smlProcessSchemaAction(info, (*pTableMeta)->schema, hashTmp, sTableData->cols, sTableData->tags, &action, false));
|
||||
SML_CHECK_CODE(smlProcessSchemaAction(info, (*pTableMeta)->schema, hashTmp, sTableData->cols, hashTmpCheck, &action, false));
|
||||
|
||||
if (action != SCHEMA_ACTION_NULL) {
|
||||
SML_CHECK_CODE(smlCheckAuth(info, conn, pName->tname, AUTH_TYPE_WRITE));
|
||||
|
@ -1079,7 +1075,8 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
}
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
SHashObj *hashTmp = NULL;
|
||||
SHashObj *colHashTmp = NULL;
|
||||
SHashObj *tagHashTmp = NULL;
|
||||
STableMeta *pTableMeta = NULL;
|
||||
|
||||
SName pName = {TSDB_TABLE_NAME_T, info->taos->acctId, {0}, {0}};
|
||||
|
@ -1119,17 +1116,21 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
SML_CHECK_CODE(TSDB_CODE_SML_NOT_SUPPORT_PK);
|
||||
}
|
||||
|
||||
hashTmp = taosHashInit(pTableMeta->tableInfo.numOfTags, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SML_CHECK_NULL(hashTmp);
|
||||
SML_CHECK_CODE(smlBuildTempHash(hashTmp, pTableMeta, pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags));
|
||||
SML_CHECK_CODE(smlModifyTag(info, hashTmp, &conn, sTableData, &pName, &pTableMeta));
|
||||
taosHashClear(hashTmp);
|
||||
SML_CHECK_CODE(smlBuildTempHash(hashTmp, pTableMeta, 0, pTableMeta->tableInfo.numOfColumns));
|
||||
SML_CHECK_CODE(smlModifyCols(info, hashTmp, &conn, sTableData, &pName, &pTableMeta));
|
||||
colHashTmp = taosHashInit(pTableMeta->tableInfo.numOfColumns, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
tagHashTmp = taosHashInit(pTableMeta->tableInfo.numOfTags, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SML_CHECK_NULL(colHashTmp);
|
||||
SML_CHECK_NULL(tagHashTmp);
|
||||
SML_CHECK_CODE(smlBuildTempHash(tagHashTmp, pTableMeta, pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags));
|
||||
SML_CHECK_CODE(smlBuildTempHash(colHashTmp, pTableMeta, 0, pTableMeta->tableInfo.numOfColumns));
|
||||
|
||||
SML_CHECK_CODE(smlModifyTag(info, colHashTmp, tagHashTmp, &conn, sTableData, &pName, &pTableMeta));
|
||||
SML_CHECK_CODE(smlModifyCols(info, tagHashTmp, colHashTmp, &conn, sTableData, &pName, &pTableMeta));
|
||||
|
||||
needCheckMeta = true;
|
||||
taosHashCleanup(hashTmp);
|
||||
hashTmp = NULL;
|
||||
taosHashCleanup(colHashTmp);
|
||||
taosHashCleanup(tagHashTmp);
|
||||
colHashTmp = NULL;
|
||||
tagHashTmp = NULL;
|
||||
} else {
|
||||
uError("SML:0x%" PRIx64 " %s load table meta error: %s", info->id, __FUNCTION__, tstrerror(code));
|
||||
goto END;
|
||||
|
@ -1153,7 +1154,8 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
|
||||
END:
|
||||
taosHashCancelIterate(info->superTables, tmp);
|
||||
taosHashCleanup(hashTmp);
|
||||
taosHashCleanup(colHashTmp);
|
||||
taosHashCleanup(tagHashTmp);
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
(void)catalogRefreshTableMeta(info->pCatalog, &conn, &pName, 1); // ignore refresh meta code if there is an error
|
||||
uError("SML:0x%" PRIx64 " %s end failed:%d:%s, format:%d, needModifySchema:%d", info->id, __FUNCTION__, code,
|
||||
|
@ -1924,3 +1926,4 @@ TAOS_RES *taos_schemaless_insert_raw(TAOS *taos, char *lines, int len, int32_t *
|
|||
return taos_schemaless_insert_raw_ttl_with_reqid(taos, lines, len, totalRows, protocol, precision,
|
||||
TSDB_DEFAULT_TABLE_TTL, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -1259,6 +1259,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
|||
SDbObj *pDb = NULL;
|
||||
SMCreateStbReq createReq = {0};
|
||||
bool isAlter = false;
|
||||
SHashObj *pHash = NULL;
|
||||
|
||||
if (tDeserializeSMCreateStbReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
|
@ -1319,6 +1320,33 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
pHash = taosHashInit(createReq.numOfColumns + createReq.numOfTags, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY),
|
||||
false, HASH_NO_LOCK);
|
||||
if (pHash == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < createReq.numOfColumns; ++i) {
|
||||
SFieldWithOptions *pField = taosArrayGet(createReq.pColumns, i);
|
||||
if ((code = taosHashPut(pHash, pField->name, strlen(pField->name), NULL, 0)) != 0) {
|
||||
if (code == TSDB_CODE_DUP_KEY) {
|
||||
code = TSDB_CODE_TSC_DUP_COL_NAMES;
|
||||
}
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < createReq.numOfTags; ++i) {
|
||||
SField *pField = taosArrayGet(createReq.pTags, i);
|
||||
if ((code = taosHashPut(pHash, pField->name, strlen(pField->name), NULL, 0)) != 0) {
|
||||
if (code == TSDB_CODE_DUP_KEY) {
|
||||
code = TSDB_CODE_TSC_DUP_COL_NAMES;
|
||||
}
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
||||
pDb = mndAcquireDbByStb(pMnode, createReq.name);
|
||||
if (pDb == NULL) {
|
||||
code = TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||
|
@ -1383,6 +1411,10 @@ _OVER:
|
|||
mndReleaseDb(pMnode, pDb);
|
||||
tFreeSMCreateStbReq(&createReq);
|
||||
|
||||
if (pHash != NULL) {
|
||||
taosHashCleanup(pHash);
|
||||
}
|
||||
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ class MndTestStb : public ::testing::Test {
|
|||
void* BuildCreateDbReq(const char* dbname, int32_t* pContLen);
|
||||
void* BuildDropDbReq(const char* dbname, int32_t* pContLen);
|
||||
void* BuildCreateStbReq(const char* stbname, int32_t* pContLen);
|
||||
void* BuildCreateStbDuplicateReq(const char* stbname, int32_t* pContLen);
|
||||
void* BuildAlterStbAddTagReq(const char* stbname, const char* tagname, int32_t* pContLen);
|
||||
void* BuildAlterStbDropTagReq(const char* stbname, const char* tagname, int32_t* pContLen);
|
||||
void* BuildAlterStbUpdateTagNameReq(const char* stbname, const char* tagname, const char* newtagname,
|
||||
|
@ -137,6 +138,71 @@ void* MndTestStb::BuildCreateStbReq(const char* stbname, int32_t* pContLen) {
|
|||
return pHead;
|
||||
}
|
||||
|
||||
void* MndTestStb::BuildCreateStbDuplicateReq(const char* stbname, int32_t* pContLen) {
|
||||
SMCreateStbReq createReq = {0};
|
||||
createReq.numOfColumns = 2;
|
||||
createReq.numOfTags = 4;
|
||||
createReq.igExists = 0;
|
||||
createReq.pColumns = taosArrayInit(createReq.numOfColumns, sizeof(SField));
|
||||
createReq.pTags = taosArrayInit(createReq.numOfTags, sizeof(SField));
|
||||
strcpy(createReq.name, stbname);
|
||||
|
||||
{
|
||||
SField field = {0};
|
||||
field.bytes = 8;
|
||||
field.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(field.name, "ts");
|
||||
taosArrayPush(createReq.pColumns, &field);
|
||||
}
|
||||
|
||||
{
|
||||
SField field = {0};
|
||||
field.bytes = 12;
|
||||
field.type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(field.name, "col1");
|
||||
taosArrayPush(createReq.pColumns, &field);
|
||||
}
|
||||
|
||||
{
|
||||
SField field = {0};
|
||||
field.bytes = 2;
|
||||
field.type = TSDB_DATA_TYPE_TINYINT;
|
||||
strcpy(field.name, "tag1");
|
||||
taosArrayPush(createReq.pTags, &field);
|
||||
}
|
||||
|
||||
{
|
||||
SField field = {0};
|
||||
field.bytes = 8;
|
||||
field.type = TSDB_DATA_TYPE_BIGINT;
|
||||
strcpy(field.name, "tag2");
|
||||
taosArrayPush(createReq.pTags, &field);
|
||||
}
|
||||
|
||||
{
|
||||
SField field = {0};
|
||||
field.bytes = 16;
|
||||
field.type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(field.name, "tag3");
|
||||
taosArrayPush(createReq.pTags, &field);
|
||||
}
|
||||
|
||||
{
|
||||
SField field = {0};
|
||||
field.bytes = 16;
|
||||
field.type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(field.name, "tag3");
|
||||
taosArrayPush(createReq.pTags, &field);
|
||||
}
|
||||
|
||||
int32_t tlen = tSerializeSMCreateStbReq(NULL, 0, &createReq);
|
||||
void* pHead = rpcMallocCont(tlen);
|
||||
tSerializeSMCreateStbReq(pHead, tlen, &createReq);
|
||||
tFreeSMCreateStbReq(&createReq);
|
||||
*pContLen = tlen;
|
||||
return pHead;
|
||||
}
|
||||
|
||||
void* MndTestStb::BuildAlterStbAddTagReq(const char* stbname, const char* tagname, int32_t* pContLen) {
|
||||
SMAlterStbReq req = {0};
|
||||
strcpy(req.name, stbname);
|
||||
|
@ -896,3 +962,26 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
|
|||
rpcFreeCont(pRsp->pCont);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MndTestStb, 09_Create_Duplicate_Stb) {
|
||||
const char* dbname = "1.d2";
|
||||
const char* stbname = "1.d2.stb";
|
||||
|
||||
{
|
||||
int32_t contLen = 0;
|
||||
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
rpcFreeCont(pRsp->pCont);
|
||||
}
|
||||
|
||||
{
|
||||
int32_t contLen = 0;
|
||||
void* pReq = BuildCreateStbDuplicateReq(stbname, &contLen);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_TSC_DUP_COL_NAMES);
|
||||
rpcFreeCont(pRsp->pCont);
|
||||
}
|
||||
}
|
|
@ -87,7 +87,7 @@ void taosRandStr(char* str, int32_t size) {
|
|||
|
||||
void taosRandStr2(char* str, int32_t size) {
|
||||
const char* set = "abcdefghijklmnopqrstuvwxyz0123456789@";
|
||||
int32_t len = strlen(set);
|
||||
int32_t len = 37;
|
||||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
str[i] = set[taosRand() % len];
|
||||
|
|
|
@ -114,6 +114,7 @@ int32_t taosDflSignal(int32_t signum) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t taosKillChildOnParentStopped() {
|
||||
#ifndef _TD_DARWIN_64
|
||||
int32_t code = prctl(PR_SET_PDEATHSIG, SIGKILL);
|
||||
|
@ -126,5 +127,6 @@ int32_t taosKillChildOnParentStopped() {
|
|||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -294,6 +294,7 @@ int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes) {
|
|||
//#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4) {
|
||||
if (target_ucs4 == NULL || source_ucs4 == NULL || len_ucs4 <= 0) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
|
@ -307,11 +308,12 @@ int32_t tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4)
|
|||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
iconv_t taosAcquireConv(int32_t *idx, ConvType type, void* charsetCxt) {
|
||||
if(idx == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return (iconv_t)-1;
|
||||
return (iconv_t)NULL;
|
||||
}
|
||||
if (charsetCxt == NULL){
|
||||
charsetCxt = tsCharsetCxt;
|
||||
|
|
|
@ -147,7 +147,6 @@ static void taosGetProcIOnfos() {
|
|||
#endif
|
||||
|
||||
static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
|
||||
OS_PARAM_CHECK(cpuInfo);
|
||||
int32_t code = 0;
|
||||
#ifdef WINDOWS
|
||||
FILETIME pre_idleTime = {0};
|
||||
|
@ -200,7 +199,6 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
|
|||
}
|
||||
|
||||
static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
|
||||
OS_PARAM_CHECK(cpuInfo);
|
||||
int32_t code = 0;
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
@ -541,7 +539,6 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
|
|||
|
||||
// Returns the container's CPU quota if successful, otherwise returns the physical CPU cores
|
||||
static int32_t taosCntrGetCpuCores(float *numOfCores) {
|
||||
OS_PARAM_CHECK(numOfCores);
|
||||
#ifdef WINDOWS
|
||||
return TSDB_CODE_UNSUPPORT_OS;
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
|
@ -1092,6 +1089,7 @@ void taosSetDefaultCardInfoDelta(int64_t *receive_bytes, int64_t *transmit_bytes
|
|||
if (transmit_bytes) *transmit_bytes = 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void taosKillSystem() {
|
||||
#ifdef WINDOWS
|
||||
printf("function taosKillSystem, exit!");
|
||||
|
@ -1105,6 +1103,7 @@ void taosKillSystem() {
|
|||
(void)kill(tsProcId, 2);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#define UUIDLEN (36)
|
||||
int32_t taosGetSystemUUIDLimit36(char *uid, int32_t uidlen) {
|
||||
|
|
|
@ -21,30 +21,41 @@ add_test(
|
|||
NAME osAtomicTests
|
||||
COMMAND osAtomicTests
|
||||
)
|
||||
endif()
|
||||
|
||||
if(TD_LINUX)
|
||||
add_executable(osDirTests "osDirTests.cpp")
|
||||
target_link_libraries(osDirTests os util gtest_main)
|
||||
add_test(
|
||||
NAME osDirTests
|
||||
COMMAND osDirTests
|
||||
)
|
||||
|
||||
add_executable(osFileTests "osFileTests.cpp")
|
||||
target_link_libraries(osFileTests os util gtest_main)
|
||||
add_test(
|
||||
NAME osFileTests
|
||||
COMMAND osFileTests
|
||||
)
|
||||
endif()
|
||||
|
||||
if(TD_LINUX)
|
||||
add_executable(osEnvTests "osEnvTests.cpp")
|
||||
target_link_libraries(osEnvTests os util gtest_main)
|
||||
add_test(
|
||||
NAME osEnvTests
|
||||
COMMAND osEnvTests
|
||||
)
|
||||
|
||||
add_executable(osTests "osTests.cpp")
|
||||
target_link_libraries(osTests os util gtest_main)
|
||||
add_test(
|
||||
NAME osTests
|
||||
COMMAND osTests
|
||||
)
|
||||
|
||||
add_executable(osThreadTests "osThreadTests.cpp")
|
||||
target_link_libraries(osThreadTests os util gtest_main)
|
||||
add_test(
|
||||
NAME osThreadTests
|
||||
COMMAND osThreadTests
|
||||
)
|
||||
endif()
|
||||
|
||||
add_executable(osMathTests "osMathTests.cpp")
|
||||
|
@ -61,13 +72,6 @@ add_test(
|
|||
COMMAND osSemaphoreTests
|
||||
)
|
||||
|
||||
add_executable(osSignalTests "osSignalTests.cpp")
|
||||
target_link_libraries(osSignalTests os util gtest_main)
|
||||
add_test(
|
||||
NAME osSignalTests
|
||||
COMMAND osSignalTests
|
||||
)
|
||||
|
||||
add_executable(osSleepTests "osSleepTests.cpp")
|
||||
target_link_libraries(osSleepTests os util gtest_main)
|
||||
add_test(
|
||||
|
@ -82,13 +86,6 @@ add_test(
|
|||
COMMAND osStringTests
|
||||
)
|
||||
|
||||
add_executable(osTests "osTests.cpp")
|
||||
target_link_libraries(osTests os util gtest_main)
|
||||
add_test(
|
||||
NAME osTests
|
||||
COMMAND osTests
|
||||
)
|
||||
|
||||
add_executable(osSystemTests "osSystemTests.cpp")
|
||||
target_link_libraries(osSystemTests os util gtest_main)
|
||||
add_test(
|
||||
|
@ -96,19 +93,9 @@ add_test(
|
|||
COMMAND osSystemTests
|
||||
)
|
||||
|
||||
if(TD_LINUX)
|
||||
add_executable(osThreadTests "osThreadTests.cpp")
|
||||
target_link_libraries(osThreadTests os util gtest_main)
|
||||
add_test(
|
||||
NAME osThreadTests
|
||||
COMMAND osThreadTests
|
||||
)
|
||||
endif()
|
||||
|
||||
add_executable(osTimeTests "osTimeTests.cpp")
|
||||
target_link_libraries(osTimeTests os util gtest_main)
|
||||
add_test(
|
||||
NAME osTimeTests
|
||||
COMMAND osTimeTests
|
||||
)
|
||||
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
#pragma GCC diagnostic ignored "-Wformat"
|
||||
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
|
||||
#pragma GCC diagnostic ignored "-Wpointer-arith"
|
||||
|
||||
#include "os.h"
|
||||
#include "tlog.h"
|
||||
|
||||
TEST(osSignalTests, taosSetSignal) {
|
||||
// Set up SIGINT handler using taosSetSignal
|
||||
//taosSetSignal(SIGINT, sigint_handler);
|
||||
|
||||
// Print PID for testing purposes
|
||||
// printf("PID: %d\n", getpid());
|
||||
|
||||
// Wait for signal to be received
|
||||
}
|
|
@ -250,7 +250,6 @@ TEST(osStringTests, osStr2int32) {
|
|||
result = taosStr2int32(large_num, &val);
|
||||
ASSERT_EQ(result, TAOS_SYSTEM_ERROR(ERANGE));
|
||||
|
||||
|
||||
result = taosStr2int32("123abc", &val);
|
||||
ASSERT_EQ(result, 0);
|
||||
ASSERT_EQ(val, 123);
|
||||
|
@ -349,7 +348,6 @@ TEST(osStringTests, taosStr2int16) {
|
|||
ASSERT_EQ(val, 12345);
|
||||
}
|
||||
|
||||
|
||||
TEST(osStringTests, taosStr2int8) {
|
||||
int8_t val;
|
||||
int32_t result;
|
||||
|
@ -466,7 +464,6 @@ TEST(osStringTests, osStr2Uint64) {
|
|||
result = taosStr2Uint64("12345 ", &val);
|
||||
ASSERT_EQ(result, 0);
|
||||
ASSERT_EQ(val, 12345);
|
||||
|
||||
}
|
||||
|
||||
TEST(osStringTests, taosStr2Uint32) {
|
||||
|
@ -634,3 +631,157 @@ TEST(osStringTests, taosStr2Uint8) {
|
|||
ASSERT_EQ(val, 123);
|
||||
}
|
||||
|
||||
TEST(osStringTests, strint2) {
|
||||
const char* ret = tstrdup(NULL);
|
||||
EXPECT_EQ(ret, nullptr);
|
||||
|
||||
ret = taosStrndupi(NULL, 0);
|
||||
EXPECT_EQ(ret, nullptr);
|
||||
|
||||
char buf[12] = "12345";
|
||||
ret = tstrndup(buf, 4);
|
||||
EXPECT_NE(ret, nullptr);
|
||||
|
||||
int64_t val = 0;
|
||||
int32_t ret32 = taosStr2int64(NULL, &val);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosStr2int64(buf, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
TdUcs4 p1, p2;
|
||||
int32_t val32 = 0;
|
||||
ret32 = tasoUcs4Compare(&p1, NULL, val32);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = tasoUcs4Compare(NULL, &p2, val32);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
void* retptr = taosAcquireConv(NULL, M2C, NULL);
|
||||
EXPECT_EQ(retptr, nullptr);
|
||||
|
||||
ret32 = taosUcs4ToMbs(NULL, 0, NULL, NULL);
|
||||
EXPECT_EQ(ret32, 0);
|
||||
ret32 = taosUcs4ToMbs(NULL, -1, NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosUcs4ToMbs(NULL, 1, NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosUcs4ToMbs(&p1, 1, NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
bool retb = taosValidateEncodec(NULL);
|
||||
EXPECT_FALSE(retb);
|
||||
|
||||
ret32 = taosUcs4len(NULL);
|
||||
EXPECT_EQ(ret32, 0);
|
||||
|
||||
unsigned char src[24] = "1234";
|
||||
char dst[24] = {0};
|
||||
int32_t len = 5;
|
||||
int32_t bufSize = 24;
|
||||
ret32 = taosHexEncode(NULL, NULL, len, -1);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosHexEncode(src, NULL, len, -1);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosHexEncode(src, dst, len, -1);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosHexEncode(src, dst, len, bufSize);
|
||||
EXPECT_EQ(ret32, 0);
|
||||
|
||||
char dst2[24] = {0};
|
||||
ret32 = taosHexDecode(NULL, NULL, 0);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosHexDecode(NULL, dst2, 0);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosHexDecode(dst, NULL, 0);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosHexDecode(dst, dst2, 24);
|
||||
EXPECT_EQ(ret32, 0);
|
||||
EXPECT_STREQ((char*)src, dst2);
|
||||
}
|
||||
|
||||
TEST(osStringTests, wchartest) {
|
||||
char src[24] = "1234";
|
||||
TdWchar dst[24] = {0};
|
||||
|
||||
int32_t ret32 = taosWcharsWidth(NULL, 0);
|
||||
EXPECT_LT(ret32, 0);
|
||||
ret32 = taosWcharsWidth(dst, 0);
|
||||
EXPECT_LT(ret32, 0);
|
||||
|
||||
ret32 = taosMbToWchar(NULL, NULL, 0);
|
||||
EXPECT_LT(ret32, 0);
|
||||
ret32 = taosMbToWchar(dst, NULL, 0);
|
||||
EXPECT_LT(ret32, 0);
|
||||
ret32 = taosMbToWchar(dst, src, 0);
|
||||
EXPECT_LT(ret32, 0);
|
||||
ret32 = taosMbToWchar(dst, src, 4);
|
||||
EXPECT_GT(ret32, 0);
|
||||
ret32 = taosWcharsWidth(dst, ret32);
|
||||
EXPECT_GT(ret32, 0);
|
||||
|
||||
ret32 = taosMbsToWchars(NULL, NULL, 0);
|
||||
EXPECT_LT(ret32, 0);
|
||||
ret32 = taosMbsToWchars(dst, NULL, 0);
|
||||
EXPECT_LT(ret32, 0);
|
||||
ret32 = taosMbsToWchars(dst, src, 0);
|
||||
EXPECT_LT(ret32, 0);
|
||||
ret32 = taosMbsToWchars(dst, src, 4);
|
||||
EXPECT_GT(ret32, 0);
|
||||
ret32 = taosWcharsWidth(dst, ret32);
|
||||
EXPECT_GT(ret32, 0);
|
||||
|
||||
ret32 = taosWcharsWidth(NULL, dst[0]);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosWcharToMb(src, dst[0]);
|
||||
EXPECT_NE(ret32, 0);
|
||||
}
|
||||
|
||||
TEST(osStringTests, strtransform) {
|
||||
char src[12] = "12";
|
||||
|
||||
void* retptr = taosStrCaseStr(NULL, NULL);
|
||||
EXPECT_EQ(retptr, nullptr);
|
||||
retptr = taosStrCaseStr(src, NULL);
|
||||
EXPECT_NE(retptr, nullptr);
|
||||
|
||||
int64_t ret64 = taosStr2Int64(NULL, NULL, 0);
|
||||
EXPECT_EQ(ret64, 0);
|
||||
uint64_t retu64 = taosStr2UInt64(NULL, NULL, 0);
|
||||
EXPECT_EQ(retu64, 0);
|
||||
int32_t ret32 = taosStr2Int32(NULL, NULL, 0);
|
||||
EXPECT_EQ(ret32, 0);
|
||||
uint32_t retu32 = taosStr2UInt32(NULL, NULL, 0);
|
||||
EXPECT_EQ(retu32, 0);
|
||||
ret32 = taosStr2Int16(NULL, NULL, 0);
|
||||
EXPECT_EQ(ret32, 0);
|
||||
ret32 = taosStr2UInt16(NULL, NULL, 0);
|
||||
EXPECT_EQ(ret32, 0);
|
||||
ret32 = taosStr2Int8(NULL, NULL, 0);
|
||||
EXPECT_EQ(ret32, 0);
|
||||
ret32 = taosStr2UInt8(NULL, NULL, 0);
|
||||
EXPECT_EQ(ret32, 0);
|
||||
|
||||
double retd = taosStr2Double(NULL, NULL);
|
||||
EXPECT_EQ((int32_t)retd, 0);
|
||||
float retf = taosStr2Float(NULL, NULL);
|
||||
EXPECT_EQ((int32_t)retf, 0);
|
||||
|
||||
bool retb = isValidateHex(NULL, 0);
|
||||
EXPECT_FALSE(retb);
|
||||
|
||||
char z[12] = {0};
|
||||
ret32 = taosHex2Ascii(NULL, 0, NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosHex2Ascii(z, 0, NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosHex2Ascii(z, 0, (void**)&z, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
ret64 = tsnprintf(NULL, 0, NULL);
|
||||
EXPECT_EQ(ret64, 0);
|
||||
ret64 = tsnprintf(z, 4, NULL);
|
||||
EXPECT_EQ(ret64, 0);
|
||||
ret64 = tsnprintf(z, 0, "ab");
|
||||
EXPECT_EQ(ret64, 0);
|
||||
ret64 = tsnprintf(z, 1, "ab");
|
||||
EXPECT_EQ(ret64, 0);
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
#include <inttypes.h>
|
||||
#include <iostream>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||
|
@ -36,6 +36,230 @@
|
|||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
TEST(osTest, locale) {
|
||||
char *ret = taosCharsetReplace(NULL);
|
||||
EXPECT_EQ(ret, nullptr);
|
||||
|
||||
ret = taosCharsetReplace("utf8");
|
||||
EXPECT_NE(ret, nullptr);
|
||||
|
||||
ret = taosCharsetReplace("utf-8");
|
||||
EXPECT_NE(ret, nullptr);
|
||||
|
||||
taosGetSystemLocale(NULL, "");
|
||||
taosGetSystemLocale("", NULL);
|
||||
}
|
||||
|
||||
TEST(osTest, memory) {
|
||||
int32_t ret = taosMemoryDbgInitRestore();
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
int64_t ret64 = taosMemSize(NULL);
|
||||
EXPECT_EQ(ret64, 0);
|
||||
}
|
||||
|
||||
TEST(osTest, rand2) {
|
||||
char str[128] = {0};
|
||||
taosRandStr2(str, 100);
|
||||
}
|
||||
|
||||
TEST(osTest, socket2) {
|
||||
int32_t ret32 = taosCloseSocket(NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
ret32 = taosSetSockOpt(NULL, 0, 0, NULL, 0);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
#if defined(LINUX)
|
||||
struct in_addr ipInt;
|
||||
ipInt.s_addr = htonl(0x7F000001);
|
||||
char buf[128] = {0};
|
||||
taosInetNtop(ipInt, buf, 32);
|
||||
#endif
|
||||
|
||||
ret32 = taosGetIpv4FromFqdn("localhost", NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
uint32_t ip = 0;
|
||||
ret32 = taosGetIpv4FromFqdn(NULL, &ip);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
taosInetNtoa(NULL, ip);
|
||||
ret32 = taosInetAddr(NULL);
|
||||
EXPECT_EQ(ret32, 0);
|
||||
|
||||
ret32 = taosWinSocketInit();
|
||||
EXPECT_EQ(ret32, 0);
|
||||
}
|
||||
|
||||
TEST(osTest, time2) {
|
||||
taosGetLocalTimezoneOffset();
|
||||
|
||||
char buf[12] = {0};
|
||||
char fmt[12] = {0};
|
||||
void *retptr = taosStrpTime(NULL, fmt, NULL);
|
||||
EXPECT_EQ(retptr, nullptr);
|
||||
retptr = taosStrpTime(buf, NULL, NULL);
|
||||
EXPECT_EQ(retptr, nullptr);
|
||||
|
||||
size_t ret = taosStrfTime(NULL, 0, fmt, NULL);
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = taosStrfTime(buf, 0, NULL, NULL);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
time_t tp = {0};
|
||||
struct tm *retptr2 = taosGmTimeR(&tp, NULL);
|
||||
EXPECT_EQ(retptr2, nullptr);
|
||||
retptr2 = taosGmTimeR(NULL, NULL);
|
||||
EXPECT_EQ(retptr2, nullptr);
|
||||
|
||||
time_t rett = taosTimeGm(NULL);
|
||||
EXPECT_EQ(rett, -1);
|
||||
|
||||
timezone_t tz = {0};
|
||||
retptr2 = taosLocalTime(&tp, NULL, NULL, 0, tz);
|
||||
EXPECT_EQ(retptr2, nullptr);
|
||||
retptr2 = taosLocalTime(NULL, NULL, NULL, 0, tz);
|
||||
EXPECT_EQ(retptr2, nullptr);
|
||||
}
|
||||
|
||||
TEST(osTest, system) {
|
||||
#if defined(LINUX)
|
||||
taosSetConsoleEcho(false);
|
||||
taosSetConsoleEcho(true);
|
||||
|
||||
taosGetOldTerminalMode();
|
||||
taosCloseCmd(NULL);
|
||||
|
||||
TdCmdPtr ptr = taosOpenCmd(NULL);
|
||||
EXPECT_EQ(ptr, nullptr);
|
||||
taosCloseCmd(&ptr);
|
||||
|
||||
ptr = taosOpenCmd("echo 'hello world'");
|
||||
ASSERT_NE(ptr, nullptr);
|
||||
|
||||
char buf[256] = {0};
|
||||
int64_t ret64 = taosGetsCmd(NULL, 0, NULL);
|
||||
EXPECT_LE(ret64, 0);
|
||||
ret64 = taosGetsCmd(ptr, 0, NULL);
|
||||
EXPECT_LE(ret64, 0);
|
||||
ret64 = taosGetsCmd(ptr, 255, buf);
|
||||
EXPECT_GT(ret64, 0);
|
||||
taosCloseCmd(&ptr);
|
||||
|
||||
ptr = taosOpenCmd("echoxxx 'hello world'");
|
||||
ASSERT_NE(ptr, nullptr);
|
||||
ret64 = taosGetsCmd(ptr, 255, buf);
|
||||
EXPECT_LE(ret64, 0);
|
||||
taosCloseCmd(&ptr);
|
||||
|
||||
ret64 = taosGetLineCmd(NULL, NULL);
|
||||
EXPECT_LE(ret64, 0);
|
||||
ret64 = taosGetLineCmd(ptr, NULL);
|
||||
EXPECT_LE(ret64, 0);
|
||||
|
||||
ptr = taosOpenCmd("echo 'hello world'");
|
||||
ASSERT_NE(ptr, nullptr);
|
||||
char *ptrBuf = NULL;
|
||||
ret64 = taosGetLineCmd(ptr, &ptrBuf);
|
||||
EXPECT_GE(ret64, 0);
|
||||
taosCloseCmd(&ptr);
|
||||
|
||||
ptr = taosOpenCmd("echoxxx 'hello world'");
|
||||
ASSERT_NE(ptr, nullptr);
|
||||
ret64 = taosGetLineCmd(ptr, &ptrBuf);
|
||||
EXPECT_LE(ret64, 0);
|
||||
taosCloseCmd(&ptr);
|
||||
|
||||
int32_t ret32 = taosEOFCmd(NULL);
|
||||
EXPECT_EQ(ret32, 0);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(osTest, sysinfo) {
|
||||
#if defined(LINUX)
|
||||
|
||||
int32_t ret32 = 0;
|
||||
|
||||
ret32 = taosGetEmail(NULL, 0);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
ret32 = taosGetOsReleaseName(NULL, NULL, NULL, 0);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
char buf[128] = {0};
|
||||
float numOfCores = 0;
|
||||
ret32 = taosGetCpuInfo(buf, 0, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetCpuInfo(NULL, 0, &numOfCores);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
|
||||
ret32 = taosGetCpuCores(NULL, false);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetTotalMemory(NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetProcMemory(NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetSysMemory(NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
ret32 = taosGetDiskSize(buf, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
SDiskSize disksize = {0};
|
||||
ret32 = taosGetDiskSize(NULL, &disksize);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
int64_t tmp = 0;
|
||||
ret32 = taosGetProcIO(NULL, NULL, NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetProcIO(&tmp, NULL, NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetProcIO(&tmp, &tmp, NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetProcIO(&tmp, &tmp, &tmp, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
ret32 = taosGetProcIODelta(NULL, NULL, NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetProcIODelta(&tmp, NULL, NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetProcIODelta(&tmp, &tmp, NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetProcIODelta(&tmp, &tmp, &tmp, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
taosGetProcIODelta(NULL, NULL, NULL, NULL);
|
||||
taosGetProcIODelta(&tmp, &tmp, &tmp, &tmp);
|
||||
|
||||
ret32 = taosGetCardInfo(NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetCardInfo(&tmp, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
ret32 = taosGetCardInfoDelta(NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetCardInfoDelta(&tmp, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
taosGetCardInfoDelta(NULL, NULL);
|
||||
taosGetCardInfoDelta(&tmp, &tmp);
|
||||
|
||||
ret32 = taosGetSystemUUIDLimit36(NULL, 0);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
ret32 = taosGetSystemUUIDLen(NULL, 0);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetSystemUUIDLen(buf, -1);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
taosSetCoreDump(false);
|
||||
|
||||
ret32 = taosGetlocalhostname(NULL, 0);
|
||||
EXPECT_NE(ret32, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(osTest, osFQDNSuccess) {
|
||||
char fqdn[TD_FQDN_LEN];
|
||||
char ipString[INET_ADDRSTRLEN];
|
||||
|
@ -178,18 +402,109 @@ TEST(osTest, osFile) {
|
|||
#define TESTTIMES 1000
|
||||
|
||||
char *getRandomWord() {
|
||||
static char words[][MAX_WORD_LENGTH] = {
|
||||
"Lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit",
|
||||
"sed", "do", "eiusmod", "tempor", "incididunt", "ut", "labore", "et", "dolore", "magna",
|
||||
"aliqua", "Ut", "enim", "ad", "minim", "veniam", "quis", "nostrud", "exercitation", "ullamco",
|
||||
"Why", "do", "programmers", "prefer", "using", "dark", "mode?", "Because", "light", "attracts",
|
||||
"bugs", "and", "they", "want", "to", "code", "in", "peace,", "like", "a", "ninja", "in", "the", "shadows."
|
||||
"aliqua", "Ut", "enim", "ad", "minim", "veniam", "quis", "nostrud", "exercitation", "ullamco",
|
||||
"laboris", "nisi", "ut", "aliquip", "ex", "ea", "commodo", "consequat", "Duis", "aute", "irure",
|
||||
"dolor", "in", "reprehenderit", "in", "voluptate", "velit", "esse", "cillum", "dolore", "eu",
|
||||
"fugiat", "nulla", "pariatur", "Excepteur", "sint", "occaecat", "cupidatat", "non", "proident",
|
||||
"sunt", "in", "culpa", "qui", "officia", "deserunt", "mollit", "anim", "id", "est", "laborum"
|
||||
};
|
||||
static char words[][MAX_WORD_LENGTH] = {"Lorem",
|
||||
"ipsum",
|
||||
"dolor",
|
||||
"sit",
|
||||
"amet",
|
||||
"consectetur",
|
||||
"adipiscing",
|
||||
"elit",
|
||||
"sed",
|
||||
"do",
|
||||
"eiusmod",
|
||||
"tempor",
|
||||
"incididunt",
|
||||
"ut",
|
||||
"labore",
|
||||
"et",
|
||||
"dolore",
|
||||
"magna",
|
||||
"aliqua",
|
||||
"Ut",
|
||||
"enim",
|
||||
"ad",
|
||||
"minim",
|
||||
"veniam",
|
||||
"quis",
|
||||
"nostrud",
|
||||
"exercitation",
|
||||
"ullamco",
|
||||
"Why",
|
||||
"do",
|
||||
"programmers",
|
||||
"prefer",
|
||||
"using",
|
||||
"dark",
|
||||
"mode?",
|
||||
"Because",
|
||||
"light",
|
||||
"attracts",
|
||||
"bugs",
|
||||
"and",
|
||||
"they",
|
||||
"want",
|
||||
"to",
|
||||
"code",
|
||||
"in",
|
||||
"peace,",
|
||||
"like",
|
||||
"a",
|
||||
"ninja",
|
||||
"in",
|
||||
"the",
|
||||
"shadows."
|
||||
"aliqua",
|
||||
"Ut",
|
||||
"enim",
|
||||
"ad",
|
||||
"minim",
|
||||
"veniam",
|
||||
"quis",
|
||||
"nostrud",
|
||||
"exercitation",
|
||||
"ullamco",
|
||||
"laboris",
|
||||
"nisi",
|
||||
"ut",
|
||||
"aliquip",
|
||||
"ex",
|
||||
"ea",
|
||||
"commodo",
|
||||
"consequat",
|
||||
"Duis",
|
||||
"aute",
|
||||
"irure",
|
||||
"dolor",
|
||||
"in",
|
||||
"reprehenderit",
|
||||
"in",
|
||||
"voluptate",
|
||||
"velit",
|
||||
"esse",
|
||||
"cillum",
|
||||
"dolore",
|
||||
"eu",
|
||||
"fugiat",
|
||||
"nulla",
|
||||
"pariatur",
|
||||
"Excepteur",
|
||||
"sint",
|
||||
"occaecat",
|
||||
"cupidatat",
|
||||
"non",
|
||||
"proident",
|
||||
"sunt",
|
||||
"in",
|
||||
"culpa",
|
||||
"qui",
|
||||
"officia",
|
||||
"deserunt",
|
||||
"mollit",
|
||||
"anim",
|
||||
"id",
|
||||
"est",
|
||||
"laborum"};
|
||||
|
||||
return words[taosRand() % MAX_WORDS];
|
||||
}
|
||||
|
|
|
@ -498,4 +498,42 @@ TEST(osThreadTests, spinlock) {
|
|||
TEST(osThreadTests, others) {
|
||||
taosThreadTestCancel();
|
||||
taosThreadClear(NULL);
|
||||
|
||||
TdThread tid1 = {0};
|
||||
TdThread tid2 = {0};
|
||||
TdThread *thread = &tid1;
|
||||
taosResetPthread(NULL);
|
||||
taosResetPthread(thread);
|
||||
|
||||
bool retb = taosComparePthread(tid1, tid2);
|
||||
EXPECT_TRUE(retb);
|
||||
|
||||
int32_t ret32 = taosGetAppName(NULL, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
char name[32] = {0};
|
||||
int32_t pid;
|
||||
ret32 = taosGetPIdByName(name, NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = taosGetPIdByName(NULL, &pid);
|
||||
EXPECT_NE(ret32, 0);
|
||||
|
||||
ret32 = tsem_timewait(NULL, 124);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = tsem_wait(NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = tsem2_init(NULL, 0, 0);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = tsem_post(NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = tsem_destroy(NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = tsem2_post(NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = tsem2_destroy(NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = tsem2_wait(NULL);
|
||||
EXPECT_NE(ret32, 0);
|
||||
ret32 = tsem2_timewait(NULL, 128);
|
||||
EXPECT_NE(ret32, 0);
|
||||
}
|
Loading…
Reference in New Issue