From: Julien Desfossez Date: Wed, 5 Feb 2014 19:55:11 +0000 (-0500) Subject: Fix: add flag to create session command and fix tests X-Git-Tag: v2.5.0-rc1~204 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=25b50f8fb2a2e9bdd1866dd22c1b2d72929d293f;p=lttng-tools.git Fix: add flag to create session command and fix tests Signed-off-by: Julien Desfossez --- diff --git a/src/bin/lttng-relayd/lttng-viewer-abi.h b/src/bin/lttng-relayd/lttng-viewer-abi.h index f9bce98d0..77b3a5e01 100644 --- a/src/bin/lttng-relayd/lttng-viewer-abi.h +++ b/src/bin/lttng-relayd/lttng-viewer-abi.h @@ -105,6 +105,13 @@ enum lttng_viewer_create_session_return_code { LTTNG_VIEWER_CREATE_SESSION_ERR = 2, }; +/* Flags set when creating a viewer session. */ +enum { + /* New metadata is required to read this packet. */ + LTTNG_VIEWER_OPTION_NOTIFY_NEW_SESSIONS = (1 << 0), +}; + + struct lttng_viewer_session { uint64_t id; uint32_t live_timer; @@ -230,6 +237,7 @@ struct lttng_viewer_new_streams_response { struct lttng_viewer_create_session_response { /* enum lttng_viewer_create_session_return_code */ uint32_t status; + uint32_t options; /* LTTNG_VIEWER_OPTION_* */ } __attribute__((__packed__)); #endif /* LTTNG_VIEWER_ABI_H */ diff --git a/tests/regression/tools/live/live_test.c b/tests/regression/tools/live/live_test.c index 864f6702b..aff897724 100644 --- a/tests/regression/tools/live/live_test.c +++ b/tests/regression/tools/live/live_test.c @@ -48,7 +48,7 @@ #define LIVE_TIMER 2000000 /* Number of TAP tests in this file */ -#define NUM_TESTS 7 +#define NUM_TESTS 8 #define mmap_size 524288 int ust_consumerd32_fd; @@ -213,6 +213,48 @@ error: return ret; } +int create_viewer_session() +{ + struct lttng_viewer_cmd cmd; + struct lttng_viewer_create_session_response resp; + int ret; + ssize_t ret_len; + + cmd.cmd = htobe32(LTTNG_VIEWER_CREATE_SESSION); + cmd.data_size = 0; + cmd.cmd_version = 0; + + do { + ret_len = send(control_sock, &cmd, sizeof(cmd), 0); + } while (ret_len < 0 && errno == EINTR); + if (ret_len < 0) { + fprintf(stderr, "[error] Error sending cmd\n"); + ret = ret_len; + goto error; + } + assert(ret_len == sizeof(cmd)); + + do { + ret_len = recv(control_sock, &resp, sizeof(resp), 0); + } while (ret_len < 0 && errno == EINTR); + if (ret_len < 0) { + fprintf(stderr, "[error] Error receiving create session reply\n"); + ret = ret_len; + goto error; + } + assert(ret_len == sizeof(resp)); + + if (be32toh(resp.status) != LTTNG_VIEWER_CREATE_SESSION_OK) { + fprintf(stderr, "[error] Error creating viewer session\n"); + ret = -1; + goto error; + } + ret = 0; + +error: + return ret; +} + int attach_session(int id) { struct lttng_viewer_cmd cmd; @@ -580,6 +622,9 @@ int main(int argc, char **argv) ret = list_sessions(&session_id); ok(ret > 0, "List sessions : %d session(s)", ret); + ret = create_viewer_session(); + ok(ret == 0, "Create viewer session"); + ret = attach_session(session_id); ok(ret > 0, "Attach to session, %d streams received", ret);