Add declarations for exported functions in health_exit.c
[lttng-tools.git] / tests / regression / tools / health / health_stall.c
1 /*
2 * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
3 * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 */
8
9 #include <stdlib.h>
10 #include <string.h>
11 #include <pthread.h>
12 #include <unistd.h>
13 #include <urcu.h>
14
15 #define STALL_TIME 60
16
17 /*
18 * Check if the specified environment variable is set.
19 * Return 1 if set, otherwise 0.
20 */
21 static
22 int check_env_var(const char *env)
23 {
24 if (env) {
25 char *env_val = getenv(env);
26 if (env_val && (strncmp(env_val, "1", 1) == 0)) {
27 return 1;
28 }
29 }
30
31 return 0;
32 }
33
34 static
35 void do_stall(void)
36 {
37 unsigned int sleep_time = STALL_TIME;
38
39 while (sleep_time > 0) {
40 sleep_time = sleep(sleep_time);
41 }
42 }
43
44 /* Session daemon */
45
46 int __testpoint_sessiond_thread_manage_clients(void);
47 int __testpoint_sessiond_thread_manage_clients(void)
48 {
49 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_CLIENTS_STALL";
50
51 if (check_env_var(var)) {
52 do_stall();
53 }
54
55 return 0;
56 }
57
58 int __testpoint_sessiond_thread_registration_apps(void);
59 int __testpoint_sessiond_thread_registration_apps(void)
60 {
61 const char *var = "LTTNG_SESSIOND_THREAD_REG_APPS_STALL";
62
63 if (check_env_var(var)) {
64 do_stall();
65 }
66
67 return 0;
68 }
69
70 int __testpoint_sessiond_thread_manage_apps(void);
71 int __testpoint_sessiond_thread_manage_apps(void)
72 {
73 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_APPS_STALL";
74
75 if (check_env_var(var)) {
76 do_stall();
77 }
78
79 return 0;
80 }
81
82 int __testpoint_sessiond_thread_manage_kernel(void);
83 int __testpoint_sessiond_thread_manage_kernel(void)
84 {
85 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_KERNEL_STALL";
86
87 if (check_env_var(var)) {
88 do_stall();
89 }
90
91 return 0;
92 }
93
94 int __testpoint_sessiond_thread_manage_consumer(void);
95 int __testpoint_sessiond_thread_manage_consumer(void)
96 {
97 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_CONSUMER_STALL";
98
99 if (check_env_var(var)) {
100 do_stall();
101 }
102
103 return 0;
104 }
105
106 int __testpoint_sessiond_thread_ht_cleanup(void);
107 int __testpoint_sessiond_thread_ht_cleanup(void)
108 {
109 const char *var = "LTTNG_SESSIOND_THREAD_HT_CLEANUP_STALL";
110
111 if (check_env_var(var)) {
112 do_stall();
113 }
114
115 return 0;
116 }
117
118 int __testpoint_sessiond_thread_app_manage_notify(void);
119 int __testpoint_sessiond_thread_app_manage_notify(void)
120 {
121 const char *var = "LTTNG_SESSIOND_THREAD_APP_MANAGE_NOTIFY_STALL";
122
123 if (check_env_var(var)) {
124 do_stall();
125 }
126
127 return 0;
128 }
129
130 int __testpoint_sessiond_thread_app_reg_dispatch(void);
131 int __testpoint_sessiond_thread_app_reg_dispatch(void)
132 {
133 const char *var = "LTTNG_SESSIOND_THREAD_APP_REG_DISPATCH_STALL";
134
135 if (check_env_var(var)) {
136 do_stall();
137 }
138
139 return 0;
140 }
141
142 /* Consumer daemon */
143
144 int __testpoint_consumerd_thread_channel(void);
145 int __testpoint_consumerd_thread_channel(void)
146 {
147 const char *var = "LTTNG_CONSUMERD_THREAD_CHANNEL_STALL";
148
149 if (check_env_var(var)) {
150 do_stall();
151 }
152
153 return 0;
154 }
155
156 int __testpoint_consumerd_thread_metadata(void);
157 int __testpoint_consumerd_thread_metadata(void)
158 {
159 const char *var = "LTTNG_CONSUMERD_THREAD_METADATA_STALL";
160
161 if (check_env_var(var)) {
162 do_stall();
163 }
164
165 return 0;
166 }
167
168 int __testpoint_consumerd_thread_data(void);
169 int __testpoint_consumerd_thread_data(void)
170 {
171 const char *var = "LTTNG_CONSUMERD_THREAD_DATA_STALL";
172
173 if (check_env_var(var)) {
174 do_stall();
175 }
176
177 return 0;
178 }
179
180 int __testpoint_consumerd_thread_sessiond(void);
181 int __testpoint_consumerd_thread_sessiond(void)
182 {
183 const char *var = "LTTNG_CONSUMERD_THREAD_SESSIOND_STALL";
184
185 if (check_env_var(var)) {
186 do_stall();
187 }
188
189 return 0;
190 }
191
192 int __testpoint_consumerd_thread_metadata_timer(void);
193 int __testpoint_consumerd_thread_metadata_timer(void)
194 {
195 const char *var = "LTTNG_CONSUMERD_THREAD_METADATA_TIMER_STALL";
196
197 if (check_env_var(var)) {
198 do_stall();
199 }
200
201 return 0;
202 }
203
204 /* Relay daemon */
205
206 int __testpoint_relayd_thread_dispatcher(void);
207 int __testpoint_relayd_thread_dispatcher(void)
208 {
209 const char *var = "LTTNG_RELAYD_THREAD_DISPATCHER_STALL";
210
211 if (check_env_var(var)) {
212 do_stall();
213 }
214
215 return 0;
216 }
217
218 int __testpoint_relayd_thread_worker(void);
219 int __testpoint_relayd_thread_worker(void)
220 {
221 const char *var = "LTTNG_RELAYD_THREAD_WORKER_STALL";
222
223 if (check_env_var(var)) {
224 do_stall();
225 }
226
227 return 0;
228 }
229
230 int __testpoint_relayd_thread_listener(void);
231 int __testpoint_relayd_thread_listener(void)
232 {
233 const char *var = "LTTNG_RELAYD_THREAD_LISTENER_STALL";
234
235 if (check_env_var(var)) {
236 do_stall();
237 }
238
239 return 0;
240 }
241
242 int __testpoint_relayd_thread_live_dispatcher(void);
243 int __testpoint_relayd_thread_live_dispatcher(void)
244 {
245 const char *var = "LTTNG_RELAYD_THREAD_LIVE_DISPATCHER_STALL";
246
247 if (check_env_var(var)) {
248 do_stall();
249 }
250
251 return 0;
252 }
253
254 int __testpoint_relayd_thread_live_worker(void);
255 int __testpoint_relayd_thread_live_worker(void)
256 {
257 const char *var = "LTTNG_RELAYD_THREAD_LIVE_WORKER_STALL";
258
259 if (check_env_var(var)) {
260 do_stall();
261 }
262
263 return 0;
264 }
265
266 int __testpoint_relayd_thread_live_listener(void);
267 int __testpoint_relayd_thread_live_listener(void)
268 {
269 const char *var = "LTTNG_RELAYD_THREAD_LIVE_LISTENER_STALL";
270
271 if (check_env_var(var)) {
272 do_stall();
273 }
274
275 return 0;
276 }
This page took 0.052324 seconds and 4 git commands to generate.