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;
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 */
#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;
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;
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);