Fix: Use tmpdir for intermediary files
[lttng-tools.git] / tests / regression / tools / health / health_stall.c
CommitLineData
5862a19a
CB
1/*
2 * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com>
a33d2d4a 3 * Copyright (C) 2014 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5862a19a
CB
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License, version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#include <stdlib.h>
20#include <string.h>
a33d2d4a 21#include <pthread.h>
5862a19a 22#include <unistd.h>
a33d2d4a 23#include <urcu.h>
5862a19a
CB
24
25#define STALL_TIME 60
26
27/*
28 * Check if the specified environment variable is set.
29 * Return 1 if set, otherwise 0.
30 */
a33d2d4a 31static
5862a19a
CB
32int check_env_var(const char *env)
33{
34 if (env) {
35 char *env_val = getenv(env);
36 if (env_val && (strncmp(env_val, "1", 1) == 0)) {
37 return 1;
38 }
39 }
40
41 return 0;
42}
43
a33d2d4a
MD
44static
45void do_stall(void)
46{
47 unsigned int sleep_time = STALL_TIME;
48
49 while (sleep_time > 0) {
50 sleep_time = sleep(sleep_time);
51 }
52}
53
54/* Session daemon */
55
56int __testpoint_sessiond_thread_manage_clients(void)
5862a19a 57{
e547b070 58 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_CLIENTS_STALL";
5862a19a
CB
59
60 if (check_env_var(var)) {
a33d2d4a 61 do_stall();
5862a19a 62 }
6993eeb3
CB
63
64 return 0;
5862a19a
CB
65}
66
a33d2d4a 67int __testpoint_sessiond_thread_registration_apps(void)
5862a19a 68{
a33d2d4a 69 const char *var = "LTTNG_SESSIOND_THREAD_REG_APPS_STALL";
5862a19a
CB
70
71 if (check_env_var(var)) {
a33d2d4a 72 do_stall();
5862a19a 73 }
6993eeb3
CB
74
75 return 0;
5862a19a
CB
76}
77
a33d2d4a 78int __testpoint_sessiond_thread_manage_apps(void)
5862a19a 79{
e547b070 80 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_APPS_STALL";
5862a19a
CB
81
82 if (check_env_var(var)) {
a33d2d4a
MD
83 do_stall();
84 }
85
86 return 0;
87}
88
89int __testpoint_sessiond_thread_manage_kernel(void)
90{
91 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_KERNEL_STALL";
92
93 if (check_env_var(var)) {
94 do_stall();
95 }
96
97 return 0;
98}
99
100int __testpoint_sessiond_thread_manage_consumer(void)
101{
102 const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_CONSUMER_STALL";
103
104 if (check_env_var(var)) {
105 do_stall();
106 }
107
108 return 0;
109}
110
111int __testpoint_sessiond_thread_ht_cleanup(void)
112{
113 const char *var = "LTTNG_SESSIOND_THREAD_HT_CLEANUP_STALL";
114
115 if (check_env_var(var)) {
116 do_stall();
117 }
118
119 return 0;
120}
121
122int __testpoint_sessiond_thread_app_manage_notify(void)
123{
124 const char *var = "LTTNG_SESSIOND_THREAD_APP_MANAGE_NOTIFY_STALL";
125
126 if (check_env_var(var)) {
127 do_stall();
128 }
129
130 return 0;
131}
132
133int __testpoint_sessiond_thread_app_reg_dispatch(void)
134{
135 const char *var = "LTTNG_SESSIOND_THREAD_APP_REG_DISPATCH_STALL";
136
137 if (check_env_var(var)) {
138 do_stall();
139 }
140
141 return 0;
142}
143
144/* Consumer daemon */
145
146int __testpoint_consumerd_thread_channel(void)
147{
148 const char *var = "LTTNG_CONSUMERD_THREAD_CHANNEL_STALL";
149
150 if (check_env_var(var)) {
151 do_stall();
152 }
153
154 return 0;
155}
156
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
168int __testpoint_consumerd_thread_data(void)
169{
170 const char *var = "LTTNG_CONSUMERD_THREAD_DATA_STALL";
171
172 if (check_env_var(var)) {
173 do_stall();
174 }
175
176 return 0;
177}
178
179int __testpoint_consumerd_thread_sessiond(void)
180{
181 const char *var = "LTTNG_CONSUMERD_THREAD_SESSIOND_STALL";
182
183 if (check_env_var(var)) {
184 do_stall();
185 }
186
187 return 0;
188}
189
190int __testpoint_consumerd_thread_metadata_timer(void)
191{
192 const char *var = "LTTNG_CONSUMERD_THREAD_METADATA_TIMER_STALL";
193
194 if (check_env_var(var)) {
195 do_stall();
196 }
197
198 return 0;
199}
200
201/* Relay daemon */
202
203int __testpoint_relayd_thread_dispatcher(void)
204{
205 const char *var = "LTTNG_RELAYD_THREAD_DISPATCHER_STALL";
206
207 if (check_env_var(var)) {
208 do_stall();
209 }
210
211 return 0;
212}
213
214int __testpoint_relayd_thread_worker(void)
215{
216 const char *var = "LTTNG_RELAYD_THREAD_WORKER_STALL";
217
218 if (check_env_var(var)) {
219 do_stall();
220 }
221
222 return 0;
223}
224
225int __testpoint_relayd_thread_listener(void)
226{
227 const char *var = "LTTNG_RELAYD_THREAD_LISTENER_STALL";
228
229 if (check_env_var(var)) {
230 do_stall();
231 }
232
233 return 0;
234}
235
236int __testpoint_relayd_thread_live_dispatcher(void)
237{
238 const char *var = "LTTNG_RELAYD_THREAD_LIVE_DISPATCHER_STALL";
239
240 if (check_env_var(var)) {
241 do_stall();
242 }
243
244 return 0;
245}
246
247int __testpoint_relayd_thread_live_worker(void)
248{
249 const char *var = "LTTNG_RELAYD_THREAD_LIVE_WORKER_STALL";
250
251 if (check_env_var(var)) {
252 do_stall();
253 }
254
255 return 0;
256}
257
258int __testpoint_relayd_thread_live_listener(void)
259{
260 const char *var = "LTTNG_RELAYD_THREAD_LIVE_LISTENER_STALL";
261
262 if (check_env_var(var)) {
263 do_stall();
5862a19a 264 }
6993eeb3
CB
265
266 return 0;
5862a19a 267}
This page took 0.051013 seconds and 4 git commands to generate.