X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Flive%2Flive_test.c;h=b428f1add176567f5972126581b0dac3fb25c2df;hb=a0377dfefe40662ba7d68617bce6ff467114136c;hp=8a884ab6bf68d3b5d8cbc04cfcbfdcf609f70388;hpb=8674c9bffaabd99472c684286b8da9e0d01517f7;p=lttng-tools.git diff --git a/tests/regression/tools/live/live_test.c b/tests/regression/tools/live/live_test.c index 8a884ab6b..b428f1add 100644 --- a/tests/regression/tools/live/live_test.c +++ b/tests/regression/tools/live/live_test.c @@ -1,22 +1,10 @@ /* - * Copyright (c) - 2013 Julien Desfossez + * Copyright (C) 2013 Julien Desfossez * - * 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 -#include #include #include #include @@ -41,6 +29,7 @@ #include #include +#include #include #define SESSION1 "test1" @@ -51,8 +40,10 @@ #define NUM_TESTS 11 #define mmap_size 524288 -int ust_consumerd32_fd; -int ust_consumerd64_fd; +#ifdef HAVE_LIBLTTNG_UST_CTL +#include +DEFINE_LTTNG_UST_SIGBUS_STATE(); +#endif static int control_sock; struct live_session *session; @@ -86,7 +77,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; } @@ -110,7 +101,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,6 +142,7 @@ end: return ret; } +static int establish_connection(void) { struct lttng_viewer_cmd cmd; @@ -195,6 +187,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; @@ -242,6 +235,7 @@ error: return -1; } +static int create_viewer_session(void) { struct lttng_viewer_cmd cmd; @@ -257,7 +251,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) { @@ -268,7 +262,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"); @@ -280,6 +274,7 @@ error: return -1; } +static int attach_session(uint64_t id) { struct lttng_viewer_cmd cmd; @@ -369,6 +364,7 @@ error: return -1; } +static int get_metadata(void) { struct lttng_viewer_cmd cmd; @@ -399,6 +395,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 +420,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 +451,7 @@ int get_metadata(void) } free(data); ret = len; -end: + return ret; error_free_data: @@ -463,6 +460,7 @@ error: return -1; } +static int get_next_index(void) { struct lttng_viewer_cmd cmd; @@ -628,6 +626,7 @@ error: return -1; } +static int detach_viewer_session(uint64_t id) { struct lttng_viewer_cmd cmd;