X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Ftools%2Fhealth%2Fhealth_stall.c;fp=tests%2Ftools%2Fhealth%2Fhealth_stall.c;h=f91bd49a8e9209d34d7835841bba68b020469de7;hp=0000000000000000000000000000000000000000;hb=5862a19a5aeac6abf7a2c9de3cc4a903619abb25;hpb=9e32c5c0340e16a4c08a87d8c953306abfdc2e64 diff --git a/tests/tools/health/health_stall.c b/tests/tools/health/health_stall.c new file mode 100644 index 000000000..f91bd49a8 --- /dev/null +++ b/tests/tools/health/health_stall.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2012 - Christian Babeux + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License, version 2 only, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include +#include + +#define STALL_TIME 60 + +/* + * Check if the specified environment variable is set. + * Return 1 if set, otherwise 0. + */ +int check_env_var(const char *env) +{ + if (env) { + char *env_val = getenv(env); + if (env_val && (strncmp(env_val, "1", 1) == 0)) { + return 1; + } + } + + return 0; +} + +void __testpoint_thread_manage_clients_before_loop(void) +{ + const char *var = "LTTNG_THREAD_MANAGE_CLIENTS_STALL"; + + if (check_env_var(var)) { + sleep(STALL_TIME); + } +} + +void __testpoint_thread_manage_kernel_before_loop(void) +{ + const char *var = "LTTNG_THREAD_MANAGE_KERNEL_STALL"; + + if (check_env_var(var)) { + sleep(STALL_TIME); + } +} + +void __testpoint_thread_manage_apps_before_loop(void) +{ + const char *var = "LTTNG_THREAD_MANAGE_APPS_STALL"; + + if (check_env_var(var)) { + sleep(STALL_TIME); + } +}