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
257 257
	return ret;
258 258
}
259 259

  
260
int detach_viewer_session(uint64_t id)
261
{
262
	struct lttng_viewer_cmd cmd;
263
	struct lttng_viewer_detach_session_response resp;
264
	struct lttng_viewer_detach_session_request rq;
265
	int ret;
266
	ssize_t ret_len;
267

  
268
	cmd.cmd = htobe32(LTTNG_VIEWER_DETACH_SESSION);
269
	cmd.data_size = sizeof(rq);
270
	cmd.cmd_version = 0;
271

  
272
	memset(&rq, 0, sizeof(rq));
273
	rq.session_id = htobe64(id);
274

  
275
	do {
276
		ret_len = send(control_sock, &cmd, sizeof(cmd), 0);
277
	} while (ret_len < 0 && errno == EINTR);
278
	if (ret_len < 0) {
279
		fprintf(stderr, "[error] Error sending cmd\n");
280
		ret = ret_len;
281
		goto error;
282
	}
283
	assert(ret_len == sizeof(cmd));
284
	do {
285
		ret = send(control_sock, &rq, sizeof(rq), 0);
286
	} while (ret < 0 && errno == EINTR);
287
	if (ret < 0) {
288
		fprintf(stderr, "Error sending attach request\n");
289
		goto error;
290
	}
291

  
292
	do {
293
		ret_len = recv(control_sock, &resp, sizeof(resp), 0);
294
	} while (ret_len < 0 && errno == EINTR);
295
	if (ret_len < 0) {
296
		fprintf(stderr, "[error] Error receiving detach session reply\n");
297
		ret = ret_len;
298
		goto error;
299
	}
300
	assert(ret_len == sizeof(resp));
301

  
302
	if (be32toh(resp.status) != LTTNG_VIEWER_DETACH_SESSION_OK) {
303
		fprintf(stderr, "[error] Error detaching viewer session\n");
304
		ret = -1;
305
		goto error;
306
	}
307
	ret = 0;
308

  
309
error:
310
	return ret;
311
}
312

  
260 313
int attach_session(int id)
261 314
{
262 315
	struct lttng_viewer_cmd cmd;
......
643 696
			first_packet_stream_id, first_packet_offset,
644 697
			first_packet_len);
645 698

  
699
	ret = detach_viewer_session(session_id);
700
	ok(ret == 0, "Detach viewer session");
701

  
702
	ret = list_sessions(&session_id);
703
	ok(ret > 0, "List sessions : %d session(s)", ret);
704

  
705
	ret = attach_session(session_id);
706
	ok(ret > 0, "Attach to session, %d streams received", ret);
707

  
646 708
	return exit_status();
647 709
}
648
- 
(3-3/3)