lib: compile liblttng-ctl as C++
[lttng-tools.git] / tests / regression / tools / live / live_test.c
index 151e23fb6eb60089df712efcc51eacba017283af..40d0f6270b69a962e6a660841d439723997cfc18 100644 (file)
@@ -1,22 +1,10 @@
 /*
- * 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>
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -41,6 +29,7 @@
 #include <bin/lttng-relayd/lttng-viewer-abi.h>
 #include <common/index/ctf-index.h>
 
+#include <common/compat/errno.h>
 #include <common/compat/endian.h>
 
 #define SESSION1 "test1"
 #define NUM_TESTS 11
 #define mmap_size 524288
 
+#ifdef HAVE_LIBLTTNG_UST_CTL
+#include <lttng/lttng-export.h>
+#include <lttng/ust-sigbus.h>
+LTTNG_EXPORT DEFINE_LTTNG_UST_SIGBUS_STATE();
+#endif
+
 static int control_sock;
 struct live_session *session;
 
@@ -83,7 +78,7 @@ ssize_t lttng_live_recv(int fd, void *buf, size_t len)
        do {
                ret = recv(fd, buf + copied, to_copy, 0);
                if (ret > 0) {
-                       assert(ret <= to_copy);
+                       LTTNG_ASSERT(ret <= to_copy);
                        copied += ret;
                        to_copy -= ret;
                }
@@ -107,7 +102,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;
@@ -148,6 +143,7 @@ end:
        return ret;
 }
 
+static
 int establish_connection(void)
 {
        struct lttng_viewer_cmd cmd;
@@ -192,6 +188,7 @@ error:
 /*
  * Returns the number of sessions, should be 1 during the unit test.
  */
+static
 int list_sessions(uint64_t *session_id)
 {
        struct lttng_viewer_cmd cmd;
@@ -239,6 +236,7 @@ error:
        return -1;
 }
 
+static
 int create_viewer_session(void)
 {
        struct lttng_viewer_cmd cmd;
@@ -254,7 +252,7 @@ int create_viewer_session(void)
                diag("[error] Error sending cmd");
                goto error;
        }
-       assert(ret_len == sizeof(cmd));
+       LTTNG_ASSERT(ret_len == sizeof(cmd));
 
        ret_len = lttng_live_recv(control_sock, &resp, sizeof(resp));
        if (ret_len == 0) {
@@ -265,7 +263,7 @@ int create_viewer_session(void)
                diag("[error] Error receiving create session reply");
                goto error;
        }
-       assert(ret_len == sizeof(resp));
+       LTTNG_ASSERT(ret_len == sizeof(resp));
 
        if (be32toh(resp.status) != LTTNG_VIEWER_CREATE_SESSION_OK) {
                diag("[error] Error creating viewer session");
@@ -277,6 +275,7 @@ error:
        return -1;
 }
 
+static
 int attach_session(uint64_t id)
 {
        struct lttng_viewer_cmd cmd;
@@ -366,6 +365,7 @@ error:
        return -1;
 }
 
+static
 int get_metadata(void)
 {
        struct lttng_viewer_cmd cmd;
@@ -461,6 +461,7 @@ error:
        return -1;
 }
 
+static
 int get_next_index(void)
 {
        struct lttng_viewer_cmd cmd;
@@ -626,6 +627,7 @@ error:
        return -1;
 }
 
+static
 int detach_viewer_session(uint64_t id)
 {
        struct lttng_viewer_cmd cmd;
This page took 0.024757 seconds and 4 git commands to generate.