Merge branch 'master' into benchmark
authorDavid Goulet <dgoulet@efficios.com>
Tue, 10 Apr 2012 21:50:16 +0000 (17:50 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 10 Apr 2012 21:50:16 +0000 (17:50 -0400)
19 files changed:
.gitignore
src/bin/lttng-sessiond/event.c
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/trace-ust.c
src/bin/lttng/commands/create.c
src/bin/lttng/utils.c
src/bin/lttng/utils.h
src/common/sessiond-comm/sessiond-comm.c
src/common/sessiond-comm/sessiond-comm.h
tests/kernel/kernel_all_events_basic.c
tests/kernel/kernel_event_basic.c
tests/kernel/run-kernel-tests.sh
tests/ust/Makefile.am
tests/ust/high-throughput/run
tests/ust/run-ust-global-tests.sh
tests/ust/ust_global_all_events_basic.c [deleted file]
tests/ust/ust_global_event_basic.c
tests/ust/ust_global_event_wildcard.c [new file with mode: 0644]
tests/utils.sh

index 969e75ba5797c88b6da2cb1141c96d687b395fbe..bbb67422382bd92f1d9c8bb0fc473f64551519ba 100644 (file)
@@ -41,7 +41,7 @@ test_kernel_data_trace
 test_ust_data_trace
 kernel_all_events_basic
 kernel_event_basic
-ust_global_all_events_basic
+ust_global_event_wildcard
 ust_global_event_basic
 gen-nevents
 gen-events-time
index ac4b0b4a365f7f493973f7389cd58f241c8292ae..5a6825e6ef8a7412ec679bbb9f0c67cb95b12e7b 100644 (file)
@@ -134,10 +134,16 @@ int event_kernel_enable_tracepoint(struct ltt_kernel_session *ksession,
        if (kevent == NULL) {
                ret = kernel_create_event(event, kchan);
                if (ret < 0) {
-                       if (ret == -EEXIST) {
+                       switch (-ret) {
+                       case EEXIST:
                                ret = LTTCOMM_KERN_EVENT_EXIST;
-                       } else {
+                               break;
+                       case ENOSYS:
+                               ret = LTTCOMM_KERN_EVENT_ENOSYS;
+                               break;
+                       default:
                                ret = LTTCOMM_KERN_ENABLE_FAIL;
+                               break;
                        }
                        goto end;
                }
@@ -239,15 +245,26 @@ end:
 int event_kernel_enable_all(struct ltt_kernel_session *ksession,
                struct ltt_kernel_channel *kchan, int kernel_tracer_fd)
 {
-       int ret;
+       int tp_ret;
 
-       ret = event_kernel_enable_all_tracepoints(ksession, kchan, kernel_tracer_fd);
-       if (ret != LTTCOMM_OK) {
+       tp_ret = event_kernel_enable_all_tracepoints(ksession, kchan, kernel_tracer_fd);
+       if (tp_ret != LTTCOMM_OK) {
                goto end;
        }
-       ret = event_kernel_enable_all_syscalls(ksession, kchan, kernel_tracer_fd);
+
+       /*
+        * Reaching this code path means that all tracepoints were enabled without
+        * errors so we ignore the error value of syscalls.
+        *
+        * At the moment, failing to enable syscalls on "lttng enable-event -a -k"
+        * is not considered an error that need to be returned to the client since
+        * tracepoints did not fail. Future work will allow us to send back
+        * multiple errors to the client in one API call.
+        */
+       (void) event_kernel_enable_all_syscalls(ksession, kchan, kernel_tracer_fd);
+
 end:
-       return ret;
+       return tp_ret;
 }
 
 /*
index 596af588c5800c4bd6754bd9ec00de93b3381649..39006ab2f37b508107fb468a427debb7d82bb566 100644 (file)
@@ -196,7 +196,13 @@ int kernel_create_event(struct lttng_event *ev,
 
        ret = kernctl_create_event(channel->fd, event->event);
        if (ret < 0) {
-               if (errno != EEXIST) {
+               switch (errno) {
+               case EEXIST:
+                       break;
+               case ENOSYS:
+                       WARN("Event type not implemented");
+                       break;
+               default:
                        PERROR("create event ioctl");
                }
                ret = -errno;
index c8b3b72f91ca3343a9a507dd343d5447ea6eb323..1d48002d07297dad4ff88f8903c3d9ab422416b6 100644 (file)
@@ -250,6 +250,10 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev)
        lttng_ht_node_init_str(&lue->node, lue->attr.name);
        /* Alloc context hash tables */
        lue->ctx = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
+       if (lue->ctx == NULL) {
+               ERR("Unable to create context hash table for event %s", ev->name);
+               goto error_free_event;
+       }
 
        DBG2("Trace UST event %s, loglevel (%d,%d) created",
                lue->attr.name, lue->attr.loglevel_type,
@@ -258,7 +262,6 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev)
        return lue;
 
 error_free_event:
-       lttng_ht_destroy(lue->ctx);
        free(lue);
 error:
        return NULL;
index b1f3e8a777a0420ca4f5de66c7c9032118780015..2778ef553cdd2a24c27567f780be0b1c950678c6 100644 (file)
@@ -115,7 +115,11 @@ static int create_session()
                        goto error;
                }
        } else {
-               traces_path = opt_output_path;
+               traces_path = expand_full_path(opt_output_path);
+               if (traces_path == NULL) {
+                       ret = CMD_ERROR;
+                       goto error;
+               }
        }
 
        ret = lttng_create_session(session_name, traces_path);
index b982bd5936149ab7667e64176a9f0c499dfd0207..8ae984836595d1271b0a38a8809e2e5f5e0d88b9 100644 (file)
 #define _GNU_SOURCE
 #include <stdlib.h>
 #include <ctype.h>
+#include <limits.h>
 
 #include <common/error.h>
 
 #include "conf.h"
 #include "utils.h"
 
+/*
+ * Return the realpath(3) of the path even if the last directory token does not
+ * exist. For example, with /tmp/test1/test2, if test2/ does not exist but the
+ * /tmp/test1 does, the real path is returned. In normal time, realpath(3)
+ * fails if the end point directory does not exist.
+ */
+char *expand_full_path(const char *path)
+{
+       const char *end_path = path;
+       char *next, *cut_path, *expanded_path;
+
+       /* Find last token delimited by '/' */
+       while ((next = strpbrk(end_path + 1, "/"))) {
+               end_path = next;
+       }
+
+       /* Cut last token from original path */
+       cut_path = strndup(path, end_path - path);
+
+       expanded_path = malloc(PATH_MAX);
+       if (expanded_path == NULL) {
+               goto error;
+       }
+
+       expanded_path = realpath((char *)cut_path, expanded_path);
+       if (expanded_path == NULL) {
+               switch (errno) {
+               case ENOENT:
+                       ERR("%s: No such file or directory", cut_path);
+                       break;
+               default:
+                       perror("realpath");
+                       break;
+               }
+               goto error;
+       }
+
+       /* Add end part to expanded path */
+       strcat(expanded_path, end_path);
+
+       free(cut_path);
+       return expanded_path;
+
+error:
+       free(cut_path);
+       return NULL;
+}
+
 /*
  *  get_session_name
  *
index 9c51b67e341a73b461e698e9ca52d57677a35270..a430b8bdf3e9577ebf5bbcb1e176f519cc9c50fc 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <popt.h>
 
+char *expand_full_path(const char *path);
 char *get_config_file_path(void);
 char *get_session_name(void);
 int set_session_name(char *name);
index f396c42f3c4417499a4534af41523a56fd2a1d33..11319f333e84f34d30a75132d981444d136f7e24 100644 (file)
@@ -105,6 +105,7 @@ static const char *lttcomm_readable_code[] = {
        [ LTTCOMM_ERR_INDEX(LTTCOMM_NEED_ROOT_SESSIOND) ] = "Tracing the kernel requires a root lttng-sessiond daemon and \"tracing\" group user membership",
        [ LTTCOMM_ERR_INDEX(LTTCOMM_TRACE_ALREADY_STARTED) ] = "Tracing already started",
        [ LTTCOMM_ERR_INDEX(LTTCOMM_TRACE_ALREADY_STOPPED) ] = "Tracing already stopped",
+       [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_EVENT_ENOSYS) ] = "Kernel event type not supported",
 
        [ LTTCOMM_ERR_INDEX(CONSUMERD_COMMAND_SOCK_READY) ] = "consumerd command socket ready",
        [ LTTCOMM_ERR_INDEX(CONSUMERD_SUCCESS_RECV_FD) ] = "consumerd success on receiving fds",
index dbb744c0c1bfce51be428184e38176b1251dee01..6cc98d542e9a0b54797fb143cc588dbb49133348 100644 (file)
@@ -140,6 +140,7 @@ enum lttcomm_return_code {
        LTTCOMM_NEED_ROOT_SESSIOND,             /* root sessiond is needed */
        LTTCOMM_TRACE_ALREADY_STARTED,  /* Tracing already started */
        LTTCOMM_TRACE_ALREADY_STOPPED,  /* Tracing already stopped */
+       LTTCOMM_KERN_EVENT_ENOSYS,      /* Kernel event type not supported */
 
        CONSUMERD_COMMAND_SOCK_READY,           /* when consumerd command socket ready */
        CONSUMERD_SUCCESS_RECV_FD,              /* success on receiving fds */
index 2e56e6a671464f3133a77310a00e02c6c8d0cc89..b80dbd32269e500d35b8a13b47dd4c3983d96a48 100644 (file)
@@ -104,10 +104,10 @@ int main(int argc, char **argv)
 
        return 0;
 
-create_fail:
-       assert(ret != 0);
 handle_fail:
        assert(handle != NULL);
+create_fail:
+       assert(ret != 0);
 
 stop_fail:
 start_fail:
index a7d7dfae8df6c4ba8d9f0168dda6825bc23acbc3..b0cbf669fa788be9d1e4d0f1667ef174a3478106 100644 (file)
@@ -176,10 +176,10 @@ int main(int argc, char **argv)
 
        return 0;
 
-create_fail:
-       assert(ret != 0);
 handle_fail:
        assert(handle != NULL);
+create_fail:
+       assert(ret != 0);
 
 stop_fail:
 start_fail:
index 2881c426e38dae64500bf92b9f542154317e691f..f77c43758091d7cf683f08f0250febc8d0def7f0 100755 (executable)
@@ -1,18 +1,24 @@
 #!/bin/bash
 
 SESSIOND_BIN="lttng-sessiond"
-TESTDIR=$(dirname $0)/..
+CURDIR=$(dirname $0)
+TESTDIR=$CURDIR/..
 
 source $TESTDIR/utils.sh
 
 tmpdir=`mktemp -d`
-tests=( kernel_event_basic kernel_all_events_basic )
+tests=( $CURDIR/kernel_event_basic $CURDIR/kernel_all_events_basic )
 exit_code=0
 
 function start_tests ()
 {
     for bin in ${tests[@]};
     do
+               if [ ! -e $bin ]; then
+                       echo -e "$bin not found, passing"
+                       continue
+               fi
+
                start_sessiond
 
         ./$bin $tmpdir
index 9eda72c5d447370a21ff34a18725a171b3bdd2f8..7c7bcba41a813c99189e8336e924830248f05fbe 100644 (file)
@@ -6,13 +6,13 @@ AM_LDFLAGS = -lurcu -lurcu-cds
 
 EXTRA_DIST = runall.sh utils.sh run-ust-global-tests.sh
 
-noinst_PROGRAMS = ust_global_event_basic ust_global_all_events_basic
+noinst_PROGRAMS = ust_global_event_basic ust_global_event_wildcard
 
 UTILS=utils.h
 LIBLTTNG=$(top_srcdir)/src/lib/lttng-ctl/lttng-ctl.c \
                 $(top_srcdir)/src/common/sessiond-comm/sessiond-comm.c
 
-ust_global_all_events_basic_SOURCES = ust_global_all_events_basic.c $(UTILS) $(LIBLTTNG)
+ust_global_event_wildcard_SOURCES = ust_global_event_wildcard.c $(UTILS) $(LIBLTTNG)
 
 ust_global_event_basic_SOURCES = ust_global_event_basic.c $(UTILS) $(LIBLTTNG)
 endif
index a97d2756664550795e38a25c6f87210a0725d5ae..05f8e85eab4c9f1be5effb6d8ab408b2f68ae2c8 100755 (executable)
@@ -48,8 +48,9 @@ for i in `seq 1 $NR_ITER`; do
        ./$CURDIR/$BIN_NAME & >/dev/null 2>&1
 done
 
-echo "Waiting for all tracing to settle"
-sleep 5
+echo "Waiting for all tracing to settle (7 secs)"
+echo "Warning: this arbitrary time can make the test fail on slower system"
+sleep 7
 
 stop_tracing $SESSION_NAME
 destroy_lttng_session $SESSION_NAME
index 96c1f9e54d759e071e1a43e59d9dcd19c394916f..969e217332fe2eafd2b27e51ea754870dafe8c2c 100755 (executable)
@@ -7,7 +7,7 @@ TESTDIR=$CURDIR/..
 source $TESTDIR/utils.sh
 
 tmpdir=`mktemp -d`
-tests=( $CURDIR/ust_global_event_basic $CURDIR/ust_global_all_events_basic )
+tests=( $CURDIR/ust_global_event_basic $CURDIR/ust_global_event_wildcard )
 exit_code=0
 
 function start_tests ()
diff --git a/tests/ust/ust_global_all_events_basic.c b/tests/ust/ust_global_all_events_basic.c
deleted file mode 100644 (file)
index 3ae786e..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * as published by the Free Software Foundation; only version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#define _GNU_SOURCE
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
-
-#include <lttng/lttng.h>
-
-#include "utils.h"
-
-int lttng_opt_quiet;
-
-int main(int argc, char **argv)
-{
-       struct lttng_handle *handle = NULL;
-       struct lttng_domain dom;
-       struct lttng_event event;
-       char *channel_name = "channel0";
-       char *session_name = "ust_global_all_events_basic";
-       int ret = 0;
-
-       memset(&dom, 0, sizeof(dom));
-       memset(&event, 0, sizeof(event));
-       dom.type = LTTNG_DOMAIN_UST;
-       event.type = LTTNG_EVENT_TRACEPOINT;
-       event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
-       printf("\nTesting tracing all UST events:\n");
-       printf("-----------\n");
-
-       if (argc < 2) {
-               printf("Missing session trace path\n");
-               return 1;
-       }
-
-       printf("Creating tracing session (%s): ", argv[1]);
-       if ((ret = lttng_create_session(session_name, argv[1])) < 0) {
-               printf("error creating the session : %s\n", lttng_strerror(ret));
-               goto create_fail;
-       }
-       PRINT_OK();
-
-       printf("Creating session handle: ");
-       if ((handle = lttng_create_handle(session_name, &dom)) == NULL) {
-               printf("error creating handle: %s\n", lttng_strerror(ret));
-               goto handle_fail;
-       }
-       PRINT_OK();
-
-       printf("Enabling all UST events: ");
-       if ((ret = lttng_enable_event(handle, &event, channel_name)) < 0) {
-               printf("error enabling event: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Start tracing: ");
-       if ((ret = lttng_start_tracing(session_name)) < 0) {
-               printf("error starting tracing: %s\n", lttng_strerror(ret));
-               goto start_fail;
-       }
-       PRINT_OK();
-
-       sleep(2);
-
-       printf("Stop tracing: ");
-       if ((ret = lttng_stop_tracing(session_name)) < 0) {
-               printf("error stopping tracing: %s\n", lttng_strerror(ret));
-               goto stop_fail;
-       }
-       PRINT_OK();
-
-       printf("Destroy tracing session: ");
-       if ((ret = lttng_destroy_session(session_name)) < 0) {
-               printf("error destroying session: %s\n", lttng_strerror(ret));
-       }
-       PRINT_OK();
-
-       return 0;
-
-create_fail:
-       assert(ret != 0);
-handle_fail:
-       assert(handle != NULL);
-
-stop_fail:
-start_fail:
-enable_fail:
-       lttng_destroy_session(session_name);
-       lttng_destroy_handle(handle);
-
-       return 1;
-}
index 24dcec53d9d473f9b34f6491dc39fc521aeccabf..ad14afbb358a42f50dd911b44c9a04ce4b94e5f4 100644 (file)
@@ -35,18 +35,24 @@ int main(int argc, char **argv)
 {
        struct lttng_handle *handle = NULL;
        struct lttng_domain dom;
-       struct lttng_channel channel;
+       struct lttng_channel channel, channel2;
        struct lttng_event ev1, ev2, ev3;
+       struct lttng_event_context context;
        char *session_name = "ust_global_event_basic";
+       char *session_name2 = "ust_global_event_basic2";
        int ret = 0;
 
        memset(&dom, 0, sizeof(dom));
        memset(&channel, 0, sizeof(channel));
+       memset(&channel2, 0, sizeof(channel2));
        memset(&ev1, 0, sizeof(ev1));
        memset(&ev2, 0, sizeof(ev2));
        memset(&ev3, 0, sizeof(ev3));
+       memset(&context, 0, sizeof(context));
 
        dom.type = LTTNG_DOMAIN_UST;
+
+       /* Setup channel 1 */
        strcpy(channel.name, "mychan");
        channel.attr.overwrite = 0;
        channel.attr.subbuf_size = 4096;
@@ -55,6 +61,15 @@ int main(int argc, char **argv)
        channel.attr.read_timer_interval = 200;
        channel.attr.output = LTTNG_EVENT_MMAP;
 
+       /* Setup channel 2 */
+       strcpy(channel2.name, "mychan2");
+       channel2.attr.overwrite = 0;
+       channel2.attr.subbuf_size = 8192;
+       channel2.attr.num_subbuf = 8;
+       channel2.attr.switch_timer_interval = 0;
+       channel2.attr.read_timer_interval = 500;
+       channel2.attr.output = LTTNG_EVENT_MMAP;
+
        strcpy(ev1.name, "tp1");
        ev1.type = LTTNG_EVENT_TRACEPOINT;
        ev1.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
@@ -82,6 +97,13 @@ int main(int argc, char **argv)
        }
        PRINT_OK();
 
+       printf("Creating tracing session 2 (%s): ", argv[1]);
+       if ((ret = lttng_create_session(session_name2, argv[1])) < 0) {
+               printf("error creating the session : %s\n", lttng_strerror(ret));
+               goto create_fail;
+       }
+       PRINT_OK();
+
        printf("Creating session handle: ");
        if ((handle = lttng_create_handle(session_name, &dom)) == NULL) {
                printf("error creating handle: %s\n", lttng_strerror(ret));
@@ -96,27 +118,89 @@ int main(int argc, char **argv)
        }
        PRINT_OK();
 
-       printf("Enabling %s UST event: ", ev1.name);
+       printf("Enabling %s UST channel2: ", channel2.name);
+       if ((ret = lttng_enable_channel(handle, &channel2)) < 0) {
+               printf("error enable channel: %s\n", lttng_strerror(ret));
+               goto enable_fail;
+       }
+       PRINT_OK();
+
+       printf("Enabling %s UST event in channel %s: ", ev1.name, channel.name);
        if ((ret = lttng_enable_event(handle, &ev1, channel.name)) < 0) {
                printf("error enabling event: %s\n", lttng_strerror(ret));
                goto enable_fail;
        }
        PRINT_OK();
 
-       printf("Enabling %s UST event: ", ev2.name);
+       printf("Enabling %s UST event in channel %s: ", ev2.name, channel.name);
        if ((ret = lttng_enable_event(handle, &ev2, channel.name)) < 0) {
                printf("error enabling event: %s\n", lttng_strerror(ret));
                goto enable_fail;
        }
        PRINT_OK();
 
-       printf("Enabling %s UST event: ", ev3.name);
-       if ((ret = lttng_enable_event(handle, &ev3, channel.name)) < 0) {
+       printf("Enabling %s UST event in channel %s: ", ev3.name, channel2.name);
+       if ((ret = lttng_enable_event(handle, &ev3, channel2.name)) < 0) {
                printf("error enabling event: %s\n", lttng_strerror(ret));
                goto enable_fail;
        }
        PRINT_OK();
 
+       context.ctx = LTTNG_EVENT_CONTEXT_VPID;
+
+       printf("Adding context VPID to UST event %s in channel %s: ", ev1.name,
+                       channel.name);
+       if ((ret = lttng_add_context(handle, &context, ev1.name,
+                                       channel.name)) < 0) {
+               printf("error adding context VPID: %s\n", lttng_strerror(ret));
+               goto context_fail;
+       }
+       PRINT_OK();
+
+       context.ctx = LTTNG_EVENT_CONTEXT_VTID;
+
+       printf("Adding context VTID to UST event %s in channel %s: ", ev1.name,
+                       channel.name);
+       if ((ret = lttng_add_context(handle, &context, ev1.name,
+                                       channel.name)) < 0) {
+               printf("error adding context VTID: %s\n", lttng_strerror(ret));
+               goto context_fail;
+       }
+       PRINT_OK();
+
+       context.ctx = LTTNG_EVENT_CONTEXT_PTHREAD_ID;
+
+       printf("Adding context PTHREAD_ID to UST event %s in channel %s: ",
+                       ev1.name, channel.name);
+       if ((ret = lttng_add_context(handle, &context, ev1.name,
+                                       channel.name)) < 0) {
+               printf("error adding context PTHREAD_ID: %s\n", lttng_strerror(ret));
+               goto context_fail;
+       }
+       PRINT_OK();
+
+       context.ctx = LTTNG_EVENT_CONTEXT_PROCNAME;
+
+       printf("Adding context PROCNAME to UST event %s in channel %s: ",
+                       ev1.name, channel.name);
+       if ((ret = lttng_add_context(handle, &context, ev1.name,
+                                       channel.name)) < 0) {
+               printf("error adding context PROCNAME: %s\n", lttng_strerror(ret));
+               goto context_fail;
+       }
+       PRINT_OK();
+
+       context.ctx = LTTNG_EVENT_CONTEXT_PROCNAME;
+
+       printf("Adding context PROCNAME to UST event %s in channel %s: ",
+                       ev3.name, channel2.name);
+       if ((ret = lttng_add_context(handle, &context, ev3.name,
+                                       channel2.name)) < 0) {
+               printf("error adding context PROCNAME: %s\n", lttng_strerror(ret));
+               goto context_fail;
+       }
+       PRINT_OK();
+
        printf("Disabling %s UST event: ", ev1.name);
        if ((ret = lttng_disable_event(handle, ev1.name, channel.name)) < 0) {
                printf("error enabling event: %s\n", lttng_strerror(ret));
@@ -125,7 +209,7 @@ int main(int argc, char **argv)
        PRINT_OK();
 
        printf("Disabling %s UST event: ", ev3.name);
-       if ((ret = lttng_disable_event(handle, ev3.name, channel.name)) < 0) {
+       if ((ret = lttng_disable_event(handle, ev3.name, channel2.name)) < 0) {
                printf("error enabling event: %s\n", lttng_strerror(ret));
                goto enable_fail;
        }
@@ -145,6 +229,13 @@ int main(int argc, char **argv)
        }
        PRINT_OK();
 
+       printf("Disabling channel %s: ", channel2.name);
+       if ((ret = lttng_disable_channel(handle, channel2.name)) < 0) {
+               printf("error disabling channel: %s\n", lttng_strerror(ret));
+               goto enable_fail;
+       }
+       PRINT_OK();
+
        printf("Start tracing: ");
        if ((ret = lttng_start_tracing(session_name)) < 0) {
                printf("error starting tracing: %s\n", lttng_strerror(ret));
@@ -177,6 +268,12 @@ int main(int argc, char **argv)
        }
        PRINT_OK();
 
+       printf("Destroy tracing session 2: ");
+       if ((ret = lttng_destroy_session(session_name2)) < 0) {
+               printf("error destroying session 2: %s\n", lttng_strerror(ret));
+       }
+       PRINT_OK();
+
        printf("Destroy tracing session: ");
        if ((ret = lttng_destroy_session(session_name)) < 0) {
                printf("error destroying session: %s\n", lttng_strerror(ret));
@@ -185,14 +282,16 @@ int main(int argc, char **argv)
 
        return 0;
 
-create_fail:
-       assert(ret != 0);
 handle_fail:
        assert(handle != NULL);
+create_fail:
+       assert(ret != 0);
 
 stop_fail:
 start_fail:
+context_fail:
 enable_fail:
+       lttng_destroy_session(session_name2);
        lttng_destroy_session(session_name);
        lttng_destroy_handle(handle);
 
diff --git a/tests/ust/ust_global_event_wildcard.c b/tests/ust/ust_global_event_wildcard.c
new file mode 100644 (file)
index 0000000..198a541
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * as published by the Free Software Foundation; only version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define _GNU_SOURCE
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
+
+#include <lttng/lttng.h>
+
+#include "utils.h"
+
+int lttng_opt_quiet;
+
+int main(int argc, char **argv)
+{
+       struct lttng_handle *handle = NULL;
+       struct lttng_domain dom;
+       struct lttng_event event, ev2;
+       char *channel_name = "channel0";
+       char *channel_name2 = "channel2";
+       char *session_name = "ust_global_all_events_basic";
+       int ret = 0;
+
+       memset(&dom, 0, sizeof(dom));
+       memset(&event, 0, sizeof(event));
+       memset(&ev2, 0, sizeof(ev2));
+
+       dom.type = LTTNG_DOMAIN_UST;
+
+       event.type = LTTNG_EVENT_TRACEPOINT;
+       event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+       strcpy(event.name, "*");
+
+       ev2.type = LTTNG_EVENT_TRACEPOINT;
+       ev2.loglevel_type = LTTNG_EVENT_LOGLEVEL_RANGE;
+       ev2.loglevel = LTTNG_LOGLEVEL_NOTICE;
+       strcpy(ev2.name, "abc*");
+
+       printf("\nTesting tracing all UST events:\n");
+       printf("-----------\n");
+
+       if (argc < 2) {
+               printf("Missing session trace path\n");
+               return 1;
+       }
+
+       printf("Creating tracing session (%s): ", argv[1]);
+       if ((ret = lttng_create_session(session_name, argv[1])) < 0) {
+               printf("error creating the session : %s\n", lttng_strerror(ret));
+               goto create_fail;
+       }
+       PRINT_OK();
+
+       printf("Creating session handle: ");
+       if ((handle = lttng_create_handle(session_name, &dom)) == NULL) {
+               printf("error creating handle: %s\n", lttng_strerror(ret));
+               goto handle_fail;
+       }
+       PRINT_OK();
+
+       printf("Enabling '*' UST events: ");
+       if ((ret = lttng_enable_event(handle, &event, channel_name)) < 0) {
+               printf("error enabling event: %s\n", lttng_strerror(ret));
+               goto enable_fail;
+       }
+       PRINT_OK();
+
+       printf("Enabling 'abc*' UST events: ");
+       if ((ret = lttng_enable_event(handle, &ev2, channel_name2)) < 0) {
+               printf("error enabling event: %s\n", lttng_strerror(ret));
+               goto enable_fail;
+       }
+       PRINT_OK();
+
+       printf("Start tracing: ");
+       if ((ret = lttng_start_tracing(session_name)) < 0) {
+               printf("error starting tracing: %s\n", lttng_strerror(ret));
+               goto start_fail;
+       }
+       PRINT_OK();
+
+       sleep(2);
+
+       printf("Stop tracing: ");
+       if ((ret = lttng_stop_tracing(session_name)) < 0) {
+               printf("error stopping tracing: %s\n", lttng_strerror(ret));
+               goto stop_fail;
+       }
+       PRINT_OK();
+
+       printf("Destroy tracing session: ");
+       if ((ret = lttng_destroy_session(session_name)) < 0) {
+               printf("error destroying session: %s\n", lttng_strerror(ret));
+       }
+       PRINT_OK();
+
+       return 0;
+
+handle_fail:
+       assert(handle != NULL);
+create_fail:
+       assert(ret != 0);
+
+stop_fail:
+start_fail:
+enable_fail:
+       lttng_destroy_session(session_name);
+       lttng_destroy_handle(handle);
+
+       return 1;
+}
index f0a2e25dd7fde160e603f57f8b16b65c1fae6428..0f4affd99145165bb21006416cc7aeb8a5367af9 100644 (file)
@@ -24,8 +24,6 @@ KERNEL_MAJOR_VERSION=2
 KERNEL_MINOR_VERSION=6
 KERNEL_PATCHLEVEL_VERSION=27
 
-alias realpath='readlink -f'
-
 function validate_kernel_version ()
 {
        kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n'))
@@ -51,7 +49,7 @@ function spawn_sessiond ()
                return 2
        fi
 
-       DIR=$(realpath $TESTDIR)
+       DIR=$(readlink -f $TESTDIR)
 
        if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
                $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
@@ -103,6 +101,11 @@ function stop_sessiond ()
                echo -e "\e[1;31mFAILED\e[0m"
                return 1
        else
+               out=1
+               while [ -n "$out" ]; do
+                       out=$(pidof lt-$SESSIOND_BIN)
+                       sleep 0.5
+               done
                echo -e "\e[1;32mOK\e[0m"
        fi
 }
@@ -112,14 +115,43 @@ function create_lttng_session ()
        sess_name=$1
        trace_path=$2
 
-       echo -n "Creating lttng session $SESSION_NAME in $TRACE_PATH "
+       echo -n "Creating lttng session $sess_name in $trace_path"
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -o $trace_path >/dev/null 2>&1
        if [ $? -eq 1 ]; then
                echo -e "\e[1;31mFAILED\e[0m"
                return 1
        else
                echo -e "\e[1;32mOK\e[0m"
-               #echo $out | grep "written in" | cut -d' ' -f6
+       fi
+}
+
+function enable_lttng_channel()
+{
+       sess_name=$1
+       channel_name=$2
+
+       echo -n "Enabling lttng channel $channel_name for session $sess_name"
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel $channel_name -s $sess_name >/dev/null 2>&1
+       if [ $? -eq 1 ]; then
+               echo -e "\e[1;31mFAILED\e[0m"
+               return 1
+       else
+               echo -e "\e[1;32mOK\e[0m"
+       fi
+}
+
+function disable_lttng_channel()
+{
+       sess_name=$1
+       channel_name=$2
+
+       echo -n "Disabling lttng channel $channel_name for session $sess_name"
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel $channel_name -s $sess_name >/dev/null 2>&1
+       if [ $? -eq 1 ]; then
+               echo -e "\e[1;31mFAILED\e[0m"
+               return 1
+       else
+               echo -e "\e[1;32mOK\e[0m"
        fi
 }
 
This page took 0.038652 seconds and 4 git commands to generate.