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