Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8940eb4d
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看板
提交
8940eb4d
编写于
12月 17, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
format sim scripts
上级
8e68fa6e
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
77 addition
and
78 deletion
+77
-78
tests/tsim/inc/sim.h
tests/tsim/inc/sim.h
+27
-27
tests/tsim/inc/simParse.h
tests/tsim/inc/simParse.h
+4
-4
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+26
-28
tests/tsim/src/simMain.c
tests/tsim/src/simMain.c
+3
-3
tests/tsim/src/simParse.c
tests/tsim/src/simParse.c
+15
-14
tests/tsim/src/simSystem.c
tests/tsim/src/simSystem.c
+2
-2
未找到文件。
tests/tsim/inc/sim.h
浏览文件 @
8940eb4d
...
...
@@ -113,7 +113,7 @@ typedef struct {
int16_t
errorJump
;
// sql jump flag, while '-x' exist in sql cmd, this flag
// will be SQL_JUMP_TRUE, otherwise is SQL_JUMP_FALSE */
int16_t
lineNum
;
// correspodning line number in original file
int32_t
optionOffset
;
// relative option offset
int32_t
optionOffset
;
// relative option offset
}
SCmdLine
;
typedef
struct
_var_t
{
...
...
@@ -125,7 +125,7 @@ typedef struct _var_t {
typedef
struct
_script_t
{
int32_t
type
;
bool
killed
;
void
*
taos
;
void
*
taos
;
char
rows
[
12
];
// number of rows data retrieved
char
data
[
MAX_QUERY_ROW_NUM
][
MAX_QUERY_COL_NUM
][
MAX_QUERY_VALUE_LEN
];
// query results
char
system_exit_code
[
12
];
...
...
@@ -136,7 +136,7 @@ typedef struct _script_t {
int32_t
bgScriptLen
;
char
fileName
[
MAX_FILE_NAME_LEN
];
// script file name
char
error
[
MAX_ERROR_LEN
];
char
*
optionBuffer
;
char
*
optionBuffer
;
SCmdLine
*
lines
;
// command list
SVariable
variables
[
MAX_VAR_LEN
];
pthread_t
bgPid
;
...
...
@@ -154,11 +154,11 @@ extern bool abortExecution;
SScript
*
simParseScript
(
char
*
fileName
);
SScript
*
simProcessCallOver
(
SScript
*
script
);
void
*
simExecuteScript
(
void
*
script
);
void
*
simExecuteScript
(
void
*
script
);
void
simInitsimCmdList
();
bool
simSystemInit
();
void
simSystemCleanUp
();
char
*
simGetVariable
(
SScript
*
script
,
char
*
varName
,
int32_t
varLen
);
char
*
simGetVariable
(
SScript
*
script
,
char
*
varName
,
int32_t
varLen
);
bool
simExecuteExpCmd
(
SScript
*
script
,
char
*
option
);
bool
simExecuteTestCmd
(
SScript
*
script
,
char
*
option
);
bool
simExecuteGotoCmd
(
SScript
*
script
,
char
*
option
);
...
...
tests/tsim/inc/simParse.h
浏览文件 @
8940eb4d
tests/tsim/src/simExe.c
浏览文件 @
8940eb4d
...
...
@@ -14,14 +14,14 @@
*/
#define _DEFAULT_SOURCE
#include "taos.h"
#include "cJSON.h"
#include "os.h"
#include "sim.h"
#include "taos.h"
#include "taoserror.h"
#include "tglobal.h"
#include "tutil.h"
#include "ttypes.h"
#include "tutil.h"
void
simLogSql
(
char
*
sql
,
bool
useSharp
)
{
static
FILE
*
fp
=
NULL
;
...
...
@@ -74,7 +74,7 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) {
return
"null"
;
}
char
*
keyName
;
char
*
keyName
;
int32_t
keyLen
;
paGetToken
(
varName
+
6
,
&
keyName
,
&
keyLen
);
...
...
@@ -91,7 +91,7 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) {
return
"null"
;
}
char
*
keyName
;
char
*
keyName
;
int32_t
keyLen
;
paGetToken
(
varName
+
7
,
&
keyName
,
&
keyLen
);
...
...
@@ -144,7 +144,7 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) {
}
int32_t
simExecuteExpression
(
SScript
*
script
,
char
*
exp
)
{
char
*
op1
,
*
op2
,
*
var1
,
*
var2
,
*
var3
,
*
rest
;
char
*
op1
,
*
op2
,
*
var1
,
*
var2
,
*
var3
,
*
rest
;
int32_t
op1Len
,
op2Len
,
var1Len
,
var2Len
,
var3Len
,
val0
,
val1
;
char
t0
[
1024
],
t1
[
1024
],
t2
[
1024
],
t3
[
2048
];
int32_t
result
;
...
...
@@ -302,7 +302,7 @@ bool simExecuteRunBackCmd(SScript *script, char *option) {
}
void
simReplaceShToBat
(
char
*
dst
)
{
char
*
sh
=
strstr
(
dst
,
".sh"
);
char
*
sh
=
strstr
(
dst
,
".sh"
);
if
(
sh
!=
NULL
)
{
int32_t
dstLen
=
(
int32_t
)
strlen
(
dst
);
char
*
end
=
dst
+
dstLen
;
...
...
@@ -436,7 +436,7 @@ bool simExecuteReturnCmd(SScript *script, char *option) {
}
void
simVisuallizeOption
(
SScript
*
script
,
char
*
src
,
char
*
dst
)
{
char
*
var
,
*
token
,
*
value
;
char
*
var
,
*
token
,
*
value
;
int32_t
dstLen
,
srcLen
,
tokenLen
;
dst
[
0
]
=
0
,
dstLen
=
0
;
...
...
@@ -475,9 +475,7 @@ void simCloseNativeConnect(SScript *script) {
script
->
taos
=
NULL
;
}
void
simCloseTaosdConnect
(
SScript
*
script
)
{
simCloseNativeConnect
(
script
);
}
void
simCloseTaosdConnect
(
SScript
*
script
)
{
simCloseNativeConnect
(
script
);
}
bool
simCreateNativeConnect
(
SScript
*
script
,
char
*
user
,
char
*
pass
)
{
simCloseTaosdConnect
(
script
);
...
...
@@ -512,8 +510,8 @@ bool simCreateNativeConnect(SScript *script, char *user, char *pass) {
}
bool
simCreateTaosdConnect
(
SScript
*
script
,
char
*
rest
)
{
char
*
user
=
TSDB_DEFAULT_USER
;
char
*
token
;
char
*
user
=
TSDB_DEFAULT_USER
;
char
*
token
;
int32_t
tokenLen
;
rest
=
paGetToken
(
rest
,
&
token
,
&
tokenLen
);
rest
=
paGetToken
(
rest
,
&
token
,
&
tokenLen
);
...
...
@@ -528,7 +526,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
char
timeStr
[
30
]
=
{
0
};
time_t
tt
;
struct
tm
*
tp
;
SCmdLine
*
line
=
&
script
->
lines
[
script
->
linePos
];
SCmdLine
*
line
=
&
script
->
lines
[
script
->
linePos
];
int32_t
ret
=
-
1
;
TAOS_RES
*
pSql
=
NULL
;
...
...
@@ -589,7 +587,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
while
((
row
=
taos_fetch_row
(
pSql
)))
{
if
(
numOfRows
<
MAX_QUERY_ROW_NUM
)
{
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
pSql
);
int32_t
*
length
=
taos_fetch_lengths
(
pSql
);
int32_t
*
length
=
taos_fetch_lengths
(
pSql
);
for
(
int32_t
i
=
0
;
i
<
num_fields
;
i
++
)
{
char
*
value
=
NULL
;
...
...
@@ -613,7 +611,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
sprintf
(
value
,
"%d"
,
*
((
int8_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
sprintf
(
value
,
"%u"
,
*
((
uint8_t
*
)
row
[
i
]));
sprintf
(
value
,
"%u"
,
*
((
uint8_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
sprintf
(
value
,
"%d"
,
*
((
int16_t
*
)
row
[
i
]));
...
...
@@ -803,7 +801,6 @@ bool simExecuteRestfulCmd(SScript *script, char *rest) {
return
simExecuteSystemCmd
(
script
,
cmd
);
}
bool
simExecuteSqlErrorCmd
(
SScript
*
script
,
char
*
rest
)
{
char
buf
[
3000
];
SCmdLine
*
line
=
&
script
->
lines
[
script
->
linePos
];
...
...
@@ -870,7 +867,7 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) {
simInfo
(
"script:%s, %s"
,
script
->
fileName
,
rest
);
simLogSql
(
buf
,
true
);
char
*
lines
[]
=
{
rest
};
char
*
lines
[]
=
{
rest
};
#if 0
int32_t ret = taos_insert_lines(script->taos, lines, 1);
#else
...
...
@@ -881,8 +878,8 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) {
script
->
linePos
++
;
return
true
;
}
else
{
sprintf
(
script
->
error
,
"lineNum: %d. line: %s failed, ret:%d:%s"
,
line
->
lineNum
,
rest
,
ret
&
0XFFFF
,
tstrerror
(
ret
));
sprintf
(
script
->
error
,
"lineNum: %d. line: %s failed, ret:%d:%s"
,
line
->
lineNum
,
rest
,
ret
&
0XFFFF
,
tstrerror
(
ret
));
return
false
;
}
}
...
...
@@ -897,19 +894,20 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
simInfo
(
"script:%s, %s"
,
script
->
fileName
,
rest
);
simLogSql
(
buf
,
true
);
char
*
lines
[]
=
{
rest
};
char
*
lines
[]
=
{
rest
};
#if 0
int32_t ret = taos_insert_lines(script->taos, lines, 1);
#else
int32_t
ret
=
0
;
#endif
if
(
ret
==
TSDB_CODE_SUCCESS
)
{
sprintf
(
script
->
error
,
"script:%s, taos:%p, %s executed. expect failed, but success."
,
script
->
fileName
,
script
->
taos
,
rest
);
sprintf
(
script
->
error
,
"script:%s, taos:%p, %s executed. expect failed, but success."
,
script
->
fileName
,
script
->
taos
,
rest
);
script
->
linePos
++
;
return
false
;
}
else
{
simDebug
(
"lineNum: %d. line: %s failed, ret:%d:%s. Expect failed, so success"
,
line
->
lineNum
,
rest
,
ret
&
0XFFFF
,
tstrerror
(
ret
));
simDebug
(
"lineNum: %d. line: %s failed, ret:%d:%s. Expect failed, so success"
,
line
->
lineNum
,
rest
,
ret
&
0XFFFF
,
tstrerror
(
ret
));
return
true
;
}
}
tests/tsim/src/simMain.c
浏览文件 @
8940eb4d
...
...
@@ -15,8 +15,8 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "tglobal.h"
#include "sim.h"
#include "tglobal.h"
bool
simExecSuccess
=
false
;
bool
abortExecution
=
false
;
...
...
@@ -24,8 +24,8 @@ bool abortExecution = false;
void
simHandleSignal
(
int32_t
signo
,
void
*
sigInfo
,
void
*
context
)
{
simSystemCleanUp
();
abortExecution
=
true
;
// runningScript->killed = true;
// exit(1);
// runningScript->killed = true;
// exit(1);
}
int32_t
main
(
int32_t
argc
,
char
*
argv
[])
{
...
...
tests/tsim/src/simParse.c
浏览文件 @
8940eb4d
...
...
@@ -60,9 +60,10 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "sim.h"
#include "simParse.h"
#include "tutil.h"
#include "simParse.h"
static
SCommand
*
cmdHashList
[
MAX_NUM_CMD
];
static
SCmdLine
cmdLine
[
MAX_CMD_LINES
];
static
char
parseErr
[
MAX_ERROR_LEN
];
...
...
@@ -176,11 +177,11 @@ SScript *simBuildScriptObj(char *fileName) {
}
SScript
*
simParseScript
(
char
*
fileName
)
{
FILE
*
fd
;
FILE
*
fd
;
int32_t
tokenLen
,
lineNum
=
0
;
char
buffer
[
MAX_LINE_LEN
],
name
[
128
],
*
token
,
*
rest
;
SCommand
*
pCmd
;
SScript
*
script
;
SScript
*
script
;
if
((
fileName
[
0
]
==
'.'
)
||
(
fileName
[
0
]
==
'/'
))
{
strcpy
(
name
,
fileName
);
...
...
@@ -251,7 +252,7 @@ SScript *simParseScript(char *fileName) {
}
int32_t
simCheckExpression
(
char
*
exp
)
{
char
*
op1
,
*
op2
,
*
op
,
*
rest
;
char
*
op1
,
*
op2
,
*
op
,
*
rest
;
int32_t
op1Len
,
op2Len
,
opLen
;
rest
=
paGetToken
(
exp
,
&
op1
,
&
op1Len
);
...
...
@@ -335,7 +336,7 @@ bool simParseExpression(char *token, int32_t lineNum) {
}
bool
simParseIfCmd
(
char
*
rest
,
SCommand
*
pCmd
,
int32_t
lineNum
)
{
char
*
ret
;
char
*
ret
;
int32_t
expLen
;
expLen
=
simCheckExpression
(
rest
);
...
...
@@ -501,7 +502,7 @@ bool simParseEndwCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
}
bool
simParseSwitchCmd
(
char
*
rest
,
SCommand
*
pCmd
,
int32_t
lineNum
)
{
char
*
token
;
char
*
token
;
int32_t
tokenLen
;
rest
=
paGetToken
(
rest
,
&
token
,
&
tokenLen
);
...
...
@@ -524,7 +525,7 @@ bool simParseSwitchCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
}
bool
simParseCaseCmd
(
char
*
rest
,
SCommand
*
pCmd
,
int32_t
lineNum
)
{
char
*
token
;
char
*
token
;
int32_t
tokenLen
;
rest
=
paGetToken
(
rest
,
&
token
,
&
tokenLen
);
...
...
@@ -665,7 +666,7 @@ bool simParsePrintCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
void
simCheckSqlOption
(
char
*
rest
)
{
int32_t
valueLen
;
char
*
value
,
*
xpos
;
char
*
value
,
*
xpos
;
xpos
=
strstr
(
rest
,
" -x"
);
// need a blank
if
(
xpos
)
{
...
...
@@ -749,7 +750,7 @@ bool simParseSystemContentCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
}
bool
simParseSleepCmd
(
char
*
rest
,
SCommand
*
pCmd
,
int32_t
lineNum
)
{
char
*
token
;
char
*
token
;
int32_t
tokenLen
;
cmdLine
[
numOfLines
].
cmdno
=
SIM_CMD_SLEEP
;
...
...
@@ -768,7 +769,7 @@ bool simParseSleepCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
}
bool
simParseReturnCmd
(
char
*
rest
,
SCommand
*
pCmd
,
int32_t
lineNum
)
{
char
*
token
;
char
*
token
;
int32_t
tokenLen
;
cmdLine
[
numOfLines
].
cmdno
=
SIM_CMD_RETURN
;
...
...
@@ -787,7 +788,7 @@ bool simParseReturnCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
}
bool
simParseGotoCmd
(
char
*
rest
,
SCommand
*
pCmd
,
int32_t
lineNum
)
{
char
*
token
;
char
*
token
;
int32_t
tokenLen
;
rest
=
paGetToken
(
rest
,
&
token
,
&
tokenLen
);
...
...
@@ -810,7 +811,7 @@ bool simParseGotoCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
}
bool
simParseRunCmd
(
char
*
rest
,
SCommand
*
pCmd
,
int32_t
lineNum
)
{
char
*
token
;
char
*
token
;
int32_t
tokenLen
;
rest
=
paGetToken
(
rest
,
&
token
,
&
tokenLen
);
...
...
@@ -837,7 +838,7 @@ bool simParseRunBackCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
return
true
;
}
bool
simParseLineInsertCmd
(
char
*
rest
,
SCommand
*
pCmd
,
int32_t
lineNum
)
{
bool
simParseLineInsertCmd
(
char
*
rest
,
SCommand
*
pCmd
,
int32_t
lineNum
)
{
int32_t
expLen
;
rest
++
;
...
...
@@ -853,7 +854,7 @@ bool simParseLineInsertCmd(char* rest, SCommand* pCmd, int32_t lineNum) {
return
true
;
}
bool
simParseLineInsertErrorCmd
(
char
*
rest
,
SCommand
*
pCmd
,
int32_t
lineNum
)
{
bool
simParseLineInsertErrorCmd
(
char
*
rest
,
SCommand
*
pCmd
,
int32_t
lineNum
)
{
int32_t
expLen
;
rest
++
;
...
...
tests/tsim/src/simSystem.c
浏览文件 @
8940eb4d
...
...
@@ -14,9 +14,9 @@
*/
#define _DEFAULT_SOURCE
#include "taos.h"
#include "os.h"
#include "sim.h"
#include "taos.h"
#include "taoserror.h"
#include "tglobal.h"
#include "ttimer.h"
...
...
@@ -166,7 +166,7 @@ void *simExecuteScript(void *inputScript) {
}
}
else
{
SCmdLine
*
line
=
&
script
->
lines
[
script
->
linePos
];
char
*
option
=
script
->
optionBuffer
+
line
->
optionOffset
;
char
*
option
=
script
->
optionBuffer
+
line
->
optionOffset
;
simDebug
(
"script:%s, line:%d with option
\"
%s
\"
"
,
script
->
fileName
,
line
->
lineNum
,
option
);
SCommand
*
cmd
=
&
simCmdList
[
line
->
cmdno
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录