Fix tests when lttng-ust is disabled
[lttng-tools.git] / tests / ust / ust_global_all_events_basic.c
CommitLineData
69c0b621
DG
1/*
2 * Copyright (c) 2011 David Goulet <david.goulet@polymtl.ca>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * as published by the Free Software Foundation; only version 2
7 * of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#define _GNU_SOURCE
20#include <assert.h>
21#include <errno.h>
22#include <stdio.h>
23#include <stdlib.h>
24#include <string.h>
25#include <unistd.h>
26#include <time.h>
27
28#include <lttng/lttng.h>
29
355f483d 30#include "utils.h"
69c0b621 31
97e19046 32int lttng_opt_quiet;
d2641a83 33
69c0b621
DG
34int main(int argc, char **argv)
35{
441c16a7
MD
36 struct lttng_handle *handle = NULL;
37 struct lttng_domain dom;
69c0b621 38 struct lttng_event event;
441c16a7 39 char *channel_name = "channel0";
d3e8f6bb 40 char *session_name = "ust_global_all_events_basic";
441c16a7 41 int ret = 0;
69c0b621 42
441c16a7
MD
43 memset(&dom, 0, sizeof(dom));
44 memset(&event, 0, sizeof(event));
45 dom.type = LTTNG_DOMAIN_UST;
69c0b621 46 event.type = LTTNG_EVENT_TRACEPOINT;
8005f29a 47 event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
69c0b621
DG
48
49 printf("\nTesting tracing all UST events:\n");
50 printf("-----------\n");
51
52 if (argc < 2) {
53 printf("Missing session trace path\n");
54 return 1;
55 }
56
57 printf("Creating tracing session (%s): ", argv[1]);
f973f94b
MD
58 if ((ret = lttng_create_session(session_name, argv[1])) < 0) {
59 printf("error creating the session : %s\n", lttng_strerror(ret));
69c0b621 60 goto create_fail;
f973f94b 61 }
69c0b621
DG
62 PRINT_OK();
63
64 printf("Creating session handle: ");
d3e8f6bb 65 if ((handle = lttng_create_handle(session_name, &dom)) == NULL) {
69c0b621
DG
66 printf("error creating handle: %s\n", lttng_strerror(ret));
67 goto handle_fail;
68 }
69 PRINT_OK();
70
71 printf("Enabling all UST events: ");
f973f94b
MD
72 if ((ret = lttng_enable_event(handle, &event, channel_name)) < 0) {
73 printf("error enabling event: %s\n", lttng_strerror(ret));
69c0b621 74 goto enable_fail;
f973f94b 75 }
69c0b621
DG
76 PRINT_OK();
77
78 printf("Start tracing: ");
f973f94b
MD
79 if ((ret = lttng_start_tracing(session_name)) < 0) {
80 printf("error starting tracing: %s\n", lttng_strerror(ret));
69c0b621 81 goto start_fail;
f973f94b 82 }
69c0b621
DG
83 PRINT_OK();
84
f973f94b 85 sleep(2);
69c0b621
DG
86
87 printf("Stop tracing: ");
d3e8f6bb 88 if ((ret = lttng_stop_tracing(session_name)) < 0) {
69c0b621
DG
89 printf("error stopping tracing: %s\n", lttng_strerror(ret));
90 goto stop_fail;
91 }
92 PRINT_OK();
93
94 printf("Destroy tracing session: ");
d3e8f6bb 95 if ((ret = lttng_destroy_session(session_name)) < 0) {
69c0b621
DG
96 printf("error destroying session: %s\n", lttng_strerror(ret));
97 }
98 PRINT_OK();
99
100 return 0;
101
102create_fail:
103 assert(ret != 0);
104handle_fail:
105 assert(handle != NULL);
106
107stop_fail:
108start_fail:
109enable_fail:
d3e8f6bb 110 lttng_destroy_session(session_name);
69c0b621
DG
111 lttng_destroy_handle(handle);
112
f973f94b 113 return 1;
69c0b621 114}
This page took 0.028757 seconds and 4 git commands to generate.