Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
99b2e71b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
99b2e71b
编写于
1月 03, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:write const memory
上级
f23ab585
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
11 deletion
+40
-11
utils/test/c/sml_test.c
utils/test/c/sml_test.c
+40
-11
未找到文件。
utils/test/c/sml_test.c
浏览文件 @
99b2e71b
...
...
@@ -116,11 +116,22 @@ int smlProcess_json1_Test() {
const
char
*
sql
[]
=
{
"[{
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\"
timestamp
\"
:0,
\"
value
\"
:18,
\"
tags
\"
:{
\"
host
\"
:
\"
web01
\"
,
\"
id
\"
:
\"
t1
\"
,
\"
dc
\"
:
\"
lga
\"
}},{
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\"
timestamp
\"
:1662344042,
\"
value
\"
:9,
\"
tags
\"
:{
\"
host
\"
:
\"
web02
\"
,
\"
dc
\"
:
\"
lga
\"
}}]"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
char
*
sql1
[
1
]
=
{
0
};
for
(
int
i
=
0
;
i
<
1
;
i
++
){
sql1
[
i
]
=
taosMemoryCalloc
(
1
,
1024
);
strncpy
(
sql1
[
i
],
sql
[
i
],
1023
);
}
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql1
,
sizeof
(
sql1
)
/
sizeof
(
sql1
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
taos_free_result
(
pRes
);
for
(
int
i
=
0
;
i
<
1
;
i
++
){
taosMemoryFree
(
sql1
[
i
]);
}
taos_close
(
taos
);
return
code
;
...
...
@@ -138,13 +149,22 @@ int smlProcess_json2_Test() {
const
char
*
sql
[]
=
{
"{
\"
metric
\"
:
\"
meter_current0
\"
,
\"
timestamp
\"
:{
\"
value
\"
:1662344042,
\"
type
\"
:
\"
s
\"
},
\"
value
\"
:{
\"
value
\"
:10.3,
\"
type
\"
:
\"
i64
\"
},
\"
tags
\"
:{
\"
groupid
\"
:{
\"
value
\"
:2,
\"
type
\"
:
\"
bigint
\"
},
\"
location
\"
:{
\"
value
\"
:
\"
北京
\"
,
\"
type
\"
:
\"
binary
\"
},
\"
id
\"
:
\"
d1001
\"
}}"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
char
*
sql1
[
1
]
=
{
0
};
for
(
int
i
=
0
;
i
<
1
;
i
++
){
sql1
[
i
]
=
taosMemoryCalloc
(
1
,
1024
);
strncpy
(
sql1
[
i
],
sql
[
i
],
1023
);
}
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql1
,
sizeof
(
sql1
)
/
sizeof
(
sql1
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
for
(
int
i
=
0
;
i
<
1
;
i
++
){
taosMemoryFree
(
sql1
[
i
]);
}
return
code
;
}
...
...
@@ -160,13 +180,22 @@ int smlProcess_json3_Test() {
const
char
*
sql
[]
=
{
"[{
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\"
timestamp
\"
:0,
\"
value
\"
:
\"
18
\"
,
\"
tags
\"
:{
\"
host
\"
:
\"
web01
\"
,
\"
id
\"
:
\"
t1
\"
,
\"
dc
\"
:
\"
lga
\"
}}]"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
char
*
sql1
[
1
]
=
{
0
};
for
(
int
i
=
0
;
i
<
1
;
i
++
){
sql1
[
i
]
=
taosMemoryCalloc
(
1
,
1024
);
strncpy
(
sql1
[
i
],
sql
[
i
],
1023
);
}
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql1
,
sizeof
(
sql1
)
/
sizeof
(
sql1
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
for
(
int
i
=
0
;
i
<
1
;
i
++
){
taosMemoryFree
(
sql1
[
i
]);
}
return
code
;
}
...
...
@@ -927,14 +956,14 @@ int main(int argc, char *argv[]) {
// printf("str:%s \t %d\n", str[i], smlCalTypeSum(str[i], strlen(str[i])));
// }
int
ret
=
0
;
ret
=
sml_ttl_Test
();
ASSERT
(
!
ret
);
ret
=
sml_ts2164_Test
();
ASSERT
(
!
ret
);
ret
=
smlProcess_influx_Test
();
ASSERT
(
!
ret
);
ret
=
smlProcess_telnet_Test
();
ASSERT
(
!
ret
);
//
ret = sml_ttl_Test();
//
ASSERT(!ret);
//
ret = sml_ts2164_Test();
//
ASSERT(!ret);
//
ret = smlProcess_influx_Test();
//
ASSERT(!ret);
//
ret = smlProcess_telnet_Test();
//
ASSERT(!ret);
ret
=
smlProcess_json1_Test
();
ASSERT
(
!
ret
);
ret
=
smlProcess_json2_Test
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录