SoW-2019-0002: Dynamic Snapshot
[lttng-tools.git] / tests / regression / tools / live / live_test.c
index 9f4532cfd6078c71e6e4ad0e3a547cb570ccf872..5d10d228b7d8f6f29614acbb42d966555b7a8115 100644 (file)
@@ -1,18 +1,8 @@
 /*
- * Copyright (c) - 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by as
- * published by the Free Software Foundation; only version 2 of the License.
+ * 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 <assert.h>
@@ -51,9 +41,6 @@
 #define NUM_TESTS 11
 #define mmap_size 524288
 
-int ust_consumerd32_fd;
-int ust_consumerd64_fd;
-
 static int control_sock;
 struct live_session *session;
 
@@ -110,7 +97,7 @@ ssize_t lttng_live_send(int fd, const void *buf, size_t len)
 }
 
 static
-int connect_viewer(char *hostname)
+int connect_viewer(const char *hostname)
 {
        struct hostent *host;
        struct sockaddr_in server_addr;
@@ -151,7 +138,7 @@ end:
        return ret;
 }
 
-int establish_connection(void)
+static int establish_connection(void)
 {
        struct lttng_viewer_cmd cmd;
        struct lttng_viewer_connect connect;
@@ -195,7 +182,7 @@ error:
 /*
  * Returns the number of sessions, should be 1 during the unit test.
  */
-int list_sessions(uint64_t *session_id)
+static int list_sessions(uint64_t *session_id)
 {
        struct lttng_viewer_cmd cmd;
        struct lttng_viewer_list_sessions list;
@@ -242,7 +229,7 @@ error:
        return -1;
 }
 
-int create_viewer_session(void)
+static int create_viewer_session(void)
 {
        struct lttng_viewer_cmd cmd;
        struct lttng_viewer_create_session_response resp;
@@ -280,7 +267,7 @@ error:
        return -1;
 }
 
-int attach_session(uint64_t id)
+static int attach_session(uint64_t id)
 {
        struct lttng_viewer_cmd cmd;
        struct lttng_viewer_attach_session_request rq;
@@ -369,7 +356,7 @@ error:
        return -1;
 }
 
-int get_metadata(void)
+static int get_metadata(void)
 {
        struct lttng_viewer_cmd cmd;
        struct lttng_viewer_get_metadata rq;
@@ -399,6 +386,7 @@ int get_metadata(void)
 
        rq.stream_id = htobe64(session->streams[metadata_stream_id].id);
 
+retry:
        ret_len = lttng_live_send(control_sock, &cmd, sizeof(cmd));
        if (ret_len < 0) {
                diag("Error sending cmd");
@@ -423,8 +411,8 @@ int get_metadata(void)
                break;
        case LTTNG_VIEWER_NO_NEW_METADATA:
                diag("Got LTTNG_VIEWER_NO_NEW_METADATA:");
-               ret = 0;
-               goto end;
+               usleep(50);
+               goto retry;
        case LTTNG_VIEWER_METADATA_ERR:
                diag("Got LTTNG_VIEWER_METADATA_ERR:");
                goto error;
@@ -454,7 +442,7 @@ int get_metadata(void)
        }
        free(data);
        ret = len;
-end:
+
        return ret;
 
 error_free_data:
@@ -463,7 +451,7 @@ error:
        return -1;
 }
 
-int get_next_index(void)
+static int get_next_index(void)
 {
        struct lttng_viewer_cmd cmd;
        struct lttng_viewer_get_next_index rq;
@@ -628,7 +616,7 @@ error:
        return -1;
 }
 
-int detach_viewer_session(uint64_t id)
+static int detach_viewer_session(uint64_t id)
 {
        struct lttng_viewer_cmd cmd;
        struct lttng_viewer_detach_session_response resp;
@@ -693,6 +681,9 @@ int main(int argc, char **argv)
 
        ret = list_sessions(&session_id);
        ok(ret > 0, "List sessions : %d session(s)", ret);
+       if (ret < 0) {
+               goto end;
+       }
 
        ret = create_viewer_session();
        ok(ret == 0, "Create viewer session");
@@ -721,6 +712,6 @@ int main(int argc, char **argv)
 
        ret = attach_session(session_id);
        ok(ret > 0, "Attach to session, %d streams received", ret);
-
+end:
        return exit_status();
 }
This page took 0.025809 seconds and 5 git commands to generate.