fix: add some ut
This commit is contained in:
parent
05dedfaf1a
commit
1ed9efee23
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -61,13 +61,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(
|
||||
|
|
|
@ -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
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -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];
|
||||
|
@ -47,8 +271,8 @@ TEST(osTest, osFQDNSuccess) {
|
|||
struct in_addr addr;
|
||||
addr.s_addr = htonl(ipv4);
|
||||
(void)snprintf(ipString, INET_ADDRSTRLEN, "%u.%u.%u.%u", (unsigned int)(addr.s_addr >> 24) & 0xFF,
|
||||
(unsigned int)(addr.s_addr >> 16) & 0xFF, (unsigned int)(addr.s_addr >> 8) & 0xFF,
|
||||
(unsigned int)(addr.s_addr) & 0xFF);
|
||||
(unsigned int)(addr.s_addr >> 16) & 0xFF, (unsigned int)(addr.s_addr >> 8) & 0xFF,
|
||||
(unsigned int)(addr.s_addr) & 0xFF);
|
||||
(void)printf("fqdn:%s ip:%s\n", fqdn, ipString);
|
||||
}
|
||||
|
||||
|
@ -56,7 +280,7 @@ TEST(osTest, osFQDNFailed) {
|
|||
char fqdn[1024] = "fqdn_test_not_found";
|
||||
char ipString[24];
|
||||
uint32_t ipv4 = 0;
|
||||
int32_t code = taosGetIpv4FromFqdn(fqdn, &ipv4);
|
||||
int32_t code = taosGetIpv4FromFqdn(fqdn, &ipv4);
|
||||
ASSERT_NE(code, 0);
|
||||
|
||||
terrno = TSDB_CODE_RPC_FQDN_ERROR;
|
||||
|
@ -79,7 +303,7 @@ TEST(osTest, osSystem) {
|
|||
}
|
||||
|
||||
void fileOperateOnFree(void *param) {
|
||||
char * fname = (char *)param;
|
||||
char *fname = (char *)param;
|
||||
TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE);
|
||||
(void)printf("On free thread open file\n");
|
||||
ASSERT_NE(pFile, nullptr);
|
||||
|
@ -101,7 +325,7 @@ void *fileOperateOnFreeThread(void *param) {
|
|||
return NULL;
|
||||
}
|
||||
void fileOperateOnBusy(void *param) {
|
||||
char * fname = (char *)param;
|
||||
char *fname = (char *)param;
|
||||
TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE);
|
||||
(void)printf("On busy thread open file\n");
|
||||
if (pFile == NULL) return;
|
||||
|
@ -165,9 +389,9 @@ TEST(osTest, osFile) {
|
|||
(void)taosThreadJoin(thread2, NULL);
|
||||
taosThreadClear(&thread2);
|
||||
|
||||
//int ret = taosRemoveFile(fname);
|
||||
//ASSERT_EQ(ret, 0);
|
||||
//printf("remove file success");
|
||||
// int ret = taosRemoveFile(fname);
|
||||
// ASSERT_EQ(ret, 0);
|
||||
// printf("remove file success");
|
||||
}
|
||||
|
||||
#ifndef OSFILE_PERFORMANCE_TEST
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -197,7 +512,7 @@ char *getRandomWord() {
|
|||
int64_t fillBufferWithRandomWords(char *buffer, int64_t maxBufferSize) {
|
||||
int64_t len = 0;
|
||||
while (len < maxBufferSize) {
|
||||
char * word = getRandomWord();
|
||||
char *word = getRandomWord();
|
||||
size_t wordLen = strlen(word);
|
||||
|
||||
if (len + wordLen + 1 < maxBufferSize) {
|
||||
|
@ -246,11 +561,11 @@ TEST(osTest, osFilePerformance) {
|
|||
int64_t OpenForWriteCloseFileCost;
|
||||
int64_t OpenForReadCloseFileCost;
|
||||
|
||||
char * buffer;
|
||||
char * writeBuffer = (char *)taosMemoryCalloc(1, MAX_TEST_FILE_SIZE);
|
||||
char * readBuffer = (char *)taosMemoryCalloc(1, MAX_TEST_FILE_SIZE);
|
||||
char *buffer;
|
||||
char *writeBuffer = (char *)taosMemoryCalloc(1, MAX_TEST_FILE_SIZE);
|
||||
char *readBuffer = (char *)taosMemoryCalloc(1, MAX_TEST_FILE_SIZE);
|
||||
int64_t size = fillBufferWithRandomWords(writeBuffer, MAX_TEST_FILE_SIZE);
|
||||
char * fname = "./osFilePerformanceTest.txt";
|
||||
char *fname = "./osFilePerformanceTest.txt";
|
||||
|
||||
TdFilePtr pOutFD = taosCreateFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
ASSERT_NE(pOutFD, nullptr);
|
||||
|
@ -342,6 +657,6 @@ TEST(osTest, osFilePerformance) {
|
|||
(void)printf("Test OpenForRead & Close file %d times, cost: %" PRId64 "us\n", TESTTIMES, OpenForReadCloseFileCost);
|
||||
}
|
||||
|
||||
#endif // OSFILE_PERFORMANCE_TEST
|
||||
#endif // OSFILE_PERFORMANCE_TEST
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
|
@ -110,7 +110,7 @@ TEST(osThreadTests, thread) {
|
|||
taosMsleep(300);
|
||||
|
||||
(void)taosThreadCancel(tid1);
|
||||
|
||||
|
||||
reti = taosThreadCreate(&tid2, NULL, funcPtr501, NULL);
|
||||
EXPECT_EQ(reti, 0);
|
||||
taosMsleep(1000);
|
||||
|
@ -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