4439b736957cc9e46ea47e14ea8742903f3e5d0c
[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 {
48 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_CLIENTS_STALL";
49
50 if (check_env_var(var)) {
51 do_stall();
52 }
53
54 return 0;
55 }
56
57 int __testpoint_sessiond_thread_registration_apps(void)
58 {
59 const char *var = "LTTNG_SESSIOND_THREAD_REG_APPS_STALL";
60
61 if (check_env_var(var)) {
62 do_stall();
63 }
64
65 return 0;
66 }
67
68 int __testpoint_sessiond_thread_manage_apps(void)
69 {
70 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_APPS_STALL";
71
72 if (check_env_var(var)) {
73 do_stall();
74 }
75
76 return 0;
77 }
78
79 int __testpoint_sessiond_thread_manage_kernel(void)
80 {
81 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_KERNEL_STALL";
82
83 if (check_env_var(var)) {
84 do_stall();
85 }
86
87 return 0;
88 }
89
90 int __testpoint_sessiond_thread_manage_consumer(void)
91 {
92 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_CONSUMER_STALL";
93
94 if (check_env_var(var)) {
95 do_stall();
96 }
97
98 return 0;
99 }
100
101 int __testpoint_sessiond_thread_ht_cleanup(void)
102 {
103 const char *var = "LTTNG_SESSIOND_THREAD_HT_CLEANUP_STALL";
104
105 if (check_env_var(var)) {
106 do_stall();
107 }
108
109 return 0;
110 }
111
112 int __testpoint_sessiond_thread_app_manage_notify(void)
113 {
114 const char *var = "LTTNG_SESSIOND_THREAD_APP_MANAGE_NOTIFY_STALL";
115
116 if (check_env_var(var)) {
117 do_stall();
118 }
119
120 return 0;
121 }
122
123 int __testpoint_sessiond_thread_app_reg_dispatch(void)
124 {
125 const char *var = "LTTNG_SESSIOND_THREAD_APP_REG_DISPATCH_STALL";
126
127 if (check_env_var(var)) {
128 do_stall();
129 }
130
131 return 0;
132 }
133
134 /* Consumer daemon */
135
136 int __testpoint_consumerd_thread_channel(void)
137 {
138 const char *var = "LTTNG_CONSUMERD_THREAD_CHANNEL_STALL";
139
140 if (check_env_var(var)) {
141 do_stall();
142 }
143
144 return 0;
145 }
146
147 int __testpoint_consumerd_thread_metadata(void)
148 {
149 const char *var = "LTTNG_CONSUMERD_THREAD_METADATA_STALL";
150
151 if (check_env_var(var)) {
152 do_stall();
153 }
154
155 return 0;
156 }
157
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 int __testpoint_consumerd_thread_sessiond(void)
170 {
171 const char *var = "LTTNG_CONSUMERD_THREAD_SESSIOND_STALL";
172
173 if (check_env_var(var)) {
174 do_stall();
175 }
176
177 return 0;
178 }
179
180 int __testpoint_consumerd_thread_metadata_timer(void)
181 {
182 const char *var = "LTTNG_CONSUMERD_THREAD_METADATA_TIMER_STALL";
183
184 if (check_env_var(var)) {
185 do_stall();
186 }
187
188 return 0;
189 }
190
191 /* Relay daemon */
192
193 int __testpoint_relayd_thread_dispatcher(void)
194 {
195 const char *var = "LTTNG_RELAYD_THREAD_DISPATCHER_STALL";
196
197 if (check_env_var(var)) {
198 do_stall();
199 }
200
201 return 0;
202 }
203
204 int __testpoint_relayd_thread_worker(void)
205 {
206 const char *var = "LTTNG_RELAYD_THREAD_WORKER_STALL";
207
208 if (check_env_var(var)) {
209 do_stall();
210 }
211
212 return 0;
213 }
214
215 int __testpoint_relayd_thread_listener(void)
216 {
217 const char *var = "LTTNG_RELAYD_THREAD_LISTENER_STALL";
218
219 if (check_env_var(var)) {
220 do_stall();
221 }
222
223 return 0;
224 }
225
226 int __testpoint_relayd_thread_live_dispatcher(void)
227 {
228 const char *var = "LTTNG_RELAYD_THREAD_LIVE_DISPATCHER_STALL";
229
230 if (check_env_var(var)) {
231 do_stall();
232 }
233
234 return 0;
235 }
236
237 int __testpoint_relayd_thread_live_worker(void)
238 {
239 const char *var = "LTTNG_RELAYD_THREAD_LIVE_WORKER_STALL";
240
241 if (check_env_var(var)) {
242 do_stall();
243 }
244
245 return 0;
246 }
247
248 int __testpoint_relayd_thread_live_listener(void)
249 {
250 const char *var = "LTTNG_RELAYD_THREAD_LIVE_LISTENER_STALL";
251
252 if (check_env_var(var)) {
253 do_stall();
254 }
255
256 return 0;
257 }
This page took 0.047568 seconds and 3 git commands to generate.