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

taosdata / TDengine / #4066

12 May 2025 05:35AM UTC coverage: 62.547% (+0.04%) from 62.508%
#4066

push

travis-ci

web-flow
Merge pull request #31053 from taosdata/merge/mainto3.0

merge: from main to 3.0 branch

155777 of 317858 branches covered (49.01%)

Branch coverage included in aggregate %.

382 of 573 new or added lines in 31 files covered. (66.67%)

648 existing lines in 129 files now uncovered.

241270 of 316936 relevant lines covered (76.13%)

6462449.7 hits per line

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

70.3
/tools/shell/src/shellMain.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 __USE_XOPEN
17
#include "shellAuto.h"
18
#include "shellInt.h"
19

20
extern SShellObj shell;
21

22
void shellCrashHandler(int signum, void *sigInfo, void *context) {
×
23
  taosIgnSignal(SIGTERM);
×
24
  taosIgnSignal(SIGHUP);
×
25
  taosIgnSignal(SIGINT);
×
26
  taosIgnSignal(SIGBREAK);
×
27
  taosIgnSignal(SIGABRT);
×
28
  taosIgnSignal(SIGFPE);
×
29
  taosIgnSignal(SIGSEGV);
×
30
#if !defined(WINDOWS)
31
  taosIgnSignal(SIGBUS);
×
32
#endif
33
#ifdef USE_REPORT
34
  taos_write_crashinfo(signum, sigInfo, context);
×
35
#endif
36
#ifdef _TD_DARWIN_64
37
  exit(signum);
38
#elif defined(WINDOWS)
39
  exit(signum);
40
#endif
41
}
×
42

43
// init arguments
44
void initArgument(SShellArgs *pArgs) {
14,880✔
45
  pArgs->host     = NULL;
14,880✔
46
  pArgs->port     = 0;
14,880✔
47
  pArgs->user     = NULL;
14,880✔
48
  pArgs->database = NULL;
14,880✔
49

50
  // conn mode
51
  pArgs->dsn      = NULL;
14,880✔
52
  pArgs->connMode = CONN_MODE_INVALID;
14,880✔
53

54
  pArgs->port_inputted = false;
14,880✔
55
}
14,880✔
56

57
int main(int argc, char *argv[]) {
14,880✔
58
  int code  = 0;
14,880✔
59
#if !defined(WINDOWS)
60
  taosSetSignal(SIGBUS, shellCrashHandler);
14,880✔
61
#endif
62
  taosSetSignal(SIGABRT, shellCrashHandler);
14,880✔
63
  taosSetSignal(SIGFPE, shellCrashHandler);
14,880✔
64
  taosSetSignal(SIGSEGV, shellCrashHandler);
14,880✔
65

66
  initArgument(&shell.args);
14,880✔
67

68
  if (shellCheckIntSize() != 0) {
14,880!
69
    return -1;
×
70
  }
71

72
  if (shellParseArgs(argc, argv) != 0) {
14,880✔
73
    return -1;
17✔
74
  }
75

76
  if (shell.args.is_version) {
14,847!
77
    shellPrintVersion();
×
78
    return 0;
×
79
  }
80

81
  if (shell.args.is_gen_auth) {
14,847✔
82
    shellGenerateAuth();
1✔
83
    return 0;
1✔
84
  }
85

86
  if (shell.args.is_help) {
14,846!
87
    shellPrintHelp();
×
88
    return 0;
×
89
  }
90

91
  if (shell.args.netrole != NULL) {
14,846✔
92
    shellTestNetWork();
2✔
93
    return 0;
2✔
94
  }
95

96
  if (getDsnEnv() != 0) {
14,844!
UNCOV
97
    return -1;
×
98
  }
99

100
  // first taos_option(TSDB_OPTION_DRIVER ...) no load driver
101
  if (setConnMode(shell.args.connMode, shell.args.dsn, false)) {
14,844!
102
    return -1;
×
103
  }
104

105
  // second taos_option(TSDB_OPTION_CONFIGDIR ...) set configDir global
106
  if (configDirShell[0] != 0) {
14,844✔
107
    code = taos_options(TSDB_OPTION_CONFIGDIR, configDirShell);
210✔
108
    if (code) {
210!
109
      fprintf(stderr, "failed to set config dir:%s  code:[0x%08X]\r\n", configDirShell, code);
×
110
      return -1;
×
111
    }
112
    //printf("Load with input config dir:%s\n", configDirShell);
113
  }  
114

115
#ifndef TD_ASTRA
116
  // dump config
117
  if (shell.args.is_dump_config) {
14,844✔
118
    shellDumpConfig();
3✔
119
    return 0;
3✔
120
  }
121
#endif
122

123
  // taos_init
124
  if (taos_init() != 0) {
14,841✔
125
    fprintf(stderr, "failed to init shell since %s [0x%08X]\r\n", taos_errstr(NULL), taos_errno(NULL));
1✔
126
    return -1;
1✔
127
  }
128

129
  // kill heart-beat thread when quit
130
  taos_set_hb_quit(1);
14,840✔
131

132
#ifndef TD_ASTRA
133
  if (shell.args.is_startup || shell.args.is_check) {
14,840✔
134
    shellCheckServerStatus();
6✔
135
    taos_cleanup();
6✔
136
    return 0;
6✔
137
  }
138

139
  if (shell.args.netrole != NULL) {
14,834!
140
    shellTestNetWork();
×
141
    taos_cleanup();
×
142
    return 0;
×
143
  }
144
#endif
145
  // support port feature
146
  shellAutoInit();
14,834✔
147
  int32_t ret = shellExecute(argc, argv);
14,834✔
148
  shellAutoExit();
14,834✔
149

150
  return ret;
14,834✔
151
}
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