Fix: update file listing for licensing
[lttng-tools.git] / tests / ust / ust_global_event_wildcard.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;
a62e3ec7 38 struct lttng_event event, ev2;
441c16a7 39 char *channel_name = "channel0";
a62e3ec7 40 char *channel_name2 = "channel2";
d3e8f6bb 41 char *session_name = "ust_global_all_events_basic";
441c16a7 42 int ret = 0;
69c0b621 43
441c16a7
MD
44 memset(&dom, 0, sizeof(dom));
45 memset(&event, 0, sizeof(event));
a62e3ec7
DG
46 memset(&ev2, 0, sizeof(ev2));
47
441c16a7 48 dom.type = LTTNG_DOMAIN_UST;
a62e3ec7 49
69c0b621 50 event.type = LTTNG_EVENT_TRACEPOINT;
8005f29a 51 event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
a62e3ec7
DG
52 strcpy(event.name, "*");
53
54 ev2.type = LTTNG_EVENT_TRACEPOINT;
55 ev2.loglevel_type = LTTNG_EVENT_LOGLEVEL_RANGE;
56 ev2.loglevel = LTTNG_LOGLEVEL_NOTICE;
57 strcpy(ev2.name, "abc*");
69c0b621
DG
58
59 printf("\nTesting tracing all UST events:\n");
60 printf("-----------\n");
61
62 if (argc < 2) {
63 printf("Missing session trace path\n");
64 return 1;
65 }
66
67 printf("Creating tracing session (%s): ", argv[1]);
f973f94b
MD
68 if ((ret = lttng_create_session(session_name, argv[1])) < 0) {
69 printf("error creating the session : %s\n", lttng_strerror(ret));
69c0b621 70 goto create_fail;
f973f94b 71 }
69c0b621
DG
72 PRINT_OK();
73
74 printf("Creating session handle: ");
d3e8f6bb 75 if ((handle = lttng_create_handle(session_name, &dom)) == NULL) {
69c0b621
DG
76 printf("error creating handle: %s\n", lttng_strerror(ret));
77 goto handle_fail;
78 }
79 PRINT_OK();
80
a62e3ec7 81 printf("Enabling '*' UST events: ");
f973f94b
MD
82 if ((ret = lttng_enable_event(handle, &event, channel_name)) < 0) {
83 printf("error enabling event: %s\n", lttng_strerror(ret));
69c0b621 84 goto enable_fail;
f973f94b 85 }
69c0b621
DG
86 PRINT_OK();
87
a62e3ec7
DG
88 printf("Enabling 'abc*' UST events: ");
89 if ((ret = lttng_enable_event(handle, &ev2, channel_name2)) < 0) {
90 printf("error enabling event: %s\n", lttng_strerror(ret));
91 goto enable_fail;
92 }
93 PRINT_OK();
94
69c0b621 95 printf("Start tracing: ");
f973f94b
MD
96 if ((ret = lttng_start_tracing(session_name)) < 0) {
97 printf("error starting tracing: %s\n", lttng_strerror(ret));
69c0b621 98 goto start_fail;
f973f94b 99 }
69c0b621
DG
100 PRINT_OK();
101
f973f94b 102 sleep(2);
69c0b621
DG
103
104 printf("Stop tracing: ");
d3e8f6bb 105 if ((ret = lttng_stop_tracing(session_name)) < 0) {
69c0b621
DG
106 printf("error stopping tracing: %s\n", lttng_strerror(ret));
107 goto stop_fail;
108 }
109 PRINT_OK();
110
111 printf("Destroy tracing session: ");
d3e8f6bb 112 if ((ret = lttng_destroy_session(session_name)) < 0) {
69c0b621
DG
113 printf("error destroying session: %s\n", lttng_strerror(ret));
114 }
115 PRINT_OK();
116
117 return 0;
118
69c0b621
DG
119handle_fail:
120 assert(handle != NULL);
bff9a49f
MD
121create_fail:
122 assert(ret != 0);
69c0b621
DG
123
124stop_fail:
125start_fail:
126enable_fail:
d3e8f6bb 127 lttng_destroy_session(session_name);
69c0b621
DG
128 lttng_destroy_handle(handle);
129
f973f94b 130 return 1;
69c0b621 131}
This page took 0.044305 seconds and 4 git commands to generate.