<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 26, 2015 at 5:57 PM, Julien Desfossez <span dir="ltr"><<a href="mailto:jdesfossez@efficios.com" target="_blank">jdesfossez@efficios.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Julien Desfossez <<a href="mailto:jdesfossez@efficios.com">jdesfossez@efficios.com</a>><br>
---<br>
tests/regression/tools/live/live_test.c | 64 ++++++++++++++++++++++++++++++++-<br>
1 file changed, 63 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/tests/regression/tools/live/live_test.c b/tests/regression/tools/live/live_test.c<br>
index e30c391..8d718f6 100644<br>
--- a/tests/regression/tools/live/live_test.c<br>
+++ b/tests/regression/tools/live/live_test.c<br>
@@ -50,7 +50,7 @@<br>
#define LIVE_TIMER 2000000<br>
<br>
/* Number of TAP tests in this file */<br>
-#define NUM_TESTS 8<br>
+#define NUM_TESTS 11<br>
#define mmap_size 524288<br>
<br>
int ust_consumerd32_fd;<br>
@@ -257,6 +257,59 @@ error:<br>
return ret;<br>
}<br>
<br>
+int detach_viewer_session(uint64_t id)<br>
+{<br>
+ struct lttng_viewer_cmd cmd;<br>
+ struct lttng_viewer_detach_session_response resp;<br>
+ struct lttng_viewer_detach_session_request rq;<br>
+ int ret;<br>
+ ssize_t ret_len;<br>
+<br>
+ cmd.cmd = htobe32(LTTNG_VIEWER_DETACH_SESSION);<br>
+ cmd.data_size = sizeof(rq);<br>
+ cmd.cmd_version = 0;<br>
+<br>
+ memset(&rq, 0, sizeof(rq));<br>
+ rq.session_id = htobe64(id);<br>
+<br>
+ do {<br>
+ ret_len = send(control_sock, &cmd, sizeof(cmd), 0);<br>
+ } while (ret_len < 0 && errno == EINTR);<br>
+ if (ret_len < 0) {<br>
+ fprintf(stderr, "[error] Error sending cmd\n");<br>
+ ret = ret_len;<br>
+ goto error;<br>
+ }<br>
+ assert(ret_len == sizeof(cmd));<br></blockquote><div><br></div><div>Please fail the test without asserting if this happens.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ do {<br>
+ ret = send(control_sock, &rq, sizeof(rq), 0);<br>
+ } while (ret < 0 && errno == EINTR);<br>
+ if (ret < 0) {<br>
+ fprintf(stderr, "Error sending attach request\n");<br>
+ goto error;<br>
+ }<br>
+<br>
+ do {<br>
+ ret_len = recv(control_sock, &resp, sizeof(resp), 0);<br>
+ } while (ret_len < 0 && errno == EINTR);<br>
+ if (ret_len < 0) {<br>
+ fprintf(stderr, "[error] Error receiving detach session reply\n");<br>
+ ret = ret_len;<br>
+ goto error;<br>
+ }<br>
+ assert(ret_len == sizeof(resp));<br>
</blockquote><div><br></div><div>Same here.</div><div> </div><div>Thanks!</div><div>Jérémie</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+<br>
+ if (be32toh(resp.status) != LTTNG_VIEWER_DETACH_SESSION_OK) {<br>
+ fprintf(stderr, "[error] Error detaching viewer session\n");<br>
+ ret = -1;<br>
+ goto error;<br>
+ }<br>
+ ret = 0;<br>
+<br>
+error:<br>
+ return ret;<br>
+}<br>
+<br>
int attach_session(int id)<br>
{<br>
struct lttng_viewer_cmd cmd;<br>
@@ -643,5 +696,14 @@ int main(int argc, char **argv)<br>
first_packet_stream_id, first_packet_offset,<br>
first_packet_len);<br>
<br>
+ ret = detach_viewer_session(session_id);<br>
+ ok(ret == 0, "Detach viewer session");<br>
+<br>
+ ret = list_sessions(&session_id);<br>
+ ok(ret > 0, "List sessions : %d session(s)", ret);<br>
+<br>
+ ret = attach_session(session_id);<br>
+ ok(ret > 0, "Attach to session, %d streams received", ret);<br>
+<br>
return exit_status();<br>
}<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.1<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Jérémie Galarneau<br>EfficiOS Inc.<br><a href="http://www.efficios.com" target="_blank">http://www.efficios.com</a></div>
</div></div>