X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Fhealth%2Fhealth_check.c;h=805eff8840c26203d367fb9bbf5a9db7d55ad025;hb=HEAD;hp=22cbcf12dfaad9ff0db002000ddc717d02c50baa;hpb=4d6fd6965d3dcff5ae2a157c58873f30dc117c09;p=lttng-tools.git diff --git a/tests/regression/tools/health/health_check.c b/tests/regression/tools/health/health_check.c index 22cbcf12d..805eff884 100644 --- a/tests/regression/tools/health/health_check.c +++ b/tests/regression/tools/health/health_check.c @@ -1,37 +1,30 @@ /* - * Copyright (C) 2012 - Christian Babeux + * Copyright (C) 2012 Christian Babeux + * Copyright (C) 2014 Mathieu Desnoyers * - * 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. + * SPDX-License-Identifier: GPL-2.0-only * - * 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 -#include - static const char *relayd_path; -static -int check_component(struct lttng_health *lh, const char *component_name) +static int +check_component(struct lttng_health *lh, const char *component_name, int ok_if_not_running) { const struct lttng_health_thread *thread; int nr_threads, i, status; if (lttng_health_query(lh)) { - fprintf(stderr, "Error querying %s health\n", - component_name); + if (ok_if_not_running) { + return 0; + } + fprintf(stderr, "Error querying %s health\n", component_name); return -1; } status = lttng_health_state(lh); @@ -59,15 +52,13 @@ int check_component(struct lttng_health *lh, const char *component_name) continue; } printf("Thread \"%s\" is not responding in component \"%s\".\n", - lttng_health_thread_name(thread), - component_name); - + lttng_health_thread_name(thread), + component_name); } return status; } -static -int check_sessiond(void) +static int check_sessiond(void) { struct lttng_health *lh; int status; @@ -78,15 +69,14 @@ int check_sessiond(void) return -1; } - status = check_component(lh, "sessiond"); + status = check_component(lh, "sessiond", 0); lttng_health_destroy(lh); return status; } -static -int check_consumerd(enum lttng_health_consumerd hc) +static int check_consumerd(enum lttng_health_consumerd hc) { struct lttng_health *lh; int status; @@ -102,15 +92,14 @@ int check_consumerd(enum lttng_health_consumerd hc) return -1; } - status = check_component(lh, cnames[hc]); + status = check_component(lh, cnames[hc], 1); lttng_health_destroy(lh); return status; } -static -int check_relayd(const char *path) +static int check_relayd(const char *path) { struct lttng_health *lh; int status; @@ -121,7 +110,7 @@ int check_relayd(const char *path) return -1; } - status = check_component(lh, "relayd"); + status = check_component(lh, "relayd", 0); lttng_health_destroy(lh); @@ -133,14 +122,13 @@ int main(int argc, char *argv[]) int status = 0, i; for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "--relayd-path")) { - if (i >= argc - 1) { - fprintf(stderr, "Missing relayd path\n"); - exit(EXIT_FAILURE); - } - relayd_path = argv[++i]; + size_t relayd_path_arg_len = strlen("--relayd-path="); + if (!strncmp(argv[i], "--relayd-path=", relayd_path_arg_len)) { + relayd_path = &argv[i][relayd_path_arg_len]; } else { - fprintf(stderr, "Unknown option \"%s\". Try --relayd-path PATH.\n", argv[i]); + fprintf(stderr, + "Unknown option \"%s\". Try --relayd-path=PATH.\n", + argv[i]); exit(EXIT_FAILURE); } }