Merge remote-tracking branch 'cbab-github/tests-cleanup' into cbab
authorDavid Goulet <dgoulet@efficios.com>
Mon, 11 Mar 2013 17:00:33 +0000 (13:00 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 11 Mar 2013 17:00:33 +0000 (13:00 -0400)
Conflicts:
tests/regression/tools/streaming/test_high_throughput_limits
tests/unit/test_kernel_data.c
tests/unit/test_ust_data.c

178 files changed:
.gitignore
configure.ac
tests/Makefile.am
tests/kernel/Makefile.am [deleted file]
tests/kernel/kernel_all_events_basic.c [deleted file]
tests/kernel/kernel_event_basic.c [deleted file]
tests/kernel/run-kernel-tests.sh [deleted file]
tests/kernel/runall.sh [deleted file]
tests/regression/Makefile.am [new file with mode: 0644]
tests/regression/kernel/Makefile.am [new file with mode: 0644]
tests/regression/kernel/run.sh [new file with mode: 0755]
tests/regression/kernel/test_all_events [new file with mode: 0755]
tests/regression/kernel/test_event_basic [new file with mode: 0755]
tests/regression/run-report.py [new file with mode: 0755]
tests/regression/run.sh [new file with mode: 0755]
tests/regression/test_list.py [new file with mode: 0755]
tests/regression/tools/Makefile.am [new file with mode: 0644]
tests/regression/tools/filtering/Makefile.am [new file with mode: 0644]
tests/regression/tools/filtering/babelstats.pl [new file with mode: 0755]
tests/regression/tools/filtering/gen-ust-events.c [new file with mode: 0644]
tests/regression/tools/filtering/test_invalid_filter [new file with mode: 0755]
tests/regression/tools/filtering/test_unsupported_op [new file with mode: 0755]
tests/regression/tools/filtering/test_valid_filter [new file with mode: 0755]
tests/regression/tools/filtering/tp.c [new file with mode: 0644]
tests/regression/tools/filtering/tp.h [new file with mode: 0644]
tests/regression/tools/health/Makefile.am [new file with mode: 0644]
tests/regression/tools/health/health_check.c [new file with mode: 0644]
tests/regression/tools/health/health_exit.c [new file with mode: 0644]
tests/regression/tools/health/health_fail.c [new file with mode: 0644]
tests/regression/tools/health/health_stall.c [new file with mode: 0644]
tests/regression/tools/health/test_thread_exit [new file with mode: 0755]
tests/regression/tools/health/test_thread_stall [new file with mode: 0755]
tests/regression/tools/health/test_tp_fail [new file with mode: 0755]
tests/regression/tools/run.sh [new file with mode: 0755]
tests/regression/tools/streaming/Makefile.am [new file with mode: 0644]
tests/regression/tools/streaming/gen-ust-events.c [new file with mode: 0644]
tests/regression/tools/streaming/test_high_throughput_limits [new file with mode: 0755]
tests/regression/tools/streaming/test_kernel [new file with mode: 0755]
tests/regression/tools/streaming/test_uri_switch [new file with mode: 0755]
tests/regression/tools/streaming/test_ust [new file with mode: 0755]
tests/regression/tools/streaming/tp.c [new file with mode: 0644]
tests/regression/tools/streaming/tp.h [new file with mode: 0644]
tests/regression/ust/Makefile.am [new file with mode: 0644]
tests/regression/ust/before-after/Makefile.am [new file with mode: 0644]
tests/regression/ust/before-after/gen-nevents.c [new file with mode: 0644]
tests/regression/ust/before-after/test_before_after [new file with mode: 0755]
tests/regression/ust/before-after/tp.c [new file with mode: 0644]
tests/regression/ust/before-after/ust_gen_nevents.h [new file with mode: 0644]
tests/regression/ust/high-throughput/Makefile.am [new file with mode: 0644]
tests/regression/ust/high-throughput/main.c [new file with mode: 0644]
tests/regression/ust/high-throughput/test_high_throughput [new file with mode: 0755]
tests/regression/ust/high-throughput/tp.c [new file with mode: 0644]
tests/regression/ust/high-throughput/tp.h [new file with mode: 0644]
tests/regression/ust/low-throughput/Makefile.am [new file with mode: 0644]
tests/regression/ust/low-throughput/main.c [new file with mode: 0644]
tests/regression/ust/low-throughput/test_low_throughput [new file with mode: 0755]
tests/regression/ust/low-throughput/tp.c [new file with mode: 0644]
tests/regression/ust/low-throughput/tp.h [new file with mode: 0644]
tests/regression/ust/multi-session/Makefile.am [new file with mode: 0644]
tests/regression/ust/multi-session/gen-nevents.c [new file with mode: 0644]
tests/regression/ust/multi-session/test_multi_session [new file with mode: 0755]
tests/regression/ust/multi-session/tp.c [new file with mode: 0644]
tests/regression/ust/multi-session/ust_gen_nevents.h [new file with mode: 0644]
tests/regression/ust/nprocesses/Makefile.am [new file with mode: 0644]
tests/regression/ust/nprocesses/gen-events-time.c [new file with mode: 0644]
tests/regression/ust/nprocesses/test_nprocesses [new file with mode: 0755]
tests/regression/ust/nprocesses/tp.c [new file with mode: 0644]
tests/regression/ust/nprocesses/ust_gen_event.h [new file with mode: 0644]
tests/regression/ust/overlap/Makefile.am [new file with mode: 0644]
tests/regression/ust/overlap/demo/Makefile.am [new file with mode: 0644]
tests/regression/ust/overlap/demo/demo-trace [new file with mode: 0755]
tests/regression/ust/overlap/demo/demo.c [new file with mode: 0644]
tests/regression/ust/overlap/demo/tp.c [new file with mode: 0644]
tests/regression/ust/overlap/demo/tp2.c [new file with mode: 0644]
tests/regression/ust/overlap/demo/tp3.c [new file with mode: 0644]
tests/regression/ust/overlap/demo/ust_tests_demo.h [new file with mode: 0644]
tests/regression/ust/overlap/demo/ust_tests_demo2.h [new file with mode: 0644]
tests/regression/ust/overlap/demo/ust_tests_demo3.h [new file with mode: 0644]
tests/regression/ust/overlap/test_overlap [new file with mode: 0755]
tests/regression/ust/run.sh [new file with mode: 0755]
tests/regression/ust/test_event_basic [new file with mode: 0755]
tests/regression/ust/test_event_wildcard [new file with mode: 0755]
tests/run-report.py [deleted file]
tests/run.sh [new file with mode: 0755]
tests/runall.sh [deleted file]
tests/test_list.py [deleted file]
tests/tools/Makefile.am [deleted file]
tests/tools/filtering/Makefile.am [deleted file]
tests/tools/filtering/babelstats.pl [deleted file]
tests/tools/filtering/gen-ust-events.c [deleted file]
tests/tools/filtering/invalid-filters [deleted file]
tests/tools/filtering/runall [deleted file]
tests/tools/filtering/tp.c [deleted file]
tests/tools/filtering/tp.h [deleted file]
tests/tools/filtering/unsupported-ops [deleted file]
tests/tools/filtering/valid-filters [deleted file]
tests/tools/health/Makefile.am [deleted file]
tests/tools/health/health_check.c [deleted file]
tests/tools/health/health_exit.c [deleted file]
tests/tools/health/health_fail.c [deleted file]
tests/tools/health/health_stall.c [deleted file]
tests/tools/health/health_thread_exit [deleted file]
tests/tools/health/health_thread_stall [deleted file]
tests/tools/health/health_tp_fail [deleted file]
tests/tools/health/runall [deleted file]
tests/tools/runall.sh [deleted file]
tests/tools/streaming/Makefile.am [deleted file]
tests/tools/streaming/gen-ust-events.c [deleted file]
tests/tools/streaming/high_throughput_limits [deleted file]
tests/tools/streaming/run-kernel [deleted file]
tests/tools/streaming/run-ust [deleted file]
tests/tools/streaming/runall [deleted file]
tests/tools/streaming/tp.c [deleted file]
tests/tools/streaming/tp.h [deleted file]
tests/tools/streaming/unit_tests.c [deleted file]
tests/tools/streaming/uri_switch [deleted file]
tests/tools/test_kernel_data_trace.c [deleted file]
tests/tools/test_sessions.c [deleted file]
tests/tools/test_ust_data_trace.c [deleted file]
tests/unit/Makefile.am [new file with mode: 0644]
tests/unit/run.sh [new file with mode: 0755]
tests/unit/test_kernel_data.c [new file with mode: 0644]
tests/unit/test_session.c [new file with mode: 0644]
tests/unit/test_uri.c [new file with mode: 0644]
tests/unit/test_ust_data.c [new file with mode: 0644]
tests/ust/Makefile.am [deleted file]
tests/ust/before-after/Makefile.am [deleted file]
tests/ust/before-after/gen-nevents.c [deleted file]
tests/ust/before-after/run [deleted file]
tests/ust/before-after/tp.c [deleted file]
tests/ust/before-after/ust_gen_nevents.h [deleted file]
tests/ust/high-throughput/Makefile.am [deleted file]
tests/ust/high-throughput/main.c [deleted file]
tests/ust/high-throughput/run [deleted file]
tests/ust/high-throughput/tp.c [deleted file]
tests/ust/high-throughput/tp.h [deleted file]
tests/ust/low-throughput/Makefile.am [deleted file]
tests/ust/low-throughput/main.c [deleted file]
tests/ust/low-throughput/run [deleted file]
tests/ust/low-throughput/tp.c [deleted file]
tests/ust/low-throughput/tp.h [deleted file]
tests/ust/multi-session/Makefile.am [deleted file]
tests/ust/multi-session/gen-nevents.c [deleted file]
tests/ust/multi-session/run [deleted file]
tests/ust/multi-session/tp.c [deleted file]
tests/ust/multi-session/ust_gen_nevents.h [deleted file]
tests/ust/nprocesses/Makefile.am [deleted file]
tests/ust/nprocesses/gen-events-time.c [deleted file]
tests/ust/nprocesses/run [deleted file]
tests/ust/nprocesses/tp.c [deleted file]
tests/ust/nprocesses/ust-nprocesses [deleted file]
tests/ust/nprocesses/ust_gen_event.h [deleted file]
tests/ust/overlap/Makefile.am [deleted file]
tests/ust/overlap/demo/Makefile.am [deleted file]
tests/ust/overlap/demo/demo-trace [deleted file]
tests/ust/overlap/demo/demo.c [deleted file]
tests/ust/overlap/demo/tp.c [deleted file]
tests/ust/overlap/demo/tp2.c [deleted file]
tests/ust/overlap/demo/tp3.c [deleted file]
tests/ust/overlap/demo/ust_tests_demo.h [deleted file]
tests/ust/overlap/demo/ust_tests_demo2.h [deleted file]
tests/ust/overlap/demo/ust_tests_demo3.h [deleted file]
tests/ust/overlap/overlap.sh [deleted file]
tests/ust/overlap/run [deleted file]
tests/ust/run-ust-global-tests.sh [deleted file]
tests/ust/runall.sh [deleted file]
tests/ust/ust_global_event_basic.c [deleted file]
tests/ust/ust_global_event_wildcard.c [deleted file]
tests/utils.h [deleted file]
tests/utils.sh [deleted file]
tests/utils/Makefile.am [new file with mode: 0644]
tests/utils/runner.sh [new file with mode: 0644]
tests/utils/tap/Makefile.am [new file with mode: 0644]
tests/utils/tap/tap.c [new file with mode: 0644]
tests/utils/tap/tap.h [new file with mode: 0644]
tests/utils/tap/tap.sh [new file with mode: 0755]
tests/utils/utils.h [new file with mode: 0644]
tests/utils/utils.sh [new file with mode: 0644]

index aa794ae1fad144aaacde47384a408102b6ca7e8b..5dc73aec9c03c9020d69fb27777e05f0fcb62a8c 100644 (file)
@@ -49,9 +49,10 @@ extras/bindings/swig/python/lttng_wrap.c
 .checkpatch.conf
 
 # Tests
-test_sessions
-test_kernel_data_trace
-test_ust_data_trace
+tests/unit/test_kernel_data
+tests/unit/test_session
+tests/unit/test_uri
+tests/unit/test_ust_data
 kernel_all_events_basic
 kernel_event_basic
 ust_global_event_wildcard
index 71fbb6034e72306f1b40b4b6394ec93a66c1efdd..7e35c06458fc081340b448c85d75b9c18bc94bae 100644 (file)
@@ -309,19 +309,23 @@ AC_CONFIG_FILES([
        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
+       tests/unit/Makefile
+       tests/utils/Makefile
+       tests/utils/tap/Makefile
 ])
 
 AC_OUTPUT
index bc0f0a59afc336ffb905b37c43f90309758d01d2..b75de49591fb6971e99d22672eafde6e7d16bf73 100644 (file)
@@ -1,13 +1,4 @@
-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
+SUBDIRS = utils regression unit
 
 check-am:
-       ./runall.sh
+       ./run.sh
diff --git a/tests/kernel/Makefile.am b/tests/kernel/Makefile.am
deleted file mode 100644 (file)
index 8872af4..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-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)
diff --git a/tests/kernel/kernel_all_events_basic.c b/tests/kernel/kernel_all_events_basic.c
deleted file mode 100644 (file)
index b80dbd3..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * as published by the Free Software Foundation; only version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#define _GNU_SOURCE
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
-
-#include <lttng/lttng.h>
-
-#include "utils.h"
-
-int lttng_opt_quiet;
-
-int main(int argc, char **argv)
-{
-       struct lttng_handle *handle = NULL;
-       struct lttng_domain dom;
-       struct lttng_event event;
-       char *channel_name = "channel0";
-       char *session_name = "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;
-}
diff --git a/tests/kernel/kernel_event_basic.c b/tests/kernel/kernel_event_basic.c
deleted file mode 100644 (file)
index b0cbf66..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * as published by the Free Software Foundation; only version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#define _GNU_SOURCE
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
-
-#include <lttng/lttng.h>
-
-#include "utils.h"
-
-int lttng_opt_quiet;
-
-int main(int argc, char **argv)
-{
-       struct lttng_handle *handle = NULL;
-       struct lttng_domain dom;
-       struct lttng_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;
-}
diff --git a/tests/kernel/run-kernel-tests.sh b/tests/kernel/run-kernel-tests.sh
deleted file mode 100755 (executable)
index 6948e1f..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/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
diff --git a/tests/kernel/runall.sh b/tests/kernel/runall.sh
deleted file mode 100755 (executable)
index 2b76e53..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/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
diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am
new file mode 100644 (file)
index 0000000..3641cf1
--- /dev/null
@@ -0,0 +1,8 @@
+SUBDIRS = tools kernel ust
+
+EXTRA_DIST = run-report.py test_list.py run.sh
+
+if HAVE_LIBLTTNG_UST_CTL
+SUBDIRS += ust
+endif # HAVE_LIBLTTNG_UST_CTL
+
diff --git a/tests/regression/kernel/Makefile.am b/tests/regression/kernel/Makefile.am
new file mode 100644 (file)
index 0000000..cff432d
--- /dev/null
@@ -0,0 +1 @@
+EXTRA_DIST = run.sh test_event_basic test_all_events
diff --git a/tests/regression/kernel/run.sh b/tests/regression/kernel/run.sh
new file mode 100755 (executable)
index 0000000..fe042e4
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# Copyright (C) 2013 - 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
+# 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.
+#
+
+DIR=$(dirname $0)
+TESTDIR=$DIR/../..
+source $TESTDIR/utils/runner.sh
+
+#### ADD TESTS HERE ####
+
+tests=( $DIR/test_event_basic
+        $DIR/test_all_events )
+
+#### END TESTS HERE ####
+
+opts=("$@")
+run_tests tests[@] opts[@]
diff --git a/tests/regression/kernel/test_all_events b/tests/regression/kernel/test_all_events
new file mode 100755 (executable)
index 0000000..4862748
--- /dev/null
@@ -0,0 +1,63 @@
+#!/bin/bash
+#
+# Copyright (C) - 2013 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="Kernel tracer - All events"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../..
+NUM_TESTS=8
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+function test_all_event()
+{
+       TRACE_PATH=$(mktemp -d)
+       SESSION_NAME="kernel_all_events_basic"
+
+       create_lttng_session $SESSION_NAME $TRACE_PATH
+
+       lttng_enable_kernel_event $SESSION_NAME
+
+       start_lttng_tracing
+       stop_lttng_tracing
+
+       validate_trace "sched_switch" $TRACE_PATH
+
+       destroy_lttng_session $SESSION_NAME
+
+       rm -rf $TRACE_PATH
+}
+
+# MUST set TESTDIR before calling those functions
+plan_tests $NUM_TESTS
+
+if [ "$(id -u)" == "0" ]; then
+       isroot=1
+else
+       isroot=0
+fi
+
+skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+{
+       start_lttng_sessiond
+
+       test_all_event
+
+       stop_lttng_sessiond
+}
diff --git a/tests/regression/kernel/test_event_basic b/tests/regression/kernel/test_event_basic
new file mode 100755 (executable)
index 0000000..4de94dc
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/bash
+#
+# Copyright (C) - 2013 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="Kernel tracer - Basic event"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../..
+NUM_TESTS=12
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+function test_event_basic()
+{
+       TRACE_PATH=$(mktemp -d)
+       SESSION_NAME="kernel_event_basic"
+
+       create_lttng_session $SESSION_NAME $TRACE_PATH
+
+       lttng_enable_kernel_event $SESSION_NAME "sched_switch"
+       lttng_enable_kernel_event $SESSION_NAME "sched_process_exit"
+       lttng_enable_kernel_event $SESSION_NAME "sched_process_free"
+
+       start_lttng_tracing
+       stop_lttng_tracing
+
+       validate_trace "sched_switch" $TRACE_PATH
+       validate_trace "sched_process_exit" $TRACE_PATH
+       validate_trace "sched_process_free" $TRACE_PATH
+
+       destroy_lttng_session $SESSION_NAME
+
+       rm -rf $TRACE_PATH
+}
+
+# MUST set TESTDIR before calling those functions
+plan_tests $NUM_TESTS
+
+if [ "$(id -u)" == "0" ]; then
+       isroot=1
+else
+       isroot=0
+fi
+
+skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+{
+       start_lttng_sessiond
+
+       test_event_basic
+
+       stop_lttng_sessiond
+}
diff --git a/tests/regression/run-report.py b/tests/regression/run-report.py
new file mode 100755 (executable)
index 0000000..acee181
--- /dev/null
@@ -0,0 +1,444 @@
+#!/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)
diff --git a/tests/regression/run.sh b/tests/regression/run.sh
new file mode 100755 (executable)
index 0000000..f0ea748
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# Copyright (C) 2013 - 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
+# 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.
+#
+DIR=$(dirname $0)
+
+$DIR/kernel/run.sh $@
+$DIR/ust/run.sh $@
+$DIR/tools/run.sh $@
diff --git a/tests/regression/test_list.py b/tests/regression/test_list.py
new file mode 100755 (executable)
index 0000000..2a613b9
--- /dev/null
@@ -0,0 +1,146 @@
+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
+    },
+]
diff --git a/tests/regression/tools/Makefile.am b/tests/regression/tools/Makefile.am
new file mode 100644 (file)
index 0000000..9065a37
--- /dev/null
@@ -0,0 +1,3 @@
+SUBDIRS = streaming filtering health
+
+EXTRA_DIST = run.sh
diff --git a/tests/regression/tools/filtering/Makefile.am b/tests/regression/tools/filtering/Makefile.am
new file mode 100644 (file)
index 0000000..5629da2
--- /dev/null
@@ -0,0 +1,18 @@
+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 = test_unsupported_op test_invalid_filter test_valid_filter babelstats.pl
+EXTRA_DIST = test_unsupported_op test_invalid_filter test_valid_filter babelstats.pl
diff --git a/tests/regression/tools/filtering/babelstats.pl b/tests/regression/tools/filtering/babelstats.pl
new file mode 100755 (executable)
index 0000000..d8d4dd0
--- /dev/null
@@ -0,0 +1,174 @@
+#!/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);
diff --git a/tests/regression/tools/filtering/gen-ust-events.c b/tests/regression/tools/filtering/gen-ust-events.c
new file mode 100644 (file)
index 0000000..c789c89
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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;
+}
diff --git a/tests/regression/tools/filtering/test_invalid_filter b/tests/regression/tools/filtering/test_invalid_filter
new file mode 100755 (executable)
index 0000000..700fa23
--- /dev/null
@@ -0,0 +1,150 @@
+#!/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)
+NUM_TESTS=119
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+function enable_ust_lttng_event_filter
+{
+       sess_name="$1"
+       event_name="$2"
+       filter="$3"
+
+       $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
+               fail "Enable lttng event with filtering and invalid filter"
+               return 1
+       else
+               pass "Enable lttng event with filtering and invalid filter"
+               return 0
+       fi
+}
+
+function test_invalid_filter
+{
+       test_invalid_filter="$1"
+
+       diag "Test filter expression with invalid filter"
+       diag "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'`
+
+       diag "Test 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
+}
+
+plan_tests $NUM_TESTS
+
+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
diff --git a/tests/regression/tools/filtering/test_unsupported_op b/tests/regression/tools/filtering/test_unsupported_op
new file mode 100755 (executable)
index 0000000..d0c6c86
--- /dev/null
@@ -0,0 +1,114 @@
+#!/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)
+NUM_TESTS=46
+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
+
+       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
+               fail "Enable lttng event with filtering and unsupported operator"
+               return 1
+       else
+               pass "Enable lttng event with filtering and unsupported operator"
+               return 0
+       fi
+}
+
+function test_unsupported_op
+{
+       test_op_str=$1
+       test_op_tkn=$2
+
+       diag "Test 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
+
+       grep -i -q "not[[:space:]]\+supported" $ENABLE_EVENT_STDERR
+
+       if [ $? -eq 1 ]; then
+               fail "Unsupported operator test $test_op_str ($test_op_tkn)"
+               return 1
+       else
+               pass "Unsupported operator test $test_op_str ($test_op_tkn)"
+       fi
+
+       # Destroy session
+       destroy_lttng_session $SESSION_NAME
+       return 0
+}
+
+plan_tests $NUM_TESTS
+
+# 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
diff --git a/tests/regression/tools/filtering/test_valid_filter b/tests/regression/tools/filtering/test_valid_filter
new file mode 100755 (executable)
index 0000000..09ac868
--- /dev/null
@@ -0,0 +1,403 @@
+#!/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
+NUM_TESTS=198
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+       BAIL_OUT "No UST nevents binary detected."
+fi
+
+function enable_ust_lttng_event_filter()
+{
+       sess_name="$1"
+       event_name="$2"
+       filter="$3"
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u --filter "$filter" 2>&1 >/dev/null
+
+       ok $? "Enable lttng event with filtering"
+}
+
+function run_apps
+{
+       ./$CURDIR/$BIN_NAME $NR_ITER & >/dev/null 2>&1
+}
+
+function wait_apps
+{
+       while [ -n "$(pidof $BIN_NAME)" ]; do
+               sleep 1
+       done
+       pass "Wait for application end"
+}
+
+function test_valid_filter
+{
+       filter="$1"
+       validator="$2"
+
+       diag "Test 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
+
+       stats=`babeltrace $trace_path | $CURDIR/$STATS_BIN --tracepoint $EVENT_NAME`
+
+       rm -rf $trace_path
+
+       $validator "$stats"
+
+       ok $? "Validate trace filter output"
+
+       rm -rf $trace_path
+}
+
+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
+}
+
+plan_tests $NUM_TESTS
+
+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
diff --git a/tests/regression/tools/filtering/tp.c b/tests/regression/tools/filtering/tp.c
new file mode 100644 (file)
index 0000000..a09561d
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * 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"
diff --git a/tests/regression/tools/filtering/tp.h b/tests/regression/tools/filtering/tp.h
new file mode 100644 (file)
index 0000000..15f81e5
--- /dev/null
@@ -0,0 +1,57 @@
+#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
diff --git a/tests/regression/tools/health/Makefile.am b/tests/regression/tools/health/Makefile.am
new file mode 100644 (file)
index 0000000..94e54df
--- /dev/null
@@ -0,0 +1,38 @@
+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
diff --git a/tests/regression/tools/health/health_check.c b/tests/regression/tools/health/health_check.c
new file mode 100644 (file)
index 0000000..3eef110
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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;
+}
diff --git a/tests/regression/tools/health/health_exit.c b/tests/regression/tools/health/health_exit.c
new file mode 100644 (file)
index 0000000..8e41405
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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;
+}
diff --git a/tests/regression/tools/health/health_fail.c b/tests/regression/tools/health/health_fail.c
new file mode 100644 (file)
index 0000000..6227825
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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;
+}
diff --git a/tests/regression/tools/health/health_stall.c b/tests/regression/tools/health/health_stall.c
new file mode 100644 (file)
index 0000000..127f5fc
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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;
+}
diff --git a/tests/regression/tools/health/test_thread_exit b/tests/regression/tools/health/test_thread_exit
new file mode 100755 (executable)
index 0000000..885ad19
--- /dev/null
@@ -0,0 +1,116 @@
+#!/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"
+NUM_TESTS=12
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
+       BAIL_OUT "libhealthexit.so not available for this test."
+fi
+
+function test_thread_exit
+{
+       test_thread_exit_name="$1"
+       test_thread_exit_code="$2"
+
+       diag "Test 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
+
+       # 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
+               pass "Validate thread ${test_thread_exit_name} failure"
+               stop_lttng_sessiond
+       else
+               fail "Validate thread ${test_thread_exit_name} failure"
+
+               diag "Health returned: $health_check_exit_code\n"
+
+               stop_lttng_sessiond
+               return 1
+       fi
+}
+plan_tests $NUM_TESTS
+
+THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
+       "LTTNG_THREAD_MANAGE_APPS"
+       "LTTNG_THREAD_REG_APPS")
+
+# Exit code value to indicate specific thread failure
+EXIT_CODE=(1 2 4)
+
+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
+
+# The manage kernel thread is only spawned if we are root
+if [ "$(id -u)" == "0" ]; then
+       isroot=1
+else
+       isroot=0
+fi
+
+skip $isroot "Root access is needed. Skipping LTTNG_THREAD_MANAGE_KERNEL tests." "3" ||
+{
+       test_thread_exit "LTTNG_THREAD_MANAGE_KERNEL" "8"
+}
+
+
+# TODO: Special case manage consumer, need to spawn consumer via commands.
+#"LTTNG_THREAD_MANAGE_CONSUMER"
diff --git a/tests/regression/tools/health/test_thread_stall b/tests/regression/tools/health/test_thread_stall
new file mode 100755 (executable)
index 0000000..92cfb01
--- /dev/null
@@ -0,0 +1,137 @@
+#!/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"
+NUM_TESTS=12
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
+       BAIL_OUT "libhealthstall.so not available for this test."
+fi
+
+function test_thread_stall
+{
+       test_thread_stall_name="$1"
+       test_thread_exit_code="$2"
+
+       diag "Test 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
+
+       # 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
+               pass "Validate that ${test_thread_stall_name} is stalled"
+       else
+               fail "Validate that ${test_thread_stall_name} is stalled"
+               diag "Health returned: $health_check_exit_code"
+
+               stop_lttng_sessiond
+               return 1
+       fi
+
+       # 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
+               pass "Validate that ${test_thread_stall_name} is no longer stalled"
+               stop_lttng_sessiond
+       else
+               fail "Validate that ${test_thread_stall_name} is no longer stalled"
+               diag "Health returned: $health_check_exit_code\n"
+               stop_lttng_sessiond
+               return 1
+       fi
+
+
+}
+
+plan_tests $NUM_TESTS
+
+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"
+)
+
+# Exit code value to indicate specific thread failure
+EXIT_CODE=(1
+          2
+#         4
+)
+
+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
+
+# The manage kernel thread is only spawned if we are root
+if [ "$(id -u)" == "0" ]; then
+       isroot=1
+else
+       isroot=0
+fi
+
+skip $isroot "Root access is needed. Skipping LTTNG_THREAD_MANAGE_KERNEL tests." "3" ||
+{
+       test_thread_stall "LTTNG_THREAD_MANAGE_KERNEL" "8"
+}
diff --git a/tests/regression/tools/health/test_tp_fail b/tests/regression/tools/health/test_tp_fail
new file mode 100755 (executable)
index 0000000..fdb8745
--- /dev/null
@@ -0,0 +1,108 @@
+#!/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"
+NUM_TESTS=9
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
+       BAIL_OUT "libhealthtpfail.so not available for this test."
+fi
+
+function test_tp_fail
+{
+       test_tp_fail_name="$1"
+       test_tp_fail_code="$2"
+
+       diag "Test 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
+
+       # 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
+               pass "Validate thread ${test_tp_fail_name} failure"
+               stop_lttng_sessiond
+       else
+               fail "Validate thread ${test_tp_fail_name} failure"
+               diag "Health returned: $health_check_exit_code"
+               stop_lttng_sessiond
+               return 1
+       fi
+}
+
+plan_tests $NUM_TESTS
+
+THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
+       "LTTNG_THREAD_MANAGE_APPS")
+
+# Exit code value to indicate specific thread failure
+EXIT_CODE=(1 2)
+
+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
+
+# The manage kernel thread is only spawned if we are root
+if [ "$(id -u)" == "0" ]; then
+       isroot=1
+else
+       isroot=0
+fi
+
+skip $isroot "Root access is needed. Skipping LTTNG_THREAD_MANAGE_KERNEL tests." "3" ||
+{
+       test_tp_fail "LTTNG_THREAD_MANAGE_KERNEL" "8"
+}
+
+
+# TODO: Special case manage consumer, need to spawn consumer via commands.
+#"LTTNG_THREAD_MANAGE_CONSUMER"
diff --git a/tests/regression/tools/run.sh b/tests/regression/tools/run.sh
new file mode 100755 (executable)
index 0000000..63154ac
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/bash
+#
+# Copyright (C) 2013 - 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
+# 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.
+#
+
+DIR=$(dirname $0)
+TESTDIR=$DIR/../..
+source $TESTDIR/utils/runner.sh
+
+#### ADD TESTS HERE ####
+
+tests=( $DIR/filtering/test_invalid_filter
+       $DIR/filtering/test_unsupported_op
+       $DIR/filtering/test_valid_filter
+       $DIR/health/test_thread_exit
+       $DIR/health/test_thread_stall
+       $DIR/health/test_tp_fail
+       $DIR/streaming/test_kernel
+       $DIR/streaming/test_ust
+       $DIR/streaming/test_uri_switch
+       $DIR/streaming/test_high_throughput_limits )
+
+#### END TESTS HERE ####
+
+opts=("$@")
+run_tests tests[@] opts[@]
diff --git a/tests/regression/tools/streaming/Makefile.am b/tests/regression/tools/streaming/Makefile.am
new file mode 100644 (file)
index 0000000..2dbb4d5
--- /dev/null
@@ -0,0 +1,18 @@
+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
+
+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 = test_ust test_kernel test_uri_switch test_high_throughput_limits
+EXTRA_DIST = test_ust test_kernel test_uri_switch test_high_throughput_limits
diff --git a/tests/regression/tools/streaming/gen-ust-events.c b/tests/regression/tools/streaming/gen-ust-events.c
new file mode 100644 (file)
index 0000000..1385119
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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;
+}
diff --git a/tests/regression/tools/streaming/test_high_throughput_limits b/tests/regression/tools/streaming/test_high_throughput_limits
new file mode 100755 (executable)
index 0000000..2412374
--- /dev/null
@@ -0,0 +1,191 @@
+#!/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)
+
+NUM_TESTS=112
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+       BAIL_OUT "No UST nevents binary detected."
+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}))
+
+
+       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
+
+       ok $? "Set bandwidth limits to ${limit}kbits, ${ctrlportlimit} for control and ${dataportlimit} for data"
+}
+
+function reset_bw_limit
+{
+       tc qdisc del dev $DEFAULT_IF root >/dev/null 2>&1
+       ok $? "Reset bandwith limits"
+}
+
+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
+       ok $? "Create session with uri $uri"
+}
+
+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
+{
+       while [ -n "$(pidof $BIN_NAME)" ]; do
+               sleep 1
+       done
+       pass "Wait for applications to end"
+}
+
+function test_high_throughput
+{
+       NETWORK_URI="net://localhost"
+       create_lttng_session_with_uri $SESSION_NAME $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
+               fail "Validate trace event count"
+               diag "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
+               return 1
+       else
+               pass "Validate trace event count"
+               diag "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
+
+               rm -rf $TRACE_PATH
+               rm $TEMP_FILE $TEMP_FILE_2
+
+               return 0
+       fi
+}
+
+function interrupt_cleanup()
+{
+       diag "*** Exiting ***"
+       stop_lttng_relayd
+       stop_lttng_sessiond
+       reset_bw_limit
+       exit 1
+}
+
+plan_tests $NUM_TESTS
+
+if [ "$(id -u)" == "0" ]; then
+       isroot=1
+else
+       isroot=0
+fi
+
+skip $isroot "Root access is needed to set bandwith limits. Skipping all tests." $NUM_TESTS ||
+{
+
+       # 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
+               diag "Test 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
+       done
+}
diff --git a/tests/regression/tools/streaming/test_kernel b/tests/regression/tools/streaming/test_kernel
new file mode 100755 (executable)
index 0000000..42df7b0
--- /dev/null
@@ -0,0 +1,112 @@
+#!/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)
+
+NUM_TESTS=11
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+# LTTng kernel modules check
+out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
+if [ -z "$out" ]; then
+       BAIL_OUT "LTTng modules not detected."
+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
+
+       ok $? "Create session $SESSION_NAME"
+}
+
+function test_kernel_before_start ()
+{
+       diag "Test kernel streaming with event enable BEFORE start"
+       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.
+       diag "Wait 3 seconds for the trace to be written on disk"
+       for i in `seq 1 3`; do
+               sleep 1
+       done
+}
+
+# Deactivated since this feature is not yet available where we can enable
+# an event AFTERE tracing has started.
+function test_kernel_after_start ()
+{
+       diag "Test kernel streaming with event enable AFTER start"
+       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
+}
+
+plan_tests $NUM_TESTS
+
+if [ "$(id -u)" == "0" ]; then
+       isroot=1
+else
+       isroot=0
+fi
+
+skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
+{
+       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
+
+       stop_lttng_sessiond
+       stop_lttng_relayd
+}
diff --git a/tests/regression/tools/streaming/test_uri_switch b/tests/regression/tools/streaming/test_uri_switch
new file mode 100755 (executable)
index 0000000..c340bd5
--- /dev/null
@@ -0,0 +1,215 @@
+#!/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)
+
+NUM_TESTS=186
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+       BAIL_OUT "No UST nevents binary detected. Skipping."
+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
+       ok $? "Create session with uri $URI"
+}
+
+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
+       ok $? "Enable consumer with uri $URI"
+}
+
+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
+{
+       while [ -n "$(pidof $BIN_NAME)" ]; do
+               sleep 0.5
+       done
+       pass "Wait for applications to end"
+}
+
+function test_uri_switch_localhost_folder
+{
+       IPVER=$1
+
+       diag "Test switch of localhost folder ($IPVER)"
+
+       if [ "$IPVER" == "IPv6" ]; then
+           BASE_URI="net6://localhost"
+       else
+           BASE_URI="net://localhost"
+       fi
+
+       RANDCOUNT=10
+       RAND=""
+       i=1
+
+       lttng_create_session $BASE_URI
+
+       while [ "$i" -le $RANDCOUNT ]
+       do
+           RAND=$(randstring 16 0)
+           lttng_enable_consumer "$BASE_URI/$RAND"
+           let "i += 1"
+       done
+
+       pass "Randomize output folder on $BASE_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_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
+
+       diag "Test 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)
+               diag "$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
+       diag "Test 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)
+
+           diag "$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
+}
+
+plan_tests $NUM_TESTS
+
+start_lttng_sessiond
+
+diag "Test 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
+
+diag "Test 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
diff --git a/tests/regression/tools/streaming/test_ust b/tests/regression/tools/streaming/test_ust
new file mode 100755 (executable)
index 0000000..95c833d
--- /dev/null
@@ -0,0 +1,114 @@
+#!/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)
+
+NUM_TESTS=20
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+       BAIL_OUT "No UST nevents binary detected."
+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
+       ok $? "Create session with default path"
+}
+
+function wait_apps
+{
+
+       while [ -n "$(pidof $BIN_NAME)" ]; do
+               sleep 0.5
+       done
+       pass "Wait for applications to end"
+}
+
+# MUST set TESTDIR before calling those functions
+
+function test_ust_before_start ()
+{
+       diag "Test UST streaming BEFORE tracing starts"
+       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 ()
+{
+       diag "Test UST streaming AFTER tracing starts"
+       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
+}
+
+plan_tests $NUM_TESTS
+
+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
+
+stop_lttng_sessiond
+stop_lttng_relayd
+
+exit $out
diff --git a/tests/regression/tools/streaming/tp.c b/tests/regression/tools/streaming/tp.c
new file mode 100644 (file)
index 0000000..a09561d
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * 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"
diff --git a/tests/regression/tools/streaming/tp.h b/tests/regression/tools/streaming/tp.h
new file mode 100644 (file)
index 0000000..6ffbc32
--- /dev/null
@@ -0,0 +1,56 @@
+#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
diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am
new file mode 100644 (file)
index 0000000..d8904bb
--- /dev/null
@@ -0,0 +1,7 @@
+if HAVE_LIBLTTNG_UST_CTL
+SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \
+                 overlap
+
+EXTRA_DIST = runall.sh run-ust-global-tests.sh test_event_basic test_event_wildcard
+
+endif
diff --git a/tests/regression/ust/before-after/Makefile.am b/tests/regression/ust/before-after/Makefile.am
new file mode 100644 (file)
index 0000000..f883a32
--- /dev/null
@@ -0,0 +1,16 @@
+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 = test_before_after
+EXTRA_DIST = test_before_after
diff --git a/tests/regression/ust/before-after/gen-nevents.c b/tests/regression/ust/before-after/gen-nevents.c
new file mode 100644 (file)
index 0000000..b2c1992
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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;
+}
diff --git a/tests/regression/ust/before-after/test_before_after b/tests/regression/ust/before-after/test_before_after
new file mode 100755 (executable)
index 0000000..6a5776e
--- /dev/null
@@ -0,0 +1,117 @@
+#!/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"
+NUM_TESTS=16
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/gen-nevents" ]; then
+       BAIL_OUT "No UST nevents binary detected."
+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
+
+       ./$CURDIR/gen-nevents $NR_ITER
+       ok $? "Start application to trace"
+
+       stop_lttng_tracing $SESSION_NAME
+       destroy_lttng_session $SESSION_NAME
+
+       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+
+       return $?
+}
+
+test_after_apps() {
+       local out
+
+       ./$CURDIR/gen-nevents 100 &
+       ok $? "Start application to trace"
+
+       # 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
+               fail "Trace validation"
+               diag "No event(s) found. We are supposed to have at least one."
+               out=1
+       else
+               pass "Trace validation"
+               diag "Found $out event(s). Coherent."
+               out=0
+       fi
+
+       return $out
+}
+
+# MUST set TESTDIR before calling those functions
+plan_tests $NUM_TESTS
+
+start_lttng_sessiond
+
+diag "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
+
+diag "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
diff --git a/tests/regression/ust/before-after/tp.c b/tests/regression/ust/before-after/tp.c
new file mode 100644 (file)
index 0000000..e291924
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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"
diff --git a/tests/regression/ust/before-after/ust_gen_nevents.h b/tests/regression/ust/before-after/ust_gen_nevents.h
new file mode 100644 (file)
index 0000000..bc09c44
--- /dev/null
@@ -0,0 +1,56 @@
+#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
diff --git a/tests/regression/ust/high-throughput/Makefile.am b/tests/regression/ust/high-throughput/Makefile.am
new file mode 100644 (file)
index 0000000..5446404
--- /dev/null
@@ -0,0 +1,16 @@
+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 = test_high_throughput
+EXTRA_DIST = test_high_throughput
diff --git a/tests/regression/ust/high-throughput/main.c b/tests/regression/ust/high-throughput/main.c
new file mode 100644 (file)
index 0000000..dbd2998
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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;
+}
diff --git a/tests/regression/ust/high-throughput/test_high_throughput b/tests/regression/ust/high-throughput/test_high_throughput
new file mode 100755 (executable)
index 0000000..a801400
--- /dev/null
@@ -0,0 +1,90 @@
+#!/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_APP=20
+BIN_NAME="gen-events"
+SESSION_NAME="high-throughput"
+EVENT_NAME="tp:tptest"
+NUM_TESTS=9
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+       BAIL_OUT "No UST nevents binary detected."
+fi
+
+TRACE_PATH=$(mktemp -d)
+
+# MUST set TESTDIR before calling those functions
+
+plan_tests $NUM_TESTS
+
+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_APP`; do
+       ./$CURDIR/$BIN_NAME & >/dev/null 2>&1
+done
+
+while [ -n "$(pidof $BIN_NAME)" ]; do
+       sleep 0.5
+done
+pass "Wait for application end"
+
+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_APP*1000000
+
+if [ $wanted -ne $total ]; then
+       fail "Trace validation"
+       diag "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total"
+else
+       pass "Trace validation"
+       diag "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total"
+fi
+
+rm -rf $TRACE_PATH
+rm $TEMP_FILE $TEMP_FILE_2
diff --git a/tests/regression/ust/high-throughput/tp.c b/tests/regression/ust/high-throughput/tp.c
new file mode 100644 (file)
index 0000000..1d6cbda
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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"
diff --git a/tests/regression/ust/high-throughput/tp.h b/tests/regression/ust/high-throughput/tp.h
new file mode 100644 (file)
index 0000000..12286b4
--- /dev/null
@@ -0,0 +1,61 @@
+#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
diff --git a/tests/regression/ust/low-throughput/Makefile.am b/tests/regression/ust/low-throughput/Makefile.am
new file mode 100644 (file)
index 0000000..e627060
--- /dev/null
@@ -0,0 +1,16 @@
+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 = test_low_throughput
+EXTRA_DIST = test_low_throughput
diff --git a/tests/regression/ust/low-throughput/main.c b/tests/regression/ust/low-throughput/main.c
new file mode 100644 (file)
index 0000000..06ab9ef
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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;
+}
diff --git a/tests/regression/ust/low-throughput/test_low_throughput b/tests/regression/ust/low-throughput/test_low_throughput
new file mode 100755 (executable)
index 0000000..197210a
--- /dev/null
@@ -0,0 +1,96 @@
+#!/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"
+NUM_TESTS=8
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+       BAIL_OUT "No UST nevents binary detected."
+fi
+
+TRACE_PATH=$(mktemp -d)
+
+# MUST set TESTDIR before calling those functions
+
+plan_tests $NUM_TESTS
+
+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
+                       diag "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
+                               diag "Ten minutes event failed ($val)"
+                               out=1
+                               break
+                       fi
+               fi
+       elif [ $th = '"twenty"' ]; then
+               # Test 20 minutes counter
+               if [ $val -ne 20 ]; then
+                       diag "Twenty minutes event failed ($val)"
+                       out=1
+                       break
+               fi
+       fi
+done
+
+ok $out "Trace validation"
+
+rm -rf $TRACE_PATH
diff --git a/tests/regression/ust/low-throughput/tp.c b/tests/regression/ust/low-throughput/tp.c
new file mode 100644 (file)
index 0000000..1d6cbda
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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"
diff --git a/tests/regression/ust/low-throughput/tp.h b/tests/regression/ust/low-throughput/tp.h
new file mode 100644 (file)
index 0000000..b45a3dd
--- /dev/null
@@ -0,0 +1,45 @@
+#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
diff --git a/tests/regression/ust/multi-session/Makefile.am b/tests/regression/ust/multi-session/Makefile.am
new file mode 100644 (file)
index 0000000..2d978e5
--- /dev/null
@@ -0,0 +1,16 @@
+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 = test_multi_session
+EXTRA_DIST = test_multi_session
diff --git a/tests/regression/ust/multi-session/gen-nevents.c b/tests/regression/ust/multi-session/gen-nevents.c
new file mode 100644 (file)
index 0000000..7add252
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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;
+}
diff --git a/tests/regression/ust/multi-session/test_multi_session b/tests/regression/ust/multi-session/test_multi_session
new file mode 100755 (executable)
index 0000000..ffe8355
--- /dev/null
@@ -0,0 +1,92 @@
+#!/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"
+NUM_TESTS=28
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/gen-nevents" ]; then
+       BAIL_OUT "No UST nevents binary detected."
+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
+
+       ./$CURDIR/gen-nevents $NR_ITER &
+       ok $? "Start application to generate $NR_ITER events"
+
+       # At least hit one event
+       while [ -n "$(pidof gen-nevents)" ]; do
+               sleep 0.1
+       done
+
+       pass "Wait for events to record"
+
+       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
+                       fail "Trace validation of $SESSION_NAME-$i"
+                       diag "No events found."
+                       out=1
+                       break
+               else
+                       pass "Trace validation of $SESSION_NAME-$i"
+                       diag "Found $out event(s) for $SESSION_NAME-$i."
+                       out=0
+               fi
+       done
+
+       return $out
+}
+
+# MUST set TESTDIR before calling those functions
+
+plan_tests $NUM_TESTS
+
+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"
diff --git a/tests/regression/ust/multi-session/tp.c b/tests/regression/ust/multi-session/tp.c
new file mode 100644 (file)
index 0000000..e291924
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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"
diff --git a/tests/regression/ust/multi-session/ust_gen_nevents.h b/tests/regression/ust/multi-session/ust_gen_nevents.h
new file mode 100644 (file)
index 0000000..58e4c17
--- /dev/null
@@ -0,0 +1,68 @@
+#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
diff --git a/tests/regression/ust/nprocesses/Makefile.am b/tests/regression/ust/nprocesses/Makefile.am
new file mode 100644 (file)
index 0000000..3113a34
--- /dev/null
@@ -0,0 +1,16 @@
+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 = test_nprocesses
+EXTRA_DIST = test_nprocesses
diff --git a/tests/regression/ust/nprocesses/gen-events-time.c b/tests/regression/ust/nprocesses/gen-events-time.c
new file mode 100644 (file)
index 0000000..bc5b68c
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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;
+}
diff --git a/tests/regression/ust/nprocesses/test_nprocesses b/tests/regression/ust/nprocesses/test_nprocesses
new file mode 100755 (executable)
index 0000000..e89d02e
--- /dev/null
@@ -0,0 +1,82 @@
+#!/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"
+SESSION_NAME="ust-nprocesses"
+EVENT_NAME="ust_gen_event:tptest"
+TEST_WAIT_SEC=5
+NUM_TESTS=9
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/$TEST_BIN_NAME" ]; then
+       BAIL_OUT "No UST $TEST_BIN_NAME binary detected."
+fi
+
+# MUST set TESTDIR before calling those functions
+
+plan_tests $NUM_TESTS
+
+start_lttng_sessiond
+
+# Start test for 1000 seconds
+
+for i in `seq 1 $NR_ITER`
+do
+       ./$CURDIR/$TEST_BIN_NAME 1000 >/dev/null 2>&1 &
+done
+
+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
+       fail "Trace validation"
+       diag "$reg_app_count apps listed. Expected $NR_ITER "
+else
+       pass "Trace validation"
+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
+
+diag "Sleeping $TEST_WAIT_SEC seconds for tracing to start everywhere"
+diag "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
+
+# Send SIGPIPE to 'silence' bash process status such as "Process as terminated"
+killall -s PIPE -q $TEST_BIN_NAME >/dev/null 2>&1
+
+pass "Kill all spawned applications"
+
+stop_lttng_sessiond
diff --git a/tests/regression/ust/nprocesses/tp.c b/tests/regression/ust/nprocesses/tp.c
new file mode 100644 (file)
index 0000000..438139e
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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"
diff --git a/tests/regression/ust/nprocesses/ust_gen_event.h b/tests/regression/ust/nprocesses/ust_gen_event.h
new file mode 100644 (file)
index 0000000..5bdcb37
--- /dev/null
@@ -0,0 +1,56 @@
+#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
diff --git a/tests/regression/ust/overlap/Makefile.am b/tests/regression/ust/overlap/Makefile.am
new file mode 100644 (file)
index 0000000..5e0a804
--- /dev/null
@@ -0,0 +1,4 @@
+SUBDIRS = demo
+
+noinst_SCRIPTS = test_overlap
+EXTRA_DIST = test_overlap
diff --git a/tests/regression/ust/overlap/demo/Makefile.am b/tests/regression/ust/overlap/demo/Makefile.am
new file mode 100644 (file)
index 0000000..68b6e08
--- /dev/null
@@ -0,0 +1,38 @@
+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
diff --git a/tests/regression/ust/overlap/demo/demo-trace b/tests/regression/ust/overlap/demo/demo-trace
new file mode 100755 (executable)
index 0000000..88a1be7
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+LD_PRELOAD=.libs/liblttng-ust-provider-ust-tests-demo.so:.libs/liblttng-ust-provider-ust-tests-demo3.so ./demo ${*}
diff --git a/tests/regression/ust/overlap/demo/demo.c b/tests/regression/ust/overlap/demo/demo.c
new file mode 100644 (file)
index 0000000..e2b61c2
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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;
+}
diff --git a/tests/regression/ust/overlap/demo/tp.c b/tests/regression/ust/overlap/demo/tp.c
new file mode 100644 (file)
index 0000000..288ce61
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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"
diff --git a/tests/regression/ust/overlap/demo/tp2.c b/tests/regression/ust/overlap/demo/tp2.c
new file mode 100644 (file)
index 0000000..718c9db
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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"
diff --git a/tests/regression/ust/overlap/demo/tp3.c b/tests/regression/ust/overlap/demo/tp3.c
new file mode 100644 (file)
index 0000000..b1babc7
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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"
diff --git a/tests/regression/ust/overlap/demo/ust_tests_demo.h b/tests/regression/ust/overlap/demo/ust_tests_demo.h
new file mode 100644 (file)
index 0000000..3e024b4
--- /dev/null
@@ -0,0 +1,63 @@
+#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
diff --git a/tests/regression/ust/overlap/demo/ust_tests_demo2.h b/tests/regression/ust/overlap/demo/ust_tests_demo2.h
new file mode 100644 (file)
index 0000000..cf4424b
--- /dev/null
@@ -0,0 +1,60 @@
+#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
diff --git a/tests/regression/ust/overlap/demo/ust_tests_demo3.h b/tests/regression/ust/overlap/demo/ust_tests_demo3.h
new file mode 100644 (file)
index 0000000..e58ee86
--- /dev/null
@@ -0,0 +1,45 @@
+#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
diff --git a/tests/regression/ust/overlap/test_overlap b/tests/regression/ust/overlap/test_overlap
new file mode 100755 (executable)
index 0000000..631db84
--- /dev/null
@@ -0,0 +1,672 @@
+#!/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
+
+NUM_TESTS=260
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+if [ ! -x "$CURDIR/demo/demo" ]; then
+       BAIL_OUT "No UST nevents binary detected."
+fi
+
+# MUST set TESTDIR before calling those functions
+
+run_demo_app()
+{
+       cd $CURDIR/demo
+
+       # Start test
+       ./demo-trace >/dev/null 2>&1
+       ok $? "Start application"
+
+       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*"
+
+       diag "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*"
+
+       diag "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*"
+
+       diag "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*"
+
+       diag "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*"
+
+       diag "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"
+
+       diag "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"
+
+       diag "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"
+
+       diag "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"
+
+       diag "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*"
+
+       diag "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*"
+
+       diag "Same wildcard overlap with filter 2"
+
+       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
+
+       # Enabling the same events with same filters should fail
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_wild2" -s $SESSION_NAME -u --filter "1==1" >/dev/null 2>&1
+
+       if [ $? -eq 1 ]; then
+           pass "Enable event $event_name with filtering for session $sess_name twice failure detected"
+       else
+           fail "Enable event $event_name with filtering for session $sess_name twice failure detected"
+       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*"
+
+       diag "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*"
+
+       diag "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"
+
+       diag "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*"
+
+       diag "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"
+
+       diag "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"
+
+       diag "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*"
+
+       diag "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*"
+
+       diag "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"
+
+       diag "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*"
+
+       diag "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"
+
+       diag "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"
+
+       diag "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"
+
+       diag "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 $?
+}
+
+plan_tests $NUM_TESTS
+
+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
diff --git a/tests/regression/ust/run.sh b/tests/regression/ust/run.sh
new file mode 100755 (executable)
index 0000000..79b745c
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+#
+# Copyright (C) 2013 - 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
+# 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.
+#
+
+DIR=$(dirname $0)
+TESTDIR=$DIR/../..
+source $TESTDIR/utils/runner.sh
+
+#### ADD TESTS HERE ####
+
+tests=( $DIR/test_event_basic
+       $DIR/test_event_wildcard
+       $DIR/before-after/test_before_after
+       $DIR/high-throughput/test_high_throughput
+       $DIR/low-throughput/test_low_throughput
+       $DIR/multi-session/test_multi_session
+       $DIR/nprocesses/test_nprocesses
+       $DIR/overlap/test_overlap )
+
+#### END TESTS HERE ####
+
+opts=("$@")
+run_tests tests[@] opts[@]
diff --git a/tests/regression/ust/test_event_basic b/tests/regression/ust/test_event_basic
new file mode 100755 (executable)
index 0000000..5a9cfe4
--- /dev/null
@@ -0,0 +1,118 @@
+#!/bin/bash
+#
+# Copyright (C) - 2013 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="UST tracer - Basic events"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../..
+LTTNG_BIN="lttng"
+BIN_NAME="gen-ust-events"
+SESSION_NAME="valid_filter"
+EVENT_NAME="tp:tptest"
+NUM_TESTS=25
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+function enable_ust_lttng_event_per_chan()
+{
+       sess_name="$1"
+       event_name="$2"
+       chan_name="$3"
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1
+       ok $? "Enable event $event_name for session $sess_name in channel $chan_name"
+}
+
+function disable_ust_lttng_event_per_chan()
+{
+       sess_name="$1"
+       event_name="$2"
+       chan_name="$3"
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1
+       ok $? "Disable event $event_name for session $sess_name in channel $chan_name"
+}
+
+function add_ust_lttng_context()
+{
+       sess_name="$1"
+       chan_name="$2"
+       type="$3"
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $sess_name -c $chan_name -t $type -u >/dev/null 2>&1
+       ok $? "Add context $type for session $sess_name in channel $chan_name"
+}
+
+function test_event_basic()
+{
+       TRACE_PATH=$(mktemp -d)
+       SESSION_NAME="ust_event_basic"
+       SESSION_NAME2="ust_event_basic2"
+       CHAN_NAME="mychan"
+       CHAN_NAME2="mychan2"
+       EVENT_NAME="tp1"
+       EVENT_NAME2="ev2"
+       EVENT_NAME3="ev3"
+
+       create_lttng_session $SESSION_NAME $TRACE_PATH
+       create_lttng_session $SESSION_NAME2 $TRACE_PATH
+
+       enable_ust_lttng_channel $SESSION_NAME $CHAN_NAME
+       enable_ust_lttng_channel $SESSION_NAME2 $CHAN_NAME2
+
+       enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
+       enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME2 $CHAN_NAME
+       enable_ust_lttng_event_per_chan $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
+
+       add_ust_lttng_context $SESSION_NAME $CHAN_NAME "vpid"
+       add_ust_lttng_context $SESSION_NAME $CHAN_NAME "vtid"
+       add_ust_lttng_context $SESSION_NAME $CHAN_NAME "pthread_id"
+       add_ust_lttng_context $SESSION_NAME $CHAN_NAME "procname"
+       add_ust_lttng_context $SESSION_NAME2 $CHAN_NAME2 "procname"
+
+       disable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
+       disable_ust_lttng_event_per_chan $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
+
+       enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
+       enable_ust_lttng_event_per_chan $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
+
+       start_lttng_tracing
+       stop_lttng_tracing
+
+       start_lttng_tracing
+       stop_lttng_tracing
+
+       TODO="Validate trace output is coherent"
+       ok 0 "Validate trace"
+       unset TODO
+
+       destroy_lttng_session $SESSION_NAME2
+       destroy_lttng_session $SESSION_NAME
+
+       rm -rf $TRACE_PATH
+}
+
+# MUST set TESTDIR before calling those functions
+plan_tests $NUM_TESTS
+
+start_lttng_sessiond
+
+test_event_basic
+
+stop_lttng_sessiond
diff --git a/tests/regression/ust/test_event_wildcard b/tests/regression/ust/test_event_wildcard
new file mode 100755 (executable)
index 0000000..88c02b0
--- /dev/null
@@ -0,0 +1,66 @@
+#!/bin/bash
+#
+# Copyright (C) - 2013 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="UST tracer - Event wildcard"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../..
+LTTNG_BIN="lttng"
+BIN_NAME="gen-ust-events"
+SESSION_NAME="valid_filter"
+EVENT_NAME="tp:tptest"
+NUM_TESTS=9
+
+source $TESTDIR/utils/utils.sh
+
+print_test_banner "$TEST_DESC"
+
+function test_event_wildcard()
+{
+       TRACE_PATH=$(mktemp -d)
+       SESSION_NAME="ust_event_basic"
+       SESSION_NAME2="ust_event_basic2"
+       CHAN_NAME="mychan"
+       CHAN_NAME2="mychan2"
+       EVENT_NAME="*"
+       EVENT_NAME2="abc*"
+
+       create_lttng_session $SESSION_NAME $TRACE_PATH
+
+       enable_ust_lttng_event $SESSION_NAME "$EVENT_NAME"
+       enable_ust_lttng_event $SESSION_NAME "$EVENT_NAME2"
+
+       start_lttng_tracing
+       stop_lttng_tracing
+
+       TODO="Validate trace output is coherent"
+       ok 0 "Validate trace"
+       unset TODO
+
+       destroy_lttng_session $SESSION_NAME
+
+       rm -rf $TRACE_PATH
+}
+
+# MUST set TESTDIR before calling those functions
+plan_tests $NUM_TESTS
+
+start_lttng_sessiond
+
+test_event_wildcard
+
+stop_lttng_sessiond
diff --git a/tests/run-report.py b/tests/run-report.py
deleted file mode 100755 (executable)
index acee181..0000000
+++ /dev/null
@@ -1,444 +0,0 @@
-#!/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)
diff --git a/tests/run.sh b/tests/run.sh
new file mode 100755 (executable)
index 0000000..d63c72b
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# Copyright (C) 2013 - 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
+# 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.
+#
+DIR=$(dirname $0)
+
+$DIR/regression/run.sh $@
+$DIR/unit/run.sh $@
diff --git a/tests/runall.sh b/tests/runall.sh
deleted file mode 100755 (executable)
index 0adbb2e..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/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
diff --git a/tests/test_list.py b/tests/test_list.py
deleted file mode 100755 (executable)
index 2a613b9..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-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
-    },
-]
diff --git a/tests/tools/Makefile.am b/tests/tools/Makefile.am
deleted file mode 100644 (file)
index 4fe494c..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-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
diff --git a/tests/tools/filtering/Makefile.am b/tests/tools/filtering/Makefile.am
deleted file mode 100644 (file)
index e1e715d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-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
diff --git a/tests/tools/filtering/babelstats.pl b/tests/tools/filtering/babelstats.pl
deleted file mode 100755 (executable)
index d8d4dd0..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-#!/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);
diff --git a/tests/tools/filtering/gen-ust-events.c b/tests/tools/filtering/gen-ust-events.c
deleted file mode 100644 (file)
index c789c89..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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;
-}
diff --git a/tests/tools/filtering/invalid-filters b/tests/tools/filtering/invalid-filters
deleted file mode 100755 (executable)
index b653705..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-#!/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
diff --git a/tests/tools/filtering/runall b/tests/tools/filtering/runall
deleted file mode 100755 (executable)
index c92e399..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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
diff --git a/tests/tools/filtering/tp.c b/tests/tools/filtering/tp.c
deleted file mode 100644 (file)
index a09561d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * 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"
diff --git a/tests/tools/filtering/tp.h b/tests/tools/filtering/tp.h
deleted file mode 100644 (file)
index 15f81e5..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#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
diff --git a/tests/tools/filtering/unsupported-ops b/tests/tools/filtering/unsupported-ops
deleted file mode 100755 (executable)
index 8b743f4..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/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
diff --git a/tests/tools/filtering/valid-filters b/tests/tools/filtering/valid-filters
deleted file mode 100755 (executable)
index 3d7e921..0000000
+++ /dev/null
@@ -1,417 +0,0 @@
-#!/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
diff --git a/tests/tools/health/Makefile.am b/tests/tools/health/Makefile.am
deleted file mode 100644 (file)
index 26d2461..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-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
diff --git a/tests/tools/health/health_check.c b/tests/tools/health/health_check.c
deleted file mode 100644 (file)
index 3eef110..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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;
-}
diff --git a/tests/tools/health/health_exit.c b/tests/tools/health/health_exit.c
deleted file mode 100644 (file)
index 8e41405..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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);
-       }
-
-