Gen-ust-events: use options instead of arguments
[lttng-tools.git] / tests / regression / tools / health / health_check.c
index 22cbcf12dfaad9ff0db002000ddc717d02c50baa..9109b1824336219627a24b346b28bd282ca9dba5 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com>
+ * Copyright (C) 2014 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * 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
 static const char *relayd_path;
 
 static
-int check_component(struct lttng_health *lh, const char *component_name)
+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)) {
+               if (ok_if_not_running) {
+                       return 0;
+               }
                fprintf(stderr, "Error querying %s health\n",
                        component_name);
                return -1;
@@ -78,7 +83,7 @@ int check_sessiond(void)
                return -1;
        }
 
-       status = check_component(lh, "sessiond");
+       status = check_component(lh, "sessiond", 0);
 
        lttng_health_destroy(lh);
 
@@ -102,7 +107,7 @@ 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);
 
@@ -121,7 +126,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 +138,12 @@ 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);
                }
        }
This page took 0.027473 seconds and 5 git commands to generate.