未验证 提交 81a13a3b 编写于 作者: wafwerar's avatar wafwerar 提交者: GitHub

Merge pull request #15435 from taosdata/fix/ZhiqiangWang/TD-17836-fix-get-cpuinfo-error

os: fix get cpuinfo error
...@@ -374,9 +374,10 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) { ...@@ -374,9 +374,10 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
size_t size = 0; size_t size = 0;
int32_t done = 0; int32_t done = 0;
int32_t code = -1; int32_t code = -1;
float coreCount = 0;
TdFilePtr pFile = taosOpenFile("/proc/cpuinfo", TD_FILE_READ | TD_FILE_STREAM); TdFilePtr pFile = taosOpenFile("/proc/cpuinfo", TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) return false; if (pFile == NULL) return code;
while (done != 3 && (size = taosGetLineFile(pFile, &line)) != -1) { while (done != 3 && (size = taosGetLineFile(pFile, &line)) != -1) {
line[size - 1] = '\0'; line[size - 1] = '\0';
...@@ -390,11 +391,26 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) { ...@@ -390,11 +391,26 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
*numOfCores = atof(v); *numOfCores = atof(v);
done |= 2; done |= 2;
} }
if (strncmp(line, "processor", 9) == 0) coreCount += 1;
} }
if (line != NULL) taosMemoryFree(line); if (line != NULL) taosMemoryFree(line);
taosCloseFile(&pFile); taosCloseFile(&pFile);
if (code != 0) {
TdFilePtr pFile1 = taosOpenFile("/proc/device-tree/model", TD_FILE_READ | TD_FILE_STREAM);
if (pFile1 == NULL) return code;
taosGetsFile(pFile1, maxLen, cpuModel);
taosCloseFile(&pFile1);
code = 0;
done |= 1;
}
if ((done & 2) == 0) {
*numOfCores = coreCount;
done |= 2;
}
return code; return code;
#endif #endif
} }
......
...@@ -566,8 +566,7 @@ class TDTestCase: ...@@ -566,8 +566,7 @@ class TDTestCase:
if data_ct4_c10[i] is None: if data_ct4_c10[i] is None:
tdSql.checkData( i, 0, None ) tdSql.checkData( i, 0, None )
else: else:
# time2str = str(int((data_ct4_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000)) time2str = str(int((data_ct4_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000))
time2str = str(int((datetime.datetime.timestamp(data_ct4_c10[i])-datetime.datetime.timestamp(datetime.datetime.fromtimestamp(0)))*1000))
tdSql.checkData( i, 0, time2str ) tdSql.checkData( i, 0, time2str )
tdSql.query(f"select cast(c10 as nchar(32)) as b from {self.dbname}.t1") tdSql.query(f"select cast(c10 as nchar(32)) as b from {self.dbname}.t1")
for i in range(len(data_t1_c10)): for i in range(len(data_t1_c10)):
...@@ -576,8 +575,7 @@ class TDTestCase: ...@@ -576,8 +575,7 @@ class TDTestCase:
elif i == 10: elif i == 10:
continue continue
else: else:
# time2str = str(int((data_t1_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000)) time2str = str(int((data_t1_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000))
time2str = str(int((datetime.datetime.timestamp(data_t1_c10[i])-datetime.datetime.timestamp(datetime.datetime.fromtimestamp(0)))*1000))
tdSql.checkData( i, 0, time2str ) tdSql.checkData( i, 0, time2str )
tdLog.printNoPrefix("==========step38: cast timestamp to binary, expect no changes ") tdLog.printNoPrefix("==========step38: cast timestamp to binary, expect no changes ")
...@@ -586,8 +584,7 @@ class TDTestCase: ...@@ -586,8 +584,7 @@ class TDTestCase:
if data_ct4_c10[i] is None: if data_ct4_c10[i] is None:
tdSql.checkData( i, 0, None ) tdSql.checkData( i, 0, None )
else: else:
# time2str = str(int((data_ct4_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000)) time2str = str(int((data_ct4_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000))
time2str = str(int((datetime.datetime.timestamp(data_ct4_c10[i])-datetime.datetime.timestamp(datetime.datetime.fromtimestamp(0)))*1000))
tdSql.checkData( i, 0, time2str ) tdSql.checkData( i, 0, time2str )
tdSql.query(f"select cast(c10 as binary(32)) as b from {self.dbname}.t1") tdSql.query(f"select cast(c10 as binary(32)) as b from {self.dbname}.t1")
for i in range(len(data_t1_c10)): for i in range(len(data_t1_c10)):
...@@ -596,8 +593,7 @@ class TDTestCase: ...@@ -596,8 +593,7 @@ class TDTestCase:
elif i == 10: elif i == 10:
continue continue
else: else:
# time2str = str(int((data_t1_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000)) time2str = str(int((data_t1_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000))
time2str = str(int((datetime.datetime.timestamp(data_t1_c10[i])-datetime.datetime.timestamp(datetime.datetime.fromtimestamp(0)))*1000))
tdSql.checkData( i, 0, time2str ) tdSql.checkData( i, 0, time2str )
tdLog.printNoPrefix("==========step39: cast constant operation to bigint, expect change to int ") tdLog.printNoPrefix("==========step39: cast constant operation to bigint, expect change to int ")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册