• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #3720

26 Mar 2025 06:20AM UTC coverage: 30.242% (-31.7%) from 61.936%
#3720

push

travis-ci

web-flow
feat(taosBenchmark): supports decimal data type (#30456)

* feat: taosBenchmark supports decimal data type

* build: decimal script not use pytest.sh

* fix: fix typo for decimal script

* test: insertBasic.py debug

71234 of 313946 branches covered (22.69%)

Branch coverage included in aggregate %.

38 of 423 new or added lines in 8 files covered. (8.98%)

120240 existing lines in 447 files now uncovered.

118188 of 312400 relevant lines covered (37.83%)

1450220.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.09
/utils/tsim/src/simSystem.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#define _DEFAULT_SOURCE
17
#include "simInt.h"
18
#include "tconfig.h"
19

20
SScript *simScriptList[MAX_MAIN_SCRIPT_NUM];
21
SCommand simCmdList[SIM_CMD_END];
22
int32_t  simScriptPos = -1;
23
int32_t  simScriptSucceed = 0;
24
void     simCloseTaosdConnect(SScript *script);
25
char     simScriptDir[PATH_MAX] = {0};
26

27
extern bool simExecSuccess;
28

29
int32_t simInitCfg() {
16✔
30
  taosCreateLog("simlog", 1, configDir, NULL, NULL, NULL, NULL, 1);
16✔
31
  taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1);
16✔
32

33
  SConfig *pCfg = taosGetCfg();
16✔
34
  tstrncpy(simScriptDir, cfgGetItem(pCfg, "scriptDir")->str, PATH_MAX);
16✔
35
  return 0;
16✔
36
}
37

38
void simSystemInit() {
16✔
39
  simInitCfg();
16✔
40
  simInitsimCmdList();
16✔
41
  memset(simScriptList, 0, sizeof(SScript *) * MAX_MAIN_SCRIPT_NUM);
16✔
42
}
16✔
43

44
void simSystemCleanUp() {}
1✔
45

46
void simFreeScript(SScript *script) {
56✔
47
  if (script->type == SIM_SCRIPT_TYPE_MAIN) {
56!
48
    simInfo("script:%s, background script num:%d, stop them", script->fileName, script->bgScriptLen);
56!
49

50
    for (int32_t i = 0; i < script->bgScriptLen; ++i) {
56!
UNCOV
51
      SScript *bgScript = script->bgScripts[i];
×
UNCOV
52
      simDebug("script:%s, is background script, set stop flag", bgScript->fileName);
×
UNCOV
53
      bgScript->killed = true;
×
UNCOV
54
      if (taosCheckPthreadValid(bgScript->bgPid)) {
×
UNCOV
55
        taosThreadJoin(bgScript->bgPid, NULL);
×
UNCOV
56
        taosThreadClear(&bgScript->bgPid);
×
57
      }
58

UNCOV
59
      simDebug("script:%s, background thread joined", bgScript->fileName);
×
UNCOV
60
      taos_close(bgScript->taos);
×
UNCOV
61
      taosMemoryFreeClear(bgScript->lines);
×
UNCOV
62
      taosMemoryFreeClear(bgScript->optionBuffer);
×
UNCOV
63
      taosMemoryFreeClear(bgScript);
×
64
    }
65

66
    simDebug("script:%s, is cleaned", script->fileName);
56!
67
    taos_close(script->taos);
56✔
68
    taosMemoryFreeClear(script->lines);
56!
69
    taosMemoryFreeClear(script->optionBuffer);
56!
70
    taosMemoryFreeClear(script);
56!
71
  }
72
}
56✔
73

74
SScript *simProcessCallOver(SScript *script) {
56✔
75
  if (script->type == SIM_SCRIPT_TYPE_MAIN) {
56!
76
    simDebug("script:%s, is main script, set stop flag", script->fileName);
56!
77
    if (script->killed) {
56!
UNCOV
78
      simExecSuccess = false;
×
UNCOV
79
      simInfo("script:" FAILED_PREFIX "%s" FAILED_POSTFIX ", " FAILED_PREFIX "failed" FAILED_POSTFIX ", error:%s",
×
80
              script->fileName, script->error);
81
    } else {
82
      simExecSuccess = true;
56✔
83
      simInfo("script:" SUCCESS_PREFIX "%s" SUCCESS_POSTFIX ", " SUCCESS_PREFIX "success" SUCCESS_POSTFIX,
56!
84
              script->fileName);
85
    }
86

87
    simCloseTaosdConnect(script);
56✔
88
    simScriptSucceed++;
56✔
89
    simScriptPos--;
56✔
90
    simFreeScript(script);
56✔
91

92
    if (simScriptPos == -1 && simExecSuccess) {
56!
93
      simInfo("----------------------------------------------------------------------");
13!
94
      simInfo("Simulation Test Done, " SUCCESS_PREFIX "%d" SUCCESS_POSTFIX " Passed:\n", simScriptSucceed);
13!
95
      return NULL;
13✔
96
    }
97

98
    if (simScriptPos == -1) return NULL;
43!
99
    if (!simExecSuccess) return NULL;
43!
100

101
    return simScriptList[simScriptPos];
43✔
102
  } else {
UNCOV
103
    simDebug("script:%s,  is stopped", script->fileName);
×
UNCOV
104
    simFreeScript(script);
×
UNCOV
105
    return NULL;
×
106
  }
107
}
108

109
void *simExecuteScript(void *inputScript) {
13✔
110
  SScript *script = (SScript *)inputScript;
13✔
111

112
  while (1) {
113
    if (script->type == SIM_SCRIPT_TYPE_MAIN) {
736,149!
114
      script = simScriptList[simScriptPos];
736,149✔
115
    }
116

117
    if (abortExecution) {
736,149!
118
      script->killed = true;
×
119
    }
120

121
    if (script->killed || script->linePos >= script->numOfLines) {
736,149!
122
      script = simProcessCallOver(script);
56✔
123
      if (script == NULL) {
56✔
124
        simDebug("sim test abort now!");
13!
125
        break;
13✔
126
      }
127
    } else {
128
      SCmdLine *line = &script->lines[script->linePos];
736,093✔
129
      char     *option = script->optionBuffer + line->optionOffset;
736,093✔
130
      simDebug("script:%s, line:%d with option \"%s\"", script->fileName, line->lineNum, option);
736,093!
131

132
      SCommand *cmd = &simCmdList[line->cmdno];
736,093✔
133
      int32_t   ret = (*(cmd->executeCmd))(script, option);
736,093✔
134
      if (!ret) {
736,093!
UNCOV
135
        script->killed = true;
×
136
      }
137
    }
138
  }
139

140
  simInfo("thread is stopped");
13!
141
  return NULL;
13✔
142
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc