format sim scripts

This commit is contained in:
Shengliang Guan 2021-12-17 17:16:39 +08:00
parent 8e68fa6e4d
commit 8940eb4d1a
6 changed files with 77 additions and 78 deletions

View File

@ -14,14 +14,14 @@
*/ */
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "taos.h"
#include "cJSON.h" #include "cJSON.h"
#include "os.h" #include "os.h"
#include "sim.h" #include "sim.h"
#include "taos.h"
#include "taoserror.h" #include "taoserror.h"
#include "tglobal.h" #include "tglobal.h"
#include "tutil.h"
#include "ttypes.h" #include "ttypes.h"
#include "tutil.h"
void simLogSql(char *sql, bool useSharp) { void simLogSql(char *sql, bool useSharp) {
static FILE *fp = NULL; static FILE *fp = NULL;
@ -475,9 +475,7 @@ void simCloseNativeConnect(SScript *script) {
script->taos = NULL; script->taos = NULL;
} }
void simCloseTaosdConnect(SScript *script) { void simCloseTaosdConnect(SScript *script) { simCloseNativeConnect(script); }
simCloseNativeConnect(script);
}
bool simCreateNativeConnect(SScript *script, char *user, char *pass) { bool simCreateNativeConnect(SScript *script, char *user, char *pass) {
simCloseTaosdConnect(script); simCloseTaosdConnect(script);
@ -803,7 +801,6 @@ bool simExecuteRestfulCmd(SScript *script, char *rest) {
return simExecuteSystemCmd(script, cmd); return simExecuteSystemCmd(script, cmd);
} }
bool simExecuteSqlErrorCmd(SScript *script, char *rest) { bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
char buf[3000]; char buf[3000];
SCmdLine *line = &script->lines[script->linePos]; SCmdLine *line = &script->lines[script->linePos];
@ -881,8 +878,8 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) {
script->linePos++; script->linePos++;
return true; return true;
} else { } else {
sprintf(script->error, "lineNum: %d. line: %s failed, ret:%d:%s", line->lineNum, rest, sprintf(script->error, "lineNum: %d. line: %s failed, ret:%d:%s", line->lineNum, rest, ret & 0XFFFF,
ret & 0XFFFF, tstrerror(ret)); tstrerror(ret));
return false; return false;
} }
} }
@ -904,12 +901,13 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
int32_t ret = 0; int32_t ret = 0;
#endif #endif
if (ret == TSDB_CODE_SUCCESS) { 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++; script->linePos++;
return false; return false;
} else { } else {
simDebug("lineNum: %d. line: %s failed, ret:%d:%s. Expect failed, so success", line->lineNum, rest, simDebug("lineNum: %d. line: %s failed, ret:%d:%s. Expect failed, so success", line->lineNum, rest, ret & 0XFFFF,
ret & 0XFFFF, tstrerror(ret)); tstrerror(ret));
return true; return true;
} }
} }

View File

@ -15,8 +15,8 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include "tglobal.h"
#include "sim.h" #include "sim.h"
#include "tglobal.h"
bool simExecSuccess = false; bool simExecSuccess = false;
bool abortExecution = false; bool abortExecution = false;

View File

@ -60,9 +60,10 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include "sim.h" #include "sim.h"
#include "simParse.h"
#include "tutil.h" #include "tutil.h"
#include "simParse.h"
static SCommand *cmdHashList[MAX_NUM_CMD]; static SCommand *cmdHashList[MAX_NUM_CMD];
static SCmdLine cmdLine[MAX_CMD_LINES]; static SCmdLine cmdLine[MAX_CMD_LINES];
static char parseErr[MAX_ERROR_LEN]; static char parseErr[MAX_ERROR_LEN];

View File

@ -14,9 +14,9 @@
*/ */
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "taos.h"
#include "os.h" #include "os.h"
#include "sim.h" #include "sim.h"
#include "taos.h"
#include "taoserror.h" #include "taoserror.h"
#include "tglobal.h" #include "tglobal.h"
#include "ttimer.h" #include "ttimer.h"