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

taosdata / TDengine / #3620

21 Feb 2025 09:00AM UTC coverage: 63.573% (+0.2%) from 63.423%
#3620

push

travis-ci

web-flow
ci: taosBenchmark add coverage cases branch 3.0 (#29788)

* fix: add unit test for taos-tools

* fix: only .cpp include

* fix: remove no use function

* fix: restore toolsSys.c

* fix: add toolsSys case

* fix: rebuild error fixed

* fix: fix build error

* fix: support get vgroups with core and memory limit

* fix: build error for strcasecmp

* fix: add insertBasic.py case

* fix: add command line set vgroups=3

* fix: change with ns database

* toolscJson read with int replace float and add insertPrecison.py

* fix: add insertBindVGroup.json case

* fix: remove public fun removeQuotation

* fix: vgroups change method

* fix: memory leak for runInsertLimitThread slot

* insertPrecision.py word write wrong

* fix: check isFloat number

* fix: vgroups change logic error

* fix: insertBasic.py real and expect error

* fix: adjust default vgroups

* fix: adjust default vgroups modify comment

148962 of 300203 branches covered (49.62%)

Branch coverage included in aggregate %.

15 of 16 new or added lines in 1 file covered. (93.75%)

2018 existing lines in 133 files now uncovered.

233201 of 300933 relevant lines covered (77.49%)

18174406.98 hits per line

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

52.17
/tools/shell/src/shellUtil.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 _BSD_SOURCE
17
#define _GNU_SOURCE
18
#define _XOPEN_SOURCE
19
#define _DEFAULT_SOURCE
20

21
#include "shellInt.h"
22

23
bool shellRegexMatch(const char *s, const char *reg, int32_t cflags) {
1,818,125✔
24
  regex_t regex = {0};
1,818,125✔
25
  char    msgbuf[100] = {0};
1,818,125✔
26

27
  /* Compile regular expression */
28
  if (regcomp(&regex, reg, cflags) != 0) {
1,818,125!
29
    fprintf(stderr, "Fail to compile regex");
×
30
    shellExit();
×
31
  }
32

33
  /* Execute regular expression */
34
  int32_t reti = regexec(&regex, s, 0, NULL, 0);
1,818,125✔
35
  if (!reti) {
1,818,125✔
36
    regfree(&regex);
122,432✔
37
    return true;
122,432✔
38
  } else if (reti == REG_NOMATCH) {
1,695,693!
39
    regfree(&regex);
1,695,693✔
40
    return false;
1,695,693✔
41
  } else {
42
    regerror(reti, &regex, msgbuf, sizeof(msgbuf));
×
43
    fprintf(stderr, "Regex match failed: %s\r\n", msgbuf);
×
44
    regfree(&regex);
×
45
    shellExit();
×
46
  }
47

48
  return false;
×
49
}
50

51
int32_t shellCheckIntSize() {
1,131✔
52
  if (sizeof(int8_t) != 1) {
53
    printf("int8 size is %d(!= 1)", (int)sizeof(int8_t));
54
    return -1;
55
  }
56
  if (sizeof(int16_t) != 2) {
57
    printf("int16 size is %d(!= 2)", (int)sizeof(int16_t));
58
    return -1;
59
  }
60
  if (sizeof(int32_t) != 4) {
61
    printf("int32 size is %d(!= 4)", (int)sizeof(int32_t));
62
    return -1;
63
  }
64
  if (sizeof(int64_t) != 8) {
65
    printf("int64 size is %d(!= 8)", (int)sizeof(int64_t));
66
    return -1;
67
  }
68
  return 0;
1,131✔
69
}
70

71
void shellPrintVersion() { printf("%s\r\n", shell.info.programVersion); }
×
72

73
void shellGenerateAuth() {
1✔
74
  char secretEncrypt[TSDB_PASSWORD_LEN + 1] = {0};
1✔
75
  taosEncryptPass_c((uint8_t *)shell.args.password, strlen(shell.args.password), secretEncrypt);
1✔
76
  printf("%s\r\n", secretEncrypt);
1✔
77
  fflush(stdout);
1✔
78
}
1✔
79

80
void shellDumpConfig() {
1✔
81
  SConfig *pCfg = taosGetCfg();
1✔
82
  if (pCfg == NULL) {
1!
83
    printf("read global config failed!\r\n");
×
84
  } else {
85
    cfgDumpCfg(pCfg, 1, true);
1✔
86
  }
87
  fflush(stdout);
1✔
88
}
1✔
89

90
void shellCheckServerStatus() {
4✔
91
  TSDB_SERVER_STATUS code;
92

93
  do {
×
94
    char details[1024] = {0};
4✔
95
    code = taos_check_server_status(shell.args.host, shell.args.port, details, 1024);
4✔
96
    switch (code) {
4!
97
      case TSDB_SRV_STATUS_UNAVAILABLE:
1✔
98
        printf("0: unavailable\r\n");
1✔
99
        break;
1✔
100
      case TSDB_SRV_STATUS_NETWORK_OK:
×
101
        printf("1: network ok\r\n");
×
102
        break;
×
103
      case TSDB_SRV_STATUS_SERVICE_OK:
3✔
104
        printf("2: service ok\r\n");
3✔
105
        break;
3✔
106
      case TSDB_SRV_STATUS_SERVICE_DEGRADED:
×
107
        printf("3: service degraded\r\n");
×
108
        break;
×
109
      case TSDB_SRV_STATUS_EXTING:
×
110
        printf("4: exiting\r\n");
×
111
        break;
×
112
    }
113
    if (strlen(details) != 0) {
4!
114
      printf("%s\r\n\r\n", details);
×
115
    }
116
    fflush(stdout);
4✔
117
    if (code == TSDB_SRV_STATUS_NETWORK_OK && shell.args.is_startup) {
4!
118
      taosMsleep(1000);
×
119
    } else {
120
      break;
121
    }
122
  } while (1);
123
}
4✔
124
#ifdef WEBSOCKET
125
void shellCheckConnectMode() {
1,108✔
126
        if (shell.args.dsn) {
1,108!
UNCOV
127
                shell.args.cloud = true;
×
UNCOV
128
                shell.args.restful = false;
×
UNCOV
129
                return;
×
130
        }
131
        if (shell.args.cloud) {
1,108✔
132
                shell.args.dsn = getenv("TDENGINE_CLOUD_DSN");
248✔
133
                if (shell.args.dsn && strlen(shell.args.dsn) > 4) {
248!
UNCOV
134
                        shell.args.cloud = true;
×
UNCOV
135
      shell.args.local = false;
×
UNCOV
136
                        shell.args.restful = false;
×
UNCOV
137
                        return;
×
138
                }
139

140
    shell.args.dsn = getenv("TDENGINE_DSN");
248✔
141
                if (shell.args.dsn && strlen(shell.args.dsn) > 4) {
248!
142
                        shell.args.cloud = true;
×
143
      shell.args.local = true;
×
144
                        shell.args.restful = false;
×
145
                        return;
×
146
                }
147

148
                if (shell.args.restful) {
248!
UNCOV
149
                        if (!shell.args.host) {
×
UNCOV
150
                                shell.args.host = "localhost";
×
151
                        }
UNCOV
152
                        if (!shell.args.port) {
×
UNCOV
153
                                shell.args.port = 6041;
×
154
                        }
UNCOV
155
                        shell.args.dsn = taosMemoryCalloc(1, 1024);
×
UNCOV
156
                        snprintf(shell.args.dsn, 1024, "ws://%s:%d",
×
157
                                        shell.args.host, shell.args.port);
158
                }
159
                shell.args.cloud = false;
248✔
160
                return;
248✔
161
        }
162
}
163
#endif
164

165
void shellExit() {
5✔
166
  if (shell.conn != NULL) {
5!
167
    taos_close(shell.conn);
5✔
168
    shell.conn = NULL;
5✔
169
  }
170
  shell.exit = true;
5✔
171
  taos_cleanup();
5✔
172
}
5✔
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