Also move the utils.sh and utils.h helper files under tests/utils.
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
src/bin/lttng-relayd/Makefile
src/bin/lttng/Makefile
tests/Makefile
- tests/kernel/Makefile
- tests/tools/Makefile
- tests/tools/streaming/Makefile
- tests/tools/filtering/Makefile
- tests/tools/health/Makefile
- tests/ust/Makefile
- tests/ust/nprocesses/Makefile
- tests/ust/high-throughput/Makefile
- tests/ust/low-throughput/Makefile
- tests/ust/before-after/Makefile
- tests/ust/multi-session/Makefile
- tests/ust/overlap/Makefile
- tests/ust/overlap/demo/Makefile
+ tests/regression/Makefile
+ tests/regression/kernel/Makefile
+ tests/regression/tools/Makefile
+ tests/regression/tools/streaming/Makefile
+ tests/regression/tools/filtering/Makefile
+ tests/regression/tools/health/Makefile
+ tests/regression/ust/Makefile
+ tests/regression/ust/nprocesses/Makefile
+ tests/regression/ust/high-throughput/Makefile
+ tests/regression/ust/low-throughput/Makefile
+ tests/regression/ust/before-after/Makefile
+ tests/regression/ust/multi-session/Makefile
+ tests/regression/ust/overlap/Makefile
+ tests/regression/ust/overlap/demo/Makefile
])
AC_OUTPUT
-SUBDIRS = . tools kernel
-
-AM_CFLAGS = -g -Wall
-AM_LDFLAGS = -lurcu -lurcu-cds
-
-EXTRA_DIST = run-report.py test_list.py utils.sh utils.h runall.sh
-
-if HAVE_LIBLTTNG_UST_CTL
-SUBDIRS += ust
-endif # HAVE_LIBLTTNG_UST_CTL
-
-check-am:
- ./runall.sh
+SUBDIRS = . regression
+++ /dev/null
-AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests -g -Wall
-AM_LDFLAGS = -lurcu -lurcu-cds
-
-EXTRA_DIST = runall.sh run-kernel-tests.sh
-
-noinst_PROGRAMS = kernel_all_events_basic kernel_event_basic
-
-UTILS=../utils.h
-LIBLTTNG=$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la
-
-SESSIONDSRC=$(top_srcdir)/src/common/sessiond-comm/sessiond-comm.c \
- $(top_srcdir)/src/common/sessiond-comm/unix.c \
- $(top_srcdir)/src/common/sessiond-comm/inet.c \
- $(top_srcdir)/src/common/sessiond-comm/inet6.c
-
-kernel_all_events_basic_SOURCES = kernel_all_events_basic.c $(UTILS) \
- $(SESSIONDSRC)
-kernel_all_events_basic_LDADD = $(LIBLTTNG)
-
-kernel_event_basic_SOURCES = kernel_event_basic.c $(UTILS) \
- $(SESSIONDSRC)
-kernel_event_basic_LDADD = $(LIBLTTNG)
+++ /dev/null
-/*
- * 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 = "kernel_all_events_basic";
- int ret = 0;
-
- memset(&dom, 0, sizeof(dom));
- memset(&event, 0, sizeof(event));
- dom.type = LTTNG_DOMAIN_KERNEL;
- event.type = LTTNG_EVENT_TRACEPOINT;
- event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
- printf("\nTesting tracing all kernel events:\n");
- printf("-----------\n");
- /* Check if root */
- if (getuid() != 0) {
- printf("Root access is needed.\nPlease run 'sudo make check' -- Aborting!\n");
- return 0;
- }
-
- 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 kernel 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;
-
-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;
-}
+++ /dev/null
-/*
- * 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_channel channel;
- struct lttng_event sched_switch;
- struct lttng_event sched_process_exit;
- struct lttng_event sched_process_free;
- char *session_name = "kernel_event_basic";
- int ret = 0;
-
- memset(&dom, 0, sizeof(dom));
- memset(&channel, 0, sizeof(channel));
- memset(&sched_switch, 0, sizeof(sched_switch));
- memset(&sched_process_exit, 0, sizeof(sched_process_exit));
- memset(&sched_process_free, 0, sizeof(sched_process_free));
-
- dom.type = LTTNG_DOMAIN_KERNEL;
-
- strcpy(channel.name, "mychan");
- channel.attr.overwrite = 0;
- channel.attr.subbuf_size = 4096;
- channel.attr.num_subbuf = 8;
- channel.attr.switch_timer_interval = 0;
- channel.attr.read_timer_interval = 200;
- channel.attr.output = LTTNG_EVENT_SPLICE;
-
- strcpy(sched_switch.name, "sched_switch");
- sched_switch.type = LTTNG_EVENT_TRACEPOINT;
- sched_switch.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
- strcpy(sched_process_exit.name, "sched_process_exit");
- sched_process_exit.type = LTTNG_EVENT_TRACEPOINT;
- sched_process_exit.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
- strcpy(sched_process_free.name, "sched_process_free");
- sched_process_free.type = LTTNG_EVENT_TRACEPOINT;
- sched_process_free.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
- printf("\nTesting tracing kernel events:\n");
- printf("-----------\n");
- /* Check if root */
- if (getuid() != 0) {
- printf("Root access is needed.\nPlease run 'sudo make check' -- Aborting!\n");
- return 0;
- }
-
- 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 %s kernel channel: ", channel.name);
- if ((ret = lttng_enable_channel(handle, &channel)) < 0) {
- printf("error enable channel: %s\n", lttng_strerror(ret));
- goto enable_fail;
- }
-
- printf("Enabling %s kernel event: ", sched_switch.name);
- if ((ret = lttng_enable_event(handle, &sched_switch, channel.name)) < 0) {
- printf("error enabling event: %s\n", lttng_strerror(ret));
- goto enable_fail;
- }
- PRINT_OK();
-
- printf("Enabling %s kernel event: ", sched_process_exit.name);
- if ((ret = lttng_enable_event(handle, &sched_process_exit, channel.name)) < 0) {
- printf("error enabling event: %s\n", lttng_strerror(ret));
- goto enable_fail;
- }
- PRINT_OK();
-
- printf("Enabling %s kernel event: ", sched_process_free.name);
- if ((ret = lttng_enable_event(handle, &sched_process_free, channel.name)) < 0) {
- printf("error enabling event: %s\n", lttng_strerror(ret));
- goto enable_fail;
- }
- PRINT_OK();
-
- printf("Disabling %s kernel event: ", sched_switch.name);
- if ((ret = lttng_disable_event(handle, sched_switch.name, channel.name)) < 0) {
- printf("error enabling event: %s\n", lttng_strerror(ret));
- goto enable_fail;
- }
- PRINT_OK();
-
- printf("Disabling %s kernel event: ", sched_process_free.name);
- if ((ret = lttng_disable_event(handle, sched_process_free.name, channel.name)) < 0) {
- printf("error enabling event: %s\n", lttng_strerror(ret));
- goto enable_fail;
- }
- PRINT_OK();
-
- printf("Renabling %s kernel event: ", sched_switch.name);
- if ((ret = lttng_enable_event(handle, &sched_switch, channel.name)) < 0) {
- printf("error enabling event: %s\n", lttng_strerror(ret));
- goto enable_fail;
- }
- PRINT_OK();
-
- printf("Renabling %s kernel event: ", sched_process_free.name);
- if ((ret = lttng_enable_event(handle, &sched_process_free, 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;
-
-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;
-}
+++ /dev/null
-#!/bin/bash
-
-SESSIOND_BIN="lttng-sessiond"
-CURDIR=$(dirname $0)
-TESTDIR=$CURDIR/..
-
-source $TESTDIR/utils.sh
-
-tmpdir=`mktemp -d`
-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_lttng_sessiond
-
- ./$bin $tmpdir
- # Test must return 0 to pass.
- if [ $? -ne 0 ]; then
- exit_code=1
- stop_lttng_sessiond
- break
- fi
- stop_lttng_sessiond
- done
-
- # Cleaning up
- rm -rf $tmpdir
-}
-
-function check_lttng_modules ()
-{
- local out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
- if [ -z "$out" ]; then
- echo "LTTng modules not detected. Aborting kernel tests!"
- echo ""
- # Exit status 0 so the tests can continue
- exit 0
- fi
-}
-
-
-TEST_DESC="Testing Kernel tracer"
-
-print_test_banner "$TEST_DESC"
-
-# Detect lttng-modules installed
-check_lttng_modules
-
-start_tests
-
-exit $exit_code
+++ /dev/null
-#!/bin/bash
-
-DIR=$(dirname $0)
-
-tests=( $DIR/run-kernel-tests.sh )
-exit_code=0
-
-function start_tests ()
-{
- for bin in ${tests[@]};
- do
- ./$bin
- # Test must return 0 to pass.
- if [ $? -ne 0 ]; then
- exit_code=1
- break
- fi
- done
-}
-
-start_tests
-
-exit $exit_code
--- /dev/null
+SUBDIRS = . tools kernel
+
+AM_CFLAGS = -g -Wall
+AM_LDFLAGS = -lurcu -lurcu-cds
+
+EXTRA_DIST = run-report.py test_list.py runall.sh
+
+if HAVE_LIBLTTNG_UST_CTL
+SUBDIRS += ust
+endif # HAVE_LIBLTTNG_UST_CTL
+
+check-am:
+ ./runall.sh
--- /dev/null
+AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests/utils -g -Wall
+AM_LDFLAGS = -lurcu -lurcu-cds
+
+EXTRA_DIST = runall.sh run-kernel-tests.sh
+
+noinst_PROGRAMS = kernel_all_events_basic kernel_event_basic
+
+UTILS=$(top_srcdir)/tests/utils/utils.h
+LIBLTTNG=$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la
+
+SESSIONDSRC=$(top_srcdir)/src/common/sessiond-comm/sessiond-comm.c \
+ $(top_srcdir)/src/common/sessiond-comm/unix.c \
+ $(top_srcdir)/src/common/sessiond-comm/inet.c \
+ $(top_srcdir)/src/common/sessiond-comm/inet6.c
+
+kernel_all_events_basic_SOURCES = kernel_all_events_basic.c $(UTILS) \
+ $(SESSIONDSRC)
+kernel_all_events_basic_LDADD = $(LIBLTTNG)
+
+kernel_event_basic_SOURCES = kernel_event_basic.c $(UTILS) \
+ $(SESSIONDSRC)
+kernel_event_basic_LDADD = $(LIBLTTNG)
--- /dev/null
+/*
+ * 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 = "kernel_all_events_basic";
+ int ret = 0;
+
+ memset(&dom, 0, sizeof(dom));
+ memset(&event, 0, sizeof(event));
+ dom.type = LTTNG_DOMAIN_KERNEL;
+ event.type = LTTNG_EVENT_TRACEPOINT;
+ event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+
+ printf("\nTesting tracing all kernel events:\n");
+ printf("-----------\n");
+ /* Check if root */
+ if (getuid() != 0) {
+ printf("Root access is needed.\nPlease run 'sudo make check' -- Aborting!\n");
+ return 0;
+ }
+
+ 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 kernel 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;
+
+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;
+}
--- /dev/null
+/*
+ * 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_channel channel;
+ struct lttng_event sched_switch;
+ struct lttng_event sched_process_exit;
+ struct lttng_event sched_process_free;
+ char *session_name = "kernel_event_basic";
+ int ret = 0;
+
+ memset(&dom, 0, sizeof(dom));
+ memset(&channel, 0, sizeof(channel));
+ memset(&sched_switch, 0, sizeof(sched_switch));
+ memset(&sched_process_exit, 0, sizeof(sched_process_exit));
+ memset(&sched_process_free, 0, sizeof(sched_process_free));
+
+ dom.type = LTTNG_DOMAIN_KERNEL;
+
+ strcpy(channel.name, "mychan");
+ channel.attr.overwrite = 0;
+ channel.attr.subbuf_size = 4096;
+ channel.attr.num_subbuf = 8;
+ channel.attr.switch_timer_interval = 0;
+ channel.attr.read_timer_interval = 200;
+ channel.attr.output = LTTNG_EVENT_SPLICE;
+
+ strcpy(sched_switch.name, "sched_switch");
+ sched_switch.type = LTTNG_EVENT_TRACEPOINT;
+ sched_switch.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+
+ strcpy(sched_process_exit.name, "sched_process_exit");
+ sched_process_exit.type = LTTNG_EVENT_TRACEPOINT;
+ sched_process_exit.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+
+ strcpy(sched_process_free.name, "sched_process_free");
+ sched_process_free.type = LTTNG_EVENT_TRACEPOINT;
+ sched_process_free.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+
+ printf("\nTesting tracing kernel events:\n");
+ printf("-----------\n");
+ /* Check if root */
+ if (getuid() != 0) {
+ printf("Root access is needed.\nPlease run 'sudo make check' -- Aborting!\n");
+ return 0;
+ }
+
+ 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 %s kernel channel: ", channel.name);
+ if ((ret = lttng_enable_channel(handle, &channel)) < 0) {
+ printf("error enable channel: %s\n", lttng_strerror(ret));
+ goto enable_fail;
+ }
+
+ printf("Enabling %s kernel event: ", sched_switch.name);
+ if ((ret = lttng_enable_event(handle, &sched_switch, channel.name)) < 0) {
+ printf("error enabling event: %s\n", lttng_strerror(ret));
+ goto enable_fail;
+ }
+ PRINT_OK();
+
+ printf("Enabling %s kernel event: ", sched_process_exit.name);
+ if ((ret = lttng_enable_event(handle, &sched_process_exit, channel.name)) < 0) {
+ printf("error enabling event: %s\n", lttng_strerror(ret));
+ goto enable_fail;
+ }
+ PRINT_OK();
+
+ printf("Enabling %s kernel event: ", sched_process_free.name);
+ if ((ret = lttng_enable_event(handle, &sched_process_free, channel.name)) < 0) {
+ printf("error enabling event: %s\n", lttng_strerror(ret));
+ goto enable_fail;
+ }
+ PRINT_OK();
+
+ printf("Disabling %s kernel event: ", sched_switch.name);
+ if ((ret = lttng_disable_event(handle, sched_switch.name, channel.name)) < 0) {
+ printf("error enabling event: %s\n", lttng_strerror(ret));
+ goto enable_fail;
+ }
+ PRINT_OK();
+
+ printf("Disabling %s kernel event: ", sched_process_free.name);
+ if ((ret = lttng_disable_event(handle, sched_process_free.name, channel.name)) < 0) {
+ printf("error enabling event: %s\n", lttng_strerror(ret));
+ goto enable_fail;
+ }
+ PRINT_OK();
+
+ printf("Renabling %s kernel event: ", sched_switch.name);
+ if ((ret = lttng_enable_event(handle, &sched_switch, channel.name)) < 0) {
+ printf("error enabling event: %s\n", lttng_strerror(ret));
+ goto enable_fail;
+ }
+ PRINT_OK();
+
+ printf("Renabling %s kernel event: ", sched_process_free.name);
+ if ((ret = lttng_enable_event(handle, &sched_process_free, 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;
+
+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;
+}
--- /dev/null
+#!/bin/bash
+
+SESSIOND_BIN="lttng-sessiond"
+CURDIR=$(dirname $0)
+TESTDIR=$CURDIR/../..
+
+source $TESTDIR/utils/utils.sh
+
+tmpdir=`mktemp -d`
+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_lttng_sessiond
+
+ ./$bin $tmpdir
+ # Test must return 0 to pass.
+ if [ $? -ne 0 ]; then
+ exit_code=1
+ stop_lttng_sessiond
+ break
+ fi
+ stop_lttng_sessiond
+ done
+
+ # Cleaning up
+ rm -rf $tmpdir
+}
+
+function check_lttng_modules ()
+{
+ local out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
+ if [ -z "$out" ]; then
+ echo "LTTng modules not detected. Aborting kernel tests!"
+ echo ""
+ # Exit status 0 so the tests can continue
+ exit 0
+ fi
+}
+
+
+TEST_DESC="Testing Kernel tracer"
+
+print_test_banner "$TEST_DESC"
+
+# Detect lttng-modules installed
+check_lttng_modules
+
+start_tests
+
+exit $exit_code
--- /dev/null
+#!/bin/bash
+
+DIR=$(dirname $0)
+
+tests=( $DIR/run-kernel-tests.sh )
+exit_code=0
+
+function start_tests ()
+{
+ for bin in ${tests[@]};
+ do
+ ./$bin
+ # Test must return 0 to pass.
+ if [ $? -ne 0 ]; then
+ exit_code=1
+ break
+ fi
+ done
+}
+
+start_tests
+
+exit $exit_code
--- /dev/null
+#!/usr/bin/env python
+
+import os, sys
+import subprocess
+import threading
+import Queue
+import time
+import shlex
+
+from signal import signal, SIGTERM, SIGINT, SIGPIPE, SIG_DFL
+
+SESSIOND_BIN_NAME = "lttng-sessiond"
+SESSIOND_BIN_PATH = "src/bin/lttng-sessiond/"
+CONSUMERD_BIN_NAME = "lttng-consumerd"
+CONSUMERD_BIN_PATH = "src/bin/lttng-consumerd/"
+TESTDIR_PATH = ""
+
+PRINT_BRACKET = "\033[1;34m[\033[1;33m+\033[1;34m]\033[00m"
+PRINT_RED_BRACKET = "\033[1;31m[+]\033[00m"
+PRINT_GREEN_BRACKET = "\033[1;32m[+]\033[00m"
+PRINT_ARROW = "\033[1;32m-->\033[00m"
+
+is_root = 1
+no_stats = 0
+stop_sampling = 1
+
+top_cpu_legend = { 'us': "User CPU time", 'sy': "System CPU time",
+ 'id': "Idle CPU time", 'ni': "Nice CPU time", 'wa': "iowait",
+ 'hi': "Hardware IRQ", 'si': "Software Interrupts", 'st': "Steal Time", }
+
+cpu_ret_q = Queue.Queue()
+mem_ret_q = Queue.Queue()
+test_ret_q = Queue.Queue()
+
+global sdaemon_proc
+global worker_proc
+
+def cpu_create_usage_dict(top_line):
+ """
+ Return a dictionnary from a 'top' cpu line.
+ Ex: Cpu(s): 2.1%us, 1.2%sy, 0.0%ni, 96.2%id, 0.4%wa, 0.0%hi, 0.0%si, 0.0%st
+ """
+ top_dict = {'us': 0, 'sy': 0, 'ni': 0, 'id': 0, 'wa': 0, 'hi': 0, 'si': 0, 'st': 0}
+
+ # Split expression and remove first value which is "Cpu(s)"
+ top_line = top_line.replace(",","")
+ words = top_line.split()[1:]
+
+
+ for key in top_dict:
+ index = words.index(key)
+ # Add the value to the dictionnary
+ val = words[index-1]
+ top_dict[key] = float(val)
+
+ return top_dict
+
+def cpu_average_usage(top_lines):
+ """
+ Return a dictionnary of 'top' CPU stats but averaging all values.
+ """
+ avg_dict = {'us': 0, 'sy': 0, 'ni': 0, 'id': 0, 'wa': 0, 'hi': 0, 'si': 0, 'st': 0}
+ # Average count
+ count = 0.0
+
+ for line in top_lines:
+ tmp_dict = cpu_create_usage_dict(line)
+ # Add value to avg dictionnary
+ for key in tmp_dict:
+ avg_dict[key] += tmp_dict[key]
+
+ count += 1.0
+
+ for key in avg_dict:
+ avg_dict[key] = avg_dict[key] / count
+
+ return (count, avg_dict)
+
+def cpu_sample_usage(pid=None):
+ """
+ Sample CPU usage for num iterations.
+ If num is greater than 1, the average will be computed.
+ """
+ args = ["top", "-b", "-n", "1"]
+ if pid:
+ args.append("-p")
+ args.append(str(pid))
+
+ # Spawn top process
+ top = subprocess.Popen(args, stdout = subprocess.PIPE)
+
+ grep = subprocess.Popen(["grep", "Cpu"], stdin = top.stdout,
+ stdout = subprocess.PIPE)
+ top.stdout.close()
+
+ return grep.communicate()[0].strip("\n")
+
+def mem_sample_usage(pid):
+ """
+ Sample memory usage using /proc and a pid
+ """
+ args = ["cat", "/proc/" + str(pid) + "/status"]
+
+ if not os.path.isfile(args[1]):
+ return -1
+
+ mem_proc = subprocess.Popen(args, stdout = subprocess.PIPE)
+
+ grep = subprocess.Popen(["grep", "^VmRSS"], stdin = mem_proc.stdout,
+ stdout = subprocess.PIPE)
+ mem_proc.stdout.close()
+
+ # Return virtual memory size in kilobytes (kB)
+ #ret = grep.communicate()[0].split()
+ ret = grep.communicate()[0].split()
+
+ if len(ret) > 1:
+ ret = ret[1]
+ else:
+ ret = 0
+
+ return int(ret)
+
+class SamplingWorker(threading.Thread):
+ def __init__(self, s_type, worker = None, delay = 0.2, pid = 0):
+ threading.Thread.__init__ (self)
+ self.s_type = s_type
+ self.delay = delay
+ self.pid = pid
+ self.worker = worker
+
+ def run(self):
+ count = 1
+ lines = []
+
+ if self.s_type == "cpu":
+ while 1:
+ if self.worker == None:
+ cpu_line = cpu_sample_usage(self.pid)
+ lines.append(cpu_line)
+ break
+ elif self.worker.is_alive():
+ cpu_line = cpu_sample_usage(self.pid)
+ lines.append(cpu_line)
+ else:
+ break
+
+ # Delay sec per memory sampling
+ time.sleep(self.delay)
+
+ count, stats = cpu_average_usage(lines)
+ cpu_ret_q.put((count, stats))
+ # grep process has ended here
+
+ elif self.s_type == "mem":
+ count = 0
+ mem_stat = 0
+
+ while 1:
+ if self.worker == None:
+ cpu_line = cpu_sample_usage(self.pid)
+ lines.append(cpu_line)
+ break
+ elif self.worker.is_alive():
+ mem_stat += get_mem_usage(self.pid)
+ count += 1
+ else:
+ break
+
+ # Delay sec per memory sampling
+ time.sleep(self.delay)
+
+ mem_ret_q.put((count, mem_stat))
+
+class TestWorker(threading.Thread):
+ def __init__(self, path, name, env):
+ threading.Thread.__init__(self)
+ self.path = path
+ self.name = name
+ self.env = env
+
+ def run(self):
+ bin_path_name = os.path.join(self.path, self.name)
+
+ test = subprocess.Popen([bin_path_name], env=self.env, preexec_fn = lambda: signal(SIGPIPE, SIG_DFL))
+ test.wait()
+
+ # Send ret value to main thread
+ test_ret_q.put(test.returncode)
+
+def get_pid(procname):
+ """
+ Return pid of process name using 'pidof' command
+ """
+ pidof = subprocess.Popen(["pidof", procname], stdout = subprocess.PIPE)
+ pid = pidof.communicate()[0].split()
+
+ if pid == []:
+ return 0
+
+ return int(pid[0])
+
+def spawn_session_daemon():
+ """
+ Exec the session daemon and return PID
+ """
+ global sdaemon_proc
+
+ pid = get_pid(SESSIOND_BIN_NAME)
+ if pid != 0:
+ os.kill(pid, SIGTERM)
+
+ bin_path = os.path.join(TESTDIR_PATH, "..", SESSIOND_BIN_PATH, SESSIOND_BIN_NAME)
+ consumer_path = os.path.join(TESTDIR_PATH, "..", CONSUMERD_BIN_PATH, CONSUMERD_BIN_NAME)
+
+ if not os.path.isfile(bin_path):
+ print "Error: No session daemon binary found. Compiled?"
+ return 0
+
+ try:
+ args = shlex.split("libtool execute " + bin_path
+ + " --consumerd32-path=" + consumer_path
+ + " --consumerd64-path=" + consumer_path)
+
+ sdaemon_proc = subprocess.Popen(args, shell = False, stderr = subprocess.PIPE)
+
+ except OSError, e:
+ print e
+ return 0
+
+ time.sleep(1)
+
+ return get_pid("lt-" + SESSIOND_BIN_NAME)
+
+def start_test(name):
+ """
+ Spawn test and return exit code
+ """
+ tw = TestWorker(".", name)
+ tw.start()
+
+ return test_ret_q.get(True)
+
+def print_cpu_stats(stats, count):
+ """
+ Pretty print on one line the CPU stats
+ """
+ sys.stdout.write(PRINT_ARROW + " Cpu [sampled %d time(s)]:\n " % (count))
+ for stat in stats:
+ sys.stdout.write(" %s: %.2f, " % (stat, stats[stat]))
+ print ""
+
+def get_cpu_usage(delay=1, pid=0):
+ """
+ Spawn a worker thread to sample cpu usage.
+ """
+ sw = SamplingWorker("cpu", delay = delay, pid = pid)
+ sw.start()
+
+ return cpu_ret_q.get(True)
+
+def get_mem_usage(pid):
+ """
+ Get memory usage for PID
+ """
+ return mem_sample_usage(pid)
+
+def print_test_success(ret, expect):
+ """
+ Print if test has failed or pass according to the expected value.
+ """
+ if ret != expect:
+ print "\n" + PRINT_RED_BRACKET + \
+ " Failed: ret = %d (expected %d)" % (ret, expect)
+ return 1
+ else:
+ print "\n" + PRINT_BRACKET + \
+ " Passed: ret = %d (expected %d)" % (ret, expect)
+ return 0
+
+def run_test(test):
+ """
+ Run test 'name' and output report of the test with stats.
+ """
+ global worker_proc
+ global sdaemon_proc
+ dem_pid = 0 # Session daemon pid
+
+ print PRINT_BRACKET + " %s" % (test['name'])
+ print PRINT_ARROW + " %s" % (test['desc'])
+ if no_stats:
+ print PRINT_ARROW + " Statistics will NOT be collected"
+ else:
+ print PRINT_ARROW + " Statistics of the session daemon will be collected"
+
+ if test['kern'] and not is_root:
+ print "Needs root for kernel tracing. Skipping"
+ return 0
+
+ if not os.path.isfile(test['bin']):
+ print "Unable to find test file '%s'. Skipping" % (test['bin'])
+ return 0
+
+ # Session daemon is controlled by the test
+ if test['daemon'] == "test":
+ print PRINT_ARROW + " Session daemon is controlled by the test"
+ env = os.environ
+ env['TEST_NO_SESSIOND'] = '0'
+ tw = TestWorker(".", test['bin'], env)
+ tw.start()
+ ret = test_ret_q.get(True)
+ print_test_success(ret, test['success'])
+ return 0
+ elif test['daemon'] == False:
+ print PRINT_ARROW + " No session daemon needed"
+ env = os.environ
+ env['TEST_NO_SESSIOND'] = '1'
+ tw = TestWorker(".", test['bin'], env)
+ tw.start()
+ ret = test_ret_q.get(True)
+ print_test_success(ret, test['success'])
+ return 0
+ else:
+ print PRINT_ARROW + " Session daemon needed"
+
+ dem_pid = spawn_session_daemon()
+ if dem_pid <= 0:
+ print "Unable to start %s. Stopping" % (SESSIOND_BIN_NAME)
+ print sdaemon_proc.communicate()[1]
+ return 0
+
+ print PRINT_BRACKET + " Session daemon spawned (pid: %d)\n" % (dem_pid)
+
+ if not no_stats:
+ mem_before = get_mem_usage(dem_pid)
+ print PRINT_BRACKET + " Stats *before* test:"
+ print PRINT_ARROW + " Mem (kB): %d" % (mem_before)
+ cpu_count, cpu_stats = get_cpu_usage(pid = dem_pid)
+ print_cpu_stats(cpu_stats, cpu_count)
+
+ # Sessiond was already spawned, do not let the test spawn
+ # an additional sessiond
+ env = os.environ
+ env['TEST_NO_SESSIOND'] = '1'
+
+ tw = TestWorker(".", test['bin'], env)
+ tw.start()
+
+ if not no_stats:
+ # Start CPU sampling for test
+ sw_cpu = SamplingWorker("cpu", worker = tw, pid = dem_pid)
+ sw_cpu.start()
+ sw_mem = SamplingWorker("mem", worker = tw, pid = dem_pid)
+ sw_mem.start()
+
+ ret = test_ret_q.get(True)
+
+ if not no_stats:
+ time.sleep(2)
+ # Compute memory average
+ mem_count, mem_during = mem_ret_q.get(True)
+ mem_during = float(mem_during) / float(mem_count)
+ cpu_count, cpu_stats = cpu_ret_q.get(True)
+
+ print "\n" + PRINT_BRACKET + " Stats *during* test:"
+ print PRINT_ARROW + " Mem (kB): %.0f [sampled %d time(s)]" % (mem_during, mem_count)
+ print_cpu_stats(cpu_stats, cpu_count)
+
+ mem_after = get_mem_usage(dem_pid)
+ print "\n" + PRINT_BRACKET + " Stats *after* test:"
+ print PRINT_ARROW + " Mem (kB): %d" % (mem_after)
+ cpu_count, cpu_stats = get_cpu_usage(pid = dem_pid)
+ print_cpu_stats(cpu_stats, cpu_count)
+
+ print "\n" + PRINT_BRACKET + " Memory usage differences:"
+ print PRINT_ARROW + " Diff during and before (kB): %d" % (mem_during - mem_before)
+ print PRINT_ARROW + " Diff during and after (kB): %d" % (mem_during - mem_after)
+ print PRINT_ARROW + " Diff before and after (kB): %d" % (mem_after - mem_before)
+
+ # Return value of 0 means that is passed else it failed
+ ret = print_test_success(ret, test['success'])
+
+ # Stop session daemon
+ if dem_pid > 0:
+ print PRINT_BRACKET + " Stopping session daemon (pid: %d)..." % (dem_pid)
+ try:
+ os.kill(dem_pid, SIGTERM)
+ # This call simply does not work... It seems python does not relay the signal
+ # to the child processes of sdaemon_proc.
+ # sdaemon_proc.terminate()
+ if ret != 0:
+ print sdaemon_proc.communicate()[1]
+ elif sdaemon_proc.returncode == None:
+ sdaemon_proc.communicate()
+ except OSError, e:
+ print e
+
+ # Make sure all thread are released
+ if not no_stats:
+ tw.join()
+ sw_cpu.join()
+ sw_mem.join()
+
+ return ret
+
+def main():
+ for test in Tests:
+ if not test['enabled']:
+ continue
+
+ ret = run_test(test)
+ if ret != 0:
+ # Stop all tests, the last one failed
+ return
+ print ""
+
+def cleanup(signo, stack):
+ """ Cleanup function """
+ sys.exit(0)
+
+if __name__ == "__main__":
+ if not os.getuid() == 0:
+ is_root = 0
+ print "NOTICE: Not root. No kernel tracing will be tested\n"
+
+ if os.path.isfile("test_list.py"):
+ from test_list import Tests
+ else:
+ print "No test_list.py found. Stopping"
+ cleanup(0, 0)
+
+ TESTDIR_PATH = os.getcwd()
+
+ if len(sys.argv) > 1:
+ if sys.argv[1] == "--no-stats":
+ no_stats = 1
+
+ try:
+ signal(SIGTERM, cleanup)
+ signal(SIGINT, cleanup)
+ main()
+ cleanup(0, 0)
+ except KeyboardInterrupt:
+ cleanup(0, 0)
--- /dev/null
+#!/bin/bash
+#
+# 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+#### ADD TESTS HERE ####
+
+tests=( kernel/runall.sh ust/runall.sh tools/runall.sh )
+
+#### END TESTS HERE ####
+
+TESTDIR=$(dirname $0)/..
+
+source $TESTDIR/utils/utils.sh
+
+## lttng-tools unit tests ##
+# No session daemon needed
+for bin in ${tests[@]};
+do
+ if [ ! -e $bin ]; then
+ echo -e "$bin not found, passing"
+ continue
+ fi
+
+ ./$bin
+ # Test must return 0 to pass.
+ if [ $? -ne 0 ]; then
+ echo -e '\e[1;31mFAIL\e[0m'
+ echo ""
+ exit 1
+ fi
+done
+
+# All passed
+exit 0
--- /dev/null
+Tests = \
+[
+ # lttng-tools unit tests
+ {
+ 'bin': "tools/test_sessions", 'daemon': False, 'kern': False, 'name': "Test sessions",
+ 'desc': "Test tracing session data structures and methods.",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "tools/test_kernel_data_trace", 'daemon': False, 'kern': False,
+ 'name': "Kernel data structures",
+ 'desc': "Test Kernel data structures and methods.",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "tools/test_ust_data_trace", 'daemon': False, 'kern': False,
+ 'name': "UST data structures",
+ 'desc': "Test UST data structures and methods.",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "tools/streaming/run-ust", 'daemon': True, 'kern': False,
+ 'name': "UST network streaming",
+ 'desc': "Test user space tracing network streaming support",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "tools/streaming/run-kernel", 'daemon': True, 'kern': True,
+ 'name': "Kernel network streaming",
+ 'desc': "Test kernel tracing network streaming support",
+ 'success': 0, 'enabled': True
+ },
+
+ # Kernel tests
+ {
+ 'bin': "kernel/run-kernel-tests.sh", 'daemon': True, 'kern': True,
+ 'name': "Kernel tracer - lttng client",
+ 'desc': "Test the Kernel tracer using the lttng client",
+ 'success': 0, 'enabled': True
+ },
+
+ # UST tests
+ {
+ 'bin': "ust/run-ust-global-tests.sh", 'daemon': True, 'kern': False,
+ 'name': "UST tracer - Global domain",
+ 'desc': "Test the UST tracer functionnalities for domain LTTNG_DOMAIN_UST",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "ust/nprocesses/run", 'daemon': True, 'kern': False,
+ 'name': "UST tracer - Multiple processes",
+ 'desc': "Test multiple process registering and tracing",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "ust/high-throughput/run", 'daemon': True, 'kern': False,
+ 'name': "UST tracer - Testing high events throughput",
+ 'desc': "Test multiple large number of events with concurrent application",
+ 'success': 0, 'enabled': True
+ },
+ # Deactivated. This test last 20 minutes...
+ #{
+ #'bin': "ust/low-throughput/run", 'daemon': True, 'kern': False,
+ #'name': "UST tracer - Testing high events throughput",
+ #'desc': "Test low throughput of events",
+ #'success': 0, 'enabled': False
+ #},
+ {
+ 'bin': "ust/before-after/run", 'daemon': True, 'kern': False,
+ 'name': "UST tracer - Tracing before and after app execution",
+ 'desc': "Test tracing before and after app execution",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "ust/multi-session/run", 'daemon': True, 'kern': False,
+ 'name': "UST tracer - Multi-session",
+ 'desc': "Test tracing with 4 sessions for one application",
+ 'success': 0, 'enabled': True
+ },
+
+ # Tools filtering tests
+ {
+ 'bin': "tools/filtering/unsupported-ops", 'daemon': True, 'kern': False,
+ 'name': "Filtering - Unsupported operators",
+ 'desc': "Test the failure of filter with unsupported operators",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "tools/filtering/invalid-filters", 'daemon': True, 'kern': False,
+ 'name': "Filtering - Invalid filters",
+ 'desc': "Test the failure of invalid filters",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "tools/filtering/valid-filters", 'daemon': True, 'kern': False,
+ 'name': "Filtering - Valid filters",
+ 'desc': "Validate the expected trace output of valid filters",
+ 'success': 0, 'enabled': True
+ },
+
+ # Tools health check tests
+ {
+ 'bin': "tools/health/health_thread_exit", 'daemon': "test", 'kern': True,
+ 'name': "Health check - Thread exit",
+ 'desc': "Call exit in the various lttng-sessiond threads and ensure that health failure is detected",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "tools/health/health_thread_stall", 'daemon': "test", 'kern': True,
+ 'name': "Health check - Thread stall",
+ 'desc': "Stall the various lttng-sessiond threads and ensure that health failure is detected",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "tools/health/health_tp_fail", 'daemon': "test", 'kern': True,
+ 'name': "Health check - Testpoint failure",
+ 'desc': "Trigger a failure in the testpoint mechanism in each thread to provoke thread teardown",
+ 'success': 0, 'enabled': True
+ },
+
+ # Tools streaming tests
+ {
+ 'bin': "tools/streaming/run-kernel", 'daemon': True, 'kern': True,
+ 'name': "Streaming - Kernel tracing",
+ 'desc': "Stream a kernel trace across the network",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "tools/streaming/run-ust", 'daemon': True, 'kern': False,
+ 'name': "Streaming - Userspace tracing",
+ 'desc': "Stream a userspace trace across the network",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "tools/streaming/uri_switch", 'daemon': True, 'kern': False,
+ 'name': "Streaming - URI switching",
+ 'desc': "Switch URI and verify that the trace result are in the proper location",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "tools/streaming/high_throughput_limits", 'daemon': True, 'kern': True,
+ 'name': "Streaming - High throughput with bandwith limits",
+ 'desc': "Trace streaming with bandwidth limits",
+ 'success': 0, 'enabled': True
+ },
+]
--- /dev/null
+SUBDIRS = streaming filtering health
+
+AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests/utils -g -Wall
+AM_LDFLAGS = -lurcu
+
+EXTRA_DIST = runall.sh
+
+noinst_PROGRAMS = test_sessions test_kernel_data_trace
+
+UTILS=$(top_srcdir)/tests/utils/utils.h
+SESSIONS=$(top_srcdir)/src/bin/lttng-sessiond/session.c \
+ $(top_srcdir)/src/bin/lttng-sessiond/consumer.c \
+ $(top_srcdir)/src/common/uri.c \
+ $(top_srcdir)/src/common/utils.c \
+ $(top_srcdir)/src/common/error.c
+KERN_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-kernel.c \
+ $(top_srcdir)/src/bin/lttng-sessiond/consumer.c \
+ $(top_srcdir)/src/common/uri.c \
+ $(top_srcdir)/src/common/utils.c
+COMMON=$(top_builddir)/src/common/libcommon.la
+HASHTABLE=$(top_builddir)/src/common/hashtable/libhashtable.la
+SESSIOND_COMM=$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la
+
+# Tracing sessions unit tests
+test_sessions_SOURCES = test_sessions.c $(UTILS) $(SESSIONS)
+test_sessions_LDADD = $(COMMON) $(HASHTABLE) $(SESSIOND_COMM)
+
+# Kernel trace data unit tests
+test_kernel_data_trace_SOURCES = test_kernel_data_trace.c $(UTILS) $(KERN_DATA_TRACE)
+test_kernel_data_trace_LDADD = $(COMMON) $(SESSIOND_COMM) $(HASHTABLE)
+
+if HAVE_LIBLTTNG_UST_CTL
+noinst_PROGRAMS += test_ust_data_trace
+UST_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-ust.c \
+ $(top_srcdir)/src/bin/lttng-sessiond/consumer.c \
+ $(top_srcdir)/src/common/uri.c \
+ $(top_srcdir)/src/common/utils.c
+# UST trace data unit tests
+test_ust_data_trace_SOURCES = test_ust_data_trace.c $(UTILS) $(UST_DATA_TRACE)
+test_ust_data_trace_LDADD = $(COMMON) $(HASHTABLE) $(SESSIOND_COMM)
+endif
--- /dev/null
+AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests -I$(srcdir) -O2 -g
+AM_LDFLAGS =
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+AM_LDFLAGS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+AM_LDFLAGS += -lc
+endif
+
+if HAVE_LIBLTTNG_UST_CTL
+noinst_PROGRAMS = gen-ust-events
+gen_ust_events_SOURCES = gen-ust-events.c tp.c tp.h
+gen_ust_events_LDADD = -llttng-ust
+endif
+
+noinst_SCRIPTS = runall unsupported-ops invalid-filters valid-filters babelstats.pl
+EXTRA_DIST = runall unsupported-ops invalid-filters valid-filters babelstats.pl
--- /dev/null
+#!/usr/bin/perl
+
+# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License, version 2 only, as
+# published by the Free Software Foundation.
+#
+# 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.
+
+use strict;
+use warnings;
+
+use Getopt::Long;
+
+my $opt_tracepoint;
+
+GetOptions('tracepoint=s' => \$opt_tracepoint)
+ or die("Invalid command-line option\n");
+
+defined($opt_tracepoint)
+ or die("Missing tracepoint, use --tracepoint <name>");
+
+# Parse an array string.
+# The format is as follow: [ [index] = value, ... ]
+sub parse_array
+{
+ my ($arr_str) = @_;
+ my @array = ();
+
+ # Strip leading and ending brackets, remove whitespace
+ $arr_str =~ s/^\[//;
+ $arr_str =~ s/\]$//;
+ $arr_str =~ s/\s//g;
+
+ my @entries = split(',', $arr_str);
+
+ foreach my $entry (@entries) {
+ if ($entry =~ /^\[(\d+)\]=(\d+)$/) {
+ my $index = $1;
+ my $value = $2;
+ splice @array, $index, 0, $value;
+ }
+ }
+
+ return \@array;
+}
+
+# Parse fields values.
+# Format can either be a name = array or a name = value pair.
+sub parse_fields
+{
+ my ($fields_str) = @_;
+ my %fields_hash;
+
+ my $field_name = '[\w\d_]+';
+ my $field_value = '[\w\d_\\\*"]+';
+ my $array = '\[(?:\s\[\d+\]\s=\s\d+,)*\s\[\d+\]\s=\s\d+\s\]';
+
+ # Split the various fields
+ my @fields = ($fields_str =~ /$field_name\s=\s(?:$array|$field_value)/g);
+
+ foreach my $field (@fields) {
+ if ($field =~ /($field_name)\s=\s($array)/) {
+ my $name = $1;
+ my $value = parse_array($2);
+ $fields_hash{$name} = $value;
+ }
+
+ if ($field =~ /($field_name)\s=\s($field_value)/) {
+ my $name = $1;
+ my $value = $2;
+ $fields_hash{$name} = $value;
+ }
+ }
+
+ return \%fields_hash;
+}
+
+# Using an event array, merge all the fields
+# of a particular tracepoint.
+sub merge_fields
+{
+ my ($events_ref) = @_;
+ my %merged;
+
+ foreach my $event (@{$events_ref}) {
+ my $tp_provider = $event->{'tp_provider'};
+ my $tp_name = $event->{'tp_name'};
+ my $tracepoint = "$tp_provider:$tp_name";
+
+ foreach my $key (keys %{$event->{'fields'}}) {
+ my $val = $event->{'fields'}->{$key};
+
+ # TODO: Merge of array is not implemented.
+ next if (ref($val) eq 'ARRAY');
+ $merged{$tracepoint}{$key}{$val} = undef;
+ }
+ }
+
+ return \%merged;
+}
+
+# Print the minimum and maximum of each fields
+# for a particular tracepoint.
+sub print_fields_stats
+{
+ my ($merged_ref, $tracepoint) = @_;
+
+ return unless ($tracepoint && exists $merged_ref->{$tracepoint});
+
+ foreach my $field (keys %{$merged_ref->{$tracepoint}}) {
+ my @sorted;
+ my @val = keys ($merged_ref->{$tracepoint}->{$field});
+
+ if ($val[0] =~ /^\d+$/) {
+ # Sort numerically
+ @sorted = sort { $a <=> $b } @val;
+ } elsif ($val[0] =~ /^0x[\da-f]+$/i) {
+ # Convert the hex values and sort numerically
+ @sorted = sort { hex($a) <=> hex($b) } @val;
+ } else {
+ # Fallback, alphabetical sort
+ @sorted = sort { lc($a) cmp lc($b) } @val;
+ }
+
+ my $min = $sorted[0];
+ my $max = $sorted[-1];
+
+ print "$field $min $max\n";
+ }
+}
+
+my @events;
+
+while (<>)
+{
+ my $timestamp = '\[(.*)\]';
+ my $elapsed = '\((.*)\)';
+ my $hostname = '.*';
+ my $pname = '.*';
+ my $pid = '\d+';
+ my $tp_provider = '.*';
+ my $tp_name = '.*';
+ my $cpu_info = '{\scpu_id\s=\s(\d+)\s\}';
+ my $fields = '{(.*)}';
+
+ # Parse babeltrace text output format
+ if (/$timestamp\s$elapsed\s($hostname):($pname):($pid)\s($tp_provider):($tp_name):\s$cpu_info,\s$fields/) {
+ my %event_hash;
+
+ $event_hash{'timestamp'} = $1;
+ $event_hash{'elapsed'} = $2;
+ $event_hash{'hostname'} = $3;
+ $event_hash{'pname'} = $4;
+ $event_hash{'pid'} = $5;
+ $event_hash{'tp_provider'} = $6;
+ $event_hash{'tp_name'} = $7;
+ $event_hash{'cpu_id'} = $8;
+ $event_hash{'fields'} = parse_fields($9);
+
+ push @events, \%event_hash;
+ }
+}
+
+my %merged_fields = %{merge_fields(\@{events})};
+print_fields_stats(\%merged_fields, $opt_tracepoint);
--- /dev/null
+/*
+ * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; version 2.1 of the License.
+ *
+ * This library 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 Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <arpa/inet.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define TRACEPOINT_DEFINE
+#include "tp.h"
+
+int main(int argc, char **argv)
+{
+ int i, netint;
+ long values[] = { 1, 2, 3 };
+ char text[10] = "test";
+ char escape[10] = "\\*";
+ double dbl = 2.0;
+ float flt = 2222.0;
+ /* Generate 30 events. */
+ unsigned int nr_iter = 100;
+ useconds_t nr_usec = 0;
+
+ if (argc >= 2) {
+ nr_iter = atoi(argv[1]);
+ }
+
+ if (argc == 3) {
+ /* By default, don't wait unless user specifies. */
+ nr_usec = atoi(argv[2]);
+ }
+
+ for (i = 0; i < nr_iter; i++) {
+ netint = htonl(i);
+ tracepoint(tp, tptest, i, netint, values, text, strlen(text), escape, dbl, flt);
+ usleep(nr_usec);
+ }
+
+ return 0;
+}
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License, version 2 only, as
+# published by the Free Software Foundation.
+#
+# 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.
+
+TEST_DESC="Filtering - Invalid filters"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+LTTNG_BIN="lttng"
+SESSION_NAME="filter-invalid"
+EVENT_NAME="bogus"
+ENABLE_EVENT_STDERR="/tmp/invalid-filters-stderr"
+TRACE_PATH=$(mktemp -d)
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+function enable_ust_lttng_event_filter
+{
+ sess_name="$1"
+ event_name="$2"
+ filter="$3"
+ echo -n "Enabling lttng event with filtering and invalid filter "
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u --filter "$filter" 2> $ENABLE_EVENT_STDERR 1> /dev/null
+
+ # Enable must fail
+ if [ $? -eq 0 ]; then
+ print_fail
+ return 1
+ else
+ print_ok
+ return 0
+ fi
+}
+
+function test_invalid_filter
+{
+ test_invalid_filter="$1"
+
+ echo ""
+ echo -e "=== Testing filter expression with invalid filter"
+ echo -e "Filter: $test_invalid_filter"
+
+ # Create session
+ create_lttng_session $SESSION_NAME $TRACE_PATH
+
+ # Apply filter
+ enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME "$test_invalid_filter"
+
+ # Destroy session
+ destroy_lttng_session $SESSION_NAME
+}
+
+function test_bytecode_limit
+{
+ # Current bytecode limitation is 65536 bytes long.
+ # Generate a huge bytecode with some perl-fu
+ BYTECODE_LIMIT=`perl -e 'print "intfield" . " && 1" x5460'`
+
+ echo ""
+ echo -e "=== Testing filter bytecode limits (64KiB)"
+
+ # Create session
+ create_lttng_session $SESSION_NAME $TRACE_PATH
+
+ # Apply filter
+ enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME "$BYTECODE_LIMIT"
+
+ # Destroy session
+ destroy_lttng_session $SESSION_NAME
+}
+
+IFS=$'\n'
+INVALID_FILTERS=(
+ # Unsupported ops
+ "intfield*1"
+ "intfield/1"
+ "intfield+1"
+ "intfield-1"
+ "intfield>>1"
+ "intfield<<1"
+ "intfield&1"
+ "intfield|1"
+ "intfield^1"
+ "~intfield"
+ "1+11111-3333+1"
+ "(1+2)*(55*666)"
+ "1+2*55*666"
+ "asdf + 1 > 1"
+ "asdfas < 2332 || asdf + 1 > 1"
+ "!+-+++-------+++++++++++-----!!--!44+1"
+ "aaa||(gg)+(333----1)"
+ "1+1"
+ # Unmatched parenthesis
+ "((((((((((((((intfield)))))))))))))"
+ '0 || ("abc" != "def")) && (3 < 4)'
+ # Field dereference
+ "a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a"
+ "a->"
+ "a-->a"
+ "a->a"
+ "a.b.c->d.e.f+1"
+ "!a.f.d"
+ "asdf.asdfsd.sadf < 4"
+ "asdfasdf->asdfasdf < 2"
+ # String can't be root node
+ "\"somestring\""
+ # Unary op on string not allowed
+ "!\"somestring\""
+ # Comparison with string type not allowed
+ "\"somestring\" > 42"
+ "\"somestring\" > 42.0"
+ "42 > \"somestring\""
+ "42.0 > \"somestring\""
+ # Logical operator with string type not allowed
+ "\"somestring\" || 1"
+ "1 || \"somestring\""
+ # Nesting of binary operator not allowed
+ "1 | (1 | (1 | 1))"
+ "1 > (1 > (1 > 1))"
+ )
+
+start_lttng_sessiond
+for FILTER in ${INVALID_FILTERS[@]};
+do
+ test_invalid_filter "$FILTER"
+done
+
+test_bytecode_limit
+
+unset IFS
+stop_lttng_sessiond
+
+rm -f $ENABLE_EVENT_STDERR
+rm -rf $TRACE_PATH
--- /dev/null
+#!/bin/bash
+
+DIR=$(dirname $0)
+
+tests=( $DIR/unsupported-ops $DIR/invalid-filters $DIR/valid-filters )
+exit_code=0
+
+function start_tests ()
+{
+ for bin in ${tests[@]};
+ do
+ if [ ! -e $bin ]; then
+ echo -e "$bin not found, passing"
+ continue
+ fi
+
+ ./$bin
+ # Test must return 0 to pass.
+ if [ $? -ne 0 ]; then
+ exit_code=1
+ break
+ fi
+ done
+}
+
+start_tests
+
+exit $exit_code
--- /dev/null
+/*
+ * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
+ * IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program for any purpose,
+ * provided the above notices are retained on all copies. Permission to modify
+ * the code and to distribute modified code is granted, provided the above
+ * notices are retained, and a notice that the code was modified is included
+ * with the above copyright notice.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "tp.h"
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER tp
+
+#if !defined(_TRACEPOINT_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_TP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(tp, tptest,
+ TP_ARGS(int, anint, int, netint, long *, values,
+ char *, text, size_t, textlen,
+ char *, etext, double, doublearg, float, floatarg),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer_hex(int, intfield2, anint)
+ ctf_integer(long, longfield, anint)
+ ctf_integer_network(int, netintfield, netint)
+ ctf_integer_network_hex(int, netintfieldhex, netint)
+ ctf_array(long, arrfield1, values, 3)
+ ctf_array_text(char, arrfield2, text, 10)
+ ctf_sequence(char, seqfield1, text, size_t, textlen)
+ ctf_sequence_text(char, seqfield2, text, size_t, textlen)
+ ctf_string(stringfield, text)
+ ctf_string(stringfield2, etext)
+ ctf_float(float, floatfield, floatarg)
+ ctf_float(double, doublefield, doublearg)
+ )
+)
+
+#endif /* _TRACEPOINT_TP_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./tp.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License, version 2 only, as
+# published by the Free Software Foundation.
+#
+# 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.
+
+TEST_DESC="Filtering - Unsupported operators"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+LTTNG_BIN="lttng"
+SESSION_NAME="filter-unsupported-ops"
+EVENT_NAME="bogus"
+ENABLE_EVENT_STDERR="/tmp/unsupported-ops-enable"
+TRACE_PATH=$(mktemp -d)
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+function enable_ust_lttng_event_filter_unsupported
+{
+ sess_name=$1
+ event_name=$2
+ filter=$3
+
+ echo -n "Enabling lttng event with filtering and unsupported operator "
+ enable_cmd="$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event"
+ $enable_cmd $event_name -s $sess_name -u --filter "$filter" 2> $ENABLE_EVENT_STDERR 1> /dev/null
+
+ # Enable must fail
+ if [ $? -eq 0 ]; then
+ print_fail
+ return 1
+ else
+ print_ok
+ return 0
+ fi
+}
+
+function test_unsupported_op
+{
+ test_op_str=$1
+ test_op_tkn=$2
+
+ echo ""
+ echo -e "=== Testing filter expression with unsupported operator $test_op_str ($test_op_tkn)"
+
+ # Create session
+ create_lttng_session $SESSION_NAME $TRACE_PATH
+
+ # Create filter
+ if [ "$test_op_str" == "UNARY_BIN_NOT" ]; then
+ TEST_FILTER="${test_op_tkn}1"
+ else
+ TEST_FILTER="intfield $test_op_tkn 1"
+ fi
+
+ # Apply filter
+ enable_ust_lttng_event_filter_unsupported $SESSION_NAME $EVENT_NAME "$TEST_FILTER"
+
+ # Test stderr for unsupported operator
+ echo -n "Unsupported operator test $test_op_str ($test_op_tkn) "
+ grep -i -q "not[[:space:]]\+supported" $ENABLE_EVENT_STDERR
+
+ if [ $? -eq 1 ]; then
+ print_fail
+ return 1
+ else
+ print_ok
+ fi
+
+ # Destroy session
+ destroy_lttng_session $SESSION_NAME
+ return 0
+}
+
+# Unsupported operators
+OP_STR=("MUL" "DIV" "MOD" "PLUS" "MINUS" "LSHIFT" "RSHIFT"
+ "BIN_AND" "BIN_OR" "BIN_XOR" "UNARY_BIN_NOT")
+
+OP_TKN=("*" "/" "%" "+" "-" "<<" ">>" "&" "|" "^" "~")
+
+OP_COUNT=${#OP_STR[@]}
+i=0
+
+start_lttng_sessiond
+
+while [ "$i" -lt "$OP_COUNT" ]; do
+ test_unsupported_op "${OP_STR[$i]}" "${OP_TKN[$i]}"
+
+ if [ $? -eq 1 ]; then
+ exit 1
+ fi
+
+ let "i++"
+done
+
+stop_lttng_sessiond
+
+# Cleanup
+rm -f $ENABLE_EVENT_STDERR
+rm -rf $TRACE_PATH
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License, version 2 only, as
+# published by the Free Software Foundation.
+#
+# 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.
+
+TEST_DESC="Filtering - Valid filters"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+LTTNG_BIN="lttng"
+BIN_NAME="gen-ust-events"
+STATS_BIN="babelstats.pl"
+SESSION_NAME="valid_filter"
+EVENT_NAME="tp:tptest"
+NR_ITER=100
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+ echo -e "No UST nevents binary detected. Passing."
+ exit 0
+fi
+
+function enable_ust_lttng_event_filter()
+{
+ sess_name="$1"
+ event_name="$2"
+ filter="$3"
+ echo -n "Enabling lttng event with filtering "
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u --filter "$filter" 2>&1 >/dev/null
+
+ if [ $? -eq 0 ]; then
+ print_ok
+ return 0
+ else
+ print_fail
+ return 1
+ fi
+}
+
+function run_apps
+{
+ ./$CURDIR/$BIN_NAME $NR_ITER & >/dev/null 2>&1
+}
+
+function wait_apps
+{
+ echo "Waiting for applications to end"
+ while [ -n "$(pidof $BIN_NAME)" ]; do
+ echo -n "."
+ sleep 1
+ done
+ echo ""
+}
+
+function test_valid_filter
+{
+ filter="$1"
+ validator="$2"
+
+ echo ""
+ echo -e "=== Testing valid filter: $1"
+
+ trace_path=$(mktemp -d)
+
+ # Create session
+ create_lttng_session $SESSION_NAME $trace_path
+
+ # Enable filter
+ enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME $filter
+
+ # Trace apps
+ start_lttng_tracing $SESSION_NAME
+ run_apps
+ wait_apps
+ stop_lttng_tracing $SESSION_NAME
+
+ # Destroy session
+ destroy_lttng_session $SESSION_NAME
+
+ echo -n "Validating filter output "
+ stats=`babeltrace $trace_path | $CURDIR/$STATS_BIN --tracepoint $EVENT_NAME`
+
+ rm -rf $trace_path
+
+ $validator "$stats"
+
+ if [ $? -eq 0 ]; then
+ print_ok
+# rm -rf $trace_path
+ return 0
+ else
+ print_fail
+ return 1
+ fi
+}
+
+function validate_min_max
+{
+ stats="$1"
+ field=$2
+ expected_min=$3
+ expected_max=$4
+
+ echo $stats | grep -q "$field $expected_min $expected_max"
+
+ return $?
+}
+
+function validator_intfield
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "1" "99"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "intfield2" "0x1" "0x63"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "longfield" "1" "99"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "netintfield" "1" "99"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "netintfieldhex" "0x1" "0x63"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "floatfield" "2222" "2222"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "doublefield" "2" "2"
+ status=$(($status|$?))
+
+ return $status
+}
+
+function validator_intfield_gt
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "2" "99"
+ status=$(($status|$?))
+
+ return $status
+}
+
+function validator_intfield_ge
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "1" "99"
+ status=$(($status|$?))
+
+ return $status
+}
+
+function validator_intfield_lt
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "0" "1"
+ status=$(($status|$?))
+
+ return $status
+}
+
+function validator_intfield_le
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "0" "2"
+ status=$(($status|$?))
+
+ return $status
+}
+
+function validator_intfield_eq
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "1" "1"
+ status=$(($status|$?))
+
+ return $status
+}
+
+function validator_intfield_ne
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "0" "98"
+ status=$(($status|$?))
+
+ return $status
+}
+
+function validator_intfield_not
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "0" "0"
+ status=$(($status|$?))
+
+ return $status
+}
+
+function validator_intfield_gt_and_longfield_gt
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "43" "99"
+ status=$(($status|$?))
+ validate_min_max "$stats" "longfield" "43" "99"
+ status=$(($status|$?))
+
+ return $status
+}
+
+function validator_intfield_ge_and_longfield_le
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "42" "42"
+ status=$(($status|$?))
+ validate_min_max "$stats" "longfield" "42" "42"
+ status=$(($status|$?))
+
+ return $status
+}
+
+function validator_intfield_lt_or_longfield_gt
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "0" "99"
+ status=$(($status|$?))
+ validate_min_max "$stats" "longfield" "0" "99"
+ status=$(($status|$?))
+
+ return $status
+}
+
+function validator_mixed_str_or_int_and_int
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "34" "99"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "stringfield" "\"test\"" "\"test\""
+ status=$(($status|$?))
+
+ return $status
+}
+
+function validator_mixed_int_double
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "0" "42"
+ status=$(($status|$?))
+
+ return $status
+}
+
+function validator_true_statement
+{
+ stats="$1"
+ status=0
+
+ validate_min_max "$stats" "intfield" "0" "99"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "intfield2" "0x0" "0x63"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "longfield" "0" "99"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "netintfield" "0" "99"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "netintfieldhex" "0x0" "0x63"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "floatfield" "2222" "2222"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "doublefield" "2" "2"
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "stringfield" "\"test\"" "\"test\""
+ status=$(($status|$?))
+
+ validate_min_max "$stats" "stringfield2" ""\*"" ""\*""
+ status=$(($status|$?))
+
+ return $status
+}
+
+IFS=$'\n'
+
+issue_356_filter="intfield > 0 && intfield > 1 && "
+issue_356_filter+="intfield > 2 && intfield > 3 && "
+issue_356_filter+="intfield > 4 && intfield > 5 && "
+issue_356_filter+="intfield > 6 && intfield > 7 && "
+issue_356_filter+="intfield > 8 || intfield > 0"
+
+# One to one mapping between filters and validators
+
+FILTERS=("intfield" #1
+ "intfield > 1" #2
+ "intfield >= 1" #3
+ "intfield < 2" #4
+ "intfield <= 2" #5
+ "intfield == 1" #6
+ "intfield != 99" #7
+ "!intfield" #8
+ "-intfield" #9
+ "--intfield" #10
+ "+intfield" #11
+ "++intfield" #12
+ "intfield > 1 && longfield > 42" #13
+ "intfield >= 42 && longfield <= 42" #14
+ "intfield < 1 || longfield > 98" #15
+ "(stringfield == \"test\" || intfield != 10) && intfield > 33" #16
+ "intfield < 42.4242424242" #17
+ "\"test\" == \"test\"" #18 #Issue #342
+ "stringfield == \"test\"" #19
+ "stringfield == \"t*\"" #20
+ "stringfield == \"*\"" #21
+ $issue_356_filter #22 #Issue #356
+ "intfield < 0xDEADBEEF" #23
+ "intfield < 0x2" #24
+ "intfield < 02" #25
+ "stringfield2 == \"\\\*\"" #26
+ "1.0 || intfield || 1.0" #27
+ "1 < intfield" #28
+)
+
+VALIDATOR=("validator_intfield" #1
+ "validator_intfield_gt" #2
+ "validator_intfield_ge" #3
+ "validator_intfield_lt" #4
+ "validator_intfield_le" #5
+ "validator_intfield_eq" #6
+ "validator_intfield_ne" #7
+ "validator_intfield_not" #8
+ "validator_intfield" #9
+ "validator_intfield" #10
+ "validator_intfield" #11
+ "validator_intfield" #12
+ "validator_intfield_gt_and_longfield_gt" #13
+ "validator_intfield_ge_and_longfield_le" #14
+ "validator_intfield_lt_or_longfield_gt" #15
+ "validator_mixed_str_or_int_and_int" #16
+ "validator_mixed_int_double" #17
+ "validator_true_statement" #18
+ "validator_true_statement" #19
+ "validator_true_statement" #20
+ "validator_true_statement" #21
+ "validator_intfield" #22
+ "validator_true_statement" #23
+ "validator_intfield_lt" #24
+ "validator_intfield_lt" #25
+ "validator_true_statement" #26
+ "validator_true_statement" #27
+ "validator_intfield_gt" #28
+)
+
+FILTER_COUNT=${#FILTERS[@]}
+i=0
+
+start_lttng_sessiond
+
+while [ "$i" -lt "$FILTER_COUNT" ]; do
+
+ test_valid_filter "${FILTERS[$i]}" "${VALIDATOR[$i]}"
+
+ if [ $? -eq 1 ]; then
+ stop_lttng_sessiond
+ exit 1
+ fi
+
+ let "i++"
+done
+
+stop_lttng_sessiond
--- /dev/null
+AM_CFLAGS = -I. -O2 -g -I$(top_srcdir)/include
+AM_LDFLAGS =
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+AM_LDFLAGS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+AM_LDFLAGS += -lc
+endif
+
+if NO_SHARED
+# Do not build this test if shared libraries support was
+# explicitly disabled.
+else
+# In order to test the health check feature, the libhealth* libs
+# must be built as .so to be able to LD_PRELOAD them.
+FORCE_SHARED_LIB_OPTIONS = -module -shared -avoid-version \
+ -rpath $(abs_builddir)
+
+# Health thread exit ld_preloaded test lib
+libhealthexit_la_SOURCES=health_exit.c
+libhealthexit_la_LDFLAGS= $(FORCE_SHARED_LIB_OPTIONS)
+
+# Health thread stall ld_preloaded test lib
+libhealthstall_la_SOURCES=health_stall.c
+libhealthstall_la_LDFLAGS= $(FORCE_SHARED_LIB_OPTIONS)
+
+# Health thread fail ld_preloaded test lib
+libhealthtpfail_la_SOURCES=health_fail.c
+libhealthtpfail_la_LDFLAGS= $(FORCE_SHARED_LIB_OPTIONS)
+
+noinst_PROGRAMS = health_check
+noinst_LTLIBRARIES = libhealthexit.la libhealthstall.la libhealthtpfail.la
+
+health_check_SOURCES = health_check.c $(UTILS)
+health_check_LDADD = $(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la \
+ $(top_builddir)/src/common/libcommon.la
+endif
+
+noinst_SCRIPTS = runall
+EXTRA_DIST = runall
--- /dev/null
+/*
+ * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+
+#include "lttng/lttng.h"
+
+#define HEALTH_CMD_FAIL (1 << 0)
+#define HEALTH_APP_MNG_FAIL (1 << 1)
+#define HEALTH_APP_REG_FAIL (1 << 2)
+#define HEALTH_KERNEL_FAIL (1 << 3)
+#define HEALTH_CSMR_FAIL (1 << 4)
+
+int main(int argc, char *argv[])
+{
+ int health = -1;
+ int status = 0;
+
+ /* Command thread */
+ health = lttng_health_check(LTTNG_HEALTH_CMD);
+ printf("Health check cmd: %d\n", health);
+
+ if (health) {
+ status |= HEALTH_CMD_FAIL;
+ }
+
+ /* App manage thread */
+ health = lttng_health_check(LTTNG_HEALTH_APP_MANAGE);
+ printf("Health check app. manage: %d\n", health);
+
+ if (health) {
+ status |= HEALTH_APP_MNG_FAIL;
+ }
+ /* App registration thread */
+ health = lttng_health_check(LTTNG_HEALTH_APP_REG);
+ printf("Health check app. registration: %d\n", health);
+
+ if (health) {
+ status |= HEALTH_APP_REG_FAIL;
+ }
+
+ /* Kernel thread */
+ health = lttng_health_check(LTTNG_HEALTH_KERNEL);
+ printf("Health check kernel: %d\n", health);
+
+ if (health) {
+ status |= HEALTH_KERNEL_FAIL;
+ }
+
+ /* Consumer thread */
+ health = lttng_health_check(LTTNG_HEALTH_CONSUMER);
+ printf("Health check consumer: %d\n", health);
+
+ if (health) {
+ status |= HEALTH_CSMR_FAIL;
+ }
+
+ return status;
+}
--- /dev/null
+/*
+ * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+
+/*
+ * Check if the specified environment variable is set.
+ * Return 1 if set, otherwise 0.
+ */
+int check_env_var(const char *env)
+{
+ if (env) {
+ char *env_val = getenv(env);
+ if (env_val && (strncmp(env_val, "1", 1) == 0)) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+int __testpoint_thread_manage_clients(void)
+{
+ const char *var = "LTTNG_THREAD_MANAGE_CLIENTS_EXIT";
+
+ if (check_env_var(var)) {
+ pthread_exit(NULL);
+ }
+
+ return 0;
+}
+
+int __testpoint_thread_registration_apps(void)
+{
+ const char *var = "LTTNG_THREAD_REG_APPS_EXIT";
+
+ if (check_env_var(var)) {
+ pthread_exit(NULL);
+ }
+
+ return 0;
+}
+
+int __testpoint_thread_manage_apps(void)
+{
+ const char *var = "LTTNG_THREAD_MANAGE_APPS_EXIT";
+
+ if (check_env_var(var)) {
+ pthread_exit(NULL);
+ }
+
+ return 0;
+}
+
+int __testpoint_thread_manage_kernel(void)
+{
+ const char *var = "LTTNG_THREAD_MANAGE_KERNEL_EXIT";
+
+ if (check_env_var(var)) {
+ pthread_exit(NULL);
+ }
+
+ return 0;
+}
+
+int __testpoint_thread_manage_consumer(void)
+{
+ const char *var = "LTTNG_THREAD_MANAGE_CONSUMER_EXIT";
+
+ if (check_env_var(var)) {
+ pthread_exit(NULL);
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+
+/*
+ * Check if the specified environment variable is set.
+ * Return 1 if set, otherwise 0.
+ */
+int check_env_var(const char *env)
+{
+ if (env) {
+ char *env_val = getenv(env);
+ if (env_val && (strncmp(env_val, "1", 1) == 0)) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+int __testpoint_thread_manage_clients(void)
+{
+ const char *var = "LTTNG_THREAD_MANAGE_CLIENTS_TP_FAIL";
+
+ if (check_env_var(var)) {
+ return 1;
+ }
+
+ return 0;
+}
+
+int __testpoint_thread_manage_apps(void)
+{
+ const char *var = "LTTNG_THREAD_MANAGE_APPS_TP_FAIL";
+
+ if (check_env_var(var)) {
+ return 1;
+ }
+
+ return 0;
+}
+
+int __testpoint_thread_manage_kernel(void)
+{
+ const char *var = "LTTNG_THREAD_MANAGE_KERNEL_TP_FAIL";
+
+ if (check_env_var(var)) {
+ return 1;
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#define STALL_TIME 60
+
+/*
+ * Check if the specified environment variable is set.
+ * Return 1 if set, otherwise 0.
+ */
+int check_env_var(const char *env)
+{
+ if (env) {
+ char *env_val = getenv(env);
+ if (env_val && (strncmp(env_val, "1", 1) == 0)) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+int __testpoint_thread_manage_clients_before_loop(void)
+{
+ const char *var = "LTTNG_THREAD_MANAGE_CLIENTS_STALL";
+
+ if (check_env_var(var)) {
+ unsigned int sleep_time = STALL_TIME;
+ while (sleep_time > 0) {
+ sleep_time = sleep(sleep_time);
+ }
+ }
+
+ return 0;
+}
+
+int __testpoint_thread_manage_kernel_before_loop(void)
+{
+ const char *var = "LTTNG_THREAD_MANAGE_KERNEL_STALL";
+
+ if (check_env_var(var)) {
+ unsigned int sleep_time = STALL_TIME;
+ while (sleep_time > 0) {
+ sleep_time = sleep(sleep_time);
+ }
+ }
+
+ return 0;
+}
+
+int __testpoint_thread_manage_apps_before_loop(void)
+{
+ const char *var = "LTTNG_THREAD_MANAGE_APPS_STALL";
+
+ if (check_env_var(var)) {
+ unsigned int sleep_time = STALL_TIME;
+ while (sleep_time > 0) {
+ sleep_time = sleep(sleep_time);
+ }
+ }
+
+ return 0;
+}
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License, version 2 only, as
+# published by the Free Software Foundation.
+#
+# 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.
+
+TEST_DESC="Health check - Thread exit"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+LTTNG_BIN="lttng"
+SESSION_NAME="health_thread_exit"
+EVENT_NAME="bogus"
+HEALTH_CHECK_BIN="health_check"
+SESSIOND_PRELOAD=".libs/libhealthexit.so"
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
+ echo -e "libhealthexit.so not available for this test. Skipping."
+ exit 0
+fi
+
+function test_thread_exit
+{
+ test_thread_exit_name="$1"
+ test_thread_exit_code="$2"
+
+ echo ""
+ echo -e "=== Testing health failure with ${test_thread_exit_name}"
+
+ # Activate testpoints
+ export LTTNG_TESTPOINT_ENABLE=1
+
+ # Activate specific thread exit
+ export ${test_thread_exit_name}_EXIT=1
+
+ # Spawn sessiond with preload healthexit lib
+ export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD"
+ start_lttng_sessiond
+
+ # Cleanup some env. var.
+ unset LD_PRELOAD
+ unset ${test_thread_exit_name}_EXIT
+
+ # Check initial health status
+ $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
+
+ echo -n "Validating thread ${test_thread_exit_name} failure... "
+
+ # Wait
+ sleep 25
+
+ # Check health status, exit code should indicate failure
+ $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
+
+ health_check_exit_code=$?
+
+ if [ $health_check_exit_code -eq $test_thread_exit_code ]; then
+ print_ok
+ stop_lttng_sessiond
+ else
+ print_fail
+ echo -e "Health returned: $health_check_exit_code\n"
+
+ stop_lttng_sessiond
+ return 1
+ fi
+}
+
+THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
+ "LTTNG_THREAD_MANAGE_APPS"
+ "LTTNG_THREAD_REG_APPS"
+ "LTTNG_THREAD_MANAGE_KERNEL")
+
+# Exit code value to indicate specific thread failure
+EXIT_CODE=(1 2 4 8)
+
+THREAD_COUNT=${#THREAD[@]}
+i=0
+while [ "$i" -lt "$THREAD_COUNT" ]; do
+ test_thread_exit "${THREAD[$i]}" "${EXIT_CODE[$i]}"
+
+ if [ $? -eq 1 ]; then
+ exit 1
+ fi
+
+ let "i++"
+done
+
+# Special case manage consumer, need to spawn consumer via commands.
+#"LTTNG_THREAD_MANAGE_CONSUMER"
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License, version 2 only, as
+# published by the Free Software Foundation.
+#
+# 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.
+
+TEST_DESC="Health check - Thread stall"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+LTTNG_BIN="lttng"
+SESSION_NAME="health_thread_stall"
+EVENT_NAME="bogus"
+HEALTH_CHECK_BIN="health_check"
+SESSIOND_PRELOAD=".libs/libhealthstall.so"
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
+ echo -e "libhealthstall.so not available for this test. Skipping."
+ exit 0
+fi
+
+function test_thread_stall
+{
+ test_thread_stall_name="$1"
+ test_thread_exit_code="$2"
+
+ echo ""
+ echo -e "=== Testing health failure with ${test_thread_stall_name}"
+
+ # Activate testpoints
+ export LTTNG_TESTPOINT_ENABLE=1
+
+ # Activate specific thread exit
+ export ${test_thread_stall_name}_STALL=1
+
+ # Spawn sessiond with preload healthexit lib
+ export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD"
+ start_lttng_sessiond
+
+ # Cleanup some env. var.
+ unset LD_PRELOAD
+ unset ${test_thread_stall_name}_STALL
+
+ # Check initial health status
+ $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
+
+ echo -n "Validating that ${test_thread_stall_name} is stalled... "
+
+ # Wait
+ sleep 25
+
+ # Check health status, exit code should indicate failure
+ $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
+
+ health_check_exit_code=$?
+
+ if [ $health_check_exit_code -eq $test_thread_exit_code ]; then
+ print_ok
+ else
+ print_fail
+ echo -e "Health returned: $health_check_exit_code\n"
+
+ stop_lttng_sessiond
+ return 1
+ fi
+
+ echo -n "Validating that ${test_thread_stall_name} is no longer stalled... "
+
+ # Wait
+ sleep 40
+
+ # Check health status, exit code should now pass
+ $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
+
+ health_check_exit_code=$?
+
+ if [ $health_check_exit_code -eq 0 ]; then
+ print_ok
+ stop_lttng_sessiond
+ else
+ print_fail
+ echo -e "Health returned: $health_check_exit_code\n"
+ stop_lttng_sessiond
+ return 1
+ fi
+
+
+}
+
+THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
+ "LTTNG_THREAD_MANAGE_APPS"
+# This thread is a little bit tricky to stall,
+# need to send some commands and setup an app.
+# "LTTNG_THREAD_REG_APPS"
+ "LTTNG_THREAD_MANAGE_KERNEL")
+
+# Exit code value to indicate specific thread failure
+EXIT_CODE=(1
+ 2
+# 4
+ 8)
+
+THREAD_COUNT=${#THREAD[@]}
+i=0
+while [ "$i" -lt "$THREAD_COUNT" ]; do
+ test_thread_stall "${THREAD[$i]}" "${EXIT_CODE[$i]}"
+
+ if [ $? -eq 1 ]; then
+ exit 1
+ fi
+
+ let "i++"
+done
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License, version 2 only, as
+# published by the Free Software Foundation.
+#
+# 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.
+
+TEST_DESC="Health check - Testpoint failure"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+LTTNG_BIN="lttng"
+SESSION_NAME="health_tp_fail"
+EVENT_NAME="bogus"
+HEALTH_CHECK_BIN="health_check"
+SESSIOND_PRELOAD=".libs/libhealthtpfail.so"
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
+ echo -e "libhealthtpfail.so not available for this test. Skipping."
+ exit 0
+fi
+
+function test_tp_fail
+{
+ test_tp_fail_name="$1"
+ test_tp_fail_code="$2"
+
+ echo ""
+ echo -e "=== Testing health failure with ${test_tp_fail_name}"
+
+ # Activate testpoints
+ export LTTNG_TESTPOINT_ENABLE=1
+
+ # Activate specific testpoint failure
+ export ${test_tp_fail_name}_TP_FAIL=1
+
+ # Spawn sessiond with preload healthexit lib
+ export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD"
+ start_lttng_sessiond
+
+ # Cleanup some env. var.
+ unset LD_PRELOAD
+ unset ${test_tp_fail_name}_TP_FAIL
+
+ echo -n "Validating thread ${test_tp_fail_name} failure... "
+
+ # Check health status, exit code should indicate failure
+ $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
+
+ health_check_exit_code=$?
+
+ if [ $health_check_exit_code -eq $test_tp_fail_code ]; then
+ print_ok
+ stop_lttng_sessiond
+ else
+ print_fail
+ echo -e "Health returned: $health_check_exit_code\n"
+
+ stop_lttng_sessiond
+ return 1
+ fi
+}
+
+THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
+ "LTTNG_THREAD_MANAGE_APPS"
+ "LTTNG_THREAD_MANAGE_KERNEL")
+
+# Exit code value to indicate specific thread failure
+EXIT_CODE=(1 2 8)
+
+THREAD_COUNT=${#THREAD[@]}
+i=0
+while [ "$i" -lt "$THREAD_COUNT" ]; do
+ test_tp_fail "${THREAD[$i]}" "${EXIT_CODE[$i]}"
+
+ if [ $? -eq 1 ]; then
+ exit 1
+ fi
+
+ let "i++"
+done
+
+# Special case manage consumer, need to spawn consumer via commands.
+#"LTTNG_THREAD_MANAGE_CONSUMER"
--- /dev/null
+#!/bin/bash
+
+DIR=$(dirname $0)
+
+tests=( $DIR/health_thread_exit $DIR/health_thread_stall $DIR/health_tp_fail)
+exit_code=0
+
+function start_tests ()
+{
+ for bin in ${tests[@]};
+ do
+ if [ ! -e $bin ]; then
+ echo -e "$bin not found, passing"
+ continue
+ fi
+
+ ./$bin
+ # Test must return 0 to pass.
+ if [ $? -ne 0 ]; then
+ exit_code=1
+ break
+ fi
+ done
+}
+
+if [ "$(id -u)" != "0" ]; then
+ echo -e "Need root for health test."
+ exit 0
+fi
+
+start_tests
+
+exit $exit_code
--- /dev/null
+#!/bin/bash
+
+DIR=$(dirname $0)
+
+tests=( $DIR/test_kernel_data_trace $DIR/test_sessions $DIR/test_ust_data_trace \
+ $DIR/streaming/runall $DIR/health/runall $DIR/filtering/runall)
+
+exit_code=0
+
+function start_tests ()
+{
+ for bin in ${tests[@]};
+ do
+ if [ ! -e $bin ]; then
+ echo -e "$bin not found, passing"
+ continue
+ fi
+
+ ./$bin
+ # Test must return 0 to pass.
+ if [ $? -ne 0 ]; then
+ exit_code=1
+ break
+ fi
+ done
+}
+
+start_tests
+
+exit $exit_code
--- /dev/null
+AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests/utils -I$(srcdir) -O2 -g
+AM_LDFLAGS =
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+AM_LDFLAGS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+AM_LDFLAGS += -lc
+endif
+
+#UTILS=../../utils.h
+UTILS=
+LIBSESSIOND_COMM=$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la
+LIBCOMMON=$(top_builddir)/src/common/libcommon.la
+
+noinst_PROGRAMS = unit_tests
+unit_tests_SOURCES = unit_tests.c $(UTILS)
+unit_tests_LDADD = $(LIBCOMMON)
+
+if HAVE_LIBLTTNG_UST_CTL
+noinst_PROGRAMS += gen-ust-events
+gen_ust_events_SOURCES = gen-ust-events.c tp.c tp.h
+gen_ust_events_LDADD = -llttng-ust
+endif
+
+noinst_SCRIPTS = runall run-ust run-kernel uri_switch
+EXTRA_DIST = runall run-ust run-kernel uri_switch
--- /dev/null
+/*
+ * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; version 2.1 of the License.
+ *
+ * This library 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 Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <arpa/inet.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define TRACEPOINT_DEFINE
+#include "tp.h"
+
+int main(int argc, char **argv)
+{
+ int i, netint;
+ long values[] = { 1, 2, 3 };
+ char text[10] = "test";
+ double dbl = 2.0;
+ float flt = 2222.0;
+ /* Generate 30 events. */
+ unsigned int nr_iter = 100;
+ useconds_t nr_usec = 0;
+
+ if (argc >= 2) {
+ nr_iter = atoi(argv[1]);
+ }
+
+ if (argc == 3) {
+ /* By default, don't wait unless user specifies. */
+ nr_usec = atoi(argv[2]);
+ }
+
+ for (i = 0; i < nr_iter; i++) {
+ netint = htonl(i);
+ tracepoint(tp, tptest, i, netint, values, text, strlen(text), dbl,
+ flt);
+ usleep(nr_usec);
+ }
+
+ return 0;
+}
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
+# David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library 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 Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+TEST_DESC="Streaming - High throughput with bandwidth limits"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+NR_APP_ITER=10
+NR_ITER=1000000
+BIN_NAME="gen-ust-events"
+SESSION_NAME="high-throughput"
+EVENT_NAME="tp:tptest"
+SESSIOND_CTRL_PORT=5342
+SESSIOND_DATA_PORT=5343
+DEFAULT_IF="lo"
+
+TRACE_PATH=$(mktemp -d)
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+ echo -e "No UST nevents binary detected. Passing."
+ exit 0
+fi
+
+if [ "$(id -u)" != "0" ]; then
+ echo "This test must be running as root to set bandwidth limits. Aborting"
+ # Exit status 0 so the tests can continue
+ exit 0
+fi
+
+function set_bw_limit
+{
+ limit=$1
+ ctrlportlimit=$(($limit/10))
+ # failsafe to have at least 1kbit/s for control (in the case where $1 < 10)
+ [ $ctrlportlimit = 0 ] && ctrlportlimit=1
+ # if $1 < 10, we might bust the limit set here, but the
+ # parent qdisc (1:) will always limit us to the right max value
+ dataportlimit=$((9*${ctrlportlimit}))
+
+ echo -n "Setting bandwidth limits to ${limit}kbits, (${ctrlportlimit} for control and ${dataportlimit} for data)... "
+ tc qdisc add dev $DEFAULT_IF root handle 1: htb default 15 >/dev/null 2>&1
+
+ # the total bandwidth is the limit set by the user
+ tc class add dev $DEFAULT_IF parent 1: classid 1:1 htb rate ${limit}kbit ceil ${limit}kbit >/dev/null 2>&1
+ # 1/10 of the bandwidth guaranteed and traffic prioritized for the control port
+ tc class add dev $DEFAULT_IF parent 1:1 classid 1:10 htb rate ${ctrlportlimit}kbit ceil ${limit}kbit prio 1 >/dev/null 2>&1
+ # 9/10 of the bandwidth guaranteed and can borrow up to the total bandwidth (if unused)
+ tc class add dev $DEFAULT_IF parent 1:1 classid 1:11 htb rate ${dataportlimit}kbit ceil ${limit}kbit prio 2 >/dev/null 2>&1
+
+ # filter to assign control traffic to the 1:10 class
+ tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_CTRL_PORT 0xffff flowid 1:10 >/dev/null 2>&1
+ # filter to assign data traffic to the 1:11 class
+ tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_DATA_PORT 0xffff flowid 1:11 >/dev/null 2>&1
+ print_ok
+}
+
+function reset_bw_limit
+{
+ echo -n "Resetting bandwidth limits... "
+ tc qdisc del dev $DEFAULT_IF root >/dev/null 2>&1
+ print_ok
+}
+
+function create_lttng_session_with_uri
+{
+ sess_name=$1
+ uri=$2
+ # Create session with custom URI
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN create -U $uri $sess_name >/dev/null 2>&1
+}
+
+function enable_lttng_consumer
+{
+ uri=$1
+ # Create session with custom URI
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u $uri >/dev/null 2>&1
+}
+
+function run_apps
+{
+ for i in `seq 1 $NR_APP_ITER`; do
+ # With bandwidth limitation, unfortunately, application easily timeout
+ # due to very slow communication between the consumer and relayd making
+ # the status reply from the consumer quite slow thus delaying the
+ # registration done message.
+ LTTNG_UST_REGISTER_TIMEOUT=-1 ./$CURDIR/$BIN_NAME $NR_ITER & >/dev/null 2>&1
+ done
+}
+
+function wait_apps
+{
+ echo "Waiting for applications to end"
+ while [ -n "$(pidof $BIN_NAME)" ]; do
+ echo -n "."
+ sleep 1
+ done
+ echo ""
+}
+
+function test_high_throughput
+{
+ NETWORK_URI="net://localhost"
+ create_lttng_session_with_uri $SESSION_NAME $NETWORK_URI
+ enable_lttng_consumer $NETWORK_URI
+ enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+ start_lttng_tracing $SESSION_NAME
+ run_apps
+ wait_apps
+
+ stop_lttng_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+ validate_event_count
+}
+
+function validate_event_count
+{
+
+ TEMP_FILE=$(mktemp)
+ TEMP_FILE_2=$(mktemp)
+
+ traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l)
+ babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2
+
+ cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE
+
+ dropped=0
+ while read line;
+ do
+ let dropped=$dropped+$line
+ done < $TEMP_FILE
+
+ let total=$dropped+$traced
+ let wanted=$NR_APP_ITER*$NR_ITER
+
+ if [ $wanted -ne $total ]; then
+ echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
+ print_fail
+ return 1
+ else
+ echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
+ print_ok
+
+ # Cleanup only if everything is ok and passes.
+ rm -rf $TRACE_PATH
+ rm $TEMP_FILE $TEMP_FILE_2
+
+ return 0
+ fi
+}
+
+function interrupt_cleanup()
+{
+ echo -en "\n*** Exiting ***\n"
+ stop_lttng_relayd
+ stop_lttng_sessiond
+ reset_bw_limit
+ exit 1
+}
+
+# Catch sigint and try to cleanup limits
+trap interrupt_cleanup SIGINT
+
+BW_LIMITS=(3200 1600 800 400 200 100 50 25)
+for BW in ${BW_LIMITS[@]};
+do
+ echo ""
+ echo -e "=== Testing high-throughput with bandwidth limit set to ${BW}kbits"
+ set_bw_limit $BW
+
+ start_lttng_sessiond
+ start_lttng_relayd "-o $TRACE_PATH"
+ test_high_throughput
+ result=$?
+ stop_lttng_relayd
+ stop_lttng_sessiond
+ reset_bw_limit
+
+ if [ $result -ne 0 ]; then
+ exit 1
+ fi
+done
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library 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 Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+TEST_DESC="Streaming - Kernel tracing"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+EVENT_NAME="sched_switch"
+PID_RELAYD=0
+SESSION_NAME=""
+
+TRACE_PATH=$(mktemp -d)
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ "$(id -u)" != "0" ]; then
+ echo "This test must be running as root. Aborting"
+ # Exit status 0 so the tests can continue
+ exit 0
+fi
+
+# LTTng kernel modules check
+out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
+if [ -z "$out" ]; then
+ echo "LTTng modules not detected. Aborting kernel tests!"
+ echo ""
+ # Exit status 0 so the tests can continue
+ exit 0
+fi
+
+function lttng_create_session_uri
+{
+ echo -n "Creating session $SESSION_NAME... "
+ # Create session with default path
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ print_fail
+ return 1
+ else
+ print_ok
+ fi
+}
+
+function test_kernel_before_start ()
+{
+ echo -e "\n=== Testing kernel streaming with event enable BEFORE start\n"
+ lttng_create_session_uri
+ lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
+ start_lttng_tracing $SESSION_NAME
+ # Give a second
+ sleep 1
+ stop_lttng_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+
+ # We can not predict _yet_ when the trace is available so we have to do a
+ # arbitratry sleep to validate the trace.
+ echo -n "Waiting 3 seconds for the trace to be written on disk "
+ for i in `seq 1 3`; do
+ echo -n "."
+ sleep 1
+ done
+ echo ""
+}
+
+# Deactivated since this feature is not yet available where we can enable
+# an event AFTERE tracing has started.
+function test_kernel_after_start ()
+{
+ echo -e "\n=== Testing kernel streaming with event enable AFTER start\n"
+ lttng_create_session_uri
+ start_lttng_tracing $SESSION_NAME
+ lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
+ # Give a second
+ sleep 1
+ stop_lttng_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+}
+
+start_lttng_sessiond
+start_lttng_relayd "-o $TRACE_PATH"
+
+tests=( test_kernel_before_start )
+
+for fct_test in ${tests[@]};
+do
+ SESSION_NAME=$(randstring 16 0)
+ ${fct_test}
+
+ # Validate test
+ validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
+ if [ $? -eq 0 ]; then
+ # Only delete if successful
+ rm -rf $TRACE_PATH
+ else
+ break
+ fi
+done
+
+echo ""
+stop_lttng_sessiond
+stop_lttng_relayd
+
+
+exit $out
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library 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 Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+TEST_DESC="Streaming - User space tracing"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+BIN_NAME="gen-ust-events"
+SESSION_NAME="stream"
+EVENT_NAME="tp:tptest"
+PID_RELAYD=0
+
+TRACE_PATH=$(mktemp -d)
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+ echo -e "No UST nevents binary detected. Passing."
+ exit 0
+fi
+
+function lttng_create_session_uri
+{
+ # Create session with default path
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
+}
+
+function wait_apps
+{
+ echo -n "Waiting for applications to end"
+ while [ -n "$(pidof $BIN_NAME)" ]; do
+ echo -n "."
+ sleep 0.5
+ done
+ echo ""
+}
+
+# MUST set TESTDIR before calling those functions
+
+function test_ust_before_start ()
+{
+ echo -e "\n=== Testing UST streaming BEFORE tracing starts\n"
+ lttng_create_session_uri
+ enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+
+ # Run 5 times with a 1 second delay
+ ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 &
+
+ start_lttng_tracing $SESSION_NAME
+
+ wait_apps
+ stop_lttng_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+}
+
+function test_ust_after_start ()
+{
+ echo -e "\n=== Testing UST streaming AFTER tracing starts\n"
+ lttng_create_session_uri
+ enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+ start_lttng_tracing $SESSION_NAME
+
+ # Run 5 times with a 1 second delay
+ ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 &
+
+ wait_apps
+ stop_lttng_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+}
+
+start_lttng_sessiond
+start_lttng_relayd "-o $TRACE_PATH"
+
+tests=( test_ust_before_start test_ust_after_start )
+
+for fct_test in ${tests[@]};
+do
+ SESSION_NAME=$(randstring 16 0)
+ ${fct_test}
+
+ # Validate test
+ validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
+ if [ $? -eq 0 ]; then
+ # Only delete if successful
+ rm -rf $TRACE_PATH
+ else
+ break
+ fi
+done
+
+echo ""
+stop_lttng_sessiond
+stop_lttng_relayd
+
+exit $out
--- /dev/null
+#!/bin/bash
+
+DIR=$(dirname $0)
+
+tests=( $DIR/unit_tests $DIR/run-kernel $DIR/run-ust )
+exit_code=0
+
+function start_tests ()
+{
+ for bin in ${tests[@]};
+ do
+ if [ ! -e $bin ]; then
+ echo -e "$bin not found, passing"
+ continue
+ fi
+
+ ./$bin
+ # Test must return 0 to pass.
+ if [ $? -ne 0 ]; then
+ exit_code=1
+ break
+ fi
+ done
+}
+
+start_tests
+
+exit $exit_code
--- /dev/null
+/*
+ * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
+ * IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program for any purpose,
+ * provided the above notices are retained on all copies. Permission to modify
+ * the code and to distribute modified code is granted, provided the above
+ * notices are retained, and a notice that the code was modified is included
+ * with the above copyright notice.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "tp.h"
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER tp
+
+#if !defined(_TRACEPOINT_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_TP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(tp, tptest,
+ TP_ARGS(int, anint, int, netint, long *, values,
+ char *, text, size_t, textlen,
+ double, doublearg, float, floatarg),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer_hex(int, intfield2, anint)
+ ctf_integer(long, longfield, anint)
+ ctf_integer_network(int, netintfield, netint)
+ ctf_integer_network_hex(int, netintfieldhex, netint)
+ ctf_array(long, arrfield1, values, 3)
+ ctf_array_text(char, arrfield2, text, 10)
+ ctf_sequence(char, seqfield1, text, size_t, textlen)
+ ctf_sequence_text(char, seqfield2, text, size_t, textlen)
+ ctf_string(stringfield, text)
+ ctf_float(float, floatfield, floatarg)
+ ctf_float(double, doublefield, doublearg)
+ )
+)
+
+#endif /* _TRACEPOINT_TP_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./tp.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * 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 <sys/types.h>
+
+#include <common/sessiond-comm/sessiond-comm.h>
+#include <common/uri.h>
+
+#include "utils.h"
+
+/* This path will NEVER be created in this test */
+#define PATH1 "tmp/.test-junk-lttng"
+
+#define RANDOM_STRING_LEN 16
+
+/* For lttngerr.h */
+int lttng_opt_quiet = 1;
+int lttng_opt_verbose = 3;
+
+/*
+ * Test string URI and if uri_parse works well.
+ */
+void test_uri_parsing(void)
+{
+ ssize_t size;
+ const char *s_uri1;
+ struct lttng_uri *uri;
+
+ fprintf(stdout, "Testing URIs...\n");
+
+ s_uri1 = "net://localhost";
+ fprintf(stdout, " [+] URI set to %s ", s_uri1);
+ size = uri_parse(s_uri1, &uri);
+ assert(size == 2);
+ assert(uri[0].dtype == LTTNG_DST_IPV4);
+ assert(uri[0].utype == LTTNG_URI_DST);
+ assert(uri[0].stype == 0);
+ assert(uri[0].port == 0);
+ assert(strlen(uri[0].subdir) == 0);
+ assert(strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0);
+
+ assert(uri[1].dtype == LTTNG_DST_IPV4);
+ assert(uri[1].utype == LTTNG_URI_DST);
+ assert(uri[1].stype == 0);
+ assert(uri[1].port == 0);
+ assert(strlen(uri[1].subdir) == 0);
+ assert(strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0);
+ PRINT_OK();
+ uri_free(uri);
+
+ s_uri1 = "net://localhost:8989:4242/my/test/path";
+ fprintf(stdout, " [+] URI set to %s ", s_uri1);
+ size = uri_parse(s_uri1, &uri);
+ assert(size == 2);
+ assert(uri[0].dtype == LTTNG_DST_IPV4);
+ assert(uri[0].utype == LTTNG_URI_DST);
+ assert(uri[0].stype == 0);
+ assert(uri[0].port == 8989);
+ assert(strcmp(uri[0].subdir, "my/test/path") == 0);
+ assert(strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0);
+
+ assert(uri[1].dtype == LTTNG_DST_IPV4);
+ assert(uri[1].utype == LTTNG_URI_DST);
+ assert(uri[1].stype == 0);
+ assert(uri[1].port == 4242);
+ assert(strcmp(uri[0].subdir, "my/test/path") == 0);
+ assert(strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0);
+ PRINT_OK();
+ uri_free(uri);
+
+ s_uri1 = "net://localhost:8989:4242";
+ fprintf(stdout, " [+] URI set to %s ", s_uri1);
+ size = uri_parse(s_uri1, &uri);
+ assert(size == 2);
+ assert(uri[0].dtype == LTTNG_DST_IPV4);
+ assert(uri[0].utype == LTTNG_URI_DST);
+ assert(uri[0].stype == 0);
+ assert(uri[0].port == 8989);
+ assert(strlen(uri[1].subdir) == 0);
+ assert(strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0);
+
+ assert(uri[1].dtype == LTTNG_DST_IPV4);
+ assert(uri[1].utype == LTTNG_URI_DST);
+ assert(uri[1].stype == 0);
+ assert(uri[1].port == 4242);
+ assert(strlen(uri[1].subdir) == 0);
+ assert(strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0);
+ PRINT_OK();
+ uri_free(uri);
+
+ s_uri1 = "net6://localhost:8989";
+ fprintf(stdout, " [+] URI set to %s ", s_uri1);
+ size = uri_parse(s_uri1, &uri);
+ assert(size == 2);
+ assert(uri[0].dtype == LTTNG_DST_IPV6);
+ assert(uri[0].utype == LTTNG_URI_DST);
+ assert(uri[0].stype == 0);
+ assert(uri[0].port == 8989);
+ assert(strlen(uri[1].subdir) == 0);
+ assert(strcmp(uri[0].dst.ipv6, "::1") == 0);
+
+ assert(uri[1].dtype == LTTNG_DST_IPV6);
+ assert(uri[1].utype == LTTNG_URI_DST);
+ assert(uri[1].stype == 0);
+ assert(uri[1].port == 0);
+ assert(strlen(uri[1].subdir) == 0);
+ assert(strcmp(uri[0].dst.ipv6, "::1") == 0);
+ PRINT_OK();
+ uri_free(uri);
+
+ s_uri1 = "tcp://42.42.42.42/my/test/path";
+ fprintf(stdout, " [+] URI set to %s ", s_uri1);
+ size = uri_parse(s_uri1, &uri);
+ assert(size == 1);
+ assert(uri[0].dtype == LTTNG_DST_IPV4);
+ assert(uri[0].utype == LTTNG_URI_DST);
+ assert(uri[0].stype == 0);
+ assert(uri[0].port == 0);
+ assert(strcmp(uri[0].subdir, "my/test/path") == 0);
+ assert(strcmp(uri[0].dst.ipv4, "42.42.42.42") == 0);
+ PRINT_OK();
+ uri_free(uri);
+
+ s_uri1 = "tcp6://[fe80::f66d:4ff:fe53:d220]/my/test/path";
+ fprintf(stdout, " [+] URI set to %s ", s_uri1);
+ size = uri_parse(s_uri1, &uri);
+ assert(size == 1);
+ assert(uri[0].dtype == LTTNG_DST_IPV6);
+ assert(uri[0].utype == LTTNG_URI_DST);
+ assert(uri[0].stype == 0);
+ assert(uri[0].port == 0);
+ assert(strcmp(uri[0].subdir, "my/test/path") == 0);
+ assert(strcmp(uri[0].dst.ipv6, "fe80::f66d:4ff:fe53:d220") == 0);
+ PRINT_OK();
+ uri_free(uri);
+
+ s_uri1 = "file:///my/test/path";
+ fprintf(stdout, " [+] URI set to %s ", s_uri1);
+ size = uri_parse(s_uri1, &uri);
+ assert(size == 1);
+ assert(uri[0].dtype == LTTNG_DST_PATH);
+ assert(uri[0].utype == LTTNG_URI_DST);
+ assert(uri[0].stype == 0);
+ assert(uri[0].port == 0);
+ assert(strlen(uri[0].subdir) == 0);
+ assert(strcmp(uri[0].dst.path, "/my/test/path") == 0);
+ PRINT_OK();
+ uri_free(uri);
+
+ s_uri1 = "file/my/test/path";
+ fprintf(stdout, " [+] Bad URI set to %s ", s_uri1);
+ size = uri_parse(s_uri1, &uri);
+ assert(size == -1);
+ PRINT_OK();
+
+ s_uri1 = "net://:8999";
+ fprintf(stdout, " [+] Bad URI set to %s ", s_uri1);
+ size = uri_parse(s_uri1, &uri);
+ assert(size == -1);
+ PRINT_OK();
+}
+
+void test_uri_cmp()
+{
+ struct lttng_uri *uri1, *uri2;
+ const char *s_uri1 = "net://localhost";
+ const char *s_uri2 = "net://localhost:8989:4242";
+ ssize_t size1, size2;
+ int res;
+
+ size1 = uri_parse(s_uri1, &uri1);
+
+ /* Sanity checks */
+ assert(size1 == 2);
+ assert(uri1[0].dtype == LTTNG_DST_IPV4);
+ assert(uri1[0].utype == LTTNG_URI_DST);
+ assert(uri1[0].stype == 0);
+ assert(uri1[0].port == 0);
+ assert(strlen(uri1[0].subdir) == 0);
+ assert(strcmp(uri1[0].dst.ipv4, "127.0.0.1") == 0);
+ assert(uri1[1].dtype == LTTNG_DST_IPV4);
+ assert(uri1[1].utype == LTTNG_URI_DST);
+ assert(uri1[1].stype == 0);
+ assert(uri1[1].port == 0);
+ assert(strlen(uri1[1].subdir) == 0);
+ assert(strcmp(uri1[1].dst.ipv4, "127.0.0.1") == 0);
+
+ size2 = uri_parse(s_uri2, &uri2);
+
+ assert(size2 == 2);
+ assert(uri2[0].dtype == LTTNG_DST_IPV4);
+ assert(uri2[0].utype == LTTNG_URI_DST);
+ assert(uri2[0].stype == 0);
+ assert(uri2[0].port == 8989);
+ assert(strlen(uri2[1].subdir) == 0);
+ assert(strcmp(uri2[0].dst.ipv4, "127.0.0.1") == 0);
+ assert(uri2[1].dtype == LTTNG_DST_IPV4);
+ assert(uri2[1].utype == LTTNG_URI_DST);
+ assert(uri2[1].stype == 0);
+ assert(uri2[1].port == 4242);
+ assert(strlen(uri2[1].subdir) == 0);
+ assert(strcmp(uri2[1].dst.ipv4, "127.0.0.1") == 0);
+
+
+ res = uri_compare(uri1, uri1);
+ fprintf(stdout, " [+] %s == %s ", s_uri1, s_uri1);
+ assert(res == 0);
+ PRINT_OK();
+
+ res = uri_compare(uri1, uri2);
+ fprintf(stdout, " [+] %s != %s ", s_uri1, s_uri2);
+ assert(res != 0);
+ PRINT_OK();
+
+ uri_free(uri1);
+ uri_free(uri2);
+}
+
+int main(int argc, char **argv)
+{
+ srand(time(NULL));
+
+ printf("\nStreaming unit tests\n-----------\n");
+
+ /* URI tests */
+ test_uri_parsing();
+ test_uri_cmp();
+
+ return 0;
+}
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
+# David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library 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 Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+TEST_DESC="Streaming - URI switching"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+BIN_NAME="gen-ust-events"
+SESSION_NAME="stream"
+EVENT_NAME="tp:tptest"
+PID_RELAYD=0
+
+TRACE_PATH=$(mktemp -d)
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+ echo -e "No UST nevents binary detected. Skipping."
+ exit 0
+fi
+
+function lttng_create_session
+{
+ URI=$1
+ # Create session with custom URI
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN create -U $URI $SESSION_NAME >/dev/null 2>&1
+}
+
+function lttng_enable_consumer
+{
+ URI=$1
+ # Create session with custom URI
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u $URI >/dev/null 2>&1
+}
+
+function run_apps
+{
+ # Run 5 times with a 1 second delay
+ COUNT=5
+ APP_DELAY=1000000
+ ./$CURDIR/$BIN_NAME $COUNT $APP_DELAY >/dev/null 2>&1 &
+
+}
+
+function wait_apps
+{
+ echo -n "Waiting for applications to end"
+ while [ -n "$(pidof $BIN_NAME)" ]; do
+ echo -n "."
+ sleep 0.5
+ done
+ echo ""
+}
+
+function test_uri_switch_localhost_folder
+{
+ IPVER=$1
+ echo -e "\n=== Testing switch of localhost folder ($IPVER)\n"
+
+ if [ "$IPVER" == "IPv6" ]; then
+ BASE_URI="net6://localhost"
+ else
+ BASE_URI="net://localhost"
+ fi
+
+ RANDCOUNT=10
+ RAND=""
+ i=1
+
+ lttng_create_session $BASE_URI
+
+ echo -e "Randomizing output folder on $BASE_URI..."
+ while [ "$i" -le $RANDCOUNT ]
+ do
+ RAND=$(randstring 16 0)
+ lttng_enable_consumer "$BASE_URI/$RAND"
+ let "i += 1"
+ done
+
+ enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+ start_lttng_tracing $SESSION_NAME
+ run_apps
+ wait_apps
+ stop_lttng_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+ validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$RAND
+
+ if [ $? -eq 0 ]; then
+ # Only delete if successful
+ rm -rf $TRACE_PATH
+ fi
+}
+
+function test_uri_switch_file_network
+{
+ IPVER=$1
+ echo ""
+ echo -e "=== Testing switch file -> network ($IPVER)"
+
+ TMP_PATH=$(mktemp -d)
+ FILE_URI="file://$TMP_PATH"
+
+ if [ "$IPVER" == "IPv6" ]; then
+ NETWORK_URIS=("net6://localhost" "net6://[::1]")
+ else
+ NETWORK_URIS=("net://localhost" "net://127.0.0.1")
+ fi
+
+ NET_PATHS=("foo/bar" "OohEehOohAhAahTingTangWallaWallaBingBang" ".")
+
+ for NETWORK_URI in ${NETWORK_URIS[@]};
+ do
+ for NET_PATH in ${NET_PATHS[@]};
+ do
+ SESSION_NAME=$(randstring 16 0)
+ echo ""
+ echo "$FILE_URI -> $NETWORK_URI/$NET_PATH"
+
+ lttng_create_session $FILE_URI
+ lttng_enable_consumer "$NETWORK_URI/$NET_PATH"
+ enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+ start_lttng_tracing $SESSION_NAME
+ run_apps
+ wait_apps
+ stop_lttng_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+ validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$NET_PATH
+
+ if [ $? -eq 0 ]; then
+ # Only delete if successful
+ rm -rf $TRACE_PATH
+ else
+ break
+ fi
+ done
+ done
+ rm -rf $TMP_PATH
+}
+
+function test_uri_switch_network_file
+{
+IPVER=$1
+ echo ""
+ echo -e "=== Testing switch network ($IPVER) -> file"
+
+ if [ "$IPVER" == "IPv6" ]; then
+ NETWORK_URI="net6://localhost"
+ else
+ NETWORK_URI="net://localhost"
+ fi
+
+ FILE_PATHS=("." "foo/bar" "42")
+
+ for FILE_PATH in ${FILE_PATHS[@]};
+ do
+ TMP_PATH=$(mktemp -d)
+ FILE_URI="file://$TMP_PATH"
+ SESSION_NAME=$(randstring 16 0)
+
+ echo ""
+ echo "$NETWORK_URI -> $FILE_URI/$FILE_PATH"
+
+ lttng_create_session $NETWORK_URI
+ lttng_enable_consumer "$FILE_URI/$FILE_PATH"
+ enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+ start_lttng_tracing $SESSION_NAME
+ run_apps
+ wait_apps
+ stop_lttng_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+ validate_trace $EVENT_NAME $TMP_PATH/$FILE_PATH
+
+ if [ $? -eq 0 ]; then
+ # Only delete if successful
+ rm -rf $TMP_PATH
+ else
+ break
+ fi
+ done
+}
+
+
+start_lttng_sessiond
+
+echo ""
+echo "=== Testing with IPv4"
+start_lttng_relayd "-o $TRACE_PATH"
+test_uri_switch_localhost_folder "IPv4"
+test_uri_switch_file_network "IPv4"
+test_uri_switch_network_file "IPv4"
+stop_lttng_relayd
+
+echo ""
+echo "=== Testing with IPv6"
+start_lttng_relayd "-o $TRACE_PATH -C tcp6://localhost:5342 -D tcp6://localhost:5343"
+test_uri_switch_localhost_folder "IPv6"
+test_uri_switch_file_network "IPv6"
+test_uri_switch_network_file "IPv6"
+stop_lttng_relayd
+
+stop_lttng_sessiond
--- /dev/null
+/*
+ * 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 <bin/lttng-sessiond/trace-kernel.h>
+#include <common/defaults.h>
+
+#include "utils.h"
+
+/* This path will NEVER be created in this test */
+#define PATH1 "/tmp/.test-junk-lttng"
+
+#define RANDOM_STRING_LEN 11
+
+/* For lttngerr.h */
+int lttng_opt_quiet = 1;
+int lttng_opt_verbose;
+
+static const char alphanum[] =
+ "0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz";
+
+static struct ltt_kernel_session *kern;
+static char random_string[RANDOM_STRING_LEN];
+
+/*
+ * Return random string of 10 characters.
+ * Not thread-safe.
+ */
+static char *get_random_string(void)
+{
+ int i;
+
+ for (i = 0; i < RANDOM_STRING_LEN - 1; i++) {
+ random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
+ }
+
+ random_string[RANDOM_STRING_LEN - 1] = '\0';
+
+ return random_string;
+}
+
+static void create_one_kernel_session(void)
+{
+ printf("Create kernel session: ");
+ kern = trace_kernel_create_session(PATH1);
+ assert(kern != NULL);
+ PRINT_OK();
+
+ printf("Validating kernel session: ");
+ assert(kern->fd == -1);
+ assert(kern->metadata_stream_fd == -1);
+ assert(kern->consumer_fds_sent == 0);
+ assert(kern->channel_count == 0);
+ assert(kern->stream_count_global == 0);
+ assert(kern->metadata == NULL);
+ PRINT_OK();
+
+ /* Init list in order to avoid sefaults from cds_list_del */
+ trace_kernel_destroy_session(kern);
+}
+
+static void create_kernel_metadata(void)
+{
+ assert(kern != NULL);
+
+ printf("Create kernel metadata: ");
+ kern->metadata = trace_kernel_create_metadata();
+ assert(kern->metadata != NULL);
+ PRINT_OK();
+
+ printf("Validating kernel session metadata: ");
+ assert(kern->metadata->fd == -1);
+ assert(kern->metadata->conf != NULL);
+ assert(kern->metadata->conf->attr.overwrite
+ == DEFAULT_CHANNEL_OVERWRITE);
+ assert(kern->metadata->conf->attr.subbuf_size
+ == default_get_metadata_subbuf_size());
+ assert(kern->metadata->conf->attr.num_subbuf
+ == DEFAULT_METADATA_SUBBUF_NUM);
+ assert(kern->metadata->conf->attr.switch_timer_interval
+ == DEFAULT_CHANNEL_SWITCH_TIMER);
+ assert(kern->metadata->conf->attr.read_timer_interval
+ == DEFAULT_CHANNEL_READ_TIMER);
+ assert(kern->metadata->conf->attr.output
+ == DEFAULT_KERNEL_CHANNEL_OUTPUT);
+ PRINT_OK();
+
+ trace_kernel_destroy_metadata(kern->metadata);
+}
+
+static void create_kernel_channel(void)
+{
+ struct ltt_kernel_channel *chan;
+ struct lttng_channel attr;
+
+ memset(&attr, 0, sizeof(attr));
+
+ printf("Creating kernel channel: ");
+ chan = trace_kernel_create_channel(&attr);
+ assert(chan != NULL);
+ PRINT_OK();
+
+ printf("Validating kernel channel: ");
+ assert(chan->fd == -1);
+ assert(chan->enabled == 1);
+ assert(chan->stream_count == 0);
+ assert(chan->ctx == NULL);
+ assert(chan->channel->attr.overwrite == attr.attr.overwrite);
+ PRINT_OK();
+
+ /* Init list in order to avoid sefaults from cds_list_del */
+ CDS_INIT_LIST_HEAD(&chan->list);
+ trace_kernel_destroy_channel(chan);
+}
+
+static void create_kernel_event(void)
+{
+ struct ltt_kernel_event *event;
+ struct lttng_event ev;
+
+ memset(&ev, 0, sizeof(ev));
+ strncpy(ev.name, get_random_string(), LTTNG_KERNEL_SYM_NAME_LEN);
+ ev.type = LTTNG_EVENT_TRACEPOINT;
+ ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+
+ printf("Creating kernel event: ");
+ event = trace_kernel_create_event(&ev);
+ assert(event != NULL);
+ PRINT_OK();
+
+ printf("Validating kernel event: ");
+ assert(event->fd == -1);
+ assert(event->enabled == 1);
+ assert(event->event->instrumentation == LTTNG_KERNEL_TRACEPOINT);
+ assert(strlen(event->event->name));
+ PRINT_OK();
+
+ /* Init list in order to avoid sefaults from cds_list_del */
+ CDS_INIT_LIST_HEAD(&event->list);
+ trace_kernel_destroy_event(event);
+}
+
+static void create_kernel_stream(void)
+{
+ struct ltt_kernel_stream *stream;
+
+ printf("Creating kernel stream: ");
+ stream = trace_kernel_create_stream("stream1", 0);
+ assert(stream != NULL);
+ PRINT_OK();
+
+ printf("Validating kernel stream: ");
+ assert(stream->fd == -1);
+ assert(stream->state == 0);
+ PRINT_OK();
+
+ /* Init list in order to avoid sefaults from cds_list_del */
+ CDS_INIT_LIST_HEAD(&stream->list);
+ trace_kernel_destroy_stream(stream);
+}
+
+int main(int argc, char **argv)
+{
+ printf("\nTesting kernel data structures:\n-----------\n");
+
+ create_one_kernel_session();
+
+ create_kernel_metadata();
+ create_kernel_channel();
+
+
+ create_kernel_event();
+
+ create_kernel_stream();
+
+ /* Success */
+ return 0;
+}
--- /dev/null
+/*
+ * 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 <sys/types.h>
+
+#include <bin/lttng-sessiond/session.h>
+#include <common/sessiond-comm/sessiond-comm.h>
+#include <common/common.h>
+
+#include "utils.h"
+
+#define SESSION1 "test1"
+
+/* This path will NEVER be created in this test */
+#define PATH1 "/tmp/.test-junk-lttng"
+
+#define MAX_SESSIONS 10000
+#define RANDOM_STRING_LEN 11
+
+/*
+ * String of 263 caracters. NAME_MAX + "OVERFLOW". If OVERFLOW appears in the
+ * session name, we have a problem.
+ *
+ * NAME_MAX = 255
+ */
+#define OVERFLOW_SESSION_NAME \
+ "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" \
+ "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" \
+ "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" \
+ "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc" \
+ "OVERFLOW"
+
+static struct ltt_session_list *session_list;
+
+/* For lttngerr.h */
+int lttng_opt_quiet = 1;
+int lttng_opt_verbose = 0;
+
+static const char alphanum[] =
+ "0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz";
+static char random_string[RANDOM_STRING_LEN];
+
+/*
+ * Return random string of 10 characters.
+ * Not thread-safe.
+ */
+static char *get_random_string(void)
+{
+ int i;
+
+ for (i = 0; i < RANDOM_STRING_LEN - 1; i++) {
+ random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
+ }
+
+ random_string[RANDOM_STRING_LEN - 1] = '\0';
+
+ return random_string;
+}
+
+/*
+ * Return 0 if session name is found, else -1
+ */
+static int find_session_name(char *name)
+{
+ struct ltt_session *iter;
+
+ cds_list_for_each_entry(iter, &session_list->head, list) {
+ if (strcmp(iter->name, name) == 0) {
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+static int session_list_count(void)
+{
+ int count = 0;
+ struct ltt_session *iter;
+
+ cds_list_for_each_entry(iter, &session_list->head, list) {
+ count++;
+ }
+ return count;
+}
+
+/*
+ * Empty session list manually.
+ */
+static void empty_session_list(void)
+{
+ struct ltt_session *iter, *tmp;
+
+ cds_list_for_each_entry_safe(iter, tmp, &session_list->head, list) {
+ cds_list_del(&iter->list);
+ free(iter);
+ }
+
+ /* Session list must be 0 */
+ assert(!session_list_count());
+}
+
+/*
+ * Test creation of 1 session
+ */
+static int create_one_session(char *name, char *path)
+{
+ int ret;
+
+ ret = session_create(name, path, geteuid(), getegid());
+ if (ret == LTTNG_OK) {
+ /* Validate */
+ ret = find_session_name(name);
+ if (ret < 0) {
+ /* Session not found by name */
+ printf("session not found after creation\n");
+ return -1;
+ } else {
+ /* Success */
+ return 0;
+ }
+ } else {
+ if (ret == LTTNG_ERR_EXIST_SESS) {
+ printf("(session already exists) ");
+ }
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * Test deletion of 1 session
+ */
+static int destroy_one_session(struct ltt_session *session)
+{
+ int ret;
+
+ ret = session_destroy(session);
+
+ if (ret == LTTNG_OK) {
+ /* Validate */
+ if (session == NULL) {
+ return 0;
+ }
+ ret = find_session_name(session->name);
+ if (ret < 0) {
+ /* Success, -1 means that the sesion is NOT found */
+ return 0;
+ } else {
+ /* Fail */
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static int fuzzing_create_args(void)
+{
+ int ret;
+
+ ret = create_one_session(NULL, NULL);
+ if (ret > 0) {
+ printf("Session created with (null),(null)\n");
+ return -1;
+ }
+
+ ret = create_one_session(NULL, PATH1);
+ if (ret > 0) {
+ printf("Session created with (null), %s)\n", PATH1);
+ return -1;
+ }
+
+ /* Session list must be 0 */
+ assert(!session_list_count());
+
+ return 0;
+}
+
+/*
+ * This test is supposed to fail at the second create call. If so, return 0 for
+ * test success, else -1.
+ */
+static int two_session_same_name(void)
+{
+ int ret;
+ struct ltt_session *sess;
+
+ ret = create_one_session(SESSION1, PATH1);
+ if (ret < 0) {
+ /* Fail */
+ return -1;
+ }
+
+ sess = session_find_by_name(SESSION1);
+ if (sess) {
+ /* Success */
+ return 0;
+ }
+
+ /* Fail */
+ return -1;
+}
+
+int main(int argc, char **argv)
+{
+ int ret, i;
+ struct ltt_session *iter, *tmp;
+
+ srand(time(NULL));
+
+ printf("\nTesting Sessions:\n-----------\n");
+
+ session_list = session_get_list();
+ if (session_list == NULL) {
+ return -1;
+ }
+
+ printf("Create 1 session %s: ", SESSION1);
+ fflush(stdout);
+ ret = create_one_session(SESSION1, PATH1);
+ if (ret < 0) {
+ return -1;
+ }
+ PRINT_OK();
+
+ printf("Validating created session %s: ", SESSION1);
+ fflush(stdout);
+ tmp = session_find_by_name(SESSION1);
+ if (tmp == NULL) {
+ return -1;
+ }
+ /* Basic init session values */
+ assert(tmp->kernel_session == NULL);
+ assert(strlen(tmp->path));
+ assert(strlen(tmp->name));
+ session_lock(tmp);
+ session_unlock(tmp);
+
+ PRINT_OK();
+
+ printf("Destroy 1 session %s: ", SESSION1);
+ fflush(stdout);
+ ret = destroy_one_session(tmp);
+ if (ret < 0) {
+ return -1;
+ }
+ PRINT_OK();
+
+ printf("Two session with same name: ");
+ fflush(stdout);
+ ret = two_session_same_name();
+ if (ret < 0) {
+ return -1;
+ }
+ PRINT_OK();
+
+ empty_session_list();
+
+ printf("Fuzzing create_session arguments: ");
+ fflush(stdout);
+ ret = fuzzing_create_args();
+ if (ret < 0) {
+ return -1;
+ }
+ PRINT_OK();
+
+ printf("Creating %d sessions: ", MAX_SESSIONS);
+ fflush(stdout);
+ for (i = 0; i < MAX_SESSIONS; i++) {
+ char *tmp_name = get_random_string();
+
+ ret = create_one_session(tmp_name, PATH1);
+ if (ret < 0) {
+ printf("session %d (name: %s) creation failed\n", i, tmp_name);
+ return -1;
+ }
+
+ if ((i % 1000) == 0) {
+ fprintf(stdout, "%d..", i);
+ fflush(stdout);
+ }
+ }
+ PRINT_OK();
+
+ printf("Destroying %d sessions: ", MAX_SESSIONS);
+ fflush(stdout);
+ for (i = 0; i < MAX_SESSIONS; i++) {
+ cds_list_for_each_entry_safe(iter, tmp, &session_list->head, list) {
+ ret = destroy_one_session(iter);
+ if (ret < 0) {
+ printf("session %d (name: %s) creation failed\n", i, iter->name);
+ return -1;
+ }
+ }
+ }
+ PRINT_OK();
+
+ /* Session list must be 0 */
+ assert(!session_list_count());
+
+ /* Success */
+ return 0;
+}
--- /dev/null
+/*
+ * 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 <bin/lttng-sessiond/lttng-ust-abi.h>
+#include <common/defaults.h>
+#include <bin/lttng-sessiond/trace-ust.h>
+
+#include "utils.h"
+
+/* This path will NEVER be created in this test */
+#define PATH1 "/tmp/.test-junk-lttng"
+
+#define RANDOM_STRING_LEN 11
+
+/* For lttngerr.h */
+int lttng_opt_quiet = 1;
+int lttng_opt_verbose;
+
+static const char alphanum[] =
+ "0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz";
+static char random_string[RANDOM_STRING_LEN];
+
+static struct ltt_ust_session *usess;
+static struct lttng_domain dom;
+
+/*
+ * Return random string of 10 characters.
+ * Not thread-safe.
+ */
+static char *get_random_string(void)
+{
+ int i;
+
+ for (i = 0; i < RANDOM_STRING_LEN - 1; i++) {
+ random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
+ }
+
+ random_string[RANDOM_STRING_LEN - 1] = '\0';
+
+ return random_string;
+}
+
+static void create_one_ust_session(void)
+{
+ printf("Create UST session: ");
+
+ dom.type = LTTNG_DOMAIN_UST;
+
+ usess = trace_ust_create_session(PATH1, 42);
+ assert(usess != NULL);
+ PRINT_OK();
+
+ printf("Validating UST session: ");
+ assert(usess->id == 42);
+ assert(usess->start_trace == 0);
+ assert(usess->domain_global.channels != NULL);
+ assert(usess->domain_pid != NULL);
+ assert(usess->domain_exec != NULL);
+ assert(usess->uid == 0);
+ assert(usess->gid == 0);
+ PRINT_OK();
+
+ trace_ust_destroy_session(usess);
+}
+
+static void create_ust_metadata(void)
+{
+ struct ltt_ust_metadata *metadata;
+
+ assert(usess != NULL);
+
+ printf("Create UST metadata: ");
+ metadata = trace_ust_create_metadata(PATH1);
+ assert(metadata != NULL);
+ PRINT_OK();
+
+ printf("Validating UST session metadata: ");
+ assert(metadata->handle == -1);
+ assert(strlen(metadata->pathname));
+ assert(metadata->attr.overwrite
+ == DEFAULT_CHANNEL_OVERWRITE);
+ assert(metadata->attr.subbuf_size
+ == default_get_metadata_subbuf_size());
+ assert(metadata->attr.num_subbuf
+ == DEFAULT_METADATA_SUBBUF_NUM);
+ assert(metadata->attr.switch_timer_interval
+ == DEFAULT_CHANNEL_SWITCH_TIMER);
+ assert(metadata->attr.read_timer_interval
+ == DEFAULT_CHANNEL_READ_TIMER);
+ assert(metadata->attr.output == LTTNG_UST_MMAP);
+ PRINT_OK();
+
+ trace_ust_destroy_metadata(metadata);
+}
+
+static void create_ust_channel(void)
+{
+ struct ltt_ust_channel *uchan;
+ struct lttng_channel attr;
+
+ memset(&attr, 0, sizeof(attr));
+
+ strncpy(attr.name, "channel0", 8);
+
+ printf("Creating UST channel: ");
+ uchan = trace_ust_create_channel(&attr, PATH1);
+ assert(uchan != NULL);
+ PRINT_OK();
+
+ printf("Validating UST channel: ");
+ assert(uchan->enabled == 0);
+ assert(strcmp(PATH1, uchan->pathname) == 0);
+ assert(strncmp(uchan->name, "channel0", 8) == 0);
+ assert(uchan->name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0');
+ assert(uchan->ctx != NULL);
+ assert(uchan->events != NULL);
+ assert(uchan->attr.overwrite == attr.attr.overwrite);
+ PRINT_OK();
+
+ trace_ust_destroy_channel(uchan);
+}
+
+static void create_ust_event(void)
+{
+ struct ltt_ust_event *event;
+ struct lttng_event ev;
+
+ memset(&ev, 0, sizeof(ev));
+ strncpy(ev.name, get_random_string(), LTTNG_SYMBOL_NAME_LEN);
+ ev.type = LTTNG_EVENT_TRACEPOINT;
+ ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+
+ printf("Creating UST event: ");
+ event = trace_ust_create_event(&ev, NULL);
+ assert(event != NULL);
+ PRINT_OK();
+
+ printf("Validating UST event: ");
+ assert(event->enabled == 0);
+ assert(event->attr.instrumentation == LTTNG_UST_TRACEPOINT);
+ assert(strcmp(event->attr.name, ev.name) == 0);
+ assert(event->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0');
+ PRINT_OK();
+
+ trace_ust_destroy_event(event);
+}
+
+static void create_ust_context(void)
+{
+ struct lttng_event_context ectx;
+ struct ltt_ust_context *uctx;
+
+ ectx.ctx = LTTNG_EVENT_CONTEXT_VTID;
+
+ printf("Creating UST context: ");
+ uctx = trace_ust_create_context(&ectx);
+ assert(uctx != NULL);
+ PRINT_OK();
+
+ printf("Validating UST context: ");
+ assert((int) uctx->ctx.ctx == LTTNG_UST_CONTEXT_VTID);
+ PRINT_OK();
+}
+
+int main(int argc, char **argv)
+{
+ printf("\nTesting UST data structures:\n-----------\n");
+
+ create_one_ust_session();
+ create_ust_metadata();
+ create_ust_channel();
+ create_ust_event();
+ create_ust_context();
+
+ /* Success */
+ return 0;
+}
--- /dev/null
+if HAVE_LIBLTTNG_UST_CTL
+SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \
+ overlap
+
+AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/tests/utils -I$(top_srcdir)/src -g -Wall
+AM_LDFLAGS = -lurcu -lurcu-cds
+
+EXTRA_DIST = runall.sh run-ust-global-tests.sh
+
+noinst_PROGRAMS = ust_global_event_basic ust_global_event_wildcard
+
+UTILS=$(top_srcdir)/tests/utils/utils.h
+LIBLTTNG=$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la
+
+SESSIONDSRC=$(top_srcdir)/src/common/sessiond-comm/sessiond-comm.c \
+ $(top_srcdir)/src/common/sessiond-comm/unix.c \
+ $(top_srcdir)/src/common/sessiond-comm/inet.c \
+ $(top_srcdir)/src/common/sessiond-comm/inet6.c
+
+ust_global_event_wildcard_SOURCES = ust_global_event_wildcard.c $(UTILS) \
+ $(SESSIONDSRC)
+ust_global_event_wildcard_LDADD = $(LIBLTTNG)
+
+ust_global_event_basic_SOURCES = ust_global_event_basic.c $(UTILS) \
+ $(SESSIONDSRC)
+ust_global_event_basic_LDADD = $(LIBLTTNG)
+
+endif
--- /dev/null
+AM_CFLAGS = -I$(srcdir) -O2
+AM_LDFLAGS = -llttng-ust
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+AM_LDFLAGS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+AM_LDFLAGS += -lc
+endif
+
+noinst_PROGRAMS = gen-nevents
+gen_nevents_SOURCES = gen-nevents.c tp.c ust_gen_nevents.h
+gen_nevents_LDADD = -llttng-ust
+
+noinst_SCRIPTS = run
+EXTRA_DIST = run
--- /dev/null
+/*
+ * Copyright (C) - 2009 Pierre-Marc Fournier
+ * Copyright (C) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; version 2.1 of the License.
+ *
+ * This library 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 Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_gen_nevents.h"
+
+int main(int argc, char **argv)
+{
+ int i, netint;
+ long values[] = { 1, 2, 3 };
+ char text[10] = "test";
+ double dbl = 2.0;
+ float flt = 2222.0;
+ unsigned int nr_iter = 100;
+
+ if (argc == 2) {
+ nr_iter = atoi(argv[1]);
+ }
+
+ for (i = 0; i < nr_iter; i++) {
+ netint = htonl(i);
+ tracepoint(ust_gen_nevents, tptest, i, netint, values, text,
+ strlen(text), dbl, flt);
+ usleep(100000);
+ }
+
+ return 0;
+}
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library 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 Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+TEST_DESC="UST tracer - Start tracing before and after execution"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+NR_ITER=100
+SESSION_NAME="per-session"
+EVENT_NAME="ust_gen_nevents:tptest"
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/gen-nevents" ]; then
+ echo -e "No UST nevents binary detected. Passing."
+ exit 0
+fi
+
+# MUST set TESTDIR before calling those functions
+
+test_before_apps() {
+ local out
+
+ # BEFORE application is spawned
+ create_lttng_session $SESSION_NAME $TRACE_PATH
+ enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+ start_lttng_tracing $SESSION_NAME
+ # Start test
+ echo -n "Starting application... "
+ ./$CURDIR/gen-nevents $NR_ITER
+ echo -n "Ended "
+ print_ok
+ stop_lttng_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+
+ trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+
+ return $?
+}
+
+test_after_apps() {
+ local out
+
+ echo -n "Starting application... "
+ ./$CURDIR/gen-nevents 100 &
+ print_ok
+
+ # BEFORE application is spawned
+ create_lttng_session $SESSION_NAME $TRACE_PATH
+ enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+ start_lttng_tracing $SESSION_NAME
+
+ # At least hit one event
+ sleep 2
+
+ stop_lttng_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+
+ out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
+ if [ $out -eq 0 ]; then
+ echo -n "No event found. Suppose to have at least one... "
+ print_fail
+ out=1
+ else
+ echo -n "Found $out event(s). Coherent... "
+ print_ok
+ out=0
+ fi
+
+ return $out
+}
+
+# MUST set TESTDIR before calling those functions
+
+start_lttng_sessiond
+
+echo ""
+echo "=== Start application BEFORE tracing was started ==="
+
+TRACE_PATH=$(mktemp -d)
+
+test_before_apps
+out=$?
+if [ $out -ne 0 ]; then
+ stop_lttng_sessiond
+ exit $out
+fi
+
+rm -rf $TRACE_PATH
+
+echo ""
+echo "=== Start application AFTER tracing was started ==="
+
+TRACE_PATH=$(mktemp -d)
+
+test_after_apps
+out=$?
+if [ $out -ne 0 ]; then
+ stop_lttng_sessiond
+ exit $out
+fi
+
+stop_lttng_sessiond
+
+rm -rf $TRACE_PATH
--- /dev/null
+/*
+ * Copyright (c) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
+ * IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program for any purpose,
+ * provided the above notices are retained on all copies. Permission to modify
+ * the code and to distribute modified code is granted, provided the above
+ * notices are retained, and a notice that the code was modified is included
+ * with the above copyright notice.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_gen_nevents.h"
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_gen_nevents
+
+#if !defined(_TRACEPOINT_UST_GEN_NEVENTS_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_GEN_NEVENTS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(ust_gen_nevents, tptest,
+ TP_ARGS(int, anint, int, netint, long *, values,
+ char *, text, size_t, textlen,
+ double, doublearg, float, floatarg),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer_hex(int, intfield2, anint)
+ ctf_integer(long, longfield, anint)
+ ctf_integer_network(int, netintfield, netint)
+ ctf_integer_network_hex(int, netintfieldhex, netint)
+ ctf_array(long, arrfield1, values, 3)
+ ctf_array_text(char, arrfield2, text, 10)
+ ctf_sequence(char, seqfield1, text, size_t, textlen)
+ ctf_sequence_text(char, seqfield2, text, size_t, textlen)
+ ctf_string(stringfield, text)
+ ctf_float(float, floatfield, floatarg)
+ ctf_float(double, doublefield, doublearg)
+ )
+)
+
+#endif /* _TRACEPOINT_UST_GEN_NEVENTS_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./ust_gen_nevents.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+AM_CFLAGS = -I$(srcdir) -O2
+AM_LDFLAGS = -llttng-ust
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+AM_LDFLAGS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+AM_LDFLAGS += -lc
+endif
+
+noinst_PROGRAMS = gen-events
+gen_events_SOURCES = main.c tp.c tp.h
+gen_events_LDADD = -llttng-ust
+
+noinst_SCRIPTS = run
+EXTRA_DIST = run
--- /dev/null
+/*
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
+
+#define TRACEPOINT_DEFINE
+#include "tp.h"
+
+void inthandler(int sig)
+{
+}
+
+int init_int_handler(void)
+{
+ int result;
+ struct sigaction act;
+
+ memset(&act, 0, sizeof(act));
+ result = sigemptyset(&act.sa_mask);
+ if (result == -1) {
+ perror("sigemptyset");
+ return -1;
+ }
+
+ act.sa_handler = inthandler;
+ act.sa_flags = SA_RESTART;
+
+ /* Only defer ourselves. Also, try to restart interrupted
+ * syscalls to disturb the traced program as little as possible.
+ */
+ result = sigaction(SIGUSR1, &act, NULL);
+ if (result == -1) {
+ perror("sigaction");
+ return -1;
+ }
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int i, netint;
+ long values[] = { 1, 2, 3 };
+ char text[10] = "test";
+ double dbl = 2.0;
+ float flt = 2222.0;
+ int delay = 0;
+
+ init_int_handler();
+
+ if (argc == 2)
+ delay = atoi(argv[1]);
+
+ sleep(delay);
+
+ for (i = 0; i < 1000000; i++) {
+ netint = htonl(i);
+ tracepoint(tp, tptest, i, netint, values, text,
+ strlen(text), dbl, flt);
+ }
+
+ return 0;
+}
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library 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 Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+TEST_DESC="UST tracer - Testing high events throughput"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+NR_ITER=20
+BIN_NAME="gen-events"
+SESSION_NAME="high-throughput"
+EVENT_NAME="tp:tptest"
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+ echo -e "No UST nevents binary detected. Passing."
+ exit 0
+fi
+
+TRACE_PATH=$(mktemp -d)
+
+# MUST set TESTDIR before calling those functions
+
+start_lttng_sessiond
+
+create_lttng_session $SESSION_NAME $TRACE_PATH
+
+enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+start_lttng_tracing $SESSION_NAME
+
+for i in `seq 1 $NR_ITER`; do
+ ./$CURDIR/$BIN_NAME & >/dev/null 2>&1
+done
+
+echo "Waiting for applications to end"
+while [ -n "$(pidof $BIN_NAME)" ]; do
+ echo -n "."
+ sleep 0.5
+done
+echo ""
+
+stop_lttng_tracing $SESSION_NAME
+destroy_lttng_session $SESSION_NAME
+
+stop_lttng_sessiond
+
+# Validate test
+
+TEMP_FILE=$(mktemp)
+TEMP_FILE_2=$(mktemp)
+
+traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l)
+babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2
+
+cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE
+
+dropped=0
+while read line;
+do
+ let dropped=$dropped+$line
+done < $TEMP_FILE
+
+let total=$dropped+$traced
+let wanted=$NR_ITER*1000000
+
+if [ $wanted -ne $total ]; then
+ echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
+ print_fail
+ out=1
+else
+ echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
+ print_ok
+ out=0
+fi
+
+rm -rf $TRACE_PATH
+rm $TEMP_FILE $TEMP_FILE_2
+
+exit $out
--- /dev/null
+/*
+ * tp.c
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "tp.h"
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER tp
+
+#if !defined(_TRACEPOINT_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_TP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(tp, tptest,
+ TP_ARGS(int, anint, int, netint, long *, values,
+ char *, text, size_t, textlen, double, doublearg, float, floatarg),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer_hex(int, intfield2, anint)
+ ctf_integer(long, longfield, anint)
+ ctf_integer_network(int, netintfield, netint)
+ ctf_integer_network_hex(int, netintfieldhex, netint)
+ ctf_array(long, arrfield1, values, 3)
+ ctf_array_text(char, arrfield2, text, 10)
+ ctf_sequence(char, seqfield1, text, size_t, textlen)
+ ctf_sequence_text(char, seqfield2, text, size_t, textlen)
+ ctf_string(stringfield, text)
+ ctf_float(float, floatfield, floatarg)
+ ctf_float(double, doublefield, doublearg)
+ )
+)
+
+TRACEPOINT_EVENT(tp, tptest_sighandler,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+#endif /* _TRACEPOINT_TP_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./tp.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+AM_CFLAGS = -I$(srcdir) -O2
+AM_LDFLAGS = -llttng-ust
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+AM_LDFLAGS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+AM_LDFLAGS += -lc
+endif
+
+noinst_PROGRAMS = gen-events
+gen_events_SOURCES = main.c tp.c tp.h
+gen_events_LDADD = -llttng-ust -lurcu
+
+noinst_SCRIPTS = run
+EXTRA_DIST = run
--- /dev/null
+/*
+ * Copyright (C) 2012 - David Goulet <dgoulet@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <poll.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define TRACEPOINT_DEFINE
+#include "tp.h"
+
+/*
+ * Thread recording a tracepoint every minute for 20 minutes.
+ */
+static void *th_event_minute(void *data)
+{
+ int i;
+
+ /* Loop for 20 minutes */
+ for (i = 1; i < 21; i++) {
+ /* Sleep 60 seconds */
+ poll(NULL, 0, 60000);
+
+ /* 20 minutes tracepoint */
+ if ((i % 20) == 0) {
+ tracepoint(tp, slow, i, "twenty");
+ }
+
+ /* 10 minutes tracepoint */
+ if ((i % 10) == 0) {
+ tracepoint(tp, slow, i, "ten");
+ }
+
+ /* 1 minute tracepoint */
+ tracepoint(tp, slow, i, "one");
+ }
+
+ return NULL;
+}
+
+/*
+ * main
+ */
+int main(int argc, char **argv)
+{
+ int ret;
+ void *status;
+ pthread_t thread;
+
+ ret = pthread_create(&thread, NULL, th_event_minute, NULL);
+ if (ret != 0) {
+ perror("pthread_create event minute");
+ goto error;
+ }
+
+ ret = pthread_join(thread, &status);
+ if (ret != 0) {
+ perror("pthread_join");
+ goto error;
+ }
+
+ return 0;
+
+error:
+ return 1;
+}
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library 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 Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+TEST_DESC="UST tracer - Testing low events throughput"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+BIN_NAME="gen-events"
+SESSION_NAME="low-throughput"
+EVENT_NAME="tp:slow"
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+ echo -e "No UST nevents binary detected. Passing."
+ exit 0
+fi
+
+TRACE_PATH=$(mktemp -d)
+
+# MUST set TESTDIR before calling those functions
+
+start_lttng_sessiond
+
+create_lttng_session $SESSION_NAME $TRACE_PATH
+
+enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+start_lttng_tracing $SESSION_NAME
+
+# This is going to take 20 minutes
+./$CURDIR/$BIN_NAME >/dev/null 2>&1
+
+stop_lttng_tracing $SESSION_NAME
+destroy_lttng_session $SESSION_NAME
+
+stop_lttng_sessiond
+
+# Validate test
+
+last_val=0
+out=0
+
+babeltrace $TRACE_PATH | while read event;
+do
+ val=$(echo $event | cut -f10 -d" ")
+ val=${val%?}
+ th=$(echo $event | cut -f13 -d " ")
+
+ if [ $th = '"one"' ]; then
+ ((last_val++))
+ # We expect here a continous value from 1 to 20
+ if [ $last_val -ne $val ]; then
+ echo -n "[-] One minute event failed ($val) "
+ out=1
+ break
+ fi
+ elif [ $th = '"ten"' ]; then
+ # Test 10 minutes counter
+ if [ $val -ne 10 ]; then
+ # Test 20 minutes counter
+ if [ $val -ne 20 ]; then
+ echo -n "[-] Ten minutes event failed ($val) "
+ out=1
+ break
+ fi
+ fi
+ elif [ $th = '"twenty"' ]; then
+ # Test 20 minutes counter
+ if [ $val -ne 20 ]; then
+ echo -n "[-] Twenty minutes event failed ($val) "
+ out=1
+ break
+ fi
+ fi
+done
+
+if [ $out -eq 0 ]; then
+ echo -n "Trace is coherent... "
+ print_ok
+else
+ print_fail
+fi
+
+rm -rf $TRACE_PATH
+
+exit $out
--- /dev/null
+/*
+ * tp.c
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "tp.h"
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER tp
+
+#if !defined(_TRACEPOINT_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_TP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(tp, slow,
+ TP_ARGS(unsigned int, c, char *, thread_name),
+ TP_FIELDS(
+ ctf_integer(unsigned int, counter, c)
+ ctf_string(th_name, thread_name)
+ )
+)
+
+#endif /* _TRACEPOINT_TP_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./tp.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+AM_CFLAGS = -I$(srcdir) -O2
+AM_LDFLAGS = -llttng-ust
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+AM_LDFLAGS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+AM_LDFLAGS += -lc
+endif
+
+noinst_PROGRAMS = gen-nevents
+gen_nevents_SOURCES = gen-nevents.c tp.c ust_gen_nevents.h
+gen_nevents_LDADD = -llttng-ust
+
+noinst_SCRIPTS = run
+EXTRA_DIST = run
--- /dev/null
+/*
+ * Copyright (C) - 2009 Pierre-Marc Fournier
+ * Copyright (C) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; version 2.1 of the License.
+ *
+ * This library 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 Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_gen_nevents.h"
+
+int main(int argc, char **argv)
+{
+ int i, nr_iter = 100;
+ long value = 42;
+
+ if (argc == 2) {
+ nr_iter = atoi(argv[1]);
+ }
+
+ for (i = 0; i < nr_iter; i++) {
+ tracepoint(ust_gen_nevents, tptest0, i, value);
+ tracepoint(ust_gen_nevents, tptest1, i, value);
+ tracepoint(ust_gen_nevents, tptest2, i, value);
+ tracepoint(ust_gen_nevents, tptest3, i, value);
+ }
+
+ return 0;
+}
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library 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 Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+TEST_DESC="UST tracer - Multi-session"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+NR_ITER=100
+SESSION_NAME="multi-session"
+EVENT_NAME="ust_gen_nevents:tptest"
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/gen-nevents" ]; then
+ echo -e "No UST nevents binary detected. Passing."
+ exit 0
+fi
+
+# MUST set TESTDIR before calling those functions
+
+test_multi_session() {
+ local out
+
+ # BEFORE application is spawned
+ for i in `seq 0 3`; do
+ create_lttng_session "$SESSION_NAME-$i" "$TRACE_PATH/$i"
+ enable_ust_lttng_event "$SESSION_NAME-$i" "$EVENT_NAME$i"
+ start_lttng_tracing "$SESSION_NAME-$i"
+ done
+
+ echo -n "Starting application generating $NR_ITER events... "
+ ./$CURDIR/gen-nevents $NR_ITER &
+ print_ok
+
+ # At least hit one event
+ echo -n "Waiting for events to record "
+ while [ -n "$(pidof gen-nevents)" ]; do
+ echo -n "."
+ sleep 0.1
+ done
+ print_ok
+
+ for i in `seq 0 3`; do
+ stop_lttng_tracing "$SESSION_NAME-$i"
+ destroy_lttng_session "$SESSION_NAME-$i"
+ out=$(babeltrace "$TRACE_PATH/$i" | grep "$EVENT_NAMEi$i" | wc -l)
+ if [ $out -ne $NR_ITER ]; then
+ echo -n "No event found. Suppose to have at least one... "
+ print_fail
+ out=1
+ else
+ echo -n "Found $out event(s) for $SESSION_NAME-$i. Coherent... "
+ print_ok
+ out=0
+ fi
+ done
+
+ return $out
+}
+
+# MUST set TESTDIR before calling those functions
+
+start_lttng_sessiond
+
+TRACE_PATH=$(mktemp -d)
+
+test_multi_session
+out=$?
+if [ $out -ne 0 ]; then
+ stop_lttng_sessiond
+ exit $out
+fi
+
+stop_lttng_sessiond
+
+rm -rf "$TRACE_PATH"
--- /dev/null
+/*
+ * Copyright (c) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
+ * IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program for any purpose,
+ * provided the above notices are retained on all copies. Permission to modify
+ * the code and to distribute modified code is granted, provided the above
+ * notices are retained, and a notice that the code was modified is included
+ * with the above copyright notice.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_gen_nevents.h"
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_gen_nevents
+
+#if !defined(_TRACEPOINT_UST_GEN_NEVENTS_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_GEN_NEVENTS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(ust_gen_nevents, tptest0,
+ TP_ARGS(int, anint, long, value),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer(long, longfield, value)
+ )
+)
+
+TRACEPOINT_EVENT(ust_gen_nevents, tptest1,
+ TP_ARGS(int, anint, long, value),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer(long, longfield, value)
+ )
+)
+
+TRACEPOINT_EVENT(ust_gen_nevents, tptest2,
+ TP_ARGS(int, anint, long, value),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer(long, longfield, value)
+ )
+)
+
+TRACEPOINT_EVENT(ust_gen_nevents, tptest3,
+ TP_ARGS(int, anint, long, value),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer(long, longfield, value)
+ )
+)
+
+#endif /* _TRACEPOINT_UST_GEN_NEVENTS_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./ust_gen_nevents.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+AM_CFLAGS = -I$(srcdir) -O2
+AM_LDFLAGS = -llttng-ust
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+AM_LDFLAGS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+AM_LDFLAGS += -lc
+endif
+
+noinst_PROGRAMS = gen-events-time
+gen_events_time_SOURCES = gen-events-time.c tp.c ust_gen_event.h
+gen_events_time_LDADD = -llttng-ust
+
+noinst_SCRIPTS = run ust-nprocesses
+EXTRA_DIST = run ust-nprocesses
--- /dev/null
+/*
+ * Copyright (C) - 2009 Pierre-Marc Fournier
+ * Copyright (C) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; version 2.1 of the License.
+ *
+ * This library 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 Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_gen_event.h"
+
+int main(int argc, char **argv)
+{
+ int i, netint;
+ long values[] = { 1, 2, 3 };
+ char text[10] = "test";
+ double dbl = 2.0;
+ float flt = 2222.0;
+ /* Default loop time is 60 sec since each round sleeps 1 sec */
+ unsigned int nr_iter = 60;
+
+ fclose(stdout);
+ fclose(stderr);
+ fclose(stdin);
+
+ if (argc == 2) {
+ nr_iter = atoi(argv[1]);
+ }
+
+ for (i = 0; i < nr_iter; i++) {
+ netint = htonl(i);
+ tracepoint(ust_gen_event, tptest, i, netint, values, text,
+ strlen(text), dbl, flt);
+ sleep(1);
+ }
+
+ return 0;
+}
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library 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 Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+NR_ITER=100
+TEST_DESC="UST tracer - Generate $NR_ITER process"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+TEST_BIN_NAME="gen-events-time"
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$TEST_BIN_NAME" ]; then
+ echo -e "No UST $TEST_BIN_NAME binary detected. Passing."
+ exit 0
+fi
+
+# MUST set TESTDIR before calling those functions
+
+start_lttng_sessiond
+
+./$CURDIR/ust-nprocesses $NR_ITER
+
+stop_lttng_sessiond
+
+exit 0
--- /dev/null
+/*
+ * Copyright (c) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
+ * IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program for any purpose,
+ * provided the above notices are retained on all copies. Permission to modify
+ * the code and to distribute modified code is granted, provided the above
+ * notices are retained, and a notice that the code was modified is included
+ * with the above copyright notice.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_gen_event.h"
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library 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 Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+NR_ITER=$1
+TEST_BIN_NAME="gen-events-time"
+SESSION_NAME="ust-nprocesses"
+EVENT_NAME="ust_gen_event:tptest"
+TEST_WAIT_SEC=5
+
+source $TESTDIR/utils/utils.sh
+
+# MUST set TESTDIR before calling those functions
+
+# Start test for 1000 seconds
+
+for i in `seq 1 $NR_ITER`
+do
+ ./$CURDIR/$TEST_BIN_NAME 1000 >/dev/null 2>&1 &
+done
+
+echo -n "Validating registered apps in 3 seconds..."
+
+sleep 3
+
+listing=$($TESTDIR/../src/bin/lttng/$LTTNG_BIN list -u)
+reg_app_count=$(echo -n $listing | sed "s/$TEST_BIN_NAME/$TEST_BIN_NAME\n/g" | grep "$TEST_BIN_NAME" | wc -l)
+if [ "$reg_app_count" -ne "$NR_ITER" ]; then
+ echo -e "$reg_app_count apps listed. Expected $NR_ITER "
+ print_fail
+else
+ print_ok
+fi
+
+TRACE_PATH=$(mktemp -d)
+
+create_lttng_session $SESSION_NAME $TRACE_PATH
+
+enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+start_lttng_tracing $SESSION_NAME
+
+echo "Sleeping $TEST_WAIT_SEC seconds for tracing to start everywhere"
+echo "Warning: this arbitrary time can make the test fail on slower system"
+sleep $TEST_WAIT_SEC
+
+stop_lttng_tracing $SESSION_NAME
+destroy_lttng_session $SESSION_NAME
+
+rm -rf $TRACE_PATH
+
+echo -e -n "Killing all spawned applications..."
+killall -q $TEST_BIN_NAME >/dev/null 2>&1 &
+print_ok
+exit 0
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_gen_event
+
+#if !defined(_TRACEPOINT_UST_GEN_EVENT_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_GEN_EVENT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(ust_gen_event, tptest,
+ TP_ARGS(int, anint, int, netint, long *, values,
+ char *, text, size_t, textlen,
+ double, doublearg, float, floatarg),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer_hex(int, intfield2, anint)
+ ctf_integer(long, longfield, anint)
+ ctf_integer_network(int, netintfield, netint)
+ ctf_integer_network_hex(int, netintfieldhex, netint)
+ ctf_array(long, arrfield1, values, 3)
+ ctf_array_text(char, arrfield2, text, 10)
+ ctf_sequence(char, seqfield1, text, size_t, textlen)
+ ctf_sequence_text(char, seqfield2, text, size_t, textlen)
+ ctf_string(stringfield, text)
+ ctf_float(float, floatfield, floatarg)
+ ctf_float(double, doublefield, doublearg)
+ )
+)
+
+#endif /* _TRACEPOINT_UST_GEN_EVENT_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./ust_gen_event.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+SUBDIRS = demo
+
+noinst_SCRIPTS = run
+EXTRA_DIST = run overlap.sh
--- /dev/null
+AM_CFLAGS=-I$(srcdir)
+if NO_SHARED
+# Do not build this test if shared libraries support was
+# explicitly disabled.
+else
+# Force the shared flag on the noinst libraries since they are
+# only built static by default
+FORCE_SHARED_LIB_OPTIONS = -module -shared -avoid-version \
+ -rpath $(abs_builddir)
+
+#contains ust_tests_demo.h and ust_tests_demo2.h provider probes
+liblttng_ust_provider_ust_tests_demo_la_SOURCES = \
+ tp.c ust_tests_demo.h \
+ tp2.c ust_tests_demo2.h
+liblttng_ust_provider_ust_tests_demo_la_LIBADD = -llttng-ust
+liblttng_ust_provider_ust_tests_demo_la_LDFLAGS = $(FORCE_SHARED_LIB_OPTIONS)
+
+#contains ust_tests_demo3.h provider probes
+liblttng_ust_provider_ust_tests_demo3_la_SOURCES = tp3.c ust_tests_demo3.h
+liblttng_ust_provider_ust_tests_demo3_la_LIBADD = -llttng-ust
+liblttng_ust_provider_ust_tests_demo3_la_LDFLAGS = $(FORCE_SHARED_LIB_OPTIONS)
+
+noinst_LTLIBRARIES = liblttng-ust-provider-ust-tests-demo.la \
+ liblttng-ust-provider-ust-tests-demo3.la
+
+noinst_PROGRAMS = demo
+demo_SOURCES = demo.c ust_tests_demo.h
+# The demo program only depends on libdl/libc for dlopen().
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+demo_LDADD = -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+demo_LDADD = -lc
+endif
+
+noinst_SCRIPTS = demo-trace
+EXTRA_DIST = demo-trace
+endif
--- /dev/null
+#!/bin/sh
+
+LD_PRELOAD=.libs/liblttng-ust-provider-ust-tests-demo.so:.libs/liblttng-ust-provider-ust-tests-demo3.so ./demo ${*}
--- /dev/null
+/*
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
+
+#define TRACEPOINT_DEFINE
+#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
+#include "ust_tests_demo.h"
+#include "ust_tests_demo2.h"
+#include "ust_tests_demo3.h"
+
+int main(int argc, char **argv)
+{
+ int i, netint;
+ long values[] = { 1, 2, 3 };
+ char text[10] = "test";
+ double dbl = 2.0;
+ float flt = 2222.0;
+ int delay = 0;
+
+ if (argc == 2)
+ delay = atoi(argv[1]);
+
+ fprintf(stderr, "Demo program starting.\n");
+
+ sleep(delay);
+
+ fprintf(stderr, "Tracing... ");
+ tracepoint(ust_tests_demo, starting, 123);
+ for (i = 0; i < 5; i++) {
+ netint = htonl(i);
+ tracepoint(ust_tests_demo2, loop, i, netint, values,
+ text, strlen(text), dbl, flt);
+ }
+ tracepoint(ust_tests_demo, done, 456);
+ tracepoint(ust_tests_demo3, done, 42);
+ fprintf(stderr, " done.\n");
+ return 0;
+}
--- /dev/null
+/*
+ * tp.c
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_demo.h"
--- /dev/null
+/*
+ * tp2.c
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_demo2.h"
--- /dev/null
+/*
+ * tp3.c
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_demo3.h"
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_demo
+
+#if !defined(_TRACEPOINT_UST_TESTS_DEMO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_DEMO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(ust_tests_demo, starting,
+ TP_ARGS(int, value),
+ TP_FIELDS(
+ ctf_integer(int, value, value)
+ )
+)
+TRACEPOINT_LOGLEVEL(ust_tests_demo, starting, TRACE_CRIT)
+
+/*
+ * Dummy model information, just for example. TODO: we should check if
+ * EMF model URI have some standard format we should follow.
+ */
+TRACEPOINT_MODEL_EMF_URI(ust_tests_demo, starting,
+ "http://example.com/path_to_model?q=ust_tests_demo:starting")
+
+TRACEPOINT_EVENT(ust_tests_demo, done,
+ TP_ARGS(int, value),
+ TP_FIELDS(
+ ctf_integer(int, value, value)
+ )
+)
+TRACEPOINT_LOGLEVEL(ust_tests_demo, done, TRACE_CRIT)
+
+TRACEPOINT_MODEL_EMF_URI(ust_tests_demo, done,
+ "http://example.com/path_to_model?q=ust_tests_demo:done")
+
+#endif /* _TRACEPOINT_UST_TESTS_DEMO_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./ust_tests_demo.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_demo2
+
+#if !defined(_TRACEPOINT_UST_TESTS_DEMO2_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_DEMO2_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(ust_tests_demo2, loop,
+ TP_ARGS(int, anint, int, netint, long *, values,
+ char *, text, size_t, textlen,
+ double, doublearg, float, floatarg),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer_hex(int, intfield2, anint)
+ ctf_integer(long, longfield, anint)
+ ctf_integer_network(int, netintfield, netint)
+ ctf_integer_network_hex(int, netintfieldhex, netint)
+ ctf_array(long, arrfield1, values, 3)
+ ctf_array_text(char, arrfield2, text, 10)
+ ctf_sequence(char, seqfield1, text,
+ size_t, textlen)
+ ctf_sequence_text(char, seqfield2, text,
+ size_t, textlen)
+ ctf_string(stringfield, text)
+ ctf_float(float, floatfield, floatarg)
+ ctf_float(double, doublefield, doublearg)
+ )
+)
+TRACEPOINT_LOGLEVEL(ust_tests_demo2, loop, TRACE_WARNING)
+
+#endif /* _TRACEPOINT_UST_TESTS_DEMO2_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./ust_tests_demo2.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_demo3
+
+#if !defined(_TRACEPOINT_UST_TESTS_DEMO3_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_DEMO3_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(ust_tests_demo3, done,
+ TP_ARGS(int, value),
+ TP_FIELDS(
+ ctf_integer(int, value, value)
+ )
+)
+TRACEPOINT_LOGLEVEL(ust_tests_demo3, done, TRACE_WARNING)
+
+#endif /* _TRACEPOINT_UST_TESTS_DEMO3_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./ust_tests_demo3.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library 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 Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+TEST_DESC="UST - Wildcard overlap"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+SESSION_NAME="wildcard-overlap"
+
+DEMO_EVENT1="ust_tests_demo:starting"
+DEMO_EVENT1_2="ust_tests_demo:done"
+DEMO_EVENT2="ust_tests_demo2:loop"
+DEMO_EVENT3="ust_tests_demo3:done"
+
+NUM_DEMO1_EVENT=1
+NUM_DEMO1_2_EVENT=1
+NUM_DEMO2_EVENT=5
+NUM_DEMO3_EVENT=1
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/demo/demo" ]; then
+ echo -e "No UST nevents binary detected. Passing."
+ exit 0
+fi
+
+# MUST set TESTDIR before calling those functions
+
+run_demo_app()
+{
+ cd $CURDIR/demo
+
+ # Start test
+ echo -n "Starting application... "
+ ./demo-trace >/dev/null 2>&1
+ echo -n "Ended "
+ print_ok
+
+ cd -
+}
+
+# Ease our life a bit ;)
+trace_match_demo1_events()
+{
+ trace_matches "$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
+ trace_matches "$DEMO_EVENT1_2" $NUM_DEMO1_EVENT $TRACE_PATH
+}
+
+# Ease our life a bit ;)
+trace_match_all_demo_events()
+{
+ trace_match_demo1_events
+ trace_matches "$DEMO_EVENT2" $NUM_DEMO2_EVENT $TRACE_PATH
+ trace_matches "$DEMO_EVENT3" $NUM_DEMO3_EVENT $TRACE_PATH
+}
+
+# Ease our life a bit ;)
+trace_match_no_demo_events()
+{
+ trace_matches "$DEMO_EVENT1" 0 $TRACE_PATH
+ trace_matches "$DEMO_EVENT1_2" 0 $TRACE_PATH
+ trace_matches "$DEMO_EVENT2" 0 $TRACE_PATH
+ trace_matches "$DEMO_EVENT3" 0 $TRACE_PATH
+}
+
+# Expect all "demo" events, no duplicate.
+test_enable_simple_wildcard()
+{
+ local event_wild1="us*"
+ local event_wild2="ust*"
+
+ echo ""
+ echo "=== Simple wildcard overlap"
+
+ enable_ust_lttng_event $SESSION_NAME "$event_wild1"
+ enable_ust_lttng_event $SESSION_NAME "$event_wild2"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+
+ return $?
+}
+
+# Expect all "demo" events, no duplicate.
+test_enable_wildcard_filter()
+{
+ local event_wild1="us*"
+ local event_wild2="ust*"
+
+ echo ""
+ echo "=== Wildcard overlap with filter"
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+ return $?
+}
+
+# Expect all "demo" events, no duplicate.
+test_enable_wildcard_filter_2()
+{
+ local event_wild1="us*"
+ local event_wild2="ust*"
+
+ echo ""
+ echo "=== Wildcard overlap with filter 2"
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+ return $?
+}
+
+# Expect all "demo" events, no duplicate.
+test_enable_wildcard_filter_3()
+{
+ local event_wild1="us*"
+ local event_wild2="ust*"
+
+ echo ""
+ echo "=== Wildcard overlap with filter 3"
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+ return $?
+}
+
+# Expected: No events.
+test_enable_wildcard_filter_4()
+{
+ local event_wild1="us*"
+ local event_wild2="ust*"
+
+ echo ""
+ echo "=== Wildcard overlap with filter 4"
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_no_demo_events
+ return $?
+}
+
+# Expect all "demo" events, no duplicate.
+test_enable_wildcard_filter_5()
+{
+ local event_wild1="us*"
+ local event_wild2="$DEMO_EVENT1"
+
+ echo ""
+ echo "=== Wildcard overlap with filter 5"
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+ return $?
+}
+
+# Expect all $DEMO_EVENT1 events, no duplicate.
+test_enable_wildcard_filter_6()
+{
+ local event_wild1="us*"
+ local event_wild2="$DEMO_EVENT1"
+
+ echo ""
+ echo "=== Wildcard overlap with filter 6"
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
+ trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH
+ trace_matches $DEMO_EVENT2 0 $TRACE_PATH
+ trace_matches $DEMO_EVENT3 0 $TRACE_PATH
+ return $?
+}
+
+# Expect all events, no duplicate.
+test_enable_wildcard_filter_7()
+{
+ local event_wild1="us*"
+ local event_wild2="$DEMO_EVENT1"
+
+ echo ""
+ echo "=== Wildcard overlap with filter 7"
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+ return $?
+}
+
+# Expected: No events.
+test_enable_wildcard_filter_8()
+{
+ local event_wild1="us*"
+ local event_wild2="$DEMO_EVENT1"
+
+ echo ""
+ echo "=== Wildcard overlap with filter 8"
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_no_demo_events
+ return $?
+}
+
+# Expect all events.
+test_enable_same_wildcard_filter()
+{
+ local event_wild1="ust*"
+ local event_wild2="ust*"
+
+ echo ""
+ echo "=== Same wildcard overlap with filter"
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+ return $?
+}
+
+# Expect all events.
+test_enable_same_wildcard_filter_2()
+{
+ local event_wild1="ust*"
+ local event_wild2="ust*"
+
+ echo ""
+ echo "=== Same wildcard overlap with filter 2"
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
+ if [ $? -eq 1 ]; then
+ echo -n "FAIL is normal. Same event with same filter is denied by the sessiond "
+ print_ok
+ else
+ print_fail
+ fi
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+ return $?
+}
+
+# Expect all events.
+test_enable_same_wildcard_filter_3()
+{
+ local event_wild1="ust*"
+ local event_wild2="ust*"
+
+ echo ""
+ echo "=== Same wildcard overlap with filter 3"
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+ return $?
+}
+
+# Expected: No events.
+test_enable_same_wildcard_filter_4()
+{
+ local event_wild1="ust*"
+ local event_wild2="ust*"
+
+ echo ""
+ echo "=== Same wildcard overlap with filter 4"
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0&&1==0"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_no_demo_events
+ return $?
+}
+
+# Expected: Only $DEMO_EVENT1
+test_enable_same_event_filter()
+{
+ local event_wild1="$DEMO_EVENT1"
+ local event_wild2="$DEMO_EVENT1"
+
+ echo ""
+ echo "=== Enable same event with filter."
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
+
+ disable_ust_lttng_event $SESSION_NAME "ust*"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
+ trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH
+ trace_matches $DEMO_EVENT2 0 $TRACE_PATH
+ trace_matches $DEMO_EVENT3 0 $TRACE_PATH
+ return $?
+}
+
+# Expected: No events.
+test_disable_same_wildcard_filter()
+{
+ local event_wild1="ust*"
+ local event_wild2="ust*"
+
+ echo ""
+ echo "=== Disable same wildcard with filter."
+
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1"
+ enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
+
+ disable_ust_lttng_event $SESSION_NAME "ust*"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_no_demo_events
+ return $?
+}
+
+# Expect no events
+test_enable_bad_wildcard()
+{
+ # Invalid event
+ local event_wild1="ust_tests_demo"
+ local event_wild2="ust_tests_demo2"
+ local event_wild3="ust_tests_demo3"
+
+ echo ""
+ echo "=== Enable bad wildcard"
+
+ enable_ust_lttng_event $SESSION_NAME "$event_wild1"
+ enable_ust_lttng_event $SESSION_NAME "$event_wild2"
+ enable_ust_lttng_event $SESSION_NAME "$event_wild3"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_no_demo_events
+ return $?
+}
+
+# Expect all "demo" events, no duplicate.
+test_enable_simple_wildcard_2()
+{
+ local event_wild1="us*"
+ local event_wild2="$DEMO_EVENT1"
+
+ echo ""
+ echo "=== Simple wildcard 2"
+
+ enable_ust_lttng_event $SESSION_NAME "$event_wild1"
+ enable_ust_lttng_event $SESSION_NAME "$event_wild2"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+ return $?
+}
+
+# Expected: all CRIT events, + all warning events.
+test_enable_loglevel_overlap()
+{
+ local event_wild1="us*"
+ local event_wild2="ust*"
+
+ echo ""
+ echo "=== Enable loglevel overlap"
+
+ enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING"
+ enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_CRIT"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+ return $?
+}
+
+# Expected: all CRIT events, + all warning events.
+test_enable_loglevel_only_overlap()
+{
+ local event_wild1="us*"
+ local event_wild2="ust*"
+
+ echo ""
+ echo "=== Enable loglevel only overlap"
+
+ enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING"
+ enable_ust_lttng_event_loglevel_only $SESSION_NAME "$event_wild2" "TRACE_CRIT"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+ return $?
+}
+
+# Expected: all events
+test_enable_loglevel_overlap_2()
+{
+ local event_wild1="us*"
+ local event_wild2="$DEMO_EVENT2"
+
+ echo ""
+ echo "=== Enable loglevel overlap 2"
+
+ enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING"
+ enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_CRIT"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+ return $?
+}
+
+# Expected only ust_tests_demo* events.
+test_enable_same_wildcard_loglevels()
+{
+ local event_wild1="ust*"
+ local event_wild2="ust*"
+
+ echo ""
+ echo "=== Enable same wildcard with different loglevels"
+
+ enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_CRIT"
+ enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_WARNING"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_match_all_demo_events
+ return $?
+}
+
+# Expected only ust_tests_demo:starting events.
+test_enable_same_event_loglevels()
+{
+ local event_wild1="$DEMO_EVENT1"
+ local event_wild2="$DEMO_EVENT1"
+
+ echo ""
+ echo "=== Enable same event with different loglevels"
+
+ enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_CRIT"
+ enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_WARNING"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
+ trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH
+ trace_matches $DEMO_EVENT2 0 $TRACE_PATH
+ trace_matches $DEMO_EVENT3 0 $TRACE_PATH
+ return $?
+}
+
+# Expect 0 event
+test_disable_simple_wildcard()
+{
+ local event_wild1="us*"
+ local event_wild2="$DEMO_EVENT1"
+
+ echo ""
+ echo "=== Disable simple wildcard"
+
+ enable_ust_lttng_event $SESSION_NAME "$event_wild1"
+ enable_ust_lttng_event $SESSION_NAME "$event_wild2"
+
+ disable_ust_lttng_event $SESSION_NAME "$event_wild1"
+ disable_ust_lttng_event $SESSION_NAME "$event_wild2"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ # No events are expected.
+ trace_match_no_demo_events
+ return $?
+}
+
+# Expect only "ust_tests_demo" events.
+test_disable_wildcard_overlap()
+{
+ local event_wild1="us*"
+ local event_wild2="$DEMO_EVENT1"
+
+ echo ""
+ echo "=== Disable wildcard overlap"
+
+ enable_ust_lttng_event $SESSION_NAME "$event_wild1"
+ enable_ust_lttng_event $SESSION_NAME "$event_wild2"
+
+ disable_ust_lttng_event $SESSION_NAME "$event_wild1"
+
+ start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ run_demo_app
+
+ stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
+
+ # Expect only "ust_tests_demo" events.
+ trace_matches "$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
+ trace_matches "$DEMO_EVENT1_2" 0 $TRACE_PATH
+ trace_matches "$DEMO_EVENT2" 0 $TRACE_PATH
+ trace_matches "$DEMO_EVENT3" 0 $TRACE_PATH
+ return $?
+}
+
+TESTS=(
+ "test_enable_wildcard_filter"
+ "test_enable_wildcard_filter_2"
+ "test_enable_wildcard_filter_3"
+ "test_enable_wildcard_filter_4"
+ "test_enable_wildcard_filter_5"
+ "test_enable_wildcard_filter_6"
+ "test_enable_wildcard_filter_7"
+ "test_enable_wildcard_filter_8"
+ "test_enable_same_wildcard_filter"
+ "test_enable_same_wildcard_filter_2"
+ "test_enable_same_wildcard_filter_3"
+ "test_enable_same_wildcard_filter_4"
+ "test_enable_same_event_filter"
+ "test_enable_loglevel_only_overlap"
+ "test_enable_same_event_loglevels"
+ "test_enable_same_wildcard_loglevels"
+ "test_enable_bad_wildcard"
+ "test_enable_loglevel_overlap_2"
+ "test_enable_simple_wildcard"
+ "test_enable_simple_wildcard_2"
+ "test_enable_loglevel_overlap"
+ "test_disable_simple_wildcard"
+ "test_disable_wildcard_overlap"
+)
+
+TEST_COUNT=${#TESTS[@]}
+i=0
+
+start_lttng_sessiond
+
+while [ "$i" -lt "$TEST_COUNT" ]; do
+
+ TRACE_PATH=$(mktemp -d)
+
+ create_lttng_session $SESSION_NAME $TRACE_PATH >/dev/null 2>&1
+
+ # Execute test
+ ${TESTS[$i]}
+ if [ $? -ne 0 ]; then
+ stop_lttng_sessiond
+ exit 1
+ fi
+
+ destroy_lttng_session $SESSION_NAME >/dev/null 2>&1
+
+ rm -rf $TRACE_PATH
+
+ let "i++"
+done
+
+stop_lttng_sessiond
--- /dev/null
+#!/bin/bash
+
+DIR=$(dirname $0)
+
+tests=( $DIR/overlap.sh)
+
+exit_code=0
+
+function start_tests ()
+{
+ for bin in ${tests[@]};
+ do
+ ./$bin
+ # Test must return 0 to pass.
+ if [ $? -ne 0 ]; then
+ exit_code=1
+ break
+ fi
+ done
+}
+
+start_tests
+
+exit $exit_code
--- /dev/null
+#!/bin/bash
+
+SESSIOND_BIN="lttng-sessiond"
+CURDIR=$(dirname $0)
+TESTDIR=$CURDIR/../..
+
+source $TESTDIR/utils/utils.sh
+
+tmpdir=`mktemp -d`
+tests=( $CURDIR/ust_global_event_basic $CURDIR/ust_global_event_wildcard )
+exit_code=0
+
+function start_tests ()
+{
+ for bin in ${tests[@]};
+ do
+ if [ ! -e $bin ]; then
+ echo -e "$bin not found, passing"
+ continue
+ fi
+
+ start_lttng_sessiond
+
+ ./$bin $tmpdir
+ # Test must return 0 to pass.
+ if [ $? -ne 0 ]; then
+ exit_code=1
+ stop_lttng_sessiond
+ break
+ fi
+ stop_lttng_sessiond
+ done
+
+ # Cleaning up
+ rm -rf $tmpdir
+}
+
+TEST_DESC="UST tracer - Global domain (LTTNG_DOMAIN_UST)"
+
+print_test_banner "$TEST_DESC"
+
+start_tests
+
+exit $exit_code
--- /dev/null
+#!/bin/bash
+
+DIR=$(dirname $0)
+
+tests=( $DIR/run-ust-global-tests.sh $DIR/nprocesses/run \
+ $DIR/high-throughput/run $DIR/before-after/run \
+ $DIR/multi-session/run $DIR/overlap/run )
+
+# $DIR/low-throughput/run --> DEACTIVATED.
+# Use only for release. This test last 20 minutes
+
+exit_code=0
+
+function start_tests ()
+{
+ for bin in ${tests[@]};
+ do
+ ./$bin
+ # Test must return 0 to pass.
+ if [ $? -ne 0 ]; then
+ exit_code=1
+ break
+ fi
+ done
+}
+
+start_tests
+
+exit $exit_code
--- /dev/null
+/*
+ * 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_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;
+ channel.attr.num_subbuf = 4;
+ channel.attr.switch_timer_interval = 0;
+ 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;
+
+ strcpy(ev2.name, "ev2");
+ ev2.type = LTTNG_EVENT_TRACEPOINT;
+ ev2.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+
+ strcpy(ev3.name, "ev3");
+ ev3.type = LTTNG_EVENT_TRACEPOINT;
+ ev3.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+
+ printf("\nTesting tracing 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 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));
+ goto handle_fail;
+ }
+ PRINT_OK();
+
+ printf("Enabling %s UST channel: ", channel.name);
+ if ((ret = lttng_enable_channel(handle, &channel)) < 0) {
+ printf("error enable channel: %s\n", lttng_strerror(ret));
+ goto enable_fail;
+ }
+ PRINT_OK();
+
+ 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 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 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));
+ goto enable_fail;
+ }
+ PRINT_OK();
+
+ printf("Disabling %s UST event: ", ev3.name);
+ if ((ret = lttng_disable_event(handle, ev3.name, channel2.name)) < 0) {
+ printf("error enabling event: %s\n", lttng_strerror(ret));
+ goto enable_fail;
+ }
+ PRINT_OK();
+
+ printf("Renabling %s UST event: ", ev1.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("Renabling %s UST event: ", ev3.name);
+ if ((ret = lttng_enable_event(handle, &ev3, channel.name)) < 0) {
+ printf("error enabling event: %s\n", lttng_strerror(ret));
+ goto enable_fail;
+ }
+ 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));
+ 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("Restart 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 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));
+ }
+ PRINT_OK();
+
+ return 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);
+
+ return 1;
+}
--- /dev/null
+/*
+ * 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;
+}
+++ /dev/null
-#!/usr/bin/env python
-
-import os, sys
-import subprocess
-import threading
-import Queue
-import time
-import shlex
-
-from signal import signal, SIGTERM, SIGINT, SIGPIPE, SIG_DFL
-
-SESSIOND_BIN_NAME = "lttng-sessiond"
-SESSIOND_BIN_PATH = "src/bin/lttng-sessiond/"
-CONSUMERD_BIN_NAME = "lttng-consumerd"
-CONSUMERD_BIN_PATH = "src/bin/lttng-consumerd/"
-TESTDIR_PATH = ""
-
-PRINT_BRACKET = "\033[1;34m[\033[1;33m+\033[1;34m]\033[00m"
-PRINT_RED_BRACKET = "\033[1;31m[+]\033[00m"
-PRINT_GREEN_BRACKET = "\033[1;32m[+]\033[00m"
-PRINT_ARROW = "\033[1;32m-->\033[00m"
-
-is_root = 1
-no_stats = 0
-stop_sampling = 1
-
-top_cpu_legend = { 'us': "User CPU time", 'sy': "System CPU time",
- 'id': "Idle CPU time", 'ni': "Nice CPU time", 'wa': "iowait",
- 'hi': "Hardware IRQ", 'si': "Software Interrupts", 'st': "Steal Time", }
-
-cpu_ret_q = Queue.Queue()
-mem_ret_q = Queue.Queue()
-test_ret_q = Queue.Queue()
-
-global sdaemon_proc
-global worker_proc
-
-def cpu_create_usage_dict(top_line):
- """
- Return a dictionnary from a 'top' cpu line.
- Ex: Cpu(s): 2.1%us, 1.2%sy, 0.0%ni, 96.2%id, 0.4%wa, 0.0%hi, 0.0%si, 0.0%st
- """
- top_dict = {'us': 0, 'sy': 0, 'ni': 0, 'id': 0, 'wa': 0, 'hi': 0, 'si': 0, 'st': 0}
-
- # Split expression and remove first value which is "Cpu(s)"
- top_line = top_line.replace(",","")
- words = top_line.split()[1:]
-
-
- for key in top_dict:
- index = words.index(key)
- # Add the value to the dictionnary
- val = words[index-1]
- top_dict[key] = float(val)
-
- return top_dict
-
-def cpu_average_usage(top_lines):
- """
- Return a dictionnary of 'top' CPU stats but averaging all values.
- """
- avg_dict = {'us': 0, 'sy': 0, 'ni': 0, 'id': 0, 'wa': 0, 'hi': 0, 'si': 0, 'st': 0}
- # Average count
- count = 0.0
-
- for line in top_lines:
- tmp_dict = cpu_create_usage_dict(line)
- # Add value to avg dictionnary
- for key in tmp_dict:
- avg_dict[key] += tmp_dict[key]
-
- count += 1.0
-
- for key in avg_dict:
- avg_dict[key] = avg_dict[key] / count
-
- return (count, avg_dict)
-
-def cpu_sample_usage(pid=None):
- """
- Sample CPU usage for num iterations.
- If num is greater than 1, the average will be computed.
- """
- args = ["top", "-b", "-n", "1"]
- if pid:
- args.append("-p")
- args.append(str(pid))
-
- # Spawn top process
- top = subprocess.Popen(args, stdout = subprocess.PIPE)
-
- grep = subprocess.Popen(["grep", "Cpu"], stdin = top.stdout,
- stdout = subprocess.PIPE)
- top.stdout.close()
-
- return grep.communicate()[0].strip("\n")
-
-def mem_sample_usage(pid):
- """
- Sample memory usage using /proc and a pid
- """
- args = ["cat", "/proc/" + str(pid) + "/status"]
-
- if not os.path.isfile(args[1]):
- return -1
-
- mem_proc = subprocess.Popen(args, stdout = subprocess.PIPE)
-
- grep = subprocess.Popen(["grep", "^VmRSS"], stdin = mem_proc.stdout,
- stdout = subprocess.PIPE)
- mem_proc.stdout.close()
-
- # Return virtual memory size in kilobytes (kB)
- #ret = grep.communicate()[0].split()
- ret = grep.communicate()[0].split()
-
- if len(ret) > 1:
- ret = ret[1]
- else:
- ret = 0
-
- return int(ret)
-
-class SamplingWorker(threading.Thread):
- def __init__(self, s_type, worker = None, delay = 0.2, pid = 0):
- threading.Thread.__init__ (self)
- self.s_type = s_type
- self.delay = delay
- self.pid = pid
- self.worker = worker
-
- def run(self):
- count = 1
- lines = []
-
- if self.s_type == "cpu":
- while 1:
- if self.worker == None:
- cpu_line = cpu_sample_usage(self.pid)
- lines.append(cpu_line)
- break
- elif self.worker.is_alive():
- cpu_line = cpu_sample_usage(self.pid)
- lines.append(cpu_line)
- else:
- break
-
- # Delay sec per memory sampling
- time.sleep(self.delay)
-
- count, stats = cpu_average_usage(lines)
- cpu_ret_q.put((count, stats))
- # grep process has ended here
-
- elif self.s_type == "mem":
- count = 0
- mem_stat = 0
-
- while 1:
- if self.worker == None:
- cpu_line = cpu_sample_usage(self.pid)
- lines.append(cpu_line)
- break
- elif self.worker.is_alive():
- mem_stat += get_mem_usage(self.pid)
- count += 1
- else:
- break
-
- # Delay sec per memory sampling
- time.sleep(self.delay)
-
- mem_ret_q.put((count, mem_stat))
-
-class TestWorker(threading.Thread):
- def __init__(self, path, name, env):
- threading.Thread.__init__(self)
- self.path = path
- self.name = name
- self.env = env
-
- def run(self):
- bin_path_name = os.path.join(self.path, self.name)
-
- test = subprocess.Popen([bin_path_name], env=self.env, preexec_fn = lambda: signal(SIGPIPE, SIG_DFL))
- test.wait()
-
- # Send ret value to main thread
- test_ret_q.put(test.returncode)
-
-def get_pid(procname):
- """
- Return pid of process name using 'pidof' command
- """
- pidof = subprocess.Popen(["pidof", procname], stdout = subprocess.PIPE)
- pid = pidof.communicate()[0].split()
-
- if pid == []:
- return 0
-
- return int(pid[0])
-
-def spawn_session_daemon():
- """
- Exec the session daemon and return PID
- """
- global sdaemon_proc
-
- pid = get_pid(SESSIOND_BIN_NAME)
- if pid != 0:
- os.kill(pid, SIGTERM)
-
- bin_path = os.path.join(TESTDIR_PATH, "..", SESSIOND_BIN_PATH, SESSIOND_BIN_NAME)
- consumer_path = os.path.join(TESTDIR_PATH, "..", CONSUMERD_BIN_PATH, CONSUMERD_BIN_NAME)
-
- if not os.path.isfile(bin_path):
- print "Error: No session daemon binary found. Compiled?"
- return 0
-
- try:
- args = shlex.split("libtool execute " + bin_path
- + " --consumerd32-path=" + consumer_path
- + " --consumerd64-path=" + consumer_path)
-
- sdaemon_proc = subprocess.Popen(args, shell = False, stderr = subprocess.PIPE)
-
- except OSError, e:
- print e
- return 0
-
- time.sleep(1)
-
- return get_pid("lt-" + SESSIOND_BIN_NAME)
-
-def start_test(name):
- """
- Spawn test and return exit code
- """
- tw = TestWorker(".", name)
- tw.start()
-
- return test_ret_q.get(True)
-
-def print_cpu_stats(stats, count):
- """
- Pretty print on one line the CPU stats
- """
- sys.stdout.write(PRINT_ARROW + " Cpu [sampled %d time(s)]:\n " % (count))
- for stat in stats:
- sys.stdout.write(" %s: %.2f, " % (stat, stats[stat]))
- print ""
-
-def get_cpu_usage(delay=1, pid=0):
- """
- Spawn a worker thread to sample cpu usage.
- """
- sw = SamplingWorker("cpu", delay = delay, pid = pid)
- sw.start()
-
- return cpu_ret_q.get(True)
-
-def get_mem_usage(pid):
- """
- Get memory usage for PID
- """
- return mem_sample_usage(pid)
-
-def print_test_success(ret, expect):
- """
- Print if test has failed or pass according to the expected value.
- """
- if ret != expect:
- print "\n" + PRINT_RED_BRACKET + \
- " Failed: ret = %d (expected %d)" % (ret, expect)
- return 1
- else:
- print "\n" + PRINT_BRACKET + \
- " Passed: ret = %d (expected %d)" % (ret, expect)
- return 0
-
-def run_test(test):
- """
- Run test 'name' and output report of the test with stats.
- """
- global worker_proc
- global sdaemon_proc
- dem_pid = 0 # Session daemon pid
-
- print PRINT_BRACKET + " %s" % (test['name'])
- print PRINT_ARROW + " %s" % (test['desc'])
- if no_stats:
- print PRINT_ARROW + " Statistics will NOT be collected"
- else:
- print PRINT_ARROW + " Statistics of the session daemon will be collected"
-
- if test['kern'] and not is_root:
- print "Needs root for kernel tracing. Skipping"
- return 0
-
- if not os.path.isfile(test['bin']):
- print "Unable to find test file '%s'. Skipping" % (test['bin'])
- return 0
-
- # Session daemon is controlled by the test
- if test['daemon'] == "test":
- print PRINT_ARROW + " Session daemon is controlled by the test"
- env = os.environ
- env['TEST_NO_SESSIOND'] = '0'
- tw = TestWorker(".", test['bin'], env)
- tw.start()
- ret = test_ret_q.get(True)
- print_test_success(ret, test['success'])
- return 0
- elif test['daemon'] == False:
- print PRINT_ARROW + " No session daemon needed"
- env = os.environ
- env['TEST_NO_SESSIOND'] = '1'
- tw = TestWorker(".", test['bin'], env)
- tw.start()
- ret = test_ret_q.get(True)
- print_test_success(ret, test['success'])
- return 0
- else:
- print PRINT_ARROW + " Session daemon needed"
-
- dem_pid = spawn_session_daemon()
- if dem_pid <= 0:
- print "Unable to start %s. Stopping" % (SESSIOND_BIN_NAME)
- print sdaemon_proc.communicate()[1]
- return 0
-
- print PRINT_BRACKET + " Session daemon spawned (pid: %d)\n" % (dem_pid)
-
- if not no_stats:
- mem_before = get_mem_usage(dem_pid)
- print PRINT_BRACKET + " Stats *before* test:"
- print PRINT_ARROW + " Mem (kB): %d" % (mem_before)
- cpu_count, cpu_stats = get_cpu_usage(pid = dem_pid)
- print_cpu_stats(cpu_stats, cpu_count)
-
- # Sessiond was already spawned, do not let the test spawn
- # an additional sessiond
- env = os.environ
- env['TEST_NO_SESSIOND'] = '1'
-
- tw = TestWorker(".", test['bin'], env)
- tw.start()
-
- if not no_stats:
- # Start CPU sampling for test
- sw_cpu = SamplingWorker("cpu", worker = tw, pid = dem_pid)
- sw_cpu.start()
- sw_mem = SamplingWorker("mem", worker = tw, pid = dem_pid)
- sw_mem.start()
-
- ret = test_ret_q.get(True)
-
- if not no_stats:
- time.sleep(2)
- # Compute memory average
- mem_count, mem_during = mem_ret_q.get(True)
- mem_during = float(mem_during) / float(mem_count)
- cpu_count, cpu_stats = cpu_ret_q.get(True)
-
- print "\n" + PRINT_BRACKET + " Stats *during* test:"
- print PRINT_ARROW + " Mem (kB): %.0f [sampled %d time(s)]" % (mem_during, mem_count)
- print_cpu_stats(cpu_stats, cpu_count)
-
- mem_after = get_mem_usage(dem_pid)
- print "\n" + PRINT_BRACKET + " Stats *after* test:"
- print PRINT_ARROW + " Mem (kB): %d" % (mem_after)
- cpu_count, cpu_stats = get_cpu_usage(pid = dem_pid)
- print_cpu_stats(cpu_stats, cpu_count)
-
- print "\n" + PRINT_BRACKET + " Memory usage differences:"
- print PRINT_ARROW + " Diff during and before (kB): %d" % (mem_during - mem_before)
- print PRINT_ARROW + " Diff during and after (kB): %d" % (mem_during - mem_after)
- print PRINT_ARROW + " Diff before and after (kB): %d" % (mem_after - mem_before)
-
- # Return value of 0 means that is passed else it failed
- ret = print_test_success(ret, test['success'])
-
- # Stop session daemon
- if dem_pid > 0:
- print PRINT_BRACKET + " Stopping session daemon (pid: %d)..." % (dem_pid)
- try:
- os.kill(dem_pid, SIGTERM)
- # This call simply does not work... It seems python does not relay the signal
- # to the child processes of sdaemon_proc.
- # sdaemon_proc.terminate()
- if ret != 0:
- print sdaemon_proc.communicate()[1]
- elif sdaemon_proc.returncode == None:
- sdaemon_proc.communicate()
- except OSError, e:
- print e
-
- # Make sure all thread are released
- if not no_stats:
- tw.join()
- sw_cpu.join()
- sw_mem.join()
-
- return ret
-
-def main():
- for test in Tests:
- if not test['enabled']:
- continue
-
- ret = run_test(test)
- if ret != 0:
- # Stop all tests, the last one failed
- return
- print ""
-
-def cleanup(signo, stack):
- """ Cleanup function """
- sys.exit(0)
-
-if __name__ == "__main__":
- if not os.getuid() == 0:
- is_root = 0
- print "NOTICE: Not root. No kernel tracing will be tested\n"
-
- if os.path.isfile("test_list.py"):
- from test_list import Tests
- else:
- print "No test_list.py found. Stopping"
- cleanup(0, 0)
-
- TESTDIR_PATH = os.getcwd()
-
- if len(sys.argv) > 1:
- if sys.argv[1] == "--no-stats":
- no_stats = 1
-
- try:
- signal(SIGTERM, cleanup)
- signal(SIGINT, cleanup)
- main()
- cleanup(0, 0)
- except KeyboardInterrupt:
- cleanup(0, 0)
+++ /dev/null
-#!/bin/bash
-#
-# 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-
-#### ADD TESTS HERE ####
-
-tests=( kernel/runall.sh ust/runall.sh tools/runall.sh )
-
-#### END TESTS HERE ####
-
-TESTDIR=$(dirname $0)
-
-source $TESTDIR/utils.sh
-
-## lttng-tools unit tests ##
-# No session daemon needed
-for bin in ${tests[@]};
-do
- if [ ! -e $bin ]; then
- echo -e "$bin not found, passing"
- continue
- fi
-
- ./$bin
- # Test must return 0 to pass.
- if [ $? -ne 0 ]; then
- echo -e '\e[1;31mFAIL\e[0m'
- echo ""
- exit 1
- fi
-done
-
-# All passed
-exit 0
+++ /dev/null
-Tests = \
-[
- # lttng-tools unit tests
- {
- 'bin': "tools/test_sessions", 'daemon': False, 'kern': False, 'name': "Test sessions",
- 'desc': "Test tracing session data structures and methods.",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "tools/test_kernel_data_trace", 'daemon': False, 'kern': False,
- 'name': "Kernel data structures",
- 'desc': "Test Kernel data structures and methods.",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "tools/test_ust_data_trace", 'daemon': False, 'kern': False,
- 'name': "UST data structures",
- 'desc': "Test UST data structures and methods.",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "tools/streaming/run-ust", 'daemon': True, 'kern': False,
- 'name': "UST network streaming",
- 'desc': "Test user space tracing network streaming support",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "tools/streaming/run-kernel", 'daemon': True, 'kern': True,
- 'name': "Kernel network streaming",
- 'desc': "Test kernel tracing network streaming support",
- 'success': 0, 'enabled': True
- },
-
- # Kernel tests
- {
- 'bin': "kernel/run-kernel-tests.sh", 'daemon': True, 'kern': True,
- 'name': "Kernel tracer - lttng client",
- 'desc': "Test the Kernel tracer using the lttng client",
- 'success': 0, 'enabled': True
- },
-
- # UST tests
- {
- 'bin': "ust/run-ust-global-tests.sh", 'daemon': True, 'kern': False,
- 'name': "UST tracer - Global domain",
- 'desc': "Test the UST tracer functionnalities for domain LTTNG_DOMAIN_UST",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "ust/nprocesses/run", 'daemon': True, 'kern': False,
- 'name': "UST tracer - Multiple processes",
- 'desc': "Test multiple process registering and tracing",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "ust/high-throughput/run", 'daemon': True, 'kern': False,
- 'name': "UST tracer - Testing high events throughput",
- 'desc': "Test multiple large number of events with concurrent application",
- 'success': 0, 'enabled': True
- },
- # Deactivated. This test last 20 minutes...
- #{
- #'bin': "ust/low-throughput/run", 'daemon': True, 'kern': False,
- #'name': "UST tracer - Testing high events throughput",
- #'desc': "Test low throughput of events",
- #'success': 0, 'enabled': False
- #},
- {
- 'bin': "ust/before-after/run", 'daemon': True, 'kern': False,
- 'name': "UST tracer - Tracing before and after app execution",
- 'desc': "Test tracing before and after app execution",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "ust/multi-session/run", 'daemon': True, 'kern': False,
- 'name': "UST tracer - Multi-session",
- 'desc': "Test tracing with 4 sessions for one application",
- 'success': 0, 'enabled': True
- },
-
- # Tools filtering tests
- {
- 'bin': "tools/filtering/unsupported-ops", 'daemon': True, 'kern': False,
- 'name': "Filtering - Unsupported operators",
- 'desc': "Test the failure of filter with unsupported operators",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "tools/filtering/invalid-filters", 'daemon': True, 'kern': False,
- 'name': "Filtering - Invalid filters",
- 'desc': "Test the failure of invalid filters",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "tools/filtering/valid-filters", 'daemon': True, 'kern': False,
- 'name': "Filtering - Valid filters",
- 'desc': "Validate the expected trace output of valid filters",
- 'success': 0, 'enabled': True
- },
-
- # Tools health check tests
- {
- 'bin': "tools/health/health_thread_exit", 'daemon': "test", 'kern': True,
- 'name': "Health check - Thread exit",
- 'desc': "Call exit in the various lttng-sessiond threads and ensure that health failure is detected",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "tools/health/health_thread_stall", 'daemon': "test", 'kern': True,
- 'name': "Health check - Thread stall",
- 'desc': "Stall the various lttng-sessiond threads and ensure that health failure is detected",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "tools/health/health_tp_fail", 'daemon': "test", 'kern': True,
- 'name': "Health check - Testpoint failure",
- 'desc': "Trigger a failure in the testpoint mechanism in each thread to provoke thread teardown",
- 'success': 0, 'enabled': True
- },
-
- # Tools streaming tests
- {
- 'bin': "tools/streaming/run-kernel", 'daemon': True, 'kern': True,
- 'name': "Streaming - Kernel tracing",
- 'desc': "Stream a kernel trace across the network",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "tools/streaming/run-ust", 'daemon': True, 'kern': False,
- 'name': "Streaming - Userspace tracing",
- 'desc': "Stream a userspace trace across the network",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "tools/streaming/uri_switch", 'daemon': True, 'kern': False,
- 'name': "Streaming - URI switching",
- 'desc': "Switch URI and verify that the trace result are in the proper location",
- 'success': 0, 'enabled': True
- },
- {
- 'bin': "tools/streaming/high_throughput_limits", 'daemon': True, 'kern': True,
- 'name': "Streaming - High throughput with bandwith limits",
- 'desc': "Trace streaming with bandwidth limits",
- 'success': 0, 'enabled': True
- },
-]
+++ /dev/null
-SUBDIRS = streaming filtering health
-
-AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests -g -Wall
-AM_LDFLAGS = -lurcu
-
-EXTRA_DIST = runall.sh
-
-noinst_PROGRAMS = test_sessions test_kernel_data_trace
-
-UTILS=../utils.h
-SESSIONS=$(top_srcdir)/src/bin/lttng-sessiond/session.c \
- $(top_srcdir)/src/bin/lttng-sessiond/consumer.c \
- $(top_srcdir)/src/common/uri.c \
- $(top_srcdir)/src/common/utils.c \
- $(top_srcdir)/src/common/error.c
-KERN_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-kernel.c \
- $(top_srcdir)/src/bin/lttng-sessiond/consumer.c \
- $(top_srcdir)/src/common/uri.c \
- $(top_srcdir)/src/common/utils.c
-COMMON=$(top_builddir)/src/common/libcommon.la
-HASHTABLE=$(top_builddir)/src/common/hashtable/libhashtable.la
-SESSIOND_COMM=$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la
-
-# Tracing sessions unit tests
-test_sessions_SOURCES = test_sessions.c $(UTILS) $(SESSIONS)
-test_sessions_LDADD = $(COMMON) $(HASHTABLE) $(SESSIOND_COMM)
-
-# Kernel trace data unit tests
-test_kernel_data_trace_SOURCES = test_kernel_data_trace.c $(UTILS) $(KERN_DATA_TRACE)
-test_kernel_data_trace_LDADD = $(COMMON) $(SESSIOND_COMM) $(HASHTABLE)
-
-if HAVE_LIBLTTNG_UST_CTL
-noinst_PROGRAMS += test_ust_data_trace
-UST_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-ust.c \
- $(top_srcdir)/src/bin/lttng-sessiond/consumer.c \
- $(top_srcdir)/src/common/uri.c \
- $(top_srcdir)/src/common/utils.c
-# UST trace data unit tests
-test_ust_data_trace_SOURCES = test_ust_data_trace.c $(UTILS) $(UST_DATA_TRACE)
-test_ust_data_trace_LDADD = $(COMMON) $(HASHTABLE) $(SESSIOND_COMM)
-endif
+++ /dev/null
-AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests -I$(srcdir) -O2 -g
-AM_LDFLAGS =
-
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-AM_LDFLAGS += -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-AM_LDFLAGS += -lc
-endif
-
-if HAVE_LIBLTTNG_UST_CTL
-noinst_PROGRAMS = gen-ust-events
-gen_ust_events_SOURCES = gen-ust-events.c tp.c tp.h
-gen_ust_events_LDADD = -llttng-ust
-endif
-
-noinst_SCRIPTS = runall unsupported-ops invalid-filters valid-filters babelstats.pl
-EXTRA_DIST = runall unsupported-ops invalid-filters valid-filters babelstats.pl
+++ /dev/null
-#!/usr/bin/perl
-
-# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License, version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-
-use strict;
-use warnings;
-
-use Getopt::Long;
-
-my $opt_tracepoint;
-
-GetOptions('tracepoint=s' => \$opt_tracepoint)
- or die("Invalid command-line option\n");
-
-defined($opt_tracepoint)
- or die("Missing tracepoint, use --tracepoint <name>");
-
-# Parse an array string.
-# The format is as follow: [ [index] = value, ... ]
-sub parse_array
-{
- my ($arr_str) = @_;
- my @array = ();
-
- # Strip leading and ending brackets, remove whitespace
- $arr_str =~ s/^\[//;
- $arr_str =~ s/\]$//;
- $arr_str =~ s/\s//g;
-
- my @entries = split(',', $arr_str);
-
- foreach my $entry (@entries) {
- if ($entry =~ /^\[(\d+)\]=(\d+)$/) {
- my $index = $1;
- my $value = $2;
- splice @array, $index, 0, $value;
- }
- }
-
- return \@array;
-}
-
-# Parse fields values.
-# Format can either be a name = array or a name = value pair.
-sub parse_fields
-{
- my ($fields_str) = @_;
- my %fields_hash;
-
- my $field_name = '[\w\d_]+';
- my $field_value = '[\w\d_\\\*"]+';
- my $array = '\[(?:\s\[\d+\]\s=\s\d+,)*\s\[\d+\]\s=\s\d+\s\]';
-
- # Split the various fields
- my @fields = ($fields_str =~ /$field_name\s=\s(?:$array|$field_value)/g);
-
- foreach my $field (@fields) {
- if ($field =~ /($field_name)\s=\s($array)/) {
- my $name = $1;
- my $value = parse_array($2);
- $fields_hash{$name} = $value;
- }
-
- if ($field =~ /($field_name)\s=\s($field_value)/) {
- my $name = $1;
- my $value = $2;
- $fields_hash{$name} = $value;
- }
- }
-
- return \%fields_hash;
-}
-
-# Using an event array, merge all the fields
-# of a particular tracepoint.
-sub merge_fields
-{
- my ($events_ref) = @_;
- my %merged;
-
- foreach my $event (@{$events_ref}) {
- my $tp_provider = $event->{'tp_provider'};
- my $tp_name = $event->{'tp_name'};
- my $tracepoint = "$tp_provider:$tp_name";
-
- foreach my $key (keys %{$event->{'fields'}}) {
- my $val = $event->{'fields'}->{$key};
-
- # TODO: Merge of array is not implemented.
- next if (ref($val) eq 'ARRAY');
- $merged{$tracepoint}{$key}{$val} = undef;
- }
- }
-
- return \%merged;
-}
-
-# Print the minimum and maximum of each fields
-# for a particular tracepoint.
-sub print_fields_stats
-{
- my ($merged_ref, $tracepoint) = @_;
-
- return unless ($tracepoint && exists $merged_ref->{$tracepoint});
-
- foreach my $field (keys %{$merged_ref->{$tracepoint}}) {
- my @sorted;
- my @val = keys ($merged_ref->{$tracepoint}->{$field});
-
- if ($val[0] =~ /^\d+$/) {
- # Sort numerically
- @sorted = sort { $a <=> $b } @val;
- } elsif ($val[0] =~ /^0x[\da-f]+$/i) {
- # Convert the hex values and sort numerically
- @sorted = sort { hex($a) <=> hex($b) } @val;
- } else {
- # Fallback, alphabetical sort
- @sorted = sort { lc($a) cmp lc($b) } @val;
- }
-
- my $min = $sorted[0];
- my $max = $sorted[-1];
-
- print "$field $min $max\n";
- }
-}
-
-my @events;
-
-while (<>)
-{
- my $timestamp = '\[(.*)\]';
- my $elapsed = '\((.*)\)';
- my $hostname = '.*';
- my $pname = '.*';
- my $pid = '\d+';
- my $tp_provider = '.*';
- my $tp_name = '.*';
- my $cpu_info = '{\scpu_id\s=\s(\d+)\s\}';
- my $fields = '{(.*)}';
-
- # Parse babeltrace text output format
- if (/$timestamp\s$elapsed\s($hostname):($pname):($pid)\s($tp_provider):($tp_name):\s$cpu_info,\s$fields/) {
- my %event_hash;
-
- $event_hash{'timestamp'} = $1;
- $event_hash{'elapsed'} = $2;
- $event_hash{'hostname'} = $3;
- $event_hash{'pname'} = $4;
- $event_hash{'pid'} = $5;
- $event_hash{'tp_provider'} = $6;
- $event_hash{'tp_name'} = $7;
- $event_hash{'cpu_id'} = $8;
- $event_hash{'fields'} = parse_fields($9);
-
- push @events, \%event_hash;
- }
-}
-
-my %merged_fields = %{merge_fields(\@{events})};
-print_fields_stats(\%merged_fields, $opt_tracepoint);
+++ /dev/null
-/*
- * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation; version 2.1 of the License.
- *
- * This library 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 Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <arpa/inet.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#define TRACEPOINT_DEFINE
-#include "tp.h"
-
-int main(int argc, char **argv)
-{
- int i, netint;
- long values[] = { 1, 2, 3 };
- char text[10] = "test";
- char escape[10] = "\\*";
- double dbl = 2.0;
- float flt = 2222.0;
- /* Generate 30 events. */
- unsigned int nr_iter = 100;
- useconds_t nr_usec = 0;
-
- if (argc >= 2) {
- nr_iter = atoi(argv[1]);
- }
-
- if (argc == 3) {
- /* By default, don't wait unless user specifies. */
- nr_usec = atoi(argv[2]);
- }
-
- for (i = 0; i < nr_iter; i++) {
- netint = htonl(i);
- tracepoint(tp, tptest, i, netint, values, text, strlen(text), escape, dbl, flt);
- usleep(nr_usec);
- }
-
- return 0;
-}
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License, version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-
-TEST_DESC="Filtering - Invalid filters"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-LTTNG_BIN="lttng"
-SESSION_NAME="filter-invalid"
-EVENT_NAME="bogus"
-ENABLE_EVENT_STDERR="/tmp/invalid-filters-stderr"
-TRACE_PATH=$(mktemp -d)
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-function enable_ust_lttng_event_filter
-{
- sess_name="$1"
- event_name="$2"
- filter="$3"
- echo -n "Enabling lttng event with filtering and invalid filter "
-
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u --filter "$filter" 2> $ENABLE_EVENT_STDERR 1> /dev/null
-
- # Enable must fail
- if [ $? -eq 0 ]; then
- print_fail
- return 1
- else
- print_ok
- return 0
- fi
-}
-
-function test_invalid_filter
-{
- test_invalid_filter="$1"
-
- echo ""
- echo -e "=== Testing filter expression with invalid filter"
- echo -e "Filter: $test_invalid_filter"
-
- # Create session
- create_lttng_session $SESSION_NAME $TRACE_PATH
-
- # Apply filter
- enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME "$test_invalid_filter"
-
- # Destroy session
- destroy_lttng_session $SESSION_NAME
-}
-
-function test_bytecode_limit
-{
- # Current bytecode limitation is 65536 bytes long.
- # Generate a huge bytecode with some perl-fu
- BYTECODE_LIMIT=`perl -e 'print "intfield" . " && 1" x5460'`
-
- echo ""
- echo -e "=== Testing filter bytecode limits (64KiB)"
-
- # Create session
- create_lttng_session $SESSION_NAME $TRACE_PATH
-
- # Apply filter
- enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME "$BYTECODE_LIMIT"
-
- # Destroy session
- destroy_lttng_session $SESSION_NAME
-}
-
-IFS=$'\n'
-INVALID_FILTERS=(
- # Unsupported ops
- "intfield*1"
- "intfield/1"
- "intfield+1"
- "intfield-1"
- "intfield>>1"
- "intfield<<1"
- "intfield&1"
- "intfield|1"
- "intfield^1"
- "~intfield"
- "1+11111-3333+1"
- "(1+2)*(55*666)"
- "1+2*55*666"
- "asdf + 1 > 1"
- "asdfas < 2332 || asdf + 1 > 1"
- "!+-+++-------+++++++++++-----!!--!44+1"
- "aaa||(gg)+(333----1)"
- "1+1"
- # Unmatched parenthesis
- "((((((((((((((intfield)))))))))))))"
- '0 || ("abc" != "def")) && (3 < 4)'
- # Field dereference
- "a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a"
- "a->"
- "a-->a"
- "a->a"
- "a.b.c->d.e.f+1"
- "!a.f.d"
- "asdf.asdfsd.sadf < 4"
- "asdfasdf->asdfasdf < 2"
- # String can't be root node
- "\"somestring\""
- # Unary op on string not allowed
- "!\"somestring\""
- # Comparison with string type not allowed
- "\"somestring\" > 42"
- "\"somestring\" > 42.0"
- "42 > \"somestring\""
- "42.0 > \"somestring\""
- # Logical operator with string type not allowed
- "\"somestring\" || 1"
- "1 || \"somestring\""
- # Nesting of binary operator not allowed
- "1 | (1 | (1 | 1))"
- "1 > (1 > (1 > 1))"
- )
-
-start_lttng_sessiond
-for FILTER in ${INVALID_FILTERS[@]};
-do
- test_invalid_filter "$FILTER"
-done
-
-test_bytecode_limit
-
-unset IFS
-stop_lttng_sessiond
-
-rm -f $ENABLE_EVENT_STDERR
-rm -rf $TRACE_PATH
+++ /dev/null
-#!/bin/bash
-
-DIR=$(dirname $0)
-
-tests=( $DIR/unsupported-ops $DIR/invalid-filters $DIR/valid-filters )
-exit_code=0
-
-function start_tests ()
-{
- for bin in ${tests[@]};
- do
- if [ ! -e $bin ]; then
- echo -e "$bin not found, passing"
- continue
- fi
-
- ./$bin
- # Test must return 0 to pass.
- if [ $? -ne 0 ]; then
- exit_code=1
- break
- fi
- done
-}
-
-start_tests
-
-exit $exit_code
+++ /dev/null
-/*
- * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
- * IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program for any purpose,
- * provided the above notices are retained on all copies. Permission to modify
- * the code and to distribute modified code is granted, provided the above
- * notices are retained, and a notice that the code was modified is included
- * with the above copyright notice.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "tp.h"
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER tp
-
-#if !defined(_TRACEPOINT_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_TP_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_EVENT(tp, tptest,
- TP_ARGS(int, anint, int, netint, long *, values,
- char *, text, size_t, textlen,
- char *, etext, double, doublearg, float, floatarg),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer_hex(int, intfield2, anint)
- ctf_integer(long, longfield, anint)
- ctf_integer_network(int, netintfield, netint)
- ctf_integer_network_hex(int, netintfieldhex, netint)
- ctf_array(long, arrfield1, values, 3)
- ctf_array_text(char, arrfield2, text, 10)
- ctf_sequence(char, seqfield1, text, size_t, textlen)
- ctf_sequence_text(char, seqfield2, text, size_t, textlen)
- ctf_string(stringfield, text)
- ctf_string(stringfield2, etext)
- ctf_float(float, floatfield, floatarg)
- ctf_float(double, doublefield, doublearg)
- )
-)
-
-#endif /* _TRACEPOINT_TP_H */
-
-#undef TRACEPOINT_INCLUDE_FILE
-#define TRACEPOINT_INCLUDE_FILE ./tp.h
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License, version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-
-TEST_DESC="Filtering - Unsupported operators"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-LTTNG_BIN="lttng"
-SESSION_NAME="filter-unsupported-ops"
-EVENT_NAME="bogus"
-ENABLE_EVENT_STDERR="/tmp/unsupported-ops-enable"
-TRACE_PATH=$(mktemp -d)
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-function enable_ust_lttng_event_filter_unsupported
-{
- sess_name=$1
- event_name=$2
- filter=$3
-
- echo -n "Enabling lttng event with filtering and unsupported operator "
- enable_cmd="$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event"
- $enable_cmd $event_name -s $sess_name -u --filter "$filter" 2> $ENABLE_EVENT_STDERR 1> /dev/null
-
- # Enable must fail
- if [ $? -eq 0 ]; then
- print_fail
- return 1
- else
- print_ok
- return 0
- fi
-}
-
-function test_unsupported_op
-{
- test_op_str=$1
- test_op_tkn=$2
-
- echo ""
- echo -e "=== Testing filter expression with unsupported operator $test_op_str ($test_op_tkn)"
-
- # Create session
- create_lttng_session $SESSION_NAME $TRACE_PATH
-
- # Create filter
- if [ "$test_op_str" == "UNARY_BIN_NOT" ]; then
- TEST_FILTER="${test_op_tkn}1"
- else
- TEST_FILTER="intfield $test_op_tkn 1"
- fi
-
- # Apply filter
- enable_ust_lttng_event_filter_unsupported $SESSION_NAME $EVENT_NAME "$TEST_FILTER"
-
- # Test stderr for unsupported operator
- echo -n "Unsupported operator test $test_op_str ($test_op_tkn) "
- grep -i -q "not[[:space:]]\+supported" $ENABLE_EVENT_STDERR
-
- if [ $? -eq 1 ]; then
- print_fail
- return 1
- else
- print_ok
- fi
-
- # Destroy session
- destroy_lttng_session $SESSION_NAME
- return 0
-}
-
-# Unsupported operators
-OP_STR=("MUL" "DIV" "MOD" "PLUS" "MINUS" "LSHIFT" "RSHIFT"
- "BIN_AND" "BIN_OR" "BIN_XOR" "UNARY_BIN_NOT")
-
-OP_TKN=("*" "/" "%" "+" "-" "<<" ">>" "&" "|" "^" "~")
-
-OP_COUNT=${#OP_STR[@]}
-i=0
-
-start_lttng_sessiond
-
-while [ "$i" -lt "$OP_COUNT" ]; do
- test_unsupported_op "${OP_STR[$i]}" "${OP_TKN[$i]}"
-
- if [ $? -eq 1 ]; then
- exit 1
- fi
-
- let "i++"
-done
-
-stop_lttng_sessiond
-
-# Cleanup
-rm -f $ENABLE_EVENT_STDERR
-rm -rf $TRACE_PATH
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License, version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-
-TEST_DESC="Filtering - Valid filters"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-LTTNG_BIN="lttng"
-BIN_NAME="gen-ust-events"
-STATS_BIN="babelstats.pl"
-SESSION_NAME="valid_filter"
-EVENT_NAME="tp:tptest"
-NR_ITER=100
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/$BIN_NAME" ]; then
- echo -e "No UST nevents binary detected. Passing."
- exit 0
-fi
-
-function enable_ust_lttng_event_filter()
-{
- sess_name="$1"
- event_name="$2"
- filter="$3"
- echo -n "Enabling lttng event with filtering "
-
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u --filter "$filter" 2>&1 >/dev/null
-
- if [ $? -eq 0 ]; then
- print_ok
- return 0
- else
- print_fail
- return 1
- fi
-}
-
-function run_apps
-{
- ./$CURDIR/$BIN_NAME $NR_ITER & >/dev/null 2>&1
-}
-
-function wait_apps
-{
- echo "Waiting for applications to end"
- while [ -n "$(pidof $BIN_NAME)" ]; do
- echo -n "."
- sleep 1
- done
- echo ""
-}
-
-function test_valid_filter
-{
- filter="$1"
- validator="$2"
-
- echo ""
- echo -e "=== Testing valid filter: $1"
-
- trace_path=$(mktemp -d)
-
- # Create session
- create_lttng_session $SESSION_NAME $trace_path
-
- # Enable filter
- enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME $filter
-
- # Trace apps
- start_lttng_tracing $SESSION_NAME
- run_apps
- wait_apps
- stop_lttng_tracing $SESSION_NAME
-
- # Destroy session
- destroy_lttng_session $SESSION_NAME
-
- echo -n "Validating filter output "
- stats=`babeltrace $trace_path | $CURDIR/$STATS_BIN --tracepoint $EVENT_NAME`
-
- rm -rf $trace_path
-
- $validator "$stats"
-
- if [ $? -eq 0 ]; then
- print_ok
-# rm -rf $trace_path
- return 0
- else
- print_fail
- return 1
- fi
-}
-
-function validate_min_max
-{
- stats="$1"
- field=$2
- expected_min=$3
- expected_max=$4
-
- echo $stats | grep -q "$field $expected_min $expected_max"
-
- return $?
-}
-
-function validator_intfield
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "1" "99"
- status=$(($status|$?))
-
- validate_min_max "$stats" "intfield2" "0x1" "0x63"
- status=$(($status|$?))
-
- validate_min_max "$stats" "longfield" "1" "99"
- status=$(($status|$?))
-
- validate_min_max "$stats" "netintfield" "1" "99"
- status=$(($status|$?))
-
- validate_min_max "$stats" "netintfieldhex" "0x1" "0x63"
- status=$(($status|$?))
-
- validate_min_max "$stats" "floatfield" "2222" "2222"
- status=$(($status|$?))
-
- validate_min_max "$stats" "doublefield" "2" "2"
- status=$(($status|$?))
-
- return $status
-}
-
-function validator_intfield_gt
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "2" "99"
- status=$(($status|$?))
-
- return $status
-}
-
-function validator_intfield_ge
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "1" "99"
- status=$(($status|$?))
-
- return $status
-}
-
-function validator_intfield_lt
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "0" "1"
- status=$(($status|$?))
-
- return $status
-}
-
-function validator_intfield_le
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "0" "2"
- status=$(($status|$?))
-
- return $status
-}
-
-function validator_intfield_eq
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "1" "1"
- status=$(($status|$?))
-
- return $status
-}
-
-function validator_intfield_ne
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "0" "98"
- status=$(($status|$?))
-
- return $status
-}
-
-function validator_intfield_not
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "0" "0"
- status=$(($status|$?))
-
- return $status
-}
-
-function validator_intfield_gt_and_longfield_gt
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "43" "99"
- status=$(($status|$?))
- validate_min_max "$stats" "longfield" "43" "99"
- status=$(($status|$?))
-
- return $status
-}
-
-function validator_intfield_ge_and_longfield_le
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "42" "42"
- status=$(($status|$?))
- validate_min_max "$stats" "longfield" "42" "42"
- status=$(($status|$?))
-
- return $status
-}
-
-function validator_intfield_lt_or_longfield_gt
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "0" "99"
- status=$(($status|$?))
- validate_min_max "$stats" "longfield" "0" "99"
- status=$(($status|$?))
-
- return $status
-}
-
-function validator_mixed_str_or_int_and_int
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "34" "99"
- status=$(($status|$?))
-
- validate_min_max "$stats" "stringfield" "\"test\"" "\"test\""
- status=$(($status|$?))
-
- return $status
-}
-
-function validator_mixed_int_double
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "0" "42"
- status=$(($status|$?))
-
- return $status
-}
-
-function validator_true_statement
-{
- stats="$1"
- status=0
-
- validate_min_max "$stats" "intfield" "0" "99"
- status=$(($status|$?))
-
- validate_min_max "$stats" "intfield2" "0x0" "0x63"
- status=$(($status|$?))
-
- validate_min_max "$stats" "longfield" "0" "99"
- status=$(($status|$?))
-
- validate_min_max "$stats" "netintfield" "0" "99"
- status=$(($status|$?))
-
- validate_min_max "$stats" "netintfieldhex" "0x0" "0x63"
- status=$(($status|$?))
-
- validate_min_max "$stats" "floatfield" "2222" "2222"
- status=$(($status|$?))
-
- validate_min_max "$stats" "doublefield" "2" "2"
- status=$(($status|$?))
-
- validate_min_max "$stats" "stringfield" "\"test\"" "\"test\""
- status=$(($status|$?))
-
- validate_min_max "$stats" "stringfield2" ""\*"" ""\*""
- status=$(($status|$?))
-
- return $status
-}
-
-IFS=$'\n'
-
-issue_356_filter="intfield > 0 && intfield > 1 && "
-issue_356_filter+="intfield > 2 && intfield > 3 && "
-issue_356_filter+="intfield > 4 && intfield > 5 && "
-issue_356_filter+="intfield > 6 && intfield > 7 && "
-issue_356_filter+="intfield > 8 || intfield > 0"
-
-# One to one mapping between filters and validators
-
-FILTERS=("intfield" #1
- "intfield > 1" #2
- "intfield >= 1" #3
- "intfield < 2" #4
- "intfield <= 2" #5
- "intfield == 1" #6
- "intfield != 99" #7
- "!intfield" #8
- "-intfield" #9
- "--intfield" #10
- "+intfield" #11
- "++intfield" #12
- "intfield > 1 && longfield > 42" #13
- "intfield >= 42 && longfield <= 42" #14
- "intfield < 1 || longfield > 98" #15
- "(stringfield == \"test\" || intfield != 10) && intfield > 33" #16
- "intfield < 42.4242424242" #17
- "\"test\" == \"test\"" #18 #Issue #342
- "stringfield == \"test\"" #19
- "stringfield == \"t*\"" #20
- "stringfield == \"*\"" #21
- $issue_356_filter #22 #Issue #356
- "intfield < 0xDEADBEEF" #23
- "intfield < 0x2" #24
- "intfield < 02" #25
- "stringfield2 == \"\\\*\"" #26
- "1.0 || intfield || 1.0" #27
- "1 < intfield" #28
-)
-
-VALIDATOR=("validator_intfield" #1
- "validator_intfield_gt" #2
- "validator_intfield_ge" #3
- "validator_intfield_lt" #4
- "validator_intfield_le" #5
- "validator_intfield_eq" #6
- "validator_intfield_ne" #7
- "validator_intfield_not" #8
- "validator_intfield" #9
- "validator_intfield" #10
- "validator_intfield" #11
- "validator_intfield" #12
- "validator_intfield_gt_and_longfield_gt" #13
- "validator_intfield_ge_and_longfield_le" #14
- "validator_intfield_lt_or_longfield_gt" #15
- "validator_mixed_str_or_int_and_int" #16
- "validator_mixed_int_double" #17
- "validator_true_statement" #18
- "validator_true_statement" #19
- "validator_true_statement" #20
- "validator_true_statement" #21
- "validator_intfield" #22
- "validator_true_statement" #23
- "validator_intfield_lt" #24
- "validator_intfield_lt" #25
- "validator_true_statement" #26
- "validator_true_statement" #27
- "validator_intfield_gt" #28
-)
-
-FILTER_COUNT=${#FILTERS[@]}
-i=0
-
-start_lttng_sessiond
-
-while [ "$i" -lt "$FILTER_COUNT" ]; do
-
- test_valid_filter "${FILTERS[$i]}" "${VALIDATOR[$i]}"
-
- if [ $? -eq 1 ]; then
- stop_lttng_sessiond
- exit 1
- fi
-
- let "i++"
-done
-
-stop_lttng_sessiond
+++ /dev/null
-AM_CFLAGS = -I. -O2 -g -I../../../include
-AM_LDFLAGS =
-
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-AM_LDFLAGS += -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-AM_LDFLAGS += -lc
-endif
-
-if NO_SHARED
-# Do not build this test if shared libraries support was
-# explicitly disabled.
-else
-# In order to test the health check feature, the libhealth* libs
-# must be built as .so to be able to LD_PRELOAD them.
-FORCE_SHARED_LIB_OPTIONS = -module -shared -avoid-version \
- -rpath $(abs_builddir)
-
-# Health thread exit ld_preloaded test lib
-libhealthexit_la_SOURCES=health_exit.c
-libhealthexit_la_LDFLAGS= $(FORCE_SHARED_LIB_OPTIONS)
-
-# Health thread stall ld_preloaded test lib
-libhealthstall_la_SOURCES=health_stall.c
-libhealthstall_la_LDFLAGS= $(FORCE_SHARED_LIB_OPTIONS)
-
-# Health thread fail ld_preloaded test lib
-libhealthtpfail_la_SOURCES=health_fail.c
-libhealthtpfail_la_LDFLAGS= $(FORCE_SHARED_LIB_OPTIONS)
-
-noinst_PROGRAMS = health_check
-noinst_LTLIBRARIES = libhealthexit.la libhealthstall.la libhealthtpfail.la
-
-health_check_SOURCES = health_check.c $(UTILS)
-health_check_LDADD = $(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la \
- $(top_builddir)/src/common/libcommon.la
-endif
-
-noinst_SCRIPTS = runall
-EXTRA_DIST = runall
+++ /dev/null
-/*
- * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.
- */
-
-#include <stdio.h>
-
-#include "lttng/lttng.h"
-
-#define HEALTH_CMD_FAIL (1 << 0)
-#define HEALTH_APP_MNG_FAIL (1 << 1)
-#define HEALTH_APP_REG_FAIL (1 << 2)
-#define HEALTH_KERNEL_FAIL (1 << 3)
-#define HEALTH_CSMR_FAIL (1 << 4)
-
-int main(int argc, char *argv[])
-{
- int health = -1;
- int status = 0;
-
- /* Command thread */
- health = lttng_health_check(LTTNG_HEALTH_CMD);
- printf("Health check cmd: %d\n", health);
-
- if (health) {
- status |= HEALTH_CMD_FAIL;
- }
-
- /* App manage thread */
- health = lttng_health_check(LTTNG_HEALTH_APP_MANAGE);
- printf("Health check app. manage: %d\n", health);
-
- if (health) {
- status |= HEALTH_APP_MNG_FAIL;
- }
- /* App registration thread */
- health = lttng_health_check(LTTNG_HEALTH_APP_REG);
- printf("Health check app. registration: %d\n", health);
-
- if (health) {
- status |= HEALTH_APP_REG_FAIL;
- }
-
- /* Kernel thread */
- health = lttng_health_check(LTTNG_HEALTH_KERNEL);
- printf("Health check kernel: %d\n", health);
-
- if (health) {
- status |= HEALTH_KERNEL_FAIL;
- }
-
- /* Consumer thread */
- health = lttng_health_check(LTTNG_HEALTH_CONSUMER);
- printf("Health check consumer: %d\n", health);
-
- if (health) {
- status |= HEALTH_CSMR_FAIL;
- }
-
- return status;
-}
+++ /dev/null
-/*
- * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <pthread.h>
-
-/*
- * Check if the specified environment variable is set.
- * Return 1 if set, otherwise 0.
- */
-int check_env_var(const char *env)
-{
- if (env) {
- char *env_val = getenv(env);
- if (env_val && (strncmp(env_val, "1", 1) == 0)) {
- return 1;
- }
- }
-
- return 0;
-}
-
-int __testpoint_thread_manage_clients(void)
-{
- const char *var = "LTTNG_THREAD_MANAGE_CLIENTS_EXIT";
-
- if (check_env_var(var)) {
- pthread_exit(NULL);
- }
-
- return 0;
-}
-
-int __testpoint_thread_registration_apps(void)
-{
- const char *var = "LTTNG_THREAD_REG_APPS_EXIT";
-
- if (check_env_var(var)) {
- pthread_exit(NULL);
- }
-
- return 0;
-}
-
-int __testpoint_thread_manage_apps(void)
-{
- const char *var = "LTTNG_THREAD_MANAGE_APPS_EXIT";
-
- if (check_env_var(var)) {
- pthread_exit(NULL);
- }
-
- return 0;
-}
-
-int __testpoint_thread_manage_kernel(void)
-{
- const char *var = "LTTNG_THREAD_MANAGE_KERNEL_EXIT";
-
- if (check_env_var(var)) {
- pthread_exit(NULL);
- }
-
- return 0;
-}
-
-int __testpoint_thread_manage_consumer(void)
-{
- const char *var = "LTTNG_THREAD_MANAGE_CONSUMER_EXIT";
-
- if (check_env_var(var)) {
- pthread_exit(NULL);
- }
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <pthread.h>
-
-/*
- * Check if the specified environment variable is set.
- * Return 1 if set, otherwise 0.
- */
-int check_env_var(const char *env)
-{
- if (env) {
- char *env_val = getenv(env);
- if (env_val && (strncmp(env_val, "1", 1) == 0)) {
- return 1;
- }
- }
-
- return 0;
-}
-
-int __testpoint_thread_manage_clients(void)
-{
- const char *var = "LTTNG_THREAD_MANAGE_CLIENTS_TP_FAIL";
-
- if (check_env_var(var)) {
- return 1;
- }
-
- return 0;
-}
-
-int __testpoint_thread_manage_apps(void)
-{
- const char *var = "LTTNG_THREAD_MANAGE_APPS_TP_FAIL";
-
- if (check_env_var(var)) {
- return 1;
- }
-
- return 0;
-}
-
-int __testpoint_thread_manage_kernel(void)
-{
- const char *var = "LTTNG_THREAD_MANAGE_KERNEL_TP_FAIL";
-
- if (check_env_var(var)) {
- return 1;
- }
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#define STALL_TIME 60
-
-/*
- * Check if the specified environment variable is set.
- * Return 1 if set, otherwise 0.
- */
-int check_env_var(const char *env)
-{
- if (env) {
- char *env_val = getenv(env);
- if (env_val && (strncmp(env_val, "1", 1) == 0)) {
- return 1;
- }
- }
-
- return 0;
-}
-
-int __testpoint_thread_manage_clients_before_loop(void)
-{
- const char *var = "LTTNG_THREAD_MANAGE_CLIENTS_STALL";
-
- if (check_env_var(var)) {
- unsigned int sleep_time = STALL_TIME;
- while (sleep_time > 0) {
- sleep_time = sleep(sleep_time);
- }
- }
-
- return 0;
-}
-
-int __testpoint_thread_manage_kernel_before_loop(void)
-{
- const char *var = "LTTNG_THREAD_MANAGE_KERNEL_STALL";
-
- if (check_env_var(var)) {
- unsigned int sleep_time = STALL_TIME;
- while (sleep_time > 0) {
- sleep_time = sleep(sleep_time);
- }
- }
-
- return 0;
-}
-
-int __testpoint_thread_manage_apps_before_loop(void)
-{
- const char *var = "LTTNG_THREAD_MANAGE_APPS_STALL";
-
- if (check_env_var(var)) {
- unsigned int sleep_time = STALL_TIME;
- while (sleep_time > 0) {
- sleep_time = sleep(sleep_time);
- }
- }
-
- return 0;
-}
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License, version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-
-TEST_DESC="Health check - Thread exit"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-LTTNG_BIN="lttng"
-SESSION_NAME="health_thread_exit"
-EVENT_NAME="bogus"
-HEALTH_CHECK_BIN="health_check"
-SESSIOND_PRELOAD=".libs/libhealthexit.so"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
- echo -e "libhealthexit.so not available for this test. Skipping."
- exit 0
-fi
-
-function test_thread_exit
-{
- test_thread_exit_name="$1"
- test_thread_exit_code="$2"
-
- echo ""
- echo -e "=== Testing health failure with ${test_thread_exit_name}"
-
- # Activate testpoints
- export LTTNG_TESTPOINT_ENABLE=1
-
- # Activate specific thread exit
- export ${test_thread_exit_name}_EXIT=1
-
- # Spawn sessiond with preload healthexit lib
- export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD"
- start_lttng_sessiond
-
- # Cleanup some env. var.
- unset LD_PRELOAD
- unset ${test_thread_exit_name}_EXIT
-
- # Check initial health status
- $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
-
- echo -n "Validating thread ${test_thread_exit_name} failure... "
-
- # Wait
- sleep 25
-
- # Check health status, exit code should indicate failure
- $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
-
- health_check_exit_code=$?
-
- if [ $health_check_exit_code -eq $test_thread_exit_code ]; then
- print_ok
- stop_lttng_sessiond
- else
- print_fail
- echo -e "Health returned: $health_check_exit_code\n"
-
- stop_lttng_sessiond
- return 1
- fi
-}
-
-THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
- "LTTNG_THREAD_MANAGE_APPS"
- "LTTNG_THREAD_REG_APPS"
- "LTTNG_THREAD_MANAGE_KERNEL")
-
-# Exit code value to indicate specific thread failure
-EXIT_CODE=(1 2 4 8)
-
-THREAD_COUNT=${#THREAD[@]}
-i=0
-while [ "$i" -lt "$THREAD_COUNT" ]; do
- test_thread_exit "${THREAD[$i]}" "${EXIT_CODE[$i]}"
-
- if [ $? -eq 1 ]; then
- exit 1
- fi
-
- let "i++"
-done
-
-# Special case manage consumer, need to spawn consumer via commands.
-#"LTTNG_THREAD_MANAGE_CONSUMER"
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License, version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-
-TEST_DESC="Health check - Thread stall"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-LTTNG_BIN="lttng"
-SESSION_NAME="health_thread_stall"
-EVENT_NAME="bogus"
-HEALTH_CHECK_BIN="health_check"
-SESSIOND_PRELOAD=".libs/libhealthstall.so"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
- echo -e "libhealthstall.so not available for this test. Skipping."
- exit 0
-fi
-
-function test_thread_stall
-{
- test_thread_stall_name="$1"
- test_thread_exit_code="$2"
-
- echo ""
- echo -e "=== Testing health failure with ${test_thread_stall_name}"
-
- # Activate testpoints
- export LTTNG_TESTPOINT_ENABLE=1
-
- # Activate specific thread exit
- export ${test_thread_stall_name}_STALL=1
-
- # Spawn sessiond with preload healthexit lib
- export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD"
- start_lttng_sessiond
-
- # Cleanup some env. var.
- unset LD_PRELOAD
- unset ${test_thread_stall_name}_STALL
-
- # Check initial health status
- $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
-
- echo -n "Validating that ${test_thread_stall_name} is stalled... "
-
- # Wait
- sleep 25
-
- # Check health status, exit code should indicate failure
- $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
-
- health_check_exit_code=$?
-
- if [ $health_check_exit_code -eq $test_thread_exit_code ]; then
- print_ok
- else
- print_fail
- echo -e "Health returned: $health_check_exit_code\n"
-
- stop_lttng_sessiond
- return 1
- fi
-
- echo -n "Validating that ${test_thread_stall_name} is no longer stalled... "
-
- # Wait
- sleep 40
-
- # Check health status, exit code should now pass
- $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
-
- health_check_exit_code=$?
-
- if [ $health_check_exit_code -eq 0 ]; then
- print_ok
- stop_lttng_sessiond
- else
- print_fail
- echo -e "Health returned: $health_check_exit_code\n"
- stop_lttng_sessiond
- return 1
- fi
-
-
-}
-
-THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
- "LTTNG_THREAD_MANAGE_APPS"
-# This thread is a little bit tricky to stall,
-# need to send some commands and setup an app.
-# "LTTNG_THREAD_REG_APPS"
- "LTTNG_THREAD_MANAGE_KERNEL")
-
-# Exit code value to indicate specific thread failure
-EXIT_CODE=(1
- 2
-# 4
- 8)
-
-THREAD_COUNT=${#THREAD[@]}
-i=0
-while [ "$i" -lt "$THREAD_COUNT" ]; do
- test_thread_stall "${THREAD[$i]}" "${EXIT_CODE[$i]}"
-
- if [ $? -eq 1 ]; then
- exit 1
- fi
-
- let "i++"
-done
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License, version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-
-TEST_DESC="Health check - Testpoint failure"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-LTTNG_BIN="lttng"
-SESSION_NAME="health_tp_fail"
-EVENT_NAME="bogus"
-HEALTH_CHECK_BIN="health_check"
-SESSIOND_PRELOAD=".libs/libhealthtpfail.so"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
- echo -e "libhealthtpfail.so not available for this test. Skipping."
- exit 0
-fi
-
-function test_tp_fail
-{
- test_tp_fail_name="$1"
- test_tp_fail_code="$2"
-
- echo ""
- echo -e "=== Testing health failure with ${test_tp_fail_name}"
-
- # Activate testpoints
- export LTTNG_TESTPOINT_ENABLE=1
-
- # Activate specific testpoint failure
- export ${test_tp_fail_name}_TP_FAIL=1
-
- # Spawn sessiond with preload healthexit lib
- export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD"
- start_lttng_sessiond
-
- # Cleanup some env. var.
- unset LD_PRELOAD
- unset ${test_tp_fail_name}_TP_FAIL
-
- echo -n "Validating thread ${test_tp_fail_name} failure... "
-
- # Check health status, exit code should indicate failure
- $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
-
- health_check_exit_code=$?
-
- if [ $health_check_exit_code -eq $test_tp_fail_code ]; then
- print_ok
- stop_lttng_sessiond
- else
- print_fail
- echo -e "Health returned: $health_check_exit_code\n"
-
- stop_lttng_sessiond
- return 1
- fi
-}
-
-THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
- "LTTNG_THREAD_MANAGE_APPS"
- "LTTNG_THREAD_MANAGE_KERNEL")
-
-# Exit code value to indicate specific thread failure
-EXIT_CODE=(1 2 8)
-
-THREAD_COUNT=${#THREAD[@]}
-i=0
-while [ "$i" -lt "$THREAD_COUNT" ]; do
- test_tp_fail "${THREAD[$i]}" "${EXIT_CODE[$i]}"
-
- if [ $? -eq 1 ]; then
- exit 1
- fi
-
- let "i++"
-done
-
-# Special case manage consumer, need to spawn consumer via commands.
-#"LTTNG_THREAD_MANAGE_CONSUMER"
+++ /dev/null
-#!/bin/bash
-
-DIR=$(dirname $0)
-
-tests=( $DIR/health_thread_exit $DIR/health_thread_stall $DIR/health_tp_fail)
-exit_code=0
-
-function start_tests ()
-{
- for bin in ${tests[@]};
- do
- if [ ! -e $bin ]; then
- echo -e "$bin not found, passing"
- continue
- fi
-
- ./$bin
- # Test must return 0 to pass.
- if [ $? -ne 0 ]; then
- exit_code=1
- break
- fi
- done
-}
-
-if [ "$(id -u)" != "0" ]; then
- echo -e "Need root for health test."
- exit 0
-fi
-
-start_tests
-
-exit $exit_code
+++ /dev/null
-#!/bin/bash
-
-DIR=$(dirname $0)
-
-tests=( $DIR/test_kernel_data_trace $DIR/test_sessions $DIR/test_ust_data_trace \
- $DIR/streaming/runall $DIR/health/runall $DIR/filtering/runall)
-
-exit_code=0
-
-function start_tests ()
-{
- for bin in ${tests[@]};
- do
- if [ ! -e $bin ]; then
- echo -e "$bin not found, passing"
- continue
- fi
-
- ./$bin
- # Test must return 0 to pass.
- if [ $? -ne 0 ]; then
- exit_code=1
- break
- fi
- done
-}
-
-start_tests
-
-exit $exit_code
+++ /dev/null
-AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests -I$(srcdir) -O2 -g
-AM_LDFLAGS =
-
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-AM_LDFLAGS += -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-AM_LDFLAGS += -lc
-endif
-
-#UTILS=../../utils.h
-UTILS=
-LIBSESSIOND_COMM=$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la
-LIBCOMMON=$(top_builddir)/src/common/libcommon.la
-
-noinst_PROGRAMS = unit_tests
-unit_tests_SOURCES = unit_tests.c $(UTILS)
-unit_tests_LDADD = $(LIBCOMMON)
-
-if HAVE_LIBLTTNG_UST_CTL
-noinst_PROGRAMS += gen-ust-events
-gen_ust_events_SOURCES = gen-ust-events.c tp.c tp.h
-gen_ust_events_LDADD = -llttng-ust
-endif
-
-noinst_SCRIPTS = runall run-ust run-kernel uri_switch
-EXTRA_DIST = runall run-ust run-kernel uri_switch
+++ /dev/null
-/*
- * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation; version 2.1 of the License.
- *
- * This library 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 Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <arpa/inet.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#define TRACEPOINT_DEFINE
-#include "tp.h"
-
-int main(int argc, char **argv)
-{
- int i, netint;
- long values[] = { 1, 2, 3 };
- char text[10] = "test";
- double dbl = 2.0;
- float flt = 2222.0;
- /* Generate 30 events. */
- unsigned int nr_iter = 100;
- useconds_t nr_usec = 0;
-
- if (argc >= 2) {
- nr_iter = atoi(argv[1]);
- }
-
- if (argc == 3) {
- /* By default, don't wait unless user specifies. */
- nr_usec = atoi(argv[2]);
- }
-
- for (i = 0; i < nr_iter; i++) {
- netint = htonl(i);
- tracepoint(tp, tptest, i, netint, values, text, strlen(text), dbl,
- flt);
- usleep(nr_usec);
- }
-
- return 0;
-}
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
-# David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library 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 Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-TEST_DESC="Streaming - High throughput with bandwidth limits"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-NR_APP_ITER=10
-NR_ITER=1000000
-BIN_NAME="gen-ust-events"
-SESSION_NAME="high-throughput"
-EVENT_NAME="tp:tptest"
-SESSIOND_CTRL_PORT=5342
-SESSIOND_DATA_PORT=5343
-DEFAULT_IF="lo"
-
-TRACE_PATH=$(mktemp -d)
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/$BIN_NAME" ]; then
- echo -e "No UST nevents binary detected. Passing."
- exit 0
-fi
-
-if [ "$(id -u)" != "0" ]; then
- echo "This test must be running as root to set bandwidth limits. Aborting"
- # Exit status 0 so the tests can continue
- exit 0
-fi
-
-function set_bw_limit
-{
- limit=$1
- ctrlportlimit=$(($limit/10))
- # failsafe to have at least 1kbit/s for control (in the case where $1 < 10)
- [ $ctrlportlimit = 0 ] && ctrlportlimit=1
- # if $1 < 10, we might bust the limit set here, but the
- # parent qdisc (1:) will always limit us to the right max value
- dataportlimit=$((9*${ctrlportlimit}))
-
- echo -n "Setting bandwidth limits to ${limit}kbits, (${ctrlportlimit} for control and ${dataportlimit} for data)... "
- tc qdisc add dev $DEFAULT_IF root handle 1: htb default 15 >/dev/null 2>&1
-
- # the total bandwidth is the limit set by the user
- tc class add dev $DEFAULT_IF parent 1: classid 1:1 htb rate ${limit}kbit ceil ${limit}kbit >/dev/null 2>&1
- # 1/10 of the bandwidth guaranteed and traffic prioritized for the control port
- tc class add dev $DEFAULT_IF parent 1:1 classid 1:10 htb rate ${ctrlportlimit}kbit ceil ${limit}kbit prio 1 >/dev/null 2>&1
- # 9/10 of the bandwidth guaranteed and can borrow up to the total bandwidth (if unused)
- tc class add dev $DEFAULT_IF parent 1:1 classid 1:11 htb rate ${dataportlimit}kbit ceil ${limit}kbit prio 2 >/dev/null 2>&1
-
- # filter to assign control traffic to the 1:10 class
- tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_CTRL_PORT 0xffff flowid 1:10 >/dev/null 2>&1
- # filter to assign data traffic to the 1:11 class
- tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_DATA_PORT 0xffff flowid 1:11 >/dev/null 2>&1
- print_ok
-}
-
-function reset_bw_limit
-{
- echo -n "Resetting bandwidth limits... "
- tc qdisc del dev $DEFAULT_IF root >/dev/null 2>&1
- print_ok
-}
-
-function create_lttng_session_with_uri
-{
- sess_name=$1
- uri=$2
- # Create session with custom URI
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN create -U $uri $sess_name >/dev/null 2>&1
-}
-
-function enable_lttng_consumer
-{
- uri=$1
- # Create session with custom URI
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u $uri >/dev/null 2>&1
-}
-
-function run_apps
-{
- for i in `seq 1 $NR_APP_ITER`; do
- # With bandwidth limitation, unfortunately, application easily timeout
- # due to very slow communication between the consumer and relayd making
- # the status reply from the consumer quite slow thus delaying the
- # registration done message.
- LTTNG_UST_REGISTER_TIMEOUT=-1 ./$CURDIR/$BIN_NAME $NR_ITER & >/dev/null 2>&1
- done
-}
-
-function wait_apps
-{
- echo "Waiting for applications to end"
- while [ -n "$(pidof $BIN_NAME)" ]; do
- echo -n "."
- sleep 1
- done
- echo ""
-}
-
-function test_high_throughput
-{
- NETWORK_URI="net://localhost"
- create_lttng_session_with_uri $SESSION_NAME $NETWORK_URI
- enable_lttng_consumer $NETWORK_URI
- enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
- start_lttng_tracing $SESSION_NAME
- run_apps
- wait_apps
-
- stop_lttng_tracing $SESSION_NAME
- destroy_lttng_session $SESSION_NAME
- validate_event_count
-}
-
-function validate_event_count
-{
-
- TEMP_FILE=$(mktemp)
- TEMP_FILE_2=$(mktemp)
-
- traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l)
- babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2
-
- cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE
-
- dropped=0
- while read line;
- do
- let dropped=$dropped+$line
- done < $TEMP_FILE
-
- let total=$dropped+$traced
- let wanted=$NR_APP_ITER*$NR_ITER
-
- if [ $wanted -ne $total ]; then
- echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
- print_fail
- return 1
- else
- echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
- print_ok
-
- # Cleanup only if everything is ok and passes.
- rm -rf $TRACE_PATH
- rm $TEMP_FILE $TEMP_FILE_2
-
- return 0
- fi
-}
-
-function interrupt_cleanup()
-{
- echo -en "\n*** Exiting ***\n"
- stop_lttng_relayd
- stop_lttng_sessiond
- reset_bw_limit
- exit 1
-}
-
-# Catch sigint and try to cleanup limits
-trap interrupt_cleanup SIGINT
-
-BW_LIMITS=(3200 1600 800 400 200 100 50 25)
-for BW in ${BW_LIMITS[@]};
-do
- echo ""
- echo -e "=== Testing high-throughput with bandwidth limit set to ${BW}kbits"
- set_bw_limit $BW
-
- start_lttng_sessiond
- start_lttng_relayd "-o $TRACE_PATH"
- test_high_throughput
- result=$?
- stop_lttng_relayd
- stop_lttng_sessiond
- reset_bw_limit
-
- if [ $result -ne 0 ]; then
- exit 1
- fi
-done
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library 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 Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-TEST_DESC="Streaming - Kernel tracing"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-EVENT_NAME="sched_switch"
-PID_RELAYD=0
-SESSION_NAME=""
-
-TRACE_PATH=$(mktemp -d)
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ "$(id -u)" != "0" ]; then
- echo "This test must be running as root. Aborting"
- # Exit status 0 so the tests can continue
- exit 0
-fi
-
-# LTTng kernel modules check
-out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
-if [ -z "$out" ]; then
- echo "LTTng modules not detected. Aborting kernel tests!"
- echo ""
- # Exit status 0 so the tests can continue
- exit 0
-fi
-
-function lttng_create_session_uri
-{
- echo -n "Creating session $SESSION_NAME... "
- # Create session with default path
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
- if [ $? -eq 1 ]; then
- print_fail
- return 1
- else
- print_ok
- fi
-}
-
-function test_kernel_before_start ()
-{
- echo -e "\n=== Testing kernel streaming with event enable BEFORE start\n"
- lttng_create_session_uri
- lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
- start_lttng_tracing $SESSION_NAME
- # Give a second
- sleep 1
- stop_lttng_tracing $SESSION_NAME
- destroy_lttng_session $SESSION_NAME
-
- # We can not predict _yet_ when the trace is available so we have to do a
- # arbitratry sleep to validate the trace.
- echo -n "Waiting 3 seconds for the trace to be written on disk "
- for i in `seq 1 3`; do
- echo -n "."
- sleep 1
- done
- echo ""
-}
-
-# Deactivated since this feature is not yet available where we can enable
-# an event AFTERE tracing has started.
-function test_kernel_after_start ()
-{
- echo -e "\n=== Testing kernel streaming with event enable AFTER start\n"
- lttng_create_session_uri
- start_lttng_tracing $SESSION_NAME
- lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
- # Give a second
- sleep 1
- stop_lttng_tracing $SESSION_NAME
- destroy_lttng_session $SESSION_NAME
-}
-
-start_lttng_sessiond
-start_lttng_relayd "-o $TRACE_PATH"
-
-tests=( test_kernel_before_start )
-
-for fct_test in ${tests[@]};
-do
- SESSION_NAME=$(randstring 16 0)
- ${fct_test}
-
- # Validate test
- validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
- if [ $? -eq 0 ]; then
- # Only delete if successful
- rm -rf $TRACE_PATH
- else
- break
- fi
-done
-
-echo ""
-stop_lttng_sessiond
-stop_lttng_relayd
-
-
-exit $out
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library 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 Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-TEST_DESC="Streaming - User space tracing"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-BIN_NAME="gen-ust-events"
-SESSION_NAME="stream"
-EVENT_NAME="tp:tptest"
-PID_RELAYD=0
-
-TRACE_PATH=$(mktemp -d)
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/$BIN_NAME" ]; then
- echo -e "No UST nevents binary detected. Passing."
- exit 0
-fi
-
-function lttng_create_session_uri
-{
- # Create session with default path
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
-}
-
-function wait_apps
-{
- echo -n "Waiting for applications to end"
- while [ -n "$(pidof $BIN_NAME)" ]; do
- echo -n "."
- sleep 0.5
- done
- echo ""
-}
-
-# MUST set TESTDIR before calling those functions
-
-function test_ust_before_start ()
-{
- echo -e "\n=== Testing UST streaming BEFORE tracing starts\n"
- lttng_create_session_uri
- enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-
- # Run 5 times with a 1 second delay
- ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 &
-
- start_lttng_tracing $SESSION_NAME
-
- wait_apps
- stop_lttng_tracing $SESSION_NAME
- destroy_lttng_session $SESSION_NAME
-}
-
-function test_ust_after_start ()
-{
- echo -e "\n=== Testing UST streaming AFTER tracing starts\n"
- lttng_create_session_uri
- enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
- start_lttng_tracing $SESSION_NAME
-
- # Run 5 times with a 1 second delay
- ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 &
-
- wait_apps
- stop_lttng_tracing $SESSION_NAME
- destroy_lttng_session $SESSION_NAME
-}
-
-start_lttng_sessiond
-start_lttng_relayd "-o $TRACE_PATH"
-
-tests=( test_ust_before_start test_ust_after_start )
-
-for fct_test in ${tests[@]};
-do
- SESSION_NAME=$(randstring 16 0)
- ${fct_test}
-
- # Validate test
- validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
- if [ $? -eq 0 ]; then
- # Only delete if successful
- rm -rf $TRACE_PATH
- else
- break
- fi
-done
-
-echo ""
-stop_lttng_sessiond
-stop_lttng_relayd
-
-exit $out
+++ /dev/null
-#!/bin/bash
-
-DIR=$(dirname $0)
-
-tests=( $DIR/unit_tests $DIR/run-kernel $DIR/run-ust )
-exit_code=0
-
-function start_tests ()
-{
- for bin in ${tests[@]};
- do
- if [ ! -e $bin ]; then
- echo -e "$bin not found, passing"
- continue
- fi
-
- ./$bin
- # Test must return 0 to pass.
- if [ $? -ne 0 ]; then
- exit_code=1
- break
- fi
- done
-}
-
-start_tests
-
-exit $exit_code
+++ /dev/null
-/*
- * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
- * IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program for any purpose,
- * provided the above notices are retained on all copies. Permission to modify
- * the code and to distribute modified code is granted, provided the above
- * notices are retained, and a notice that the code was modified is included
- * with the above copyright notice.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "tp.h"
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER tp
-
-#if !defined(_TRACEPOINT_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_TP_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_EVENT(tp, tptest,
- TP_ARGS(int, anint, int, netint, long *, values,
- char *, text, size_t, textlen,
- double, doublearg, float, floatarg),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer_hex(int, intfield2, anint)
- ctf_integer(long, longfield, anint)
- ctf_integer_network(int, netintfield, netint)
- ctf_integer_network_hex(int, netintfieldhex, netint)
- ctf_array(long, arrfield1, values, 3)
- ctf_array_text(char, arrfield2, text, 10)
- ctf_sequence(char, seqfield1, text, size_t, textlen)
- ctf_sequence_text(char, seqfield2, text, size_t, textlen)
- ctf_string(stringfield, text)
- ctf_float(float, floatfield, floatarg)
- ctf_float(double, doublefield, doublearg)
- )
-)
-
-#endif /* _TRACEPOINT_TP_H */
-
-#undef TRACEPOINT_INCLUDE_FILE
-#define TRACEPOINT_INCLUDE_FILE ./tp.h
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
- *
- * 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 <sys/types.h>
-
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/uri.h>
-
-#include "utils.h"
-
-/* This path will NEVER be created in this test */
-#define PATH1 "tmp/.test-junk-lttng"
-
-#define RANDOM_STRING_LEN 16
-
-/* For lttngerr.h */
-int lttng_opt_quiet = 1;
-int lttng_opt_verbose = 3;
-
-/*
- * Test string URI and if uri_parse works well.
- */
-void test_uri_parsing(void)
-{
- ssize_t size;
- const char *s_uri1;
- struct lttng_uri *uri;
-
- fprintf(stdout, "Testing URIs...\n");
-
- s_uri1 = "net://localhost";
- fprintf(stdout, " [+] URI set to %s ", s_uri1);
- size = uri_parse(s_uri1, &uri);
- assert(size == 2);
- assert(uri[0].dtype == LTTNG_DST_IPV4);
- assert(uri[0].utype == LTTNG_URI_DST);
- assert(uri[0].stype == 0);
- assert(uri[0].port == 0);
- assert(strlen(uri[0].subdir) == 0);
- assert(strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0);
-
- assert(uri[1].dtype == LTTNG_DST_IPV4);
- assert(uri[1].utype == LTTNG_URI_DST);
- assert(uri[1].stype == 0);
- assert(uri[1].port == 0);
- assert(strlen(uri[1].subdir) == 0);
- assert(strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0);
- PRINT_OK();
- uri_free(uri);
-
- s_uri1 = "net://localhost:8989:4242/my/test/path";
- fprintf(stdout, " [+] URI set to %s ", s_uri1);
- size = uri_parse(s_uri1, &uri);
- assert(size == 2);
- assert(uri[0].dtype == LTTNG_DST_IPV4);
- assert(uri[0].utype == LTTNG_URI_DST);
- assert(uri[0].stype == 0);
- assert(uri[0].port == 8989);
- assert(strcmp(uri[0].subdir, "my/test/path") == 0);
- assert(strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0);
-
- assert(uri[1].dtype == LTTNG_DST_IPV4);
- assert(uri[1].utype == LTTNG_URI_DST);
- assert(uri[1].stype == 0);
- assert(uri[1].port == 4242);
- assert(strcmp(uri[0].subdir, "my/test/path") == 0);
- assert(strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0);
- PRINT_OK();
- uri_free(uri);
-
- s_uri1 = "net://localhost:8989:4242";
- fprintf(stdout, " [+] URI set to %s ", s_uri1);
- size = uri_parse(s_uri1, &uri);
- assert(size == 2);
- assert(uri[0].dtype == LTTNG_DST_IPV4);
- assert(uri[0].utype == LTTNG_URI_DST);
- assert(uri[0].stype == 0);
- assert(uri[0].port == 8989);
- assert(strlen(uri[1].subdir) == 0);
- assert(strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0);
-
- assert(uri[1].dtype == LTTNG_DST_IPV4);
- assert(uri[1].utype == LTTNG_URI_DST);
- assert(uri[1].stype == 0);
- assert(uri[1].port == 4242);
- assert(strlen(uri[1].subdir) == 0);
- assert(strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0);
- PRINT_OK();
- uri_free(uri);
-
- s_uri1 = "net6://localhost:8989";
- fprintf(stdout, " [+] URI set to %s ", s_uri1);
- size = uri_parse(s_uri1, &uri);
- assert(size == 2);
- assert(uri[0].dtype == LTTNG_DST_IPV6);
- assert(uri[0].utype == LTTNG_URI_DST);
- assert(uri[0].stype == 0);
- assert(uri[0].port == 8989);
- assert(strlen(uri[1].subdir) == 0);
- assert(strcmp(uri[0].dst.ipv6, "::1") == 0);
-
- assert(uri[1].dtype == LTTNG_DST_IPV6);
- assert(uri[1].utype == LTTNG_URI_DST);
- assert(uri[1].stype == 0);
- assert(uri[1].port == 0);
- assert(strlen(uri[1].subdir) == 0);
- assert(strcmp(uri[0].dst.ipv6, "::1") == 0);
- PRINT_OK();
- uri_free(uri);
-
- s_uri1 = "tcp://42.42.42.42/my/test/path";
- fprintf(stdout, " [+] URI set to %s ", s_uri1);
- size = uri_parse(s_uri1, &uri);
- assert(size == 1);
- assert(uri[0].dtype == LTTNG_DST_IPV4);
- assert(uri[0].utype == LTTNG_URI_DST);
- assert(uri[0].stype == 0);
- assert(uri[0].port == 0);
- assert(strcmp(uri[0].subdir, "my/test/path") == 0);
- assert(strcmp(uri[0].dst.ipv4, "42.42.42.42") == 0);
- PRINT_OK();
- uri_free(uri);
-
- s_uri1 = "tcp6://[fe80::f66d:4ff:fe53:d220]/my/test/path";
- fprintf(stdout, " [+] URI set to %s ", s_uri1);
- size = uri_parse(s_uri1, &uri);
- assert(size == 1);
- assert(uri[0].dtype == LTTNG_DST_IPV6);
- assert(uri[0].utype == LTTNG_URI_DST);
- assert(uri[0].stype == 0);
- assert(uri[0].port == 0);
- assert(strcmp(uri[0].subdir, "my/test/path") == 0);
- assert(strcmp(uri[0].dst.ipv6, "fe80::f66d:4ff:fe53:d220") == 0);
- PRINT_OK();
- uri_free(uri);
-
- s_uri1 = "file:///my/test/path";
- fprintf(stdout, " [+] URI set to %s ", s_uri1);
- size = uri_parse(s_uri1, &uri);
- assert(size == 1);
- assert(uri[0].dtype == LTTNG_DST_PATH);
- assert(uri[0].utype == LTTNG_URI_DST);
- assert(uri[0].stype == 0);
- assert(uri[0].port == 0);
- assert(strlen(uri[0].subdir) == 0);
- assert(strcmp(uri[0].dst.path, "/my/test/path") == 0);
- PRINT_OK();
- uri_free(uri);
-
- s_uri1 = "file/my/test/path";
- fprintf(stdout, " [+] Bad URI set to %s ", s_uri1);
- size = uri_parse(s_uri1, &uri);
- assert(size == -1);
- PRINT_OK();
-
- s_uri1 = "net://:8999";
- fprintf(stdout, " [+] Bad URI set to %s ", s_uri1);
- size = uri_parse(s_uri1, &uri);
- assert(size == -1);
- PRINT_OK();
-}
-
-void test_uri_cmp()
-{
- struct lttng_uri *uri1, *uri2;
- const char *s_uri1 = "net://localhost";
- const char *s_uri2 = "net://localhost:8989:4242";
- ssize_t size1, size2;
- int res;
-
- size1 = uri_parse(s_uri1, &uri1);
-
- /* Sanity checks */
- assert(size1 == 2);
- assert(uri1[0].dtype == LTTNG_DST_IPV4);
- assert(uri1[0].utype == LTTNG_URI_DST);
- assert(uri1[0].stype == 0);
- assert(uri1[0].port == 0);
- assert(strlen(uri1[0].subdir) == 0);
- assert(strcmp(uri1[0].dst.ipv4, "127.0.0.1") == 0);
- assert(uri1[1].dtype == LTTNG_DST_IPV4);
- assert(uri1[1].utype == LTTNG_URI_DST);
- assert(uri1[1].stype == 0);
- assert(uri1[1].port == 0);
- assert(strlen(uri1[1].subdir) == 0);
- assert(strcmp(uri1[1].dst.ipv4, "127.0.0.1") == 0);
-
- size2 = uri_parse(s_uri2, &uri2);
-
- assert(size2 == 2);
- assert(uri2[0].dtype == LTTNG_DST_IPV4);
- assert(uri2[0].utype == LTTNG_URI_DST);
- assert(uri2[0].stype == 0);
- assert(uri2[0].port == 8989);
- assert(strlen(uri2[1].subdir) == 0);
- assert(strcmp(uri2[0].dst.ipv4, "127.0.0.1") == 0);
- assert(uri2[1].dtype == LTTNG_DST_IPV4);
- assert(uri2[1].utype == LTTNG_URI_DST);
- assert(uri2[1].stype == 0);
- assert(uri2[1].port == 4242);
- assert(strlen(uri2[1].subdir) == 0);
- assert(strcmp(uri2[1].dst.ipv4, "127.0.0.1") == 0);
-
-
- res = uri_compare(uri1, uri1);
- fprintf(stdout, " [+] %s == %s ", s_uri1, s_uri1);
- assert(res == 0);
- PRINT_OK();
-
- res = uri_compare(uri1, uri2);
- fprintf(stdout, " [+] %s != %s ", s_uri1, s_uri2);
- assert(res != 0);
- PRINT_OK();
-
- uri_free(uri1);
- uri_free(uri2);
-}
-
-int main(int argc, char **argv)
-{
- srand(time(NULL));
-
- printf("\nStreaming unit tests\n-----------\n");
-
- /* URI tests */
- test_uri_parsing();
- test_uri_cmp();
-
- return 0;
-}
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
-# David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library 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 Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-TEST_DESC="Streaming - URI switching"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-BIN_NAME="gen-ust-events"
-SESSION_NAME="stream"
-EVENT_NAME="tp:tptest"
-PID_RELAYD=0
-
-TRACE_PATH=$(mktemp -d)
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/$BIN_NAME" ]; then
- echo -e "No UST nevents binary detected. Skipping."
- exit 0
-fi
-
-function lttng_create_session
-{
- URI=$1
- # Create session with custom URI
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN create -U $URI $SESSION_NAME >/dev/null 2>&1
-}
-
-function lttng_enable_consumer
-{
- URI=$1
- # Create session with custom URI
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u $URI >/dev/null 2>&1
-}
-
-function run_apps
-{
- # Run 5 times with a 1 second delay
- COUNT=5
- APP_DELAY=1000000
- ./$CURDIR/$BIN_NAME $COUNT $APP_DELAY >/dev/null 2>&1 &
-
-}
-
-function wait_apps
-{
- echo -n "Waiting for applications to end"
- while [ -n "$(pidof $BIN_NAME)" ]; do
- echo -n "."
- sleep 0.5
- done
- echo ""
-}
-
-function test_uri_switch_localhost_folder
-{
- IPVER=$1
- echo -e "\n=== Testing switch of localhost folder ($IPVER)\n"
-
- if [ "$IPVER" == "IPv6" ]; then
- BASE_URI="net6://localhost"
- else
- BASE_URI="net://localhost"
- fi
-
- RANDCOUNT=10
- RAND=""
- i=1
-
- lttng_create_session $BASE_URI
-
- echo -e "Randomizing output folder on $BASE_URI..."
- while [ "$i" -le $RANDCOUNT ]
- do
- RAND=$(randstring 16 0)
- lttng_enable_consumer "$BASE_URI/$RAND"
- let "i += 1"
- done
-
- enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
- start_lttng_tracing $SESSION_NAME
- run_apps
- wait_apps
- stop_lttng_tracing $SESSION_NAME
- destroy_lttng_session $SESSION_NAME
- validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$RAND
-
- if [ $? -eq 0 ]; then
- # Only delete if successful
- rm -rf $TRACE_PATH
- fi
-}
-
-function test_uri_switch_file_network
-{
- IPVER=$1
- echo ""
- echo -e "=== Testing switch file -> network ($IPVER)"
-
- TMP_PATH=$(mktemp -d)
- FILE_URI="file://$TMP_PATH"
-
- if [ "$IPVER" == "IPv6" ]; then
- NETWORK_URIS=("net6://localhost" "net6://[::1]")
- else
- NETWORK_URIS=("net://localhost" "net://127.0.0.1")
- fi
-
- NET_PATHS=("foo/bar" "OohEehOohAhAahTingTangWallaWallaBingBang" ".")
-
- for NETWORK_URI in ${NETWORK_URIS[@]};
- do
- for NET_PATH in ${NET_PATHS[@]};
- do
- SESSION_NAME=$(randstring 16 0)
- echo ""
- echo "$FILE_URI -> $NETWORK_URI/$NET_PATH"
-
- lttng_create_session $FILE_URI
- lttng_enable_consumer "$NETWORK_URI/$NET_PATH"
- enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
- start_lttng_tracing $SESSION_NAME
- run_apps
- wait_apps
- stop_lttng_tracing $SESSION_NAME
- destroy_lttng_session $SESSION_NAME
- validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$NET_PATH
-
- if [ $? -eq 0 ]; then
- # Only delete if successful
- rm -rf $TRACE_PATH
- else
- break
- fi
- done
- done
- rm -rf $TMP_PATH
-}
-
-function test_uri_switch_network_file
-{
-IPVER=$1
- echo ""
- echo -e "=== Testing switch network ($IPVER) -> file"
-
- if [ "$IPVER" == "IPv6" ]; then
- NETWORK_URI="net6://localhost"
- else
- NETWORK_URI="net://localhost"
- fi
-
- FILE_PATHS=("." "foo/bar" "42")
-
- for FILE_PATH in ${FILE_PATHS[@]};
- do
- TMP_PATH=$(mktemp -d)
- FILE_URI="file://$TMP_PATH"
- SESSION_NAME=$(randstring 16 0)
-
- echo ""
- echo "$NETWORK_URI -> $FILE_URI/$FILE_PATH"
-
- lttng_create_session $NETWORK_URI
- lttng_enable_consumer "$FILE_URI/$FILE_PATH"
- enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
- start_lttng_tracing $SESSION_NAME
- run_apps
- wait_apps
- stop_lttng_tracing $SESSION_NAME
- destroy_lttng_session $SESSION_NAME
- validate_trace $EVENT_NAME $TMP_PATH/$FILE_PATH
-
- if [ $? -eq 0 ]; then
- # Only delete if successful
- rm -rf $TMP_PATH
- else
- break
- fi
- done
-}
-
-
-start_lttng_sessiond
-
-echo ""
-echo "=== Testing with IPv4"
-start_lttng_relayd "-o $TRACE_PATH"
-test_uri_switch_localhost_folder "IPv4"
-test_uri_switch_file_network "IPv4"
-test_uri_switch_network_file "IPv4"
-stop_lttng_relayd
-
-echo ""
-echo "=== Testing with IPv6"
-start_lttng_relayd "-o $TRACE_PATH -C tcp6://localhost:5342 -D tcp6://localhost:5343"
-test_uri_switch_localhost_folder "IPv6"
-test_uri_switch_file_network "IPv6"
-test_uri_switch_network_file "IPv6"
-stop_lttng_relayd
-
-stop_lttng_sessiond
+++ /dev/null
-/*
- * 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 <bin/lttng-sessiond/trace-kernel.h>
-#include <common/defaults.h>
-
-#include "utils.h"
-
-/* This path will NEVER be created in this test */
-#define PATH1 "/tmp/.test-junk-lttng"
-
-#define RANDOM_STRING_LEN 11
-
-/* For lttngerr.h */
-int lttng_opt_quiet = 1;
-int lttng_opt_verbose;
-
-static const char alphanum[] =
- "0123456789"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
-
-static struct ltt_kernel_session *kern;
-static char random_string[RANDOM_STRING_LEN];
-
-/*
- * Return random string of 10 characters.
- * Not thread-safe.
- */
-static char *get_random_string(void)
-{
- int i;
-
- for (i = 0; i < RANDOM_STRING_LEN - 1; i++) {
- random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
- }
-
- random_string[RANDOM_STRING_LEN - 1] = '\0';
-
- return random_string;
-}
-
-static void create_one_kernel_session(void)
-{
- printf("Create kernel session: ");
- kern = trace_kernel_create_session(PATH1);
- assert(kern != NULL);
- PRINT_OK();
-
- printf("Validating kernel session: ");
- assert(kern->fd == -1);
- assert(kern->metadata_stream_fd == -1);
- assert(kern->consumer_fds_sent == 0);
- assert(kern->channel_count == 0);
- assert(kern->stream_count_global == 0);
- assert(kern->metadata == NULL);
- PRINT_OK();
-
- /* Init list in order to avoid sefaults from cds_list_del */
- trace_kernel_destroy_session(kern);
-}
-
-static void create_kernel_metadata(void)
-{
- assert(kern != NULL);
-
- printf("Create kernel metadata: ");
- kern->metadata = trace_kernel_create_metadata();
- assert(kern->metadata != NULL);
- PRINT_OK();
-
- printf("Validating kernel session metadata: ");
- assert(kern->metadata->fd == -1);
- assert(kern->metadata->conf != NULL);
- assert(kern->metadata->conf->attr.overwrite
- == DEFAULT_CHANNEL_OVERWRITE);
- assert(kern->metadata->conf->attr.subbuf_size
- == default_get_metadata_subbuf_size());
- assert(kern->metadata->conf->attr.num_subbuf
- == DEFAULT_METADATA_SUBBUF_NUM);
- assert(kern->metadata->conf->attr.switch_timer_interval
- == DEFAULT_CHANNEL_SWITCH_TIMER);
- assert(kern->metadata->conf->attr.read_timer_interval
- == DEFAULT_CHANNEL_READ_TIMER);
- assert(kern->metadata->conf->attr.output
- == DEFAULT_KERNEL_CHANNEL_OUTPUT);
- PRINT_OK();
-
- trace_kernel_destroy_metadata(kern->metadata);
-}
-
-static void create_kernel_channel(void)
-{
- struct ltt_kernel_channel *chan;
- struct lttng_channel attr;
-
- memset(&attr, 0, sizeof(attr));
-
- printf("Creating kernel channel: ");
- chan = trace_kernel_create_channel(&attr);
- assert(chan != NULL);
- PRINT_OK();
-
- printf("Validating kernel channel: ");
- assert(chan->fd == -1);
- assert(chan->enabled == 1);
- assert(chan->stream_count == 0);
- assert(chan->ctx == NULL);
- assert(chan->channel->attr.overwrite == attr.attr.overwrite);
- PRINT_OK();
-
- /* Init list in order to avoid sefaults from cds_list_del */
- CDS_INIT_LIST_HEAD(&chan->list);
- trace_kernel_destroy_channel(chan);
-}
-
-static void create_kernel_event(void)
-{
- struct ltt_kernel_event *event;
- struct lttng_event ev;
-
- memset(&ev, 0, sizeof(ev));
- strncpy(ev.name, get_random_string(), LTTNG_KERNEL_SYM_NAME_LEN);
- ev.type = LTTNG_EVENT_TRACEPOINT;
- ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
- printf("Creating kernel event: ");
- event = trace_kernel_create_event(&ev);
- assert(event != NULL);
- PRINT_OK();
-
- printf("Validating kernel event: ");
- assert(event->fd == -1);
- assert(event->enabled == 1);
- assert(event->event->instrumentation == LTTNG_KERNEL_TRACEPOINT);
- assert(strlen(event->event->name));
- PRINT_OK();
-
- /* Init list in order to avoid sefaults from cds_list_del */
- CDS_INIT_LIST_HEAD(&event->list);
- trace_kernel_destroy_event(event);
-}
-
-static void create_kernel_stream(void)
-{
- struct ltt_kernel_stream *stream;
-
- printf("Creating kernel stream: ");
- stream = trace_kernel_create_stream("stream1", 0);
- assert(stream != NULL);
- PRINT_OK();
-
- printf("Validating kernel stream: ");
- assert(stream->fd == -1);
- assert(stream->state == 0);
- PRINT_OK();
-
- /* Init list in order to avoid sefaults from cds_list_del */
- CDS_INIT_LIST_HEAD(&stream->list);
- trace_kernel_destroy_stream(stream);
-}
-
-int main(int argc, char **argv)
-{
- printf("\nTesting kernel data structures:\n-----------\n");
-
- create_one_kernel_session();
-
- create_kernel_metadata();
- create_kernel_channel();
-
-
- create_kernel_event();
-
- create_kernel_stream();
-
- /* Success */
- return 0;
-}
+++ /dev/null
-/*
- * 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 <sys/types.h>
-
-#include <bin/lttng-sessiond/session.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/common.h>
-
-#include "utils.h"
-
-#define SESSION1 "test1"
-
-/* This path will NEVER be created in this test */
-#define PATH1 "/tmp/.test-junk-lttng"
-
-#define MAX_SESSIONS 10000
-#define RANDOM_STRING_LEN 11
-
-/*
- * String of 263 caracters. NAME_MAX + "OVERFLOW". If OVERFLOW appears in the
- * session name, we have a problem.
- *
- * NAME_MAX = 255
- */
-#define OVERFLOW_SESSION_NAME \
- "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" \
- "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" \
- "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" \
- "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc" \
- "OVERFLOW"
-
-static struct ltt_session_list *session_list;
-
-/* For lttngerr.h */
-int lttng_opt_quiet = 1;
-int lttng_opt_verbose = 0;
-
-static const char alphanum[] =
- "0123456789"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
-static char random_string[RANDOM_STRING_LEN];
-
-/*
- * Return random string of 10 characters.
- * Not thread-safe.
- */
-static char *get_random_string(void)
-{
- int i;
-
- for (i = 0; i < RANDOM_STRING_LEN - 1; i++) {
- random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
- }
-
- random_string[RANDOM_STRING_LEN - 1] = '\0';
-
- return random_string;
-}
-
-/*
- * Return 0 if session name is found, else -1
- */
-static int find_session_name(char *name)
-{
- struct ltt_session *iter;
-
- cds_list_for_each_entry(iter, &session_list->head, list) {
- if (strcmp(iter->name, name) == 0) {
- return 0;
- }
- }
-
- return -1;
-}
-
-static int session_list_count(void)
-{
- int count = 0;
- struct ltt_session *iter;
-
- cds_list_for_each_entry(iter, &session_list->head, list) {
- count++;
- }
- return count;
-}
-
-/*
- * Empty session list manually.
- */
-static void empty_session_list(void)
-{
- struct ltt_session *iter, *tmp;
-
- cds_list_for_each_entry_safe(iter, tmp, &session_list->head, list) {
- cds_list_del(&iter->list);
- free(iter);
- }
-
- /* Session list must be 0 */
- assert(!session_list_count());
-}
-
-/*
- * Test creation of 1 session
- */
-static int create_one_session(char *name, char *path)
-{
- int ret;
-
- ret = session_create(name, path, geteuid(), getegid());
- if (ret == LTTNG_OK) {
- /* Validate */
- ret = find_session_name(name);
- if (ret < 0) {
- /* Session not found by name */
- printf("session not found after creation\n");
- return -1;
- } else {
- /* Success */
- return 0;
- }
- } else {
- if (ret == LTTNG_ERR_EXIST_SESS) {
- printf("(session already exists) ");
- }
- return -1;
- }
-
- return 0;
-}
-
-/*
- * Test deletion of 1 session
- */
-static int destroy_one_session(struct ltt_session *session)
-{
- int ret;
-
- ret = session_destroy(session);
-
- if (ret == LTTNG_OK) {
- /* Validate */
- if (session == NULL) {
- return 0;
- }
- ret = find_session_name(session->name);
- if (ret < 0) {
- /* Success, -1 means that the sesion is NOT found */
- return 0;
- } else {
- /* Fail */
- return -1;
- }
- }
-
- return 0;
-}
-
-static int fuzzing_create_args(void)
-{
- int ret;
-
- ret = create_one_session(NULL, NULL);
- if (ret > 0) {
- printf("Session created with (null),(null)\n");
- return -1;
- }
-
- ret = create_one_session(NULL, PATH1);
- if (ret > 0) {
- printf("Session created with (null), %s)\n", PATH1);
- return -1;
- }
-
- /* Session list must be 0 */
- assert(!session_list_count());
-
- return 0;
-}
-
-/*
- * This test is supposed to fail at the second create call. If so, return 0 for
- * test success, else -1.
- */
-static int two_session_same_name(void)
-{
- int ret;
- struct ltt_session *sess;
-
- ret = create_one_session(SESSION1, PATH1);
- if (ret < 0) {
- /* Fail */
- return -1;
- }
-
- sess = session_find_by_name(SESSION1);
- if (sess) {
- /* Success */
- return 0;
- }
-
- /* Fail */
- return -1;
-}
-
-int main(int argc, char **argv)
-{
- int ret, i;
- struct ltt_session *iter, *tmp;
-
- srand(time(NULL));
-
- printf("\nTesting Sessions:\n-----------\n");
-
- session_list = session_get_list();
- if (session_list == NULL) {
- return -1;
- }
-
- printf("Create 1 session %s: ", SESSION1);
- fflush(stdout);
- ret = create_one_session(SESSION1, PATH1);
- if (ret < 0) {
- return -1;
- }
- PRINT_OK();
-
- printf("Validating created session %s: ", SESSION1);
- fflush(stdout);
- tmp = session_find_by_name(SESSION1);
- if (tmp == NULL) {
- return -1;
- }
- /* Basic init session values */
- assert(tmp->kernel_session == NULL);
- assert(strlen(tmp->path));
- assert(strlen(tmp->name));
- session_lock(tmp);
- session_unlock(tmp);
-
- PRINT_OK();
-
- printf("Destroy 1 session %s: ", SESSION1);
- fflush(stdout);
- ret = destroy_one_session(tmp);
- if (ret < 0) {
- return -1;
- }
- PRINT_OK();
-
- printf("Two session with same name: ");
- fflush(stdout);
- ret = two_session_same_name();
- if (ret < 0) {
- return -1;
- }
- PRINT_OK();
-
- empty_session_list();
-
- printf("Fuzzing create_session arguments: ");
- fflush(stdout);
- ret = fuzzing_create_args();
- if (ret < 0) {
- return -1;
- }
- PRINT_OK();
-
- printf("Creating %d sessions: ", MAX_SESSIONS);
- fflush(stdout);
- for (i = 0; i < MAX_SESSIONS; i++) {
- char *tmp_name = get_random_string();
-
- ret = create_one_session(tmp_name, PATH1);
- if (ret < 0) {
- printf("session %d (name: %s) creation failed\n", i, tmp_name);
- return -1;
- }
-
- if ((i % 1000) == 0) {
- fprintf(stdout, "%d..", i);
- fflush(stdout);
- }
- }
- PRINT_OK();
-
- printf("Destroying %d sessions: ", MAX_SESSIONS);
- fflush(stdout);
- for (i = 0; i < MAX_SESSIONS; i++) {
- cds_list_for_each_entry_safe(iter, tmp, &session_list->head, list) {
- ret = destroy_one_session(iter);
- if (ret < 0) {
- printf("session %d (name: %s) creation failed\n", i, iter->name);
- return -1;
- }
- }
- }
- PRINT_OK();
-
- /* Session list must be 0 */
- assert(!session_list_count());
-
- /* Success */
- return 0;
-}
+++ /dev/null
-/*
- * 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 <bin/lttng-sessiond/lttng-ust-abi.h>
-#include <common/defaults.h>
-#include <bin/lttng-sessiond/trace-ust.h>
-
-#include "utils.h"
-
-/* This path will NEVER be created in this test */
-#define PATH1 "/tmp/.test-junk-lttng"
-
-#define RANDOM_STRING_LEN 11
-
-/* For lttngerr.h */
-int lttng_opt_quiet = 1;
-int lttng_opt_verbose;
-
-static const char alphanum[] =
- "0123456789"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
-static char random_string[RANDOM_STRING_LEN];
-
-static struct ltt_ust_session *usess;
-static struct lttng_domain dom;
-
-/*
- * Return random string of 10 characters.
- * Not thread-safe.
- */
-static char *get_random_string(void)
-{
- int i;
-
- for (i = 0; i < RANDOM_STRING_LEN - 1; i++) {
- random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
- }
-
- random_string[RANDOM_STRING_LEN - 1] = '\0';
-
- return random_string;
-}
-
-static void create_one_ust_session(void)
-{
- printf("Create UST session: ");
-
- dom.type = LTTNG_DOMAIN_UST;
-
- usess = trace_ust_create_session(PATH1, 42);
- assert(usess != NULL);
- PRINT_OK();
-
- printf("Validating UST session: ");
- assert(usess->id == 42);
- assert(usess->start_trace == 0);
- assert(usess->domain_global.channels != NULL);
- assert(usess->domain_pid != NULL);
- assert(usess->domain_exec != NULL);
- assert(usess->uid == 0);
- assert(usess->gid == 0);
- PRINT_OK();
-
- trace_ust_destroy_session(usess);
-}
-
-static void create_ust_metadata(void)
-{
- struct ltt_ust_metadata *metadata;
-
- assert(usess != NULL);
-
- printf("Create UST metadata: ");
- metadata = trace_ust_create_metadata(PATH1);
- assert(metadata != NULL);
- PRINT_OK();
-
- printf("Validating UST session metadata: ");
- assert(metadata->handle == -1);
- assert(strlen(metadata->pathname));
- assert(metadata->attr.overwrite
- == DEFAULT_CHANNEL_OVERWRITE);
- assert(metadata->attr.subbuf_size
- == default_get_metadata_subbuf_size());
- assert(metadata->attr.num_subbuf
- == DEFAULT_METADATA_SUBBUF_NUM);
- assert(metadata->attr.switch_timer_interval
- == DEFAULT_CHANNEL_SWITCH_TIMER);
- assert(metadata->attr.read_timer_interval
- == DEFAULT_CHANNEL_READ_TIMER);
- assert(metadata->attr.output == LTTNG_UST_MMAP);
- PRINT_OK();
-
- trace_ust_destroy_metadata(metadata);
-}
-
-static void create_ust_channel(void)
-{
- struct ltt_ust_channel *uchan;
- struct lttng_channel attr;
-
- memset(&attr, 0, sizeof(attr));
-
- strncpy(attr.name, "channel0", 8);
-
- printf("Creating UST channel: ");
- uchan = trace_ust_create_channel(&attr, PATH1);
- assert(uchan != NULL);
- PRINT_OK();
-
- printf("Validating UST channel: ");
- assert(uchan->enabled == 0);
- assert(strcmp(PATH1, uchan->pathname) == 0);
- assert(strncmp(uchan->name, "channel0", 8) == 0);
- assert(uchan->name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0');
- assert(uchan->ctx != NULL);
- assert(uchan->events != NULL);
- assert(uchan->attr.overwrite == attr.attr.overwrite);
- PRINT_OK();
-
- trace_ust_destroy_channel(uchan);
-}
-
-static void create_ust_event(void)
-{
- struct ltt_ust_event *event;
- struct lttng_event ev;
-
- memset(&ev, 0, sizeof(ev));
- strncpy(ev.name, get_random_string(), LTTNG_SYMBOL_NAME_LEN);
- ev.type = LTTNG_EVENT_TRACEPOINT;
- ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
- printf("Creating UST event: ");
- event = trace_ust_create_event(&ev, NULL);
- assert(event != NULL);
- PRINT_OK();
-
- printf("Validating UST event: ");
- assert(event->enabled == 0);
- assert(event->attr.instrumentation == LTTNG_UST_TRACEPOINT);
- assert(strcmp(event->attr.name, ev.name) == 0);
- assert(event->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0');
- PRINT_OK();
-
- trace_ust_destroy_event(event);
-}
-
-static void create_ust_context(void)
-{
- struct lttng_event_context ectx;
- struct ltt_ust_context *uctx;
-
- ectx.ctx = LTTNG_EVENT_CONTEXT_VTID;
-
- printf("Creating UST context: ");
- uctx = trace_ust_create_context(&ectx);
- assert(uctx != NULL);
- PRINT_OK();
-
- printf("Validating UST context: ");
- assert((int) uctx->ctx.ctx == LTTNG_UST_CONTEXT_VTID);
- PRINT_OK();
-}
-
-int main(int argc, char **argv)
-{
- printf("\nTesting UST data structures:\n-----------\n");
-
- create_one_ust_session();
- create_ust_metadata();
- create_ust_channel();
- create_ust_event();
- create_ust_context();
-
- /* Success */
- return 0;
-}
+++ /dev/null
-if HAVE_LIBLTTNG_UST_CTL
-SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \
- overlap
-
-AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/tests -I$(top_srcdir)/src -g -Wall
-AM_LDFLAGS = -lurcu -lurcu-cds
-
-EXTRA_DIST = runall.sh run-ust-global-tests.sh
-
-noinst_PROGRAMS = ust_global_event_basic ust_global_event_wildcard
-
-UTILS=../utils.h
-LIBLTTNG=$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la
-
-SESSIONDSRC=$(top_srcdir)/src/common/sessiond-comm/sessiond-comm.c \
- $(top_srcdir)/src/common/sessiond-comm/unix.c \
- $(top_srcdir)/src/common/sessiond-comm/inet.c \
- $(top_srcdir)/src/common/sessiond-comm/inet6.c
-
-ust_global_event_wildcard_SOURCES = ust_global_event_wildcard.c $(UTILS) \
- $(SESSIONDSRC)
-ust_global_event_wildcard_LDADD = $(LIBLTTNG)
-
-ust_global_event_basic_SOURCES = ust_global_event_basic.c $(UTILS) \
- $(SESSIONDSRC)
-ust_global_event_basic_LDADD = $(LIBLTTNG)
-
-endif
+++ /dev/null
-AM_CFLAGS = -I$(srcdir) -O2
-AM_LDFLAGS = -llttng-ust
-
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-AM_LDFLAGS += -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-AM_LDFLAGS += -lc
-endif
-
-noinst_PROGRAMS = gen-nevents
-gen_nevents_SOURCES = gen-nevents.c tp.c ust_gen_nevents.h
-gen_nevents_LDADD = -llttng-ust
-
-noinst_SCRIPTS = run
-EXTRA_DIST = run
+++ /dev/null
-/*
- * Copyright (C) - 2009 Pierre-Marc Fournier
- * Copyright (C) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation; version 2.1 of the License.
- *
- * This library 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 Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <arpa/inet.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#define TRACEPOINT_DEFINE
-#include "ust_gen_nevents.h"
-
-int main(int argc, char **argv)
-{
- int i, netint;
- long values[] = { 1, 2, 3 };
- char text[10] = "test";
- double dbl = 2.0;
- float flt = 2222.0;
- unsigned int nr_iter = 100;
-
- if (argc == 2) {
- nr_iter = atoi(argv[1]);
- }
-
- for (i = 0; i < nr_iter; i++) {
- netint = htonl(i);
- tracepoint(ust_gen_nevents, tptest, i, netint, values, text,
- strlen(text), dbl, flt);
- usleep(100000);
- }
-
- return 0;
-}
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library 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 Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-TEST_DESC="UST tracer - Start tracing before and after execution"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-NR_ITER=100
-SESSION_NAME="per-session"
-EVENT_NAME="ust_gen_nevents:tptest"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/gen-nevents" ]; then
- echo -e "No UST nevents binary detected. Passing."
- exit 0
-fi
-
-# MUST set TESTDIR before calling those functions
-
-test_before_apps() {
- local out
-
- # BEFORE application is spawned
- create_lttng_session $SESSION_NAME $TRACE_PATH
- enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
- start_lttng_tracing $SESSION_NAME
- # Start test
- echo -n "Starting application... "
- ./$CURDIR/gen-nevents $NR_ITER
- echo -n "Ended "
- print_ok
- stop_lttng_tracing $SESSION_NAME
- destroy_lttng_session $SESSION_NAME
-
- trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
-
- return $?
-}
-
-test_after_apps() {
- local out
-
- echo -n "Starting application... "
- ./$CURDIR/gen-nevents 100 &
- print_ok
-
- # BEFORE application is spawned
- create_lttng_session $SESSION_NAME $TRACE_PATH
- enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
- start_lttng_tracing $SESSION_NAME
-
- # At least hit one event
- sleep 2
-
- stop_lttng_tracing $SESSION_NAME
- destroy_lttng_session $SESSION_NAME
-
- out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
- if [ $out -eq 0 ]; then
- echo -n "No event found. Suppose to have at least one... "
- print_fail
- out=1
- else
- echo -n "Found $out event(s). Coherent... "
- print_ok
- out=0
- fi
-
- return $out
-}
-
-# MUST set TESTDIR before calling those functions
-
-start_lttng_sessiond
-
-echo ""
-echo "=== Start application BEFORE tracing was started ==="
-
-TRACE_PATH=$(mktemp -d)
-
-test_before_apps
-out=$?
-if [ $out -ne 0 ]; then
- stop_lttng_sessiond
- exit $out
-fi
-
-rm -rf $TRACE_PATH
-
-echo ""
-echo "=== Start application AFTER tracing was started ==="
-
-TRACE_PATH=$(mktemp -d)
-
-test_after_apps
-out=$?
-if [ $out -ne 0 ]; then
- stop_lttng_sessiond
- exit $out
-fi
-
-stop_lttng_sessiond
-
-rm -rf $TRACE_PATH
+++ /dev/null
-/*
- * Copyright (c) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
- * IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program for any purpose,
- * provided the above notices are retained on all copies. Permission to modify
- * the code and to distribute modified code is granted, provided the above
- * notices are retained, and a notice that the code was modified is included
- * with the above copyright notice.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_gen_nevents.h"
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER ust_gen_nevents
-
-#if !defined(_TRACEPOINT_UST_GEN_NEVENTS_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_GEN_NEVENTS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_EVENT(ust_gen_nevents, tptest,
- TP_ARGS(int, anint, int, netint, long *, values,
- char *, text, size_t, textlen,
- double, doublearg, float, floatarg),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer_hex(int, intfield2, anint)
- ctf_integer(long, longfield, anint)
- ctf_integer_network(int, netintfield, netint)
- ctf_integer_network_hex(int, netintfieldhex, netint)
- ctf_array(long, arrfield1, values, 3)
- ctf_array_text(char, arrfield2, text, 10)
- ctf_sequence(char, seqfield1, text, size_t, textlen)
- ctf_sequence_text(char, seqfield2, text, size_t, textlen)
- ctf_string(stringfield, text)
- ctf_float(float, floatfield, floatarg)
- ctf_float(double, doublefield, doublearg)
- )
-)
-
-#endif /* _TRACEPOINT_UST_GEN_NEVENTS_H */
-
-#undef TRACEPOINT_INCLUDE_FILE
-#define TRACEPOINT_INCLUDE_FILE ./ust_gen_nevents.h
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-AM_CFLAGS = -I$(srcdir) -O2
-AM_LDFLAGS = -llttng-ust
-
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-AM_LDFLAGS += -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-AM_LDFLAGS += -lc
-endif
-
-noinst_PROGRAMS = gen-events
-gen_events_SOURCES = main.c tp.c tp.h
-gen_events_LDADD = -llttng-ust
-
-noinst_SCRIPTS = run
-EXTRA_DIST = run
+++ /dev/null
-/*
- * Copyright (C) 2009 Pierre-Marc Fournier
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; version 2.1 of
- * the License.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-
-#define TRACEPOINT_DEFINE
-#include "tp.h"
-
-void inthandler(int sig)
-{
-}
-
-int init_int_handler(void)
-{
- int result;
- struct sigaction act;
-
- memset(&act, 0, sizeof(act));
- result = sigemptyset(&act.sa_mask);
- if (result == -1) {
- perror("sigemptyset");
- return -1;
- }
-
- act.sa_handler = inthandler;
- act.sa_flags = SA_RESTART;
-
- /* Only defer ourselves. Also, try to restart interrupted
- * syscalls to disturb the traced program as little as possible.
- */
- result = sigaction(SIGUSR1, &act, NULL);
- if (result == -1) {
- perror("sigaction");
- return -1;
- }
-
- return 0;
-}
-
-int main(int argc, char **argv)
-{
- int i, netint;
- long values[] = { 1, 2, 3 };
- char text[10] = "test";
- double dbl = 2.0;
- float flt = 2222.0;
- int delay = 0;
-
- init_int_handler();
-
- if (argc == 2)
- delay = atoi(argv[1]);
-
- sleep(delay);
-
- for (i = 0; i < 1000000; i++) {
- netint = htonl(i);
- tracepoint(tp, tptest, i, netint, values, text,
- strlen(text), dbl, flt);
- }
-
- return 0;
-}
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library 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 Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-TEST_DESC="UST tracer - Testing high events throughput"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-NR_ITER=20
-BIN_NAME="gen-events"
-SESSION_NAME="high-throughput"
-EVENT_NAME="tp:tptest"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/$BIN_NAME" ]; then
- echo -e "No UST nevents binary detected. Passing."
- exit 0
-fi
-
-TRACE_PATH=$(mktemp -d)
-
-# MUST set TESTDIR before calling those functions
-
-start_lttng_sessiond
-
-create_lttng_session $SESSION_NAME $TRACE_PATH
-
-enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-start_lttng_tracing $SESSION_NAME
-
-for i in `seq 1 $NR_ITER`; do
- ./$CURDIR/$BIN_NAME & >/dev/null 2>&1
-done
-
-echo "Waiting for applications to end"
-while [ -n "$(pidof $BIN_NAME)" ]; do
- echo -n "."
- sleep 0.5
-done
-echo ""
-
-stop_lttng_tracing $SESSION_NAME
-destroy_lttng_session $SESSION_NAME
-
-stop_lttng_sessiond
-
-# Validate test
-
-TEMP_FILE=$(mktemp)
-TEMP_FILE_2=$(mktemp)
-
-traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l)
-babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2
-
-cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE
-
-dropped=0
-while read line;
-do
- let dropped=$dropped+$line
-done < $TEMP_FILE
-
-let total=$dropped+$traced
-let wanted=$NR_ITER*1000000
-
-if [ $wanted -ne $total ]; then
- echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
- print_fail
- out=1
-else
- echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
- print_ok
- out=0
-fi
-
-rm -rf $TRACE_PATH
-rm $TEMP_FILE $TEMP_FILE_2
-
-exit $out
+++ /dev/null
-/*
- * tp.c
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "tp.h"
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER tp
-
-#if !defined(_TRACEPOINT_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_TP_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- */
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_EVENT(tp, tptest,
- TP_ARGS(int, anint, int, netint, long *, values,
- char *, text, size_t, textlen, double, doublearg, float, floatarg),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer_hex(int, intfield2, anint)
- ctf_integer(long, longfield, anint)
- ctf_integer_network(int, netintfield, netint)
- ctf_integer_network_hex(int, netintfieldhex, netint)
- ctf_array(long, arrfield1, values, 3)
- ctf_array_text(char, arrfield2, text, 10)
- ctf_sequence(char, seqfield1, text, size_t, textlen)
- ctf_sequence_text(char, seqfield2, text, size_t, textlen)
- ctf_string(stringfield, text)
- ctf_float(float, floatfield, floatarg)
- ctf_float(double, doublefield, doublearg)
- )
-)
-
-TRACEPOINT_EVENT(tp, tptest_sighandler,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-#endif /* _TRACEPOINT_TP_H */
-
-#undef TRACEPOINT_INCLUDE_FILE
-#define TRACEPOINT_INCLUDE_FILE ./tp.h
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-AM_CFLAGS = -I$(srcdir) -O2
-AM_LDFLAGS = -llttng-ust
-
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-AM_LDFLAGS += -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-AM_LDFLAGS += -lc
-endif
-
-noinst_PROGRAMS = gen-events
-gen_events_SOURCES = main.c tp.c tp.h
-gen_events_LDADD = -llttng-ust -lurcu
-
-noinst_SCRIPTS = run
-EXTRA_DIST = run
+++ /dev/null
-/*
- * Copyright (C) 2012 - David Goulet <dgoulet@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; version 2.1 of
- * the License.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <poll.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define TRACEPOINT_DEFINE
-#include "tp.h"
-
-/*
- * Thread recording a tracepoint every minute for 20 minutes.
- */
-static void *th_event_minute(void *data)
-{
- int i;
-
- /* Loop for 20 minutes */
- for (i = 1; i < 21; i++) {
- /* Sleep 60 seconds */
- poll(NULL, 0, 60000);
-
- /* 20 minutes tracepoint */
- if ((i % 20) == 0) {
- tracepoint(tp, slow, i, "twenty");
- }
-
- /* 10 minutes tracepoint */
- if ((i % 10) == 0) {
- tracepoint(tp, slow, i, "ten");
- }
-
- /* 1 minute tracepoint */
- tracepoint(tp, slow, i, "one");
- }
-
- return NULL;
-}
-
-/*
- * main
- */
-int main(int argc, char **argv)
-{
- int ret;
- void *status;
- pthread_t thread;
-
- ret = pthread_create(&thread, NULL, th_event_minute, NULL);
- if (ret != 0) {
- perror("pthread_create event minute");
- goto error;
- }
-
- ret = pthread_join(thread, &status);
- if (ret != 0) {
- perror("pthread_join");
- goto error;
- }
-
- return 0;
-
-error:
- return 1;
-}
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library 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 Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-TEST_DESC="UST tracer - Testing low events throughput"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-BIN_NAME="gen-events"
-SESSION_NAME="low-throughput"
-EVENT_NAME="tp:slow"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/$BIN_NAME" ]; then
- echo -e "No UST nevents binary detected. Passing."
- exit 0
-fi
-
-TRACE_PATH=$(mktemp -d)
-
-# MUST set TESTDIR before calling those functions
-
-start_lttng_sessiond
-
-create_lttng_session $SESSION_NAME $TRACE_PATH
-
-enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-start_lttng_tracing $SESSION_NAME
-
-# This is going to take 20 minutes
-./$CURDIR/$BIN_NAME >/dev/null 2>&1
-
-stop_lttng_tracing $SESSION_NAME
-destroy_lttng_session $SESSION_NAME
-
-stop_lttng_sessiond
-
-# Validate test
-
-last_val=0
-out=0
-
-babeltrace $TRACE_PATH | while read event;
-do
- val=$(echo $event | cut -f10 -d" ")
- val=${val%?}
- th=$(echo $event | cut -f13 -d " ")
-
- if [ $th = '"one"' ]; then
- ((last_val++))
- # We expect here a continous value from 1 to 20
- if [ $last_val -ne $val ]; then
- echo -n "[-] One minute event failed ($val) "
- out=1
- break
- fi
- elif [ $th = '"ten"' ]; then
- # Test 10 minutes counter
- if [ $val -ne 10 ]; then
- # Test 20 minutes counter
- if [ $val -ne 20 ]; then
- echo -n "[-] Ten minutes event failed ($val) "
- out=1
- break
- fi
- fi
- elif [ $th = '"twenty"' ]; then
- # Test 20 minutes counter
- if [ $val -ne 20 ]; then
- echo -n "[-] Twenty minutes event failed ($val) "
- out=1
- break
- fi
- fi
-done
-
-if [ $out -eq 0 ]; then
- echo -n "Trace is coherent... "
- print_ok
-else
- print_fail
-fi
-
-rm -rf $TRACE_PATH
-
-exit $out
+++ /dev/null
-/*
- * tp.c
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "tp.h"
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER tp
-
-#if !defined(_TRACEPOINT_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_TP_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- */
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_EVENT(tp, slow,
- TP_ARGS(unsigned int, c, char *, thread_name),
- TP_FIELDS(
- ctf_integer(unsigned int, counter, c)
- ctf_string(th_name, thread_name)
- )
-)
-
-#endif /* _TRACEPOINT_TP_H */
-
-#undef TRACEPOINT_INCLUDE_FILE
-#define TRACEPOINT_INCLUDE_FILE ./tp.h
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-AM_CFLAGS = -I$(srcdir) -O2
-AM_LDFLAGS = -llttng-ust
-
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-AM_LDFLAGS += -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-AM_LDFLAGS += -lc
-endif
-
-noinst_PROGRAMS = gen-nevents
-gen_nevents_SOURCES = gen-nevents.c tp.c ust_gen_nevents.h
-gen_nevents_LDADD = -llttng-ust
-
-noinst_SCRIPTS = run
-EXTRA_DIST = run
+++ /dev/null
-/*
- * Copyright (C) - 2009 Pierre-Marc Fournier
- * Copyright (C) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation; version 2.1 of the License.
- *
- * This library 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 Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <arpa/inet.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#define TRACEPOINT_DEFINE
-#include "ust_gen_nevents.h"
-
-int main(int argc, char **argv)
-{
- int i, nr_iter = 100;
- long value = 42;
-
- if (argc == 2) {
- nr_iter = atoi(argv[1]);
- }
-
- for (i = 0; i < nr_iter; i++) {
- tracepoint(ust_gen_nevents, tptest0, i, value);
- tracepoint(ust_gen_nevents, tptest1, i, value);
- tracepoint(ust_gen_nevents, tptest2, i, value);
- tracepoint(ust_gen_nevents, tptest3, i, value);
- }
-
- return 0;
-}
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library 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 Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-TEST_DESC="UST tracer - Multi-session"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-NR_ITER=100
-SESSION_NAME="multi-session"
-EVENT_NAME="ust_gen_nevents:tptest"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/gen-nevents" ]; then
- echo -e "No UST nevents binary detected. Passing."
- exit 0
-fi
-
-# MUST set TESTDIR before calling those functions
-
-test_multi_session() {
- local out
-
- # BEFORE application is spawned
- for i in `seq 0 3`; do
- create_lttng_session "$SESSION_NAME-$i" "$TRACE_PATH/$i"
- enable_ust_lttng_event "$SESSION_NAME-$i" "$EVENT_NAME$i"
- start_lttng_tracing "$SESSION_NAME-$i"
- done
-
- echo -n "Starting application generating $NR_ITER events... "
- ./$CURDIR/gen-nevents $NR_ITER &
- print_ok
-
- # At least hit one event
- echo -n "Waiting for events to record "
- while [ -n "$(pidof gen-nevents)" ]; do
- echo -n "."
- sleep 0.1
- done
- print_ok
-
- for i in `seq 0 3`; do
- stop_lttng_tracing "$SESSION_NAME-$i"
- destroy_lttng_session "$SESSION_NAME-$i"
- out=$(babeltrace "$TRACE_PATH/$i" | grep "$EVENT_NAMEi$i" | wc -l)
- if [ $out -ne $NR_ITER ]; then
- echo -n "No event found. Suppose to have at least one... "
- print_fail
- out=1
- else
- echo -n "Found $out event(s) for $SESSION_NAME-$i. Coherent... "
- print_ok
- out=0
- fi
- done
-
- return $out
-}
-
-# MUST set TESTDIR before calling those functions
-
-start_lttng_sessiond
-
-TRACE_PATH=$(mktemp -d)
-
-test_multi_session
-out=$?
-if [ $out -ne 0 ]; then
- stop_lttng_sessiond
- exit $out
-fi
-
-stop_lttng_sessiond
-
-rm -rf "$TRACE_PATH"
+++ /dev/null
-/*
- * Copyright (c) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
- * IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program for any purpose,
- * provided the above notices are retained on all copies. Permission to modify
- * the code and to distribute modified code is granted, provided the above
- * notices are retained, and a notice that the code was modified is included
- * with the above copyright notice.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_gen_nevents.h"
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER ust_gen_nevents
-
-#if !defined(_TRACEPOINT_UST_GEN_NEVENTS_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_GEN_NEVENTS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_EVENT(ust_gen_nevents, tptest0,
- TP_ARGS(int, anint, long, value),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer(long, longfield, value)
- )
-)
-
-TRACEPOINT_EVENT(ust_gen_nevents, tptest1,
- TP_ARGS(int, anint, long, value),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer(long, longfield, value)
- )
-)
-
-TRACEPOINT_EVENT(ust_gen_nevents, tptest2,
- TP_ARGS(int, anint, long, value),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer(long, longfield, value)
- )
-)
-
-TRACEPOINT_EVENT(ust_gen_nevents, tptest3,
- TP_ARGS(int, anint, long, value),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer(long, longfield, value)
- )
-)
-
-#endif /* _TRACEPOINT_UST_GEN_NEVENTS_H */
-
-#undef TRACEPOINT_INCLUDE_FILE
-#define TRACEPOINT_INCLUDE_FILE ./ust_gen_nevents.h
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-AM_CFLAGS = -I$(srcdir) -O2
-AM_LDFLAGS = -llttng-ust
-
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-AM_LDFLAGS += -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-AM_LDFLAGS += -lc
-endif
-
-noinst_PROGRAMS = gen-events-time
-gen_events_time_SOURCES = gen-events-time.c tp.c ust_gen_event.h
-gen_events_time_LDADD = -llttng-ust
-
-noinst_SCRIPTS = run ust-nprocesses
-EXTRA_DIST = run ust-nprocesses
+++ /dev/null
-/*
- * Copyright (C) - 2009 Pierre-Marc Fournier
- * Copyright (C) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation; version 2.1 of the License.
- *
- * This library 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 Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <arpa/inet.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#define TRACEPOINT_DEFINE
-#include "ust_gen_event.h"
-
-int main(int argc, char **argv)
-{
- int i, netint;
- long values[] = { 1, 2, 3 };
- char text[10] = "test";
- double dbl = 2.0;
- float flt = 2222.0;
- /* Default loop time is 60 sec since each round sleeps 1 sec */
- unsigned int nr_iter = 60;
-
- fclose(stdout);
- fclose(stderr);
- fclose(stdin);
-
- if (argc == 2) {
- nr_iter = atoi(argv[1]);
- }
-
- for (i = 0; i < nr_iter; i++) {
- netint = htonl(i);
- tracepoint(ust_gen_event, tptest, i, netint, values, text,
- strlen(text), dbl, flt);
- sleep(1);
- }
-
- return 0;
-}
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library 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 Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-NR_ITER=100
-TEST_DESC="UST tracer - Generate $NR_ITER process"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-TEST_BIN_NAME="gen-events-time"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/$TEST_BIN_NAME" ]; then
- echo -e "No UST $TEST_BIN_NAME binary detected. Passing."
- exit 0
-fi
-
-# MUST set TESTDIR before calling those functions
-
-start_lttng_sessiond
-
-./$CURDIR/ust-nprocesses $NR_ITER
-
-stop_lttng_sessiond
-
-exit 0
+++ /dev/null
-/*
- * Copyright (c) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
- * IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program for any purpose,
- * provided the above notices are retained on all copies. Permission to modify
- * the code and to distribute modified code is granted, provided the above
- * notices are retained, and a notice that the code was modified is included
- * with the above copyright notice.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_gen_event.h"
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library 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 Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-NR_ITER=$1
-TEST_BIN_NAME="gen-events-time"
-SESSION_NAME="ust-nprocesses"
-EVENT_NAME="ust_gen_event:tptest"
-TEST_WAIT_SEC=5
-
-source $TESTDIR/utils.sh
-
-# MUST set TESTDIR before calling those functions
-
-# Start test for 1000 seconds
-
-for i in `seq 1 $NR_ITER`
-do
- ./$CURDIR/$TEST_BIN_NAME 1000 >/dev/null 2>&1 &
-done
-
-echo -n "Validating registered apps in 3 seconds..."
-
-sleep 3
-
-listing=$($TESTDIR/../src/bin/lttng/$LTTNG_BIN list -u)
-reg_app_count=$(echo -n $listing | sed "s/$TEST_BIN_NAME/$TEST_BIN_NAME\n/g" | grep "$TEST_BIN_NAME" | wc -l)
-if [ "$reg_app_count" -ne "$NR_ITER" ]; then
- echo -e "$reg_app_count apps listed. Expected $NR_ITER "
- print_fail
-else
- print_ok
-fi
-
-TRACE_PATH=$(mktemp -d)
-
-create_lttng_session $SESSION_NAME $TRACE_PATH
-
-enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-start_lttng_tracing $SESSION_NAME
-
-echo "Sleeping $TEST_WAIT_SEC seconds for tracing to start everywhere"
-echo "Warning: this arbitrary time can make the test fail on slower system"
-sleep $TEST_WAIT_SEC
-
-stop_lttng_tracing $SESSION_NAME
-destroy_lttng_session $SESSION_NAME
-
-rm -rf $TRACE_PATH
-
-echo -e -n "Killing all spawned applications..."
-killall -q $TEST_BIN_NAME >/dev/null 2>&1 &
-print_ok
-exit 0
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER ust_gen_event
-
-#if !defined(_TRACEPOINT_UST_GEN_EVENT_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_GEN_EVENT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_EVENT(ust_gen_event, tptest,
- TP_ARGS(int, anint, int, netint, long *, values,
- char *, text, size_t, textlen,
- double, doublearg, float, floatarg),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer_hex(int, intfield2, anint)
- ctf_integer(long, longfield, anint)
- ctf_integer_network(int, netintfield, netint)
- ctf_integer_network_hex(int, netintfieldhex, netint)
- ctf_array(long, arrfield1, values, 3)
- ctf_array_text(char, arrfield2, text, 10)
- ctf_sequence(char, seqfield1, text, size_t, textlen)
- ctf_sequence_text(char, seqfield2, text, size_t, textlen)
- ctf_string(stringfield, text)
- ctf_float(float, floatfield, floatarg)
- ctf_float(double, doublefield, doublearg)
- )
-)
-
-#endif /* _TRACEPOINT_UST_GEN_EVENT_H */
-
-#undef TRACEPOINT_INCLUDE_FILE
-#define TRACEPOINT_INCLUDE_FILE ./ust_gen_event.h
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-SUBDIRS = demo
-
-noinst_SCRIPTS = run
-EXTRA_DIST = run overlap.sh
+++ /dev/null
-AM_CFLAGS=-I$(srcdir)
-if NO_SHARED
-# Do not build this test if shared libraries support was
-# explicitly disabled.
-else
-# Force the shared flag on the noinst libraries since they are
-# only built static by default
-FORCE_SHARED_LIB_OPTIONS = -module -shared -avoid-version \
- -rpath $(abs_builddir)
-
-#contains ust_tests_demo.h and ust_tests_demo2.h provider probes
-liblttng_ust_provider_ust_tests_demo_la_SOURCES = \
- tp.c ust_tests_demo.h \
- tp2.c ust_tests_demo2.h
-liblttng_ust_provider_ust_tests_demo_la_LIBADD = -llttng-ust
-liblttng_ust_provider_ust_tests_demo_la_LDFLAGS = $(FORCE_SHARED_LIB_OPTIONS)
-
-#contains ust_tests_demo3.h provider probes
-liblttng_ust_provider_ust_tests_demo3_la_SOURCES = tp3.c ust_tests_demo3.h
-liblttng_ust_provider_ust_tests_demo3_la_LIBADD = -llttng-ust
-liblttng_ust_provider_ust_tests_demo3_la_LDFLAGS = $(FORCE_SHARED_LIB_OPTIONS)
-
-noinst_LTLIBRARIES = liblttng-ust-provider-ust-tests-demo.la \
- liblttng-ust-provider-ust-tests-demo3.la
-
-noinst_PROGRAMS = demo
-demo_SOURCES = demo.c ust_tests_demo.h
-# The demo program only depends on libdl/libc for dlopen().
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-demo_LDADD = -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-demo_LDADD = -lc
-endif
-
-noinst_SCRIPTS = demo-trace
-EXTRA_DIST = demo-trace
-endif
+++ /dev/null
-#!/bin/sh
-
-LD_PRELOAD=.libs/liblttng-ust-provider-ust-tests-demo.so:.libs/liblttng-ust-provider-ust-tests-demo3.so ./demo ${*}
+++ /dev/null
-/*
- * Copyright (C) 2009 Pierre-Marc Fournier
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; version 2.1 of
- * the License.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-
-#define TRACEPOINT_DEFINE
-#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
-#include "ust_tests_demo.h"
-#include "ust_tests_demo2.h"
-#include "ust_tests_demo3.h"
-
-int main(int argc, char **argv)
-{
- int i, netint;
- long values[] = { 1, 2, 3 };
- char text[10] = "test";
- double dbl = 2.0;
- float flt = 2222.0;
- int delay = 0;
-
- if (argc == 2)
- delay = atoi(argv[1]);
-
- fprintf(stderr, "Demo program starting.\n");
-
- sleep(delay);
-
- fprintf(stderr, "Tracing... ");
- tracepoint(ust_tests_demo, starting, 123);
- for (i = 0; i < 5; i++) {
- netint = htonl(i);
- tracepoint(ust_tests_demo2, loop, i, netint, values,
- text, strlen(text), dbl, flt);
- }
- tracepoint(ust_tests_demo, done, 456);
- tracepoint(ust_tests_demo3, done, 42);
- fprintf(stderr, " done.\n");
- return 0;
-}
+++ /dev/null
-/*
- * tp.c
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_demo.h"
+++ /dev/null
-/*
- * tp2.c
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_demo2.h"
+++ /dev/null
-/*
- * tp3.c
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_demo3.h"
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER ust_tests_demo
-
-#if !defined(_TRACEPOINT_UST_TESTS_DEMO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_TESTS_DEMO_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- */
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_EVENT(ust_tests_demo, starting,
- TP_ARGS(int, value),
- TP_FIELDS(
- ctf_integer(int, value, value)
- )
-)
-TRACEPOINT_LOGLEVEL(ust_tests_demo, starting, TRACE_CRIT)
-
-/*
- * Dummy model information, just for example. TODO: we should check if
- * EMF model URI have some standard format we should follow.
- */
-TRACEPOINT_MODEL_EMF_URI(ust_tests_demo, starting,
- "http://example.com/path_to_model?q=ust_tests_demo:starting")
-
-TRACEPOINT_EVENT(ust_tests_demo, done,
- TP_ARGS(int, value),
- TP_FIELDS(
- ctf_integer(int, value, value)
- )
-)
-TRACEPOINT_LOGLEVEL(ust_tests_demo, done, TRACE_CRIT)
-
-TRACEPOINT_MODEL_EMF_URI(ust_tests_demo, done,
- "http://example.com/path_to_model?q=ust_tests_demo:done")
-
-#endif /* _TRACEPOINT_UST_TESTS_DEMO_H */
-
-#undef TRACEPOINT_INCLUDE_FILE
-#define TRACEPOINT_INCLUDE_FILE ./ust_tests_demo.h
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER ust_tests_demo2
-
-#if !defined(_TRACEPOINT_UST_TESTS_DEMO2_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_TESTS_DEMO2_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- */
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_EVENT(ust_tests_demo2, loop,
- TP_ARGS(int, anint, int, netint, long *, values,
- char *, text, size_t, textlen,
- double, doublearg, float, floatarg),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer_hex(int, intfield2, anint)
- ctf_integer(long, longfield, anint)
- ctf_integer_network(int, netintfield, netint)
- ctf_integer_network_hex(int, netintfieldhex, netint)
- ctf_array(long, arrfield1, values, 3)
- ctf_array_text(char, arrfield2, text, 10)
- ctf_sequence(char, seqfield1, text,
- size_t, textlen)
- ctf_sequence_text(char, seqfield2, text,
- size_t, textlen)
- ctf_string(stringfield, text)
- ctf_float(float, floatfield, floatarg)
- ctf_float(double, doublefield, doublearg)
- )
-)
-TRACEPOINT_LOGLEVEL(ust_tests_demo2, loop, TRACE_WARNING)
-
-#endif /* _TRACEPOINT_UST_TESTS_DEMO2_H */
-
-#undef TRACEPOINT_INCLUDE_FILE
-#define TRACEPOINT_INCLUDE_FILE ./ust_tests_demo2.h
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER ust_tests_demo3
-
-#if !defined(_TRACEPOINT_UST_TESTS_DEMO3_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_TESTS_DEMO3_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- */
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_EVENT(ust_tests_demo3, done,
- TP_ARGS(int, value),
- TP_FIELDS(
- ctf_integer(int, value, value)
- )
-)
-TRACEPOINT_LOGLEVEL(ust_tests_demo3, done, TRACE_WARNING)
-
-#endif /* _TRACEPOINT_UST_TESTS_DEMO3_H */
-
-#undef TRACEPOINT_INCLUDE_FILE
-#define TRACEPOINT_INCLUDE_FILE ./ust_tests_demo3.h
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library 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 Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-TEST_DESC="UST - Wildcard overlap"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-SESSION_NAME="wildcard-overlap"
-
-DEMO_EVENT1="ust_tests_demo:starting"
-DEMO_EVENT1_2="ust_tests_demo:done"
-DEMO_EVENT2="ust_tests_demo2:loop"
-DEMO_EVENT3="ust_tests_demo3:done"
-
-NUM_DEMO1_EVENT=1
-NUM_DEMO1_2_EVENT=1
-NUM_DEMO2_EVENT=5
-NUM_DEMO3_EVENT=1
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/demo/demo" ]; then
- echo -e "No UST nevents binary detected. Passing."
- exit 0
-fi
-
-# MUST set TESTDIR before calling those functions
-
-run_demo_app()
-{
- cd $CURDIR/demo
-
- # Start test
- echo -n "Starting application... "
- ./demo-trace >/dev/null 2>&1
- echo -n "Ended "
- print_ok
-
- cd -
-}
-
-# Ease our life a bit ;)
-trace_match_demo1_events()
-{
- trace_matches "$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
- trace_matches "$DEMO_EVENT1_2" $NUM_DEMO1_EVENT $TRACE_PATH
-}
-
-# Ease our life a bit ;)
-trace_match_all_demo_events()
-{
- trace_match_demo1_events
- trace_matches "$DEMO_EVENT2" $NUM_DEMO2_EVENT $TRACE_PATH
- trace_matches "$DEMO_EVENT3" $NUM_DEMO3_EVENT $TRACE_PATH
-}
-
-# Ease our life a bit ;)
-trace_match_no_demo_events()
-{
- trace_matches "$DEMO_EVENT1" 0 $TRACE_PATH
- trace_matches "$DEMO_EVENT1_2" 0 $TRACE_PATH
- trace_matches "$DEMO_EVENT2" 0 $TRACE_PATH
- trace_matches "$DEMO_EVENT3" 0 $TRACE_PATH
-}
-
-# Expect all "demo" events, no duplicate.
-test_enable_simple_wildcard()
-{
- local event_wild1="us*"
- local event_wild2="ust*"
-
- echo ""
- echo "=== Simple wildcard overlap"
-
- enable_ust_lttng_event $SESSION_NAME "$event_wild1"
- enable_ust_lttng_event $SESSION_NAME "$event_wild2"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
-
- return $?
-}
-
-# Expect all "demo" events, no duplicate.
-test_enable_wildcard_filter()
-{
- local event_wild1="us*"
- local event_wild2="ust*"
-
- echo ""
- echo "=== Wildcard overlap with filter"
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
- return $?
-}
-
-# Expect all "demo" events, no duplicate.
-test_enable_wildcard_filter_2()
-{
- local event_wild1="us*"
- local event_wild2="ust*"
-
- echo ""
- echo "=== Wildcard overlap with filter 2"
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
- return $?
-}
-
-# Expect all "demo" events, no duplicate.
-test_enable_wildcard_filter_3()
-{
- local event_wild1="us*"
- local event_wild2="ust*"
-
- echo ""
- echo "=== Wildcard overlap with filter 3"
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
- return $?
-}
-
-# Expected: No events.
-test_enable_wildcard_filter_4()
-{
- local event_wild1="us*"
- local event_wild2="ust*"
-
- echo ""
- echo "=== Wildcard overlap with filter 4"
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_no_demo_events
- return $?
-}
-
-# Expect all "demo" events, no duplicate.
-test_enable_wildcard_filter_5()
-{
- local event_wild1="us*"
- local event_wild2="$DEMO_EVENT1"
-
- echo ""
- echo "=== Wildcard overlap with filter 5"
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
- return $?
-}
-
-# Expect all $DEMO_EVENT1 events, no duplicate.
-test_enable_wildcard_filter_6()
-{
- local event_wild1="us*"
- local event_wild2="$DEMO_EVENT1"
-
- echo ""
- echo "=== Wildcard overlap with filter 6"
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
- trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH
- trace_matches $DEMO_EVENT2 0 $TRACE_PATH
- trace_matches $DEMO_EVENT3 0 $TRACE_PATH
- return $?
-}
-
-# Expect all events, no duplicate.
-test_enable_wildcard_filter_7()
-{
- local event_wild1="us*"
- local event_wild2="$DEMO_EVENT1"
-
- echo ""
- echo "=== Wildcard overlap with filter 7"
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
- return $?
-}
-
-# Expected: No events.
-test_enable_wildcard_filter_8()
-{
- local event_wild1="us*"
- local event_wild2="$DEMO_EVENT1"
-
- echo ""
- echo "=== Wildcard overlap with filter 8"
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_no_demo_events
- return $?
-}
-
-# Expect all events.
-test_enable_same_wildcard_filter()
-{
- local event_wild1="ust*"
- local event_wild2="ust*"
-
- echo ""
- echo "=== Same wildcard overlap with filter"
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
- return $?
-}
-
-# Expect all events.
-test_enable_same_wildcard_filter_2()
-{
- local event_wild1="ust*"
- local event_wild2="ust*"
-
- echo ""
- echo "=== Same wildcard overlap with filter 2"
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
- if [ $? -eq 1 ]; then
- echo -n "FAIL is normal. Same event with same filter is denied by the sessiond "
- print_ok
- else
- print_fail
- fi
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
- return $?
-}
-
-# Expect all events.
-test_enable_same_wildcard_filter_3()
-{
- local event_wild1="ust*"
- local event_wild2="ust*"
-
- echo ""
- echo "=== Same wildcard overlap with filter 3"
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
- return $?
-}
-
-# Expected: No events.
-test_enable_same_wildcard_filter_4()
-{
- local event_wild1="ust*"
- local event_wild2="ust*"
-
- echo ""
- echo "=== Same wildcard overlap with filter 4"
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0&&1==0"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_no_demo_events
- return $?
-}
-
-# Expected: Only $DEMO_EVENT1
-test_enable_same_event_filter()
-{
- local event_wild1="$DEMO_EVENT1"
- local event_wild2="$DEMO_EVENT1"
-
- echo ""
- echo "=== Enable same event with filter."
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
- disable_ust_lttng_event $SESSION_NAME "ust*"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
- trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH
- trace_matches $DEMO_EVENT2 0 $TRACE_PATH
- trace_matches $DEMO_EVENT3 0 $TRACE_PATH
- return $?
-}
-
-# Expected: No events.
-test_disable_same_wildcard_filter()
-{
- local event_wild1="ust*"
- local event_wild2="ust*"
-
- echo ""
- echo "=== Disable same wildcard with filter."
-
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1"
- enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
- disable_ust_lttng_event $SESSION_NAME "ust*"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_no_demo_events
- return $?
-}
-
-# Expect no events
-test_enable_bad_wildcard()
-{
- # Invalid event
- local event_wild1="ust_tests_demo"
- local event_wild2="ust_tests_demo2"
- local event_wild3="ust_tests_demo3"
-
- echo ""
- echo "=== Enable bad wildcard"
-
- enable_ust_lttng_event $SESSION_NAME "$event_wild1"
- enable_ust_lttng_event $SESSION_NAME "$event_wild2"
- enable_ust_lttng_event $SESSION_NAME "$event_wild3"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_no_demo_events
- return $?
-}
-
-# Expect all "demo" events, no duplicate.
-test_enable_simple_wildcard_2()
-{
- local event_wild1="us*"
- local event_wild2="$DEMO_EVENT1"
-
- echo ""
- echo "=== Simple wildcard 2"
-
- enable_ust_lttng_event $SESSION_NAME "$event_wild1"
- enable_ust_lttng_event $SESSION_NAME "$event_wild2"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
- return $?
-}
-
-# Expected: all CRIT events, + all warning events.
-test_enable_loglevel_overlap()
-{
- local event_wild1="us*"
- local event_wild2="ust*"
-
- echo ""
- echo "=== Enable loglevel overlap"
-
- enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING"
- enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_CRIT"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
- return $?
-}
-
-# Expected: all CRIT events, + all warning events.
-test_enable_loglevel_only_overlap()
-{
- local event_wild1="us*"
- local event_wild2="ust*"
-
- echo ""
- echo "=== Enable loglevel only overlap"
-
- enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING"
- enable_ust_lttng_event_loglevel_only $SESSION_NAME "$event_wild2" "TRACE_CRIT"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
- return $?
-}
-
-# Expected: all events
-test_enable_loglevel_overlap_2()
-{
- local event_wild1="us*"
- local event_wild2="$DEMO_EVENT2"
-
- echo ""
- echo "=== Enable loglevel overlap 2"
-
- enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING"
- enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_CRIT"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
- return $?
-}
-
-# Expected only ust_tests_demo* events.
-test_enable_same_wildcard_loglevels()
-{
- local event_wild1="ust*"
- local event_wild2="ust*"
-
- echo ""
- echo "=== Enable same wildcard with different loglevels"
-
- enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_CRIT"
- enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_WARNING"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_match_all_demo_events
- return $?
-}
-
-# Expected only ust_tests_demo:starting events.
-test_enable_same_event_loglevels()
-{
- local event_wild1="$DEMO_EVENT1"
- local event_wild2="$DEMO_EVENT1"
-
- echo ""
- echo "=== Enable same event with different loglevels"
-
- enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_CRIT"
- enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_WARNING"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
- trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH
- trace_matches $DEMO_EVENT2 0 $TRACE_PATH
- trace_matches $DEMO_EVENT3 0 $TRACE_PATH
- return $?
-}
-
-# Expect 0 event
-test_disable_simple_wildcard()
-{
- local event_wild1="us*"
- local event_wild2="$DEMO_EVENT1"
-
- echo ""
- echo "=== Disable simple wildcard"
-
- enable_ust_lttng_event $SESSION_NAME "$event_wild1"
- enable_ust_lttng_event $SESSION_NAME "$event_wild2"
-
- disable_ust_lttng_event $SESSION_NAME "$event_wild1"
- disable_ust_lttng_event $SESSION_NAME "$event_wild2"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- # No events are expected.
- trace_match_no_demo_events
- return $?
-}
-
-# Expect only "ust_tests_demo" events.
-test_disable_wildcard_overlap()
-{
- local event_wild1="us*"
- local event_wild2="$DEMO_EVENT1"
-
- echo ""
- echo "=== Disable wildcard overlap"
-
- enable_ust_lttng_event $SESSION_NAME "$event_wild1"
- enable_ust_lttng_event $SESSION_NAME "$event_wild2"
-
- disable_ust_lttng_event $SESSION_NAME "$event_wild1"
-
- start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- run_demo_app
-
- stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
- # Expect only "ust_tests_demo" events.
- trace_matches "$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
- trace_matches "$DEMO_EVENT1_2" 0 $TRACE_PATH
- trace_matches "$DEMO_EVENT2" 0 $TRACE_PATH
- trace_matches "$DEMO_EVENT3" 0 $TRACE_PATH
- return $?
-}
-
-TESTS=(
- "test_enable_wildcard_filter"
- "test_enable_wildcard_filter_2"
- "test_enable_wildcard_filter_3"
- "test_enable_wildcard_filter_4"
- "test_enable_wildcard_filter_5"
- "test_enable_wildcard_filter_6"
- "test_enable_wildcard_filter_7"
- "test_enable_wildcard_filter_8"
- "test_enable_same_wildcard_filter"
- "test_enable_same_wildcard_filter_2"
- "test_enable_same_wildcard_filter_3"
- "test_enable_same_wildcard_filter_4"
- "test_enable_same_event_filter"
- "test_enable_loglevel_only_overlap"
- "test_enable_same_event_loglevels"
- "test_enable_same_wildcard_loglevels"
- "test_enable_bad_wildcard"
- "test_enable_loglevel_overlap_2"
- "test_enable_simple_wildcard"
- "test_enable_simple_wildcard_2"
- "test_enable_loglevel_overlap"
- "test_disable_simple_wildcard"
- "test_disable_wildcard_overlap"
-)
-
-TEST_COUNT=${#TESTS[@]}
-i=0
-
-start_lttng_sessiond
-
-while [ "$i" -lt "$TEST_COUNT" ]; do
-
- TRACE_PATH=$(mktemp -d)
-
- create_lttng_session $SESSION_NAME $TRACE_PATH >/dev/null 2>&1
-
- # Execute test
- ${TESTS[$i]}
- if [ $? -ne 0 ]; then
- stop_lttng_sessiond
- exit 1
- fi
-
- destroy_lttng_session $SESSION_NAME >/dev/null 2>&1
-
- rm -rf $TRACE_PATH
-
- let "i++"
-done
-
-stop_lttng_sessiond
+++ /dev/null
-#!/bin/bash
-
-DIR=$(dirname $0)
-
-tests=( $DIR/overlap.sh)
-
-exit_code=0
-
-function start_tests ()
-{
- for bin in ${tests[@]};
- do
- ./$bin
- # Test must return 0 to pass.
- if [ $? -ne 0 ]; then
- exit_code=1
- break
- fi
- done
-}
-
-start_tests
-
-exit $exit_code
+++ /dev/null
-#!/bin/bash
-
-SESSIOND_BIN="lttng-sessiond"
-CURDIR=$(dirname $0)
-TESTDIR=$CURDIR/..
-
-source $TESTDIR/utils.sh
-
-tmpdir=`mktemp -d`
-tests=( $CURDIR/ust_global_event_basic $CURDIR/ust_global_event_wildcard )
-exit_code=0
-
-function start_tests ()
-{
- for bin in ${tests[@]};
- do
- if [ ! -e $bin ]; then
- echo -e "$bin not found, passing"
- continue
- fi
-
- start_lttng_sessiond
-
- ./$bin $tmpdir
- # Test must return 0 to pass.
- if [ $? -ne 0 ]; then
- exit_code=1
- stop_lttng_sessiond
- break
- fi
- stop_lttng_sessiond
- done
-
- # Cleaning up
- rm -rf $tmpdir
-}
-
-TEST_DESC="UST tracer - Global domain (LTTNG_DOMAIN_UST)"
-
-print_test_banner "$TEST_DESC"
-
-start_tests
-
-exit $exit_code
+++ /dev/null
-#!/bin/bash
-
-DIR=$(dirname $0)
-
-tests=( $DIR/run-ust-global-tests.sh $DIR/nprocesses/run \
- $DIR/high-throughput/run $DIR/before-after/run \
- $DIR/multi-session/run $DIR/overlap/run )
-
-# $DIR/low-throughput/run --> DEACTIVATED.
-# Use only for release. This test last 20 minutes
-
-exit_code=0
-
-function start_tests ()
-{
- for bin in ${tests[@]};
- do
- ./$bin
- # Test must return 0 to pass.
- if [ $? -ne 0 ]; then
- exit_code=1
- break
- fi
- done
-}
-
-start_tests
-
-exit $exit_code
+++ /dev/null
-/*
- * 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_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;
- channel.attr.num_subbuf = 4;
- channel.attr.switch_timer_interval = 0;
- 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;
-
- strcpy(ev2.name, "ev2");
- ev2.type = LTTNG_EVENT_TRACEPOINT;
- ev2.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
- strcpy(ev3.name, "ev3");
- ev3.type = LTTNG_EVENT_TRACEPOINT;
- ev3.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
- printf("\nTesting tracing 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 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));
- goto handle_fail;
- }
- PRINT_OK();
-
- printf("Enabling %s UST channel: ", channel.name);
- if ((ret = lttng_enable_channel(handle, &channel)) < 0) {
- printf("error enable channel: %s\n", lttng_strerror(ret));
- goto enable_fail;
- }
- PRINT_OK();
-
- 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 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 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));
- goto enable_fail;
- }
- PRINT_OK();
-
- printf("Disabling %s UST event: ", ev3.name);
- if ((ret = lttng_disable_event(handle, ev3.name, channel2.name)) < 0) {
- printf("error enabling event: %s\n", lttng_strerror(ret));
- goto enable_fail;
- }
- PRINT_OK();
-
- printf("Renabling %s UST event: ", ev1.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("Renabling %s UST event: ", ev3.name);
- if ((ret = lttng_enable_event(handle, &ev3, channel.name)) < 0) {
- printf("error enabling event: %s\n", lttng_strerror(ret));
- goto enable_fail;
- }
- 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));
- 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("Restart 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 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));
- }
- PRINT_OK();
-
- return 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);
-
- return 1;
-}
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-
-#define BRIGHT 1
-#define GREEN 32
-#define RED 31
-
-#define PRINT_OK() \
-do { \
- /* Check for color support */ \
- if (isatty(STDOUT_FILENO)) { \
- printf("%c[%d;%dmOK%c[%dm\n", 0x1B, BRIGHT, GREEN, 0x1B, 0); \
- } else { \
- printf("OK\n"); \
- } \
-} while (0)
-
-#define PRINT_FAIL() \
-do { \
- /* Check for color support */ \
- if (isatty(STDOUT_FILENO)) { \
- printf("%c[%d;%dmFAIL%c[%dm\n", 0x1B, BRIGHT, RED, 0x1B, 0); \
- } else { \
- printf("FAIL\n"); \
- } \
-} while (0)
+++ /dev/null
-#!/src/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library 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 Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-SESSIOND_BIN="lttng-sessiond"
-RELAYD_BIN="lttng-relayd"
-LTTNG_BIN="lttng"
-BABELTRACE_BIN="babeltrace"
-
-# Minimal kernel version supported for session daemon tests
-KERNEL_MAJOR_VERSION=2
-KERNEL_MINOR_VERSION=6
-KERNEL_PATCHLEVEL_VERSION=27
-
-function print_ok ()
-{
- # Check if we are a terminal
- if [ -t 1 ]; then
- echo -e "\e[1;32mOK\e[0m"
- else
- echo -e "OK"
- fi
-}
-
-function print_fail ()
-{
- # Check if we are a terminal
- if [ -t 1 ]; then
- echo -e "\e[1;31mFAIL\e[0m"
- else
- echo -e "FAIL"
- fi
-}
-
-function print_test_banner ()
-{
- desc="$1"
-
- count=$((${#desc}+2))
- str=$(printf "%${count}s");
- echo -e "\n"
- echo -e ${str// /-}
- echo -e " $desc "
- echo -e ${str// /-}
-}
-
-function validate_kernel_version ()
-{
- kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n'))
- if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
- return 0
- fi
- if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
- return 0
- fi
- if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
- return 0
- fi
- return 1
-}
-
-# Generate a random string
-# $1 = number of characters; defaults to 16
-# $2 = include special characters; 1 = yes, 0 = no; defaults to yes
-function randstring()
-{
- [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]"
- cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-16}
- echo
-}
-
-function spawn_sessiond ()
-{
- echo ""
- echo -n "Starting session daemon... "
- validate_kernel_version
- if [ $? -ne 0 ]; then
- echo -e "\n*** Kernel too old for session daemon tests ***\n"
- return 2
- fi
-
- 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"
- #$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --verbose-consumer >>/tmp/sessiond.log 2>&1 &
- if [ $? -eq 1 ]; then
- print_fail
- return 1
- else
- print_ok
- fi
- fi
-
- return 0
-}
-
-function lttng_enable_kernel_event
-{
- sess_name=$1
- event_name=$2
-
- if [ -z $event_name ]; then
- # Enable all event if no event name specified
- $event_name="-a"
- fi
-
- echo -n "Enabling kernel event $event_name for session $sess_name"
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -k >/dev/null 2>&1
- if [ $? -eq 1 ]; then
- print_fail
- return 1
- else
- print_ok
- fi
-}
-
-function start_lttng_relayd
-{
- local opt=$1
-
- echo -e -n "Starting lttng-relayd (opt: $opt)... "
-
- DIR=$(readlink -f $TESTDIR)
-
- if [ -z $(pidof lt-$RELAYD_BIN) ]; then
- $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1 &
- #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
- if [ $? -eq 1 ]; then
- print_fail
- return 1
- else
- print_ok
- fi
- else
- print_ok
- fi
-}
-
-function stop_lttng_relayd
-{
- PID_RELAYD=`pidof lt-$RELAYD_BIN`
-
- echo -e -n "Killing lttng-relayd (pid: $PID_RELAYD)... "
- kill $PID_RELAYD >/dev/null 2>&1
- if [ $? -eq 1 ]; then
- print_fail
- return 1
- else
- out=1
- while [ -n "$out" ]; do
- out=$(pidof lt-$RELAYD_BIN)
- sleep 0.5
- done
- print_ok
- return 0
- fi
-}
-
-function start_lttng_sessiond()
-{
- if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
- # Env variable requested no session daemon
- return
- fi
-
- spawn_sessiond
- out=$?
- if [ $out -eq 2 ]; then
- # Kernel version is not compatible.
- exit 0
- elif [ $out -ne 0 ]; then
- echo "NOT bad $?"
- exit 1
- fi
-
- # Simply wait for the session daemon bootstrap
- echo "Waiting for the session daemon to bootstrap (2 secs)"
- sleep 2
-}
-
-function stop_lttng_sessiond ()
-{
- if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
- # Env variable requested no session daemon
- return
- fi
-
- PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
-
- echo -e -n "Killing session daemon... "
- kill $PID_SESSIOND >/dev/null 2>&1
- if [ $? -eq 1 ]; then
- print_fail
- return 1
- else
- out=1
- while [ -n "$out" ]; do
- out=$(pidof lt-$SESSIOND_BIN)
- sleep 0.5
- done
- print_ok
- fi
-}
-
-function create_lttng_session ()
-{
- sess_name=$1
- trace_path=$2
-
- 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
- print_fail
- return 1
- else
- print_ok
- 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
- print_fail
- return 1
- else
- print_ok
- 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
- print_fail
- return 1
- else
- print_ok
- fi
-}
-
-function enable_ust_lttng_event ()
-{
- sess_name=$1
- event_name="$2"
-
- echo -n "Enabling lttng event $event_name for session $sess_name "
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u >/dev/null 2>&1
- if [ $? -eq 1 ]; then
- print_fail
- return 1
- else
- print_ok
- fi
-}
-
-function enable_ust_lttng_event_filter()
-{
- sess_name="$1"
- event_name="$2"
- filter="$3"
- echo -n "Enabling lttng event with filtering "
-
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --filter "$filter" 2>&1 >/dev/null
- if [ $? -eq 0 ]; then
- print_ok
- return 0
- else
- print_fail
- return 1
- fi
-}
-
-function enable_ust_lttng_event_loglevel()
-{
- sess_name="$1"
- event_name="$2"
- loglevel="$3"
- echo -n "Enabling lttng event $event_name with loglevel $loglevel"
-
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel $loglevel 2>&1 >/dev/null
- if [ $? -eq 0 ]; then
- print_ok
- return 0
- else
- print_fail
- return 1
- fi
-}
-
-function enable_ust_lttng_event_loglevel_only()
-{
- sess_name="$1"
- event_name="$2"
- loglevel="$3"
- echo -n "Enabling lttng event $event_name with loglevel-only $loglevel"
-
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel-only $loglevel 2>&1 >/dev/null
- if [ $? -eq 0 ]; then
- print_ok
- return 0
- else
- print_fail
- return 1
- fi
-}
-
-function disable_ust_lttng_event ()
-{
- sess_name="$1"
- event_name="$2"
-
- echo -n "Disabling lttng event $event_name for session $sess_name "
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -u >/dev/null 2>&1
- if [ $? -eq 1 ]; then
- print_fail
- return 1
- else
- print_ok
- fi
-}
-
-function start_lttng_tracing ()
-{
- sess_name=$1
-
- echo -n "Start lttng tracing for session $sess_name "
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name >/dev/null 2>&1
- if [ $? -eq 1 ]; then
- print_fail
- return 1
- else
- print_ok
- fi
-}
-
-function stop_lttng_tracing ()
-{
- sess_name=$1
-
- echo -n "Stop lttng tracing for session $sess_name "
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name >/dev/null 2>&1
- if [ $? -eq 1 ]; then
- print_fail
- return 1
- else
- print_ok
- fi
-}
-
-function destroy_lttng_session ()
-{
- sess_name=$1
-
- echo -n "Destroy lttng session $sess_name "
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $sess_name >/dev/null 2>&1
- if [ $? -eq 1 ]; then
- print_fail
- return 1
- else
- print_ok
- fi
-}
-
-function trace_matches ()
-{
- event_name=$1
- nr_iter=$2
- trace_path=$3
-
- which $BABELTRACE_BIN >/dev/null
- if [ $? -eq 1 ]; then
- echo "Babeltrace binary not found. Skipping trace matches"
- return 0
- fi
-
- echo -n "Looking for $nr_iter $event_name in $trace_path "
-
- count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
- if [ "$count" -ne "$nr_iter" ]; then
- echo -n "$count found in trace "
- print_fail
- return 1
- else
- echo -n "Trace is coherent "
- print_ok
- return 0
- fi
-}
-
-function validate_trace
-{
- event_name=$1
- trace_path=$2
-
- which $BABELTRACE_BIN >/dev/null
- if [ $? -eq 1 ]; then
- echo "Babeltrace binary not found. Skipping trace matches"
- return 0
- fi
-
- echo -n "Validating trace for event $event_name... "
- traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $event_name | wc -l)
- if [ $traced -eq 0 ]; then
- print_fail
- return 1
- else
- print_ok
- return 0
- fi
-}
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+
+#define BRIGHT 1
+#define GREEN 32
+#define RED 31
+
+#define PRINT_OK() \
+do { \
+ /* Check for color support */ \
+ if (isatty(STDOUT_FILENO)) { \
+ printf("%c[%d;%dmOK%c[%dm\n", 0x1B, BRIGHT, GREEN, 0x1B, 0); \
+ } else { \
+ printf("OK\n"); \
+ } \
+} while (0)
+
+#define PRINT_FAIL() \
+do { \
+ /* Check for color support */ \
+ if (isatty(STDOUT_FILENO)) { \
+ printf("%c[%d;%dmFAIL%c[%dm\n", 0x1B, BRIGHT, RED, 0x1B, 0); \
+ } else { \
+ printf("FAIL\n"); \
+ } \
+} while (0)
--- /dev/null
+#!/src/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library 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 Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+SESSIOND_BIN="lttng-sessiond"
+RELAYD_BIN="lttng-relayd"
+LTTNG_BIN="lttng"
+BABELTRACE_BIN="babeltrace"
+
+# Minimal kernel version supported for session daemon tests
+KERNEL_MAJOR_VERSION=2
+KERNEL_MINOR_VERSION=6
+KERNEL_PATCHLEVEL_VERSION=27
+
+function print_ok ()
+{
+ # Check if we are a terminal
+ if [ -t 1 ]; then
+ echo -e "\e[1;32mOK\e[0m"
+ else
+ echo -e "OK"
+ fi
+}
+
+function print_fail ()
+{
+ # Check if we are a terminal
+ if [ -t 1 ]; then
+ echo -e "\e[1;31mFAIL\e[0m"
+ else
+ echo -e "FAIL"
+ fi
+}
+
+function print_test_banner ()
+{
+ desc="$1"
+
+ count=$((${#desc}+2))
+ str=$(printf "%${count}s");
+ echo -e "\n"
+ echo -e ${str// /-}
+ echo -e " $desc "
+ echo -e ${str// /-}
+}
+
+function validate_kernel_version ()
+{
+ kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n'))
+ if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
+ return 0
+ fi
+ if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
+ return 0
+ fi
+ if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
+ return 0
+ fi
+ return 1
+}
+
+# Generate a random string
+# $1 = number of characters; defaults to 16
+# $2 = include special characters; 1 = yes, 0 = no; defaults to yes
+function randstring()
+{
+ [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]"
+ cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-16}
+ echo
+}
+
+function spawn_sessiond ()
+{
+ echo ""
+ echo -n "Starting session daemon... "
+ validate_kernel_version
+ if [ $? -ne 0 ]; then
+ echo -e "\n*** Kernel too old for session daemon tests ***\n"
+ return 2
+ fi
+
+ 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"
+ #$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --verbose-consumer >>/tmp/sessiond.log 2>&1 &
+ if [ $? -eq 1 ]; then
+ print_fail
+ return 1
+ else
+ print_ok
+ fi
+ fi
+
+ return 0
+}
+
+function lttng_enable_kernel_event
+{
+ sess_name=$1
+ event_name=$2
+
+ if [ -z $event_name ]; then
+ # Enable all event if no event name specified
+ $event_name="-a"
+ fi
+
+ echo -n "Enabling kernel event $event_name for session $sess_name"
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -k >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ print_fail
+ return 1
+ else
+ print_ok
+ fi
+}
+
+function start_lttng_relayd
+{
+ local opt=$1
+
+ echo -e -n "Starting lttng-relayd (opt: $opt)... "
+
+ DIR=$(readlink -f $TESTDIR)
+
+ if [ -z $(pidof lt-$RELAYD_BIN) ]; then
+ $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1 &
+ #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
+ if [ $? -eq 1 ]; then
+ print_fail
+ return 1
+ else
+ print_ok
+ fi
+ else
+ print_ok
+ fi
+}
+
+function stop_lttng_relayd
+{
+ PID_RELAYD=`pidof lt-$RELAYD_BIN`
+
+ echo -e -n "Killing lttng-relayd (pid: $PID_RELAYD)... "
+ kill $PID_RELAYD >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ print_fail
+ return 1
+ else
+ out=1
+ while [ -n "$out" ]; do
+ out=$(pidof lt-$RELAYD_BIN)
+ sleep 0.5
+ done
+ print_ok
+ return 0
+ fi
+}
+
+function start_lttng_sessiond()
+{
+ if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
+ # Env variable requested no session daemon
+ return
+ fi
+
+ spawn_sessiond
+ out=$?
+ if [ $out -eq 2 ]; then
+ # Kernel version is not compatible.
+ exit 0
+ elif [ $out -ne 0 ]; then
+ echo "NOT bad $?"
+ exit 1
+ fi
+
+ # Simply wait for the session daemon bootstrap
+ echo "Waiting for the session daemon to bootstrap (2 secs)"
+ sleep 2
+}
+
+function stop_lttng_sessiond ()
+{
+ if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
+ # Env variable requested no session daemon
+ return
+ fi
+
+ PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
+
+ echo -e -n "Killing session daemon... "
+ kill $PID_SESSIOND >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ print_fail
+ return 1
+ else
+ out=1
+ while [ -n "$out" ]; do
+ out=$(pidof lt-$SESSIOND_BIN)
+ sleep 0.5
+ done
+ print_ok
+ fi
+}
+
+function create_lttng_session ()
+{
+ sess_name=$1
+ trace_path=$2
+
+ 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
+ print_fail
+ return 1
+ else
+ print_ok
+ 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
+ print_fail
+ return 1
+ else
+ print_ok
+ 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
+ print_fail
+ return 1
+ else
+ print_ok
+ fi
+}
+
+function enable_ust_lttng_event ()
+{
+ sess_name=$1
+ event_name="$2"
+
+ echo -n "Enabling lttng event $event_name for session $sess_name "
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ print_fail
+ return 1
+ else
+ print_ok
+ fi
+}
+
+function enable_ust_lttng_event_filter()
+{
+ sess_name="$1"
+ event_name="$2"
+ filter="$3"
+ echo -n "Enabling lttng event with filtering "
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --filter "$filter" 2>&1 >/dev/null
+ if [ $? -eq 0 ]; then
+ print_ok
+ return 0
+ else
+ print_fail
+ return 1
+ fi
+}
+
+function enable_ust_lttng_event_loglevel()
+{
+ sess_name="$1"
+ event_name="$2"
+ loglevel="$3"
+ echo -n "Enabling lttng event $event_name with loglevel $loglevel"
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel $loglevel 2>&1 >/dev/null
+ if [ $? -eq 0 ]; then
+ print_ok
+ return 0
+ else
+ print_fail
+ return 1
+ fi
+}
+
+function enable_ust_lttng_event_loglevel_only()
+{
+ sess_name="$1"
+ event_name="$2"
+ loglevel="$3"
+ echo -n "Enabling lttng event $event_name with loglevel-only $loglevel"
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel-only $loglevel 2>&1 >/dev/null
+ if [ $? -eq 0 ]; then
+ print_ok
+ return 0
+ else
+ print_fail
+ return 1
+ fi
+}
+
+function disable_ust_lttng_event ()
+{
+ sess_name="$1"
+ event_name="$2"
+
+ echo -n "Disabling lttng event $event_name for session $sess_name "
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -u >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ print_fail
+ return 1
+ else
+ print_ok
+ fi
+}
+
+function start_lttng_tracing ()
+{
+ sess_name=$1
+
+ echo -n "Start lttng tracing for session $sess_name "
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ print_fail
+ return 1
+ else
+ print_ok
+ fi
+}
+
+function stop_lttng_tracing ()
+{
+ sess_name=$1
+
+ echo -n "Stop lttng tracing for session $sess_name "
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ print_fail
+ return 1
+ else
+ print_ok
+ fi
+}
+
+function destroy_lttng_session ()
+{
+ sess_name=$1
+
+ echo -n "Destroy lttng session $sess_name "
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $sess_name >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ print_fail
+ return 1
+ else
+ print_ok
+ fi
+}
+
+function trace_matches ()
+{
+ event_name=$1
+ nr_iter=$2
+ trace_path=$3
+
+ which $BABELTRACE_BIN >/dev/null
+ if [ $? -eq 1 ]; then
+ echo "Babeltrace binary not found. Skipping trace matches"
+ return 0
+ fi
+
+ echo -n "Looking for $nr_iter $event_name in $trace_path "
+
+ count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
+ if [ "$count" -ne "$nr_iter" ]; then
+ echo -n "$count found in trace "
+ print_fail
+ return 1
+ else
+ echo -n "Trace is coherent "
+ print_ok
+ return 0
+ fi
+}
+
+function validate_trace
+{
+ event_name=$1
+ trace_path=$2
+
+ which $BABELTRACE_BIN >/dev/null
+ if [ $? -eq 1 ]; then
+ echo "Babeltrace binary not found. Skipping trace matches"
+ return 0
+ fi
+
+ echo -n "Validating trace for event $event_name... "
+ traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $event_name | wc -l)
+ if [ $traced -eq 0 ]; then
+ print_fail
+ return 1
+ else
+ print_ok
+ return 0
+ fi
+}