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

taosdata / TDengine / #3814

01 Apr 2025 05:36AM UTC coverage: 30.169% (-3.6%) from 33.798%
#3814

push

travis-ci

happyguoxy
test:add build cmake

129680 of 592945 branches covered (21.87%)

Branch coverage included in aggregate %.

196213 of 487270 relevant lines covered (40.27%)

555639.42 hits per line

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

57.43
/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) {
137✔
45
  pArgs->host     = NULL;
137✔
46
  pArgs->port     = 0;
137✔
47
  pArgs->user     = NULL;
137✔
48
  pArgs->database = NULL;
137✔
49

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

54
  pArgs->port_inputted = false;
137✔
55
}
137✔
56

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

66
  initArgument(&shell.args);
137✔
67

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

72
  if (shellParseArgs(argc, argv) != 0) {
137!
73
    return -1;
×
74
  }
75

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

81
  if (shell.args.is_gen_auth) {
130!
82
    shellGenerateAuth();
×
83
    return 0;
×
84
  }
85

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

91
  if (shell.args.netrole != NULL) {
130✔
92
    shellTestNetWork();
1✔
93
    return 0;
1✔
94
  }
95

96
  if (getDsnEnv() != 0) {
129!
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)) {
129!
102
    return -1;
×
103
  }
104

105
  // second taos_option(TSDB_OPTION_CONFIGDIR ...) set configDir global
106
  if (configDirShell[0] != 0) {
129!
107
    code = taos_options(TSDB_OPTION_CONFIGDIR, configDirShell);
×
108
    if (code) {
×
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) {
129✔
118
    shellDumpConfig();
1✔
119
    return 0;
1✔
120
  }
121
#endif
122

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

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

132
#ifndef TD_ASTRA
133
  if (shell.args.is_startup || shell.args.is_check) {
128!
134
    shellCheckServerStatus();
1✔
135
    taos_cleanup();
1✔
136
    return 0;
1✔
137
  }
138

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

150
  return ret;
127✔
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