d01ad4cb9210c2b854af4165b5c96fdec0e37c98
[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 <lttng/lttng-export.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <pthread.h>
13 #include <unistd.h>
14 #include <urcu.h>
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 */
22 static
23 int 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
35 static
36 void 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
47 LTTNG_EXPORT int __testpoint_sessiond_thread_manage_clients(void);
48 int __testpoint_sessiond_thread_manage_clients(void)
49 {
50 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_CLIENTS_STALL";
51
52 if (check_env_var(var)) {
53 do_stall();
54 }
55
56 return 0;
57 }
58
59 LTTNG_EXPORT int __testpoint_sessiond_thread_registration_apps(void);
60 int __testpoint_sessiond_thread_registration_apps(void)
61 {
62 const char *var = "LTTNG_SESSIOND_THREAD_REG_APPS_STALL";
63
64 if (check_env_var(var)) {
65 do_stall();
66 }
67
68 return 0;
69 }
70
71 LTTNG_EXPORT int __testpoint_sessiond_thread_manage_apps(void);
72 int __testpoint_sessiond_thread_manage_apps(void)
73 {
74 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_APPS_STALL";
75
76 if (check_env_var(var)) {
77 do_stall();
78 }
79
80 return 0;
81 }
82
83 LTTNG_EXPORT int __testpoint_sessiond_thread_manage_kernel(void);
84 int __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
95 LTTNG_EXPORT int __testpoint_sessiond_thread_manage_consumer(void);
96 int __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
107 LTTNG_EXPORT int __testpoint_sessiond_thread_app_manage_notify(void);
108 int __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
119 LTTNG_EXPORT int __testpoint_sessiond_thread_app_reg_dispatch(void);
120 int __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
133 LTTNG_EXPORT int __testpoint_consumerd_thread_channel(void);
134 int __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
145 LTTNG_EXPORT int __testpoint_consumerd_thread_metadata(void);
146 int __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
157 LTTNG_EXPORT int __testpoint_consumerd_thread_data(void);
158 int __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
169 LTTNG_EXPORT int __testpoint_consumerd_thread_sessiond(void);
170 int __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
181 LTTNG_EXPORT int __testpoint_consumerd_thread_metadata_timer(void);
182 int __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
195 LTTNG_EXPORT int __testpoint_relayd_thread_dispatcher(void);
196 int __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
207 LTTNG_EXPORT int __testpoint_relayd_thread_worker(void);
208 int __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
219 LTTNG_EXPORT int __testpoint_relayd_thread_listener(void);
220 int __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
231 LTTNG_EXPORT int __testpoint_relayd_thread_live_dispatcher(void);
232 int __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
243 LTTNG_EXPORT int __testpoint_relayd_thread_live_worker(void);
244 int __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
255 LTTNG_EXPORT int __testpoint_relayd_thread_live_listener(void);
256 int __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();
262 }
263
264 return 0;
265 }
This page took 0.040528 seconds and 4 git commands to generate.