Add declarations for exported functions in health_exit.c
[lttng-tools.git] / tests / regression / tools / health / health_stall.c
CommitLineData
5862a19a 1/*
9d16b343
MJ
2 * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
3 * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5862a19a 4 *
9d16b343 5 * SPDX-License-Identifier: GPL-2.0-only
5862a19a 6 *
5862a19a
CB
7 */
8
9#include <stdlib.h>
10#include <string.h>
a33d2d4a 11#include <pthread.h>
5862a19a 12#include <unistd.h>
a33d2d4a 13#include <urcu.h>
5862a19a
CB
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 */
a33d2d4a 21static
5862a19a
CB
22int 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
a33d2d4a
MD
34static
35void 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
c997c4ac 46int __testpoint_sessiond_thread_manage_clients(void);
a33d2d4a 47int __testpoint_sessiond_thread_manage_clients(void)
5862a19a 48{
e547b070 49 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_CLIENTS_STALL";
5862a19a
CB
50
51 if (check_env_var(var)) {
a33d2d4a 52 do_stall();
5862a19a 53 }
6993eeb3
CB
54
55 return 0;
5862a19a
CB
56}
57
c997c4ac 58int __testpoint_sessiond_thread_registration_apps(void);
a33d2d4a 59int __testpoint_sessiond_thread_registration_apps(void)
5862a19a 60{
a33d2d4a 61 const char *var = "LTTNG_SESSIOND_THREAD_REG_APPS_STALL";
5862a19a
CB
62
63 if (check_env_var(var)) {
a33d2d4a 64 do_stall();
5862a19a 65 }
6993eeb3
CB
66
67 return 0;
5862a19a
CB
68}
69
c997c4ac 70int __testpoint_sessiond_thread_manage_apps(void);
a33d2d4a 71int __testpoint_sessiond_thread_manage_apps(void)
5862a19a 72{
e547b070 73 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_APPS_STALL";
5862a19a
CB
74
75 if (check_env_var(var)) {
a33d2d4a
MD
76 do_stall();
77 }
78
79 return 0;
80}
81
c997c4ac 82int __testpoint_sessiond_thread_manage_kernel(void);
a33d2d4a
MD
83int __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
c997c4ac 94int __testpoint_sessiond_thread_manage_consumer(void);
a33d2d4a
MD
95int __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
c997c4ac 106int __testpoint_sessiond_thread_ht_cleanup(void);
a33d2d4a
MD
107int __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
c997c4ac 118int __testpoint_sessiond_thread_app_manage_notify(void);
a33d2d4a
MD
119int __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
c997c4ac 130int __testpoint_sessiond_thread_app_reg_dispatch(void);
a33d2d4a
MD
131int __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
c997c4ac 144int __testpoint_consumerd_thread_channel(void);
a33d2d4a
MD
145int __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
c997c4ac 156int __testpoint_consumerd_thread_metadata(void);
a33d2d4a
MD
157int __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
c997c4ac 168int __testpoint_consumerd_thread_data(void);
a33d2d4a
MD
169int __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
c997c4ac 180int __testpoint_consumerd_thread_sessiond(void);
a33d2d4a
MD
181int __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
c997c4ac 192int __testpoint_consumerd_thread_metadata_timer(void);
a33d2d4a
MD
193int __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
c997c4ac 206int __testpoint_relayd_thread_dispatcher(void);
a33d2d4a
MD
207int __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
c997c4ac 218int __testpoint_relayd_thread_worker(void);
a33d2d4a
MD
219int __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
c997c4ac 230int __testpoint_relayd_thread_listener(void);
a33d2d4a
MD
231int __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
c997c4ac 242int __testpoint_relayd_thread_live_dispatcher(void);
a33d2d4a
MD
243int __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
c997c4ac 254int __testpoint_relayd_thread_live_worker(void);
a33d2d4a
MD
255int __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
c997c4ac 266int __testpoint_relayd_thread_live_listener(void);
a33d2d4a
MD
267int __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();
5862a19a 273 }
6993eeb3
CB
274
275 return 0;
5862a19a 276}
This page took 0.079442 seconds and 4 git commands to generate.