Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fb996548
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看板
提交
fb996548
编写于
4月 21, 2023
作者:
K
kailixu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: add UT
上级
9e71b6d0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
147 addition
and
0 deletion
+147
-0
tests/script/api/makefile
tests/script/api/makefile
+3
-0
tests/script/api/passwdTest.c
tests/script/api/passwdTest.c
+144
-0
未找到文件。
tests/script/api/makefile
浏览文件 @
fb996548
...
@@ -15,8 +15,11 @@ exe:
...
@@ -15,8 +15,11 @@ exe:
gcc
$(CFLAGS)
./stopquery.c
-o
$(ROOT)
stopquery
$(LFLAGS)
gcc
$(CFLAGS)
./stopquery.c
-o
$(ROOT)
stopquery
$(LFLAGS)
gcc
$(CFLAGS)
./dbTableRoute.c
-o
$(ROOT)
dbTableRoute
$(LFLAGS)
gcc
$(CFLAGS)
./dbTableRoute.c
-o
$(ROOT)
dbTableRoute
$(LFLAGS)
gcc
$(CFLAGS)
./insertSameTs.c
-o
$(ROOT)
insertSameTs
$(LFLAGS)
gcc
$(CFLAGS)
./insertSameTs.c
-o
$(ROOT)
insertSameTs
$(LFLAGS)
gcc
$(CFLAGS)
./passwdTest.c
-o
$(ROOT)
passwdTest
$(LFLAGS)
clean
:
clean
:
rm
$(ROOT)
batchprepare
rm
$(ROOT)
batchprepare
rm
$(ROOT)
stopquery
rm
$(ROOT)
stopquery
rm
$(ROOT)
dbTableRoute
rm
$(ROOT)
dbTableRoute
rm
$(ROOT)
insertSameTs
rm
$(ROOT)
passwdTest
tests/script/api/passwdTest.c
0 → 100644
浏览文件 @
fb996548
/*
* 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/>.
*/
// TAOS standard API example. The same syntax as MySQL, but only a subset
// to compile: gcc -o demo demo.c -ltaos
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "taos.h" // TAOS header file
#define nRepetition 1
#define nTaos 10
void
Test
(
TAOS
*
taos
,
char
*
qstr
);
void
passVerTestMulti
(
const
char
*
host
,
char
*
qstr
);
int
nPassVerNotifiedMulti
=
0
;
void
__taos_notify_cb
(
void
*
param
,
void
*
ext
,
int
type
)
{
switch
(
type
)
{
case
TAOS_NOTIFY_PASSVER
:
{
++
nPassVerNotifiedMulti
;
printf
(
"%s:%d type:%d user:%s ver:%d
\n
"
,
__func__
,
__LINE__
,
type
,
param
?
(
char
*
)
param
:
"NULL"
,
*
(
int
*
)
ext
);
break
;
}
default:
printf
(
"%s:%d unknown type:%d
\n
"
,
__func__
,
__LINE__
,
type
);
break
;
}
}
static
void
queryDB
(
TAOS
*
taos
,
char
*
command
)
{
int
i
;
TAOS_RES
*
pSql
=
NULL
;
int32_t
code
=
-
1
;
for
(
i
=
0
;
i
<
nRepetition
;
++
i
)
{
if
(
NULL
!=
pSql
)
{
taos_free_result
(
pSql
);
pSql
=
NULL
;
}
pSql
=
taos_query
(
taos
,
command
);
code
=
taos_errno
(
pSql
);
if
(
0
==
code
)
{
break
;
}
}
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"failed to run: %s, reason: %s
\n
"
,
command
,
taos_errstr
(
pSql
));
taos_free_result
(
pSql
);
taos_close
(
taos
);
exit
(
EXIT_FAILURE
);
}
else
{
fprintf
(
stderr
,
"success to run: %s
\n
"
,
command
);
}
taos_free_result
(
pSql
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
char
qstr
[
1024
];
// connect to server
if
(
argc
<
2
)
{
printf
(
"please input server-ip
\n
"
);
return
0
;
}
TAOS
*
taos
=
taos_connect
(
argv
[
1
],
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"failed to connect to server, reason:%s
\n
"
,
"null taos"
/*taos_errstr(taos)*/
);
exit
(
1
);
}
passVerTestMulti
(
argv
[
1
],
qstr
);
taos_close
(
taos
);
taos_cleanup
();
}
void
passVerTestMulti
(
const
char
*
host
,
char
*
qstr
)
{
TAOS
*
taos
[
nTaos
]
=
{
0
};
char
*
userName
=
calloc
(
1
,
24
);
strcpy
(
userName
,
"root"
);
for
(
int
i
=
0
;
i
<
nTaos
;
++
i
)
{
taos
[
i
]
=
taos_connect
(
host
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
[
i
]
==
NULL
)
{
printf
(
"failed to connect to server, reason:%s
\n
"
,
"null taos"
/*taos_errstr(taos)*/
);
exit
(
1
);
}
int
code
=
taos_set_notify_cb
(
taos
[
i
],
__taos_notify_cb
,
userName
,
TAOS_NOTIFY_PASSVER
);
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"failed to run: taos_set_notify_cb since %d
\n
"
,
code
);
}
else
{
fprintf
(
stderr
,
"success to run: taos_set_notify_cb
\n
"
);
}
}
queryDB
(
taos
[
0
],
"create database if not exists demo1 vgroups 1 minrows 10"
);
queryDB
(
taos
[
0
],
"create database if not exists demo2 vgroups 1 minrows 10"
);
queryDB
(
taos
[
0
],
"create database if not exists demo3 vgroups 1 minrows 10"
);
queryDB
(
taos
[
0
],
"create table demo1.stb (ts timestamp, c1 int) tags(t1 int)"
);
queryDB
(
taos
[
0
],
"create table demo2.stb (ts timestamp, c1 int) tags(t1 int)"
);
queryDB
(
taos
[
0
],
"create table demo3.stb (ts timestamp, c1 int) tags(t1 int)"
);
strcpy
(
qstr
,
"alter user root pass 'taos'"
);
queryDB
(
taos
[
0
],
qstr
);
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
if
(
nPassVerNotifiedMulti
>=
nTaos
)
break
;
sleep
(
1
);
}
if
(
nPassVerNotifiedMulti
>=
nTaos
)
{
fprintf
(
stderr
,
"success to get passVer notification
\n
"
);
}
else
{
fprintf
(
stderr
,
"failed to get passVer notification
\n
"
);
}
// sleep(1000);
free
(
userName
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录