Test: clear: local, streaming, live, tracefile rotation
[lttng-tools.git] / tests / regression / tools / clear / relayd_state_testpoint.c
CommitLineData
d8b7ee90
JR
1/*
2 * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18#include <common/compat/getenv.h>
19#include <common/consumer/consumer.h>
20#include <common/error.h>
21#include <unistd.h>
22#include <stdbool.h>
23#include <lttng/constant.h>
24#include <fcntl.h>
25#include <dlfcn.h>
26#include <assert.h>
27#include <stdio.h>
28
29#include <bin/lttng-relayd/connection.h>
30
31int lttng_opt_verbose;
32int lttng_opt_mi;
33int lttng_opt_quiet;
34
35int __testpoint_relayd_viewer_session_attach(void)
36{
37 int ret = 0;
38 const char *state_file_path;
39 int state_fd = -1;
40
41 state_file_path = lttng_secure_getenv(
42 "RELAYD_STATE_PATH");
43 if (!state_file_path) {
44 ERR("RELAYD_STATE_PATH getenv");
45 ret = -1;
46 goto end;
47 }
48
49 state_fd = open(state_file_path, O_WRONLY | O_APPEND | O_SYNC);
50 if (state_fd == -1) {
51 ERR("RELAYD_STATE_PATH open");
52 ret = -1;
53 goto end;
54 }
55
56 dprintf(state_fd, "Viewer attached\n");
57end:
58 if(state_fd > -1) {
59 (void) close(state_fd);
60 }
61 return ret;
62}
This page took 0.02687 seconds and 5 git commands to generate.