Project

General

Profile

Feature #853 » 0002-test-live-detach.patch

Julien Desfossez, 11/18/2014 11:08 AM

View differences:

tests/regression/tools/live/live_test.c
return ret;
}
int detach_viewer_session(uint64_t id)
{
struct lttng_viewer_cmd cmd;
struct lttng_viewer_detach_session_response resp;
struct lttng_viewer_detach_session_request rq;
int ret;
ssize_t ret_len;
cmd.cmd = htobe32(LTTNG_VIEWER_DETACH_SESSION);
cmd.data_size = sizeof(rq);
cmd.cmd_version = 0;
memset(&rq, 0, sizeof(rq));
rq.session_id = htobe64(id);
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 = send(control_sock, &rq, sizeof(rq), 0);
} while (ret < 0 && errno == EINTR);
if (ret < 0) {
fprintf(stderr, "Error sending attach request\n");
goto error;
}
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 detach session reply\n");
ret = ret_len;
goto error;
}
assert(ret_len == sizeof(resp));
if (be32toh(resp.status) != LTTNG_VIEWER_DETACH_SESSION_OK) {
fprintf(stderr, "[error] Error detaching viewer session\n");
ret = -1;
goto error;
}
ret = 0;
error:
return ret;
}
int attach_session(int id)
{
struct lttng_viewer_cmd cmd;
......
first_packet_stream_id, first_packet_offset,
first_packet_len);
ret = detach_viewer_session(session_id);
ok(ret == 0, "Detach viewer session");
ret = list_sessions(&session_id);
ok(ret > 0, "List sessions : %d session(s)", ret);
ret = attach_session(session_id);
ok(ret > 0, "Attach to session, %d streams received", ret);
return exit_status();
}
(3-3/3)