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);
-       }
-
-       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/tools/health/health_fail.c b/tests/tools/health/health_fail.c
deleted file mode 100644 (file)
index 6227825..0000000
+++ /dev/null
@@ -1,69 +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_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/tools/health/health_stall.c b/tests/tools/health/health_stall.c
deleted file mode 100644 (file)
index 127f5fc..0000000
+++ /dev/null
@@ -1,81 +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 <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/tools/health/health_thread_exit b/tests/tools/health/health_thread_exit
deleted file mode 100755 (executable)
index de783ad..0000000
+++ /dev/null
@@ -1,105 +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="Health check - Thread exit"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-LTTNG_BIN="lttng"
-SESSION_NAME="health_thread_exit"
-EVENT_NAME="bogus"
-HEALTH_CHECK_BIN="health_check"
-SESSIOND_PRELOAD=".libs/libhealthexit.so"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
-       echo -e "libhealthexit.so not available for this test. Skipping."
-       exit 0
-fi
-
-function test_thread_exit
-{
-       test_thread_exit_name="$1"
-       test_thread_exit_code="$2"
-
-       echo ""
-       echo -e "=== Testing health failure with ${test_thread_exit_name}"
-
-       # Activate testpoints
-       export LTTNG_TESTPOINT_ENABLE=1
-
-       # Activate specific thread exit
-       export ${test_thread_exit_name}_EXIT=1
-
-       # Spawn sessiond with preload healthexit lib
-       export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD"
-       start_lttng_sessiond
-
-       # Cleanup some env. var.
-       unset LD_PRELOAD
-       unset ${test_thread_exit_name}_EXIT
-
-       # Check initial health status
-       $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
-
-       echo -n "Validating thread ${test_thread_exit_name} failure... "
-
-       # Wait
-       sleep 25
-
-       # Check health status, exit code should indicate failure
-       $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
-
-       health_check_exit_code=$?
-
-       if [ $health_check_exit_code -eq $test_thread_exit_code ]; then
-               print_ok
-               stop_lttng_sessiond
-       else
-               print_fail
-               echo -e "Health returned: $health_check_exit_code\n"
-
-               stop_lttng_sessiond
-               return 1
-       fi
-}
-
-THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
-       "LTTNG_THREAD_MANAGE_APPS"
-       "LTTNG_THREAD_REG_APPS"
-       "LTTNG_THREAD_MANAGE_KERNEL")
-
-# Exit code value to indicate specific thread failure
-EXIT_CODE=(1 2 4 8)
-
-THREAD_COUNT=${#THREAD[@]}
-i=0
-while [ "$i" -lt "$THREAD_COUNT" ]; do
-       test_thread_exit "${THREAD[$i]}" "${EXIT_CODE[$i]}"
-
-       if [ $? -eq 1 ]; then
-               exit 1
-       fi
-
-       let "i++"
-done
-
-# Special case manage consumer, need to spawn consumer via commands.
-#"LTTNG_THREAD_MANAGE_CONSUMER"
diff --git a/tests/tools/health/health_thread_stall b/tests/tools/health/health_thread_stall
deleted file mode 100755 (executable)
index 5fd39ed..0000000
+++ /dev/null
@@ -1,128 +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="Health check - Thread stall"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-LTTNG_BIN="lttng"
-SESSION_NAME="health_thread_stall"
-EVENT_NAME="bogus"
-HEALTH_CHECK_BIN="health_check"
-SESSIOND_PRELOAD=".libs/libhealthstall.so"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
-       echo -e "libhealthstall.so not available for this test. Skipping."
-       exit 0
-fi
-
-function test_thread_stall
-{
-       test_thread_stall_name="$1"
-       test_thread_exit_code="$2"
-
-       echo ""
-       echo -e "=== Testing health failure with ${test_thread_stall_name}"
-
-       # Activate testpoints
-       export LTTNG_TESTPOINT_ENABLE=1
-
-       # Activate specific thread exit
-       export ${test_thread_stall_name}_STALL=1
-
-       # Spawn sessiond with preload healthexit lib
-       export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD"
-       start_lttng_sessiond
-
-       # Cleanup some env. var.
-       unset LD_PRELOAD
-       unset ${test_thread_stall_name}_STALL
-
-       # Check initial health status
-       $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
-
-       echo -n "Validating that ${test_thread_stall_name} is stalled... "
-
-       # Wait
-       sleep 25
-
-       # Check health status, exit code should indicate failure
-       $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
-
-       health_check_exit_code=$?
-
-       if [ $health_check_exit_code -eq $test_thread_exit_code ]; then
-               print_ok
-       else
-               print_fail
-               echo -e "Health returned: $health_check_exit_code\n"
-
-               stop_lttng_sessiond
-               return 1
-       fi
-
-       echo -n "Validating that ${test_thread_stall_name} is no longer stalled... "
-
-       # Wait
-       sleep 40
-
-       # Check health status, exit code should now pass
-       $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
-
-       health_check_exit_code=$?
-
-       if [ $health_check_exit_code -eq 0 ]; then
-               print_ok
-               stop_lttng_sessiond
-       else
-               print_fail
-               echo -e "Health returned: $health_check_exit_code\n"
-               stop_lttng_sessiond
-               return 1
-       fi
-
-
-}
-
-THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
-       "LTTNG_THREAD_MANAGE_APPS"
-# This thread is a little bit tricky to stall,
-# need to send some commands and setup an app.
-#      "LTTNG_THREAD_REG_APPS"
-       "LTTNG_THREAD_MANAGE_KERNEL")
-
-# Exit code value to indicate specific thread failure
-EXIT_CODE=(1
-          2
-#         4
-          8)
-
-THREAD_COUNT=${#THREAD[@]}
-i=0
-while [ "$i" -lt "$THREAD_COUNT" ]; do
-       test_thread_stall "${THREAD[$i]}" "${EXIT_CODE[$i]}"
-
-       if [ $? -eq 1 ]; then
-               exit 1
-       fi
-
-       let "i++"
-done
diff --git a/tests/tools/health/health_tp_fail b/tests/tools/health/health_tp_fail
deleted file mode 100755 (executable)
index 5b68e62..0000000
+++ /dev/null
@@ -1,98 +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="Health check - Testpoint failure"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-LTTNG_BIN="lttng"
-SESSION_NAME="health_tp_fail"
-EVENT_NAME="bogus"
-HEALTH_CHECK_BIN="health_check"
-SESSIOND_PRELOAD=".libs/libhealthtpfail.so"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
-       echo -e "libhealthtpfail.so not available for this test. Skipping."
-       exit 0
-fi
-
-function test_tp_fail
-{
-       test_tp_fail_name="$1"
-       test_tp_fail_code="$2"
-
-       echo ""
-       echo -e "=== Testing health failure with ${test_tp_fail_name}"
-
-       # Activate testpoints
-       export LTTNG_TESTPOINT_ENABLE=1
-
-       # Activate specific testpoint failure
-       export ${test_tp_fail_name}_TP_FAIL=1
-
-       # Spawn sessiond with preload healthexit lib
-       export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD"
-       start_lttng_sessiond
-
-       # Cleanup some env. var.
-       unset LD_PRELOAD
-       unset ${test_tp_fail_name}_TP_FAIL
-
-       echo -n "Validating thread ${test_tp_fail_name} failure... "
-
-       # Check health status, exit code should indicate failure
-       $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
-
-       health_check_exit_code=$?
-
-       if [ $health_check_exit_code -eq $test_tp_fail_code ]; then
-               print_ok
-               stop_lttng_sessiond
-       else
-               print_fail
-               echo -e "Health returned: $health_check_exit_code\n"
-
-               stop_lttng_sessiond
-               return 1
-       fi
-}
-
-THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
-       "LTTNG_THREAD_MANAGE_APPS"
-       "LTTNG_THREAD_MANAGE_KERNEL")
-
-# Exit code value to indicate specific thread failure
-EXIT_CODE=(1 2 8)
-
-THREAD_COUNT=${#THREAD[@]}
-i=0
-while [ "$i" -lt "$THREAD_COUNT" ]; do
-       test_tp_fail "${THREAD[$i]}" "${EXIT_CODE[$i]}"
-
-       if [ $? -eq 1 ]; then
-               exit 1
-       fi
-
-       let "i++"
-done
-
-# Special case manage consumer, need to spawn consumer via commands.
-#"LTTNG_THREAD_MANAGE_CONSUMER"
diff --git a/tests/tools/health/runall b/tests/tools/health/runall
deleted file mode 100755 (executable)
index d1c8b34..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-
-DIR=$(dirname $0)
-
-tests=( $DIR/health_thread_exit $DIR/health_thread_stall $DIR/health_tp_fail)
-exit_code=0
-
-function start_tests ()
-{
-       for bin in ${tests[@]};
-       do
-               if [ ! -e $bin ]; then
-                       echo -e "$bin not found, passing"
-                       continue
-               fi
-
-               ./$bin
-               # Test must return 0 to pass.
-               if [ $? -ne 0 ]; then
-                       exit_code=1
-                       break
-               fi
-       done
-}
-
-if [ "$(id -u)" != "0" ]; then
-       echo -e "Need root for health test."
-       exit 0
-fi
-
-start_tests
-
-exit $exit_code
diff --git a/tests/tools/runall.sh b/tests/tools/runall.sh
deleted file mode 100755 (executable)
index b2be91c..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-
-DIR=$(dirname $0)
-
-tests=( $DIR/test_kernel_data_trace $DIR/test_sessions $DIR/test_ust_data_trace \
-               $DIR/streaming/runall $DIR/health/runall $DIR/filtering/runall)
-
-exit_code=0
-
-function start_tests ()
-{
-    for bin in ${tests[@]};
-    do
-               if [ ! -e $bin ]; then
-                       echo -e "$bin not found, passing"
-                       continue
-               fi
-
-        ./$bin
-        # Test must return 0 to pass.
-        if [ $? -ne 0 ]; then
-            exit_code=1
-            break
-        fi
-    done
-}
-
-start_tests
-
-exit $exit_code
diff --git a/tests/tools/streaming/Makefile.am b/tests/tools/streaming/Makefile.am
deleted file mode 100644 (file)
index 3ff8ef0..0000000
+++ /dev/null
@@ -1,27 +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
-
-#UTILS=../../utils.h
-UTILS=
-LIBSESSIOND_COMM=$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la
-LIBCOMMON=$(top_builddir)/src/common/libcommon.la
-
-noinst_PROGRAMS = unit_tests
-unit_tests_SOURCES = unit_tests.c $(UTILS)
-unit_tests_LDADD = $(LIBCOMMON)
-
-if HAVE_LIBLTTNG_UST_CTL
-noinst_PROGRAMS += gen-ust-events
-gen_ust_events_SOURCES = gen-ust-events.c tp.c tp.h
-gen_ust_events_LDADD = -llttng-ust
-endif
-
-noinst_SCRIPTS = runall run-ust run-kernel uri_switch
-EXTRA_DIST = runall run-ust run-kernel uri_switch
diff --git a/tests/tools/streaming/gen-ust-events.c b/tests/tools/streaming/gen-ust-events.c
deleted file mode 100644 (file)
index 1385119..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";
-       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/tools/streaming/high_throughput_limits b/tests/tools/streaming/high_throughput_limits
deleted file mode 100755 (executable)
index 627cb5c..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
-#                      David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-
-TEST_DESC="Streaming - High throughput with bandwidth limits"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-NR_APP_ITER=10
-NR_ITER=1000000
-BIN_NAME="gen-ust-events"
-SESSION_NAME="high-throughput"
-EVENT_NAME="tp:tptest"
-SESSIOND_CTRL_PORT=5342
-SESSIOND_DATA_PORT=5343
-DEFAULT_IF="lo"
-
-TRACE_PATH=$(mktemp -d)
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/$BIN_NAME" ]; then
-       echo -e "No UST nevents binary detected. Passing."
-       exit 0
-fi
-
-if [ "$(id -u)" != "0" ]; then
-       echo "This test must be running as root to set bandwidth limits. Aborting"
-       # Exit status 0 so the tests can continue
-       exit 0
-fi
-
-function set_bw_limit
-{
-       limit=$1
-       ctrlportlimit=$(($limit/10))
-       # failsafe to have at least 1kbit/s for control (in the case where $1 < 10)
-       [ $ctrlportlimit = 0 ] && ctrlportlimit=1
-       # if $1 < 10, we might bust the limit set here, but the
-       # parent qdisc (1:) will always limit us to the right max value
-       dataportlimit=$((9*${ctrlportlimit}))
-
-       echo -n "Setting bandwidth limits to ${limit}kbits, (${ctrlportlimit} for control and ${dataportlimit} for data)... "
-       tc qdisc add dev $DEFAULT_IF root handle 1: htb default 15 >/dev/null 2>&1
-
-       # the total bandwidth is the limit set by the user
-       tc class add dev $DEFAULT_IF parent 1: classid 1:1 htb rate ${limit}kbit ceil ${limit}kbit >/dev/null 2>&1
-       # 1/10 of the bandwidth guaranteed and traffic prioritized for the control port
-       tc class add dev $DEFAULT_IF parent 1:1 classid 1:10 htb rate ${ctrlportlimit}kbit ceil ${limit}kbit prio 1 >/dev/null 2>&1
-       # 9/10 of the bandwidth guaranteed and can borrow up to the total bandwidth (if unused)
-       tc class add dev $DEFAULT_IF parent 1:1 classid 1:11 htb rate ${dataportlimit}kbit ceil ${limit}kbit prio 2 >/dev/null 2>&1
-
-       # filter to assign control traffic to the 1:10 class
-       tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_CTRL_PORT 0xffff flowid 1:10 >/dev/null 2>&1
-       # filter to assign data traffic to the 1:11 class
-       tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_DATA_PORT 0xffff flowid 1:11 >/dev/null 2>&1
-       print_ok
-}
-
-function reset_bw_limit
-{
-       echo -n "Resetting bandwidth limits... "
-       tc qdisc del dev $DEFAULT_IF root >/dev/null 2>&1
-       print_ok
-}
-
-function create_lttng_session_with_uri
-{
-       sess_name=$1
-       uri=$2
-       # Create session with custom URI
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN create -U $uri $sess_name >/dev/null 2>&1
-}
-
-function run_apps
-{
-       for i in `seq 1 $NR_APP_ITER`; do
-               # With bandwidth limitation, unfortunately, application easily timeout
-               # due to very slow communication between the consumer and relayd making
-               # the status reply from the consumer quite slow thus delaying the
-               # registration done message.
-               LTTNG_UST_REGISTER_TIMEOUT=-1 ./$CURDIR/$BIN_NAME $NR_ITER & >/dev/null 2>&1
-       done
-}
-
-function wait_apps
-{
-       echo "Waiting for applications to end"
-       while [ -n "$(pidof $BIN_NAME)" ]; do
-               echo -n "."
-               sleep 1
-       done
-       echo ""
-}
-
-function test_high_throughput
-{
-       NETWORK_URI="net://localhost"
-       create_lttng_session_with_uri $SESSION_NAME $NETWORK_URI
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-       start_lttng_tracing $SESSION_NAME
-       run_apps
-       wait_apps
-
-       stop_lttng_tracing $SESSION_NAME
-       destroy_lttng_session $SESSION_NAME
-       validate_event_count
-}
-
-function validate_event_count
-{
-
-       TEMP_FILE=$(mktemp)
-       TEMP_FILE_2=$(mktemp)
-
-       traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l)
-       babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2
-
-       cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE
-
-       dropped=0
-       while read line;
-       do
-               let dropped=$dropped+$line
-       done < $TEMP_FILE
-
-       let total=$dropped+$traced
-       let wanted=$NR_APP_ITER*$NR_ITER
-
-       if [ $wanted -ne $total ]; then
-               echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
-               print_fail
-               return 1
-       else
-               echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
-               print_ok
-
-               # Cleanup only if everything is ok and passes.
-               rm -rf $TRACE_PATH
-               rm $TEMP_FILE $TEMP_FILE_2
-
-               return 0
-       fi
-}
-
-function interrupt_cleanup()
-{
-       echo -en "\n*** Exiting ***\n"
-       stop_lttng_relayd
-       stop_lttng_sessiond
-       reset_bw_limit
-       exit 1
-}
-
-# Catch sigint and try to cleanup limits
-trap interrupt_cleanup SIGINT
-
-BW_LIMITS=(3200 1600 800 400 200 100 50 25)
-for BW in ${BW_LIMITS[@]};
-do
-       echo ""
-       echo -e "=== Testing high-throughput with bandwidth limit set to ${BW}kbits"
-       set_bw_limit $BW
-
-       start_lttng_sessiond
-       start_lttng_relayd "-o $TRACE_PATH"
-       test_high_throughput
-       result=$?
-       stop_lttng_relayd
-       stop_lttng_sessiond
-       reset_bw_limit
-
-       if [ $result -ne 0 ]; then
-               exit 1
-       fi
-done
diff --git a/tests/tools/streaming/run-kernel b/tests/tools/streaming/run-kernel
deleted file mode 100755 (executable)
index 545cae7..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-TEST_DESC="Streaming - Kernel tracing"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-EVENT_NAME="sched_switch"
-PID_RELAYD=0
-SESSION_NAME=""
-
-TRACE_PATH=$(mktemp -d)
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ "$(id -u)" != "0" ]; then
-       echo "This test must be running as root. Aborting"
-       # Exit status 0 so the tests can continue
-       exit 0
-fi
-
-# LTTng kernel modules check
-out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
-if [ -z "$out" ]; then
-       echo "LTTng modules not detected. Aborting kernel tests!"
-       echo ""
-       # Exit status 0 so the tests can continue
-       exit 0
-fi
-
-function lttng_create_session_uri
-{
-       echo -n "Creating session $SESSION_NAME... "
-       # Create session with default path
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
-       if [ $? -eq 1 ]; then
-               print_fail
-               return 1
-       else
-               print_ok
-       fi
-}
-
-function test_kernel_before_start ()
-{
-       echo -e "\n=== Testing kernel streaming with event enable BEFORE start\n"
-       lttng_create_session_uri
-       lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
-       start_lttng_tracing $SESSION_NAME
-       # Give a second
-       sleep 1
-       stop_lttng_tracing $SESSION_NAME
-       destroy_lttng_session $SESSION_NAME
-
-       # We can not predict _yet_ when the trace is available so we have to do a
-       # arbitratry sleep to validate the trace.
-       echo -n "Waiting 3 seconds for the trace to be written on disk "
-       for i in `seq 1 3`; do
-               echo -n "."
-               sleep 1
-       done
-       echo ""
-}
-
-# Deactivated since this feature is not yet available where we can enable
-# an event AFTERE tracing has started.
-function test_kernel_after_start ()
-{
-       echo -e "\n=== Testing kernel streaming with event enable AFTER start\n"
-       lttng_create_session_uri
-       start_lttng_tracing $SESSION_NAME
-       lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
-       # Give a second
-       sleep 1
-       stop_lttng_tracing $SESSION_NAME
-       destroy_lttng_session $SESSION_NAME
-}
-
-start_lttng_sessiond
-start_lttng_relayd "-o $TRACE_PATH"
-
-tests=( test_kernel_before_start )
-
-for fct_test in ${tests[@]};
-do
-       SESSION_NAME=$(randstring 16 0)
-       ${fct_test}
-
-       # Validate test
-       validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
-       if [ $? -eq 0 ]; then
-               # Only delete if successful
-               rm -rf $TRACE_PATH
-       else
-               break
-       fi
-done
-
-echo ""
-stop_lttng_sessiond
-stop_lttng_relayd
-
-
-exit $out
diff --git a/tests/tools/streaming/run-ust b/tests/tools/streaming/run-ust
deleted file mode 100755 (executable)
index 28b72f8..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-TEST_DESC="Streaming - User space tracing"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-BIN_NAME="gen-ust-events"
-SESSION_NAME="stream"
-EVENT_NAME="tp:tptest"
-PID_RELAYD=0
-
-TRACE_PATH=$(mktemp -d)
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/$BIN_NAME" ]; then
-       echo -e "No UST nevents binary detected. Passing."
-       exit 0
-fi
-
-function lttng_create_session_uri
-{
-       # Create session with default path
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
-}
-
-function wait_apps
-{
-       echo -n "Waiting for applications to end"
-       while [ -n "$(pidof $BIN_NAME)" ]; do
-               echo -n "."
-               sleep 0.5
-       done
-       echo ""
-}
-
-# MUST set TESTDIR before calling those functions
-
-function test_ust_before_start ()
-{
-       echo -e "\n=== Testing UST streaming BEFORE tracing starts\n"
-       lttng_create_session_uri
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-
-       # Run 5 times with a 1 second delay
-       ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 &
-
-       start_lttng_tracing $SESSION_NAME
-
-       wait_apps
-       stop_lttng_tracing $SESSION_NAME
-       destroy_lttng_session $SESSION_NAME
-}
-
-function test_ust_after_start ()
-{
-       echo -e "\n=== Testing UST streaming AFTER tracing starts\n"
-       lttng_create_session_uri
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-       start_lttng_tracing $SESSION_NAME
-
-       # Run 5 times with a 1 second delay
-       ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 &
-
-       wait_apps
-       stop_lttng_tracing $SESSION_NAME
-       destroy_lttng_session $SESSION_NAME
-}
-
-start_lttng_sessiond
-start_lttng_relayd "-o $TRACE_PATH"
-
-tests=( test_ust_before_start test_ust_after_start )
-
-for fct_test in ${tests[@]};
-do
-       SESSION_NAME=$(randstring 16 0)
-       ${fct_test}
-
-       # Validate test
-       validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
-       if [ $? -eq 0 ]; then
-               # Only delete if successful
-               rm -rf $TRACE_PATH
-       else
-               break
-       fi
-done
-
-echo ""
-stop_lttng_sessiond
-stop_lttng_relayd
-
-exit $out
diff --git a/tests/tools/streaming/runall b/tests/tools/streaming/runall
deleted file mode 100755 (executable)
index dbf5228..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-
-DIR=$(dirname $0)
-
-tests=( $DIR/unit_tests $DIR/run-kernel $DIR/run-ust )
-exit_code=0
-
-function start_tests ()
-{
-    for bin in ${tests[@]};
-    do
-               if [ ! -e $bin ]; then
-                       echo -e "$bin not found, passing"
-                       continue
-               fi
-
-        ./$bin
-        # Test must return 0 to pass.
-        if [ $? -ne 0 ]; then
-            exit_code=1
-            break
-        fi
-    done
-}
-
-start_tests
-
-exit $exit_code
diff --git a/tests/tools/streaming/tp.c b/tests/tools/streaming/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/streaming/tp.h b/tests/tools/streaming/tp.h
deleted file mode 100644 (file)
index 6ffbc32..0000000
+++ /dev/null
@@ -1,56 +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,
-               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/tools/streaming/unit_tests.c b/tests/tools/streaming/unit_tests.c
deleted file mode 100644 (file)
index d00e34d..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by as
- * published by the Free Software Foundation; only version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#define _GNU_SOURCE
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
-#include <sys/types.h>
-
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/uri.h>
-
-#include "utils.h"
-
-/* This path will NEVER be created in this test */
-#define PATH1 "tmp/.test-junk-lttng"
-
-#define RANDOM_STRING_LEN 16
-
-/* For lttngerr.h */
-int lttng_opt_quiet = 1;
-int lttng_opt_verbose = 3;
-
-/*
- * Test string URI and if uri_parse works well.
- */
-void test_uri_parsing(void)
-{
-       ssize_t size;
-       const char *s_uri1;
-       struct lttng_uri *uri;
-
-       fprintf(stdout, "Testing URIs...\n");
-
-       s_uri1 = "net://localhost";
-       fprintf(stdout, " [+] URI set to %s ", s_uri1);
-       size = uri_parse(s_uri1, &uri);
-       assert(size == 2);
-       assert(uri[0].dtype == LTTNG_DST_IPV4);
-       assert(uri[0].utype == LTTNG_URI_DST);
-       assert(uri[0].stype == 0);
-       assert(uri[0].port == 0);
-       assert(strlen(uri[0].subdir) == 0);
-       assert(strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0);
-
-       assert(uri[1].dtype == LTTNG_DST_IPV4);
-       assert(uri[1].utype == LTTNG_URI_DST);
-       assert(uri[1].stype == 0);
-       assert(uri[1].port == 0);
-       assert(strlen(uri[1].subdir) == 0);
-       assert(strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0);
-       PRINT_OK();
-       uri_free(uri);
-
-       s_uri1 = "net://localhost:8989:4242/my/test/path";
-       fprintf(stdout, " [+] URI set to %s ", s_uri1);
-       size = uri_parse(s_uri1, &uri);
-       assert(size == 2);
-       assert(uri[0].dtype == LTTNG_DST_IPV4);
-       assert(uri[0].utype == LTTNG_URI_DST);
-       assert(uri[0].stype == 0);
-       assert(uri[0].port == 8989);
-       assert(strcmp(uri[0].subdir, "my/test/path") == 0);
-       assert(strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0);
-
-       assert(uri[1].dtype == LTTNG_DST_IPV4);
-       assert(uri[1].utype == LTTNG_URI_DST);
-       assert(uri[1].stype == 0);
-       assert(uri[1].port == 4242);
-       assert(strcmp(uri[0].subdir, "my/test/path") == 0);
-       assert(strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0);
-       PRINT_OK();
-       uri_free(uri);
-
-       s_uri1 = "net://localhost:8989:4242";
-       fprintf(stdout, " [+] URI set to %s ", s_uri1);
-       size = uri_parse(s_uri1, &uri);
-       assert(size == 2);
-       assert(uri[0].dtype == LTTNG_DST_IPV4);
-       assert(uri[0].utype == LTTNG_URI_DST);
-       assert(uri[0].stype == 0);
-       assert(uri[0].port == 8989);
-       assert(strlen(uri[1].subdir) == 0);
-       assert(strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0);
-
-       assert(uri[1].dtype == LTTNG_DST_IPV4);
-       assert(uri[1].utype == LTTNG_URI_DST);
-       assert(uri[1].stype == 0);
-       assert(uri[1].port == 4242);
-       assert(strlen(uri[1].subdir) == 0);
-       assert(strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0);
-       PRINT_OK();
-       uri_free(uri);
-
-       s_uri1 = "net6://localhost:8989";
-       fprintf(stdout, " [+] URI set to %s ", s_uri1);
-       size = uri_parse(s_uri1, &uri);
-       assert(size == 2);
-       assert(uri[0].dtype == LTTNG_DST_IPV6);
-       assert(uri[0].utype == LTTNG_URI_DST);
-       assert(uri[0].stype == 0);
-       assert(uri[0].port == 8989);
-       assert(strlen(uri[1].subdir) == 0);
-       assert(strcmp(uri[0].dst.ipv6, "::1") == 0);
-
-       assert(uri[1].dtype == LTTNG_DST_IPV6);
-       assert(uri[1].utype == LTTNG_URI_DST);
-       assert(uri[1].stype == 0);
-       assert(uri[1].port == 0);
-       assert(strlen(uri[1].subdir) == 0);
-       assert(strcmp(uri[0].dst.ipv6, "::1") == 0);
-       PRINT_OK();
-       uri_free(uri);
-
-       s_uri1 = "tcp://42.42.42.42/my/test/path";
-       fprintf(stdout, " [+] URI set to %s ", s_uri1);
-       size = uri_parse(s_uri1, &uri);
-       assert(size == 1);
-       assert(uri[0].dtype == LTTNG_DST_IPV4);
-       assert(uri[0].utype == LTTNG_URI_DST);
-       assert(uri[0].stype == 0);
-       assert(uri[0].port == 0);
-       assert(strcmp(uri[0].subdir, "my/test/path") == 0);
-       assert(strcmp(uri[0].dst.ipv4, "42.42.42.42") == 0);
-       PRINT_OK();
-       uri_free(uri);
-
-       s_uri1 = "tcp6://[fe80::f66d:4ff:fe53:d220]/my/test/path";
-       fprintf(stdout, " [+] URI set to %s ", s_uri1);
-       size = uri_parse(s_uri1, &uri);
-       assert(size == 1);
-       assert(uri[0].dtype == LTTNG_DST_IPV6);
-       assert(uri[0].utype == LTTNG_URI_DST);
-       assert(uri[0].stype == 0);
-       assert(uri[0].port == 0);
-       assert(strcmp(uri[0].subdir, "my/test/path") == 0);
-       assert(strcmp(uri[0].dst.ipv6, "fe80::f66d:4ff:fe53:d220") == 0);
-       PRINT_OK();
-       uri_free(uri);
-
-       s_uri1 = "file:///my/test/path";
-       fprintf(stdout, " [+] URI set to %s ", s_uri1);
-       size = uri_parse(s_uri1, &uri);
-       assert(size == 1);
-       assert(uri[0].dtype == LTTNG_DST_PATH);
-       assert(uri[0].utype == LTTNG_URI_DST);
-       assert(uri[0].stype == 0);
-       assert(uri[0].port == 0);
-       assert(strlen(uri[0].subdir) == 0);
-       assert(strcmp(uri[0].dst.path, "/my/test/path") == 0);
-       PRINT_OK();
-       uri_free(uri);
-
-       s_uri1 = "file/my/test/path";
-       fprintf(stdout, " [+] Bad URI set to %s ", s_uri1);
-       size = uri_parse(s_uri1, &uri);
-       assert(size == -1);
-       PRINT_OK();
-
-       s_uri1 = "net://:8999";
-       fprintf(stdout, " [+] Bad URI set to %s ", s_uri1);
-       size = uri_parse(s_uri1, &uri);
-       assert(size == -1);
-       PRINT_OK();
-}
-
-void test_uri_cmp()
-{
-       struct lttng_uri *uri1, *uri2;
-       const char *s_uri1 = "net://localhost";
-       const char *s_uri2 = "net://localhost:8989:4242";
-       ssize_t size1, size2;
-       int res;
-
-       size1 = uri_parse(s_uri1, &uri1);
-
-       /* Sanity checks */
-       assert(size1 == 2);
-       assert(uri1[0].dtype == LTTNG_DST_IPV4);
-       assert(uri1[0].utype == LTTNG_URI_DST);
-       assert(uri1[0].stype == 0);
-       assert(uri1[0].port == 0);
-       assert(strlen(uri1[0].subdir) == 0);
-       assert(strcmp(uri1[0].dst.ipv4, "127.0.0.1") == 0);
-       assert(uri1[1].dtype == LTTNG_DST_IPV4);
-       assert(uri1[1].utype == LTTNG_URI_DST);
-       assert(uri1[1].stype == 0);
-       assert(uri1[1].port == 0);
-       assert(strlen(uri1[1].subdir) == 0);
-       assert(strcmp(uri1[1].dst.ipv4, "127.0.0.1") == 0);
-
-       size2 = uri_parse(s_uri2, &uri2);
-
-       assert(size2 == 2);
-       assert(uri2[0].dtype == LTTNG_DST_IPV4);
-       assert(uri2[0].utype == LTTNG_URI_DST);
-       assert(uri2[0].stype == 0);
-       assert(uri2[0].port == 8989);
-       assert(strlen(uri2[1].subdir) == 0);
-       assert(strcmp(uri2[0].dst.ipv4, "127.0.0.1") == 0);
-       assert(uri2[1].dtype == LTTNG_DST_IPV4);
-       assert(uri2[1].utype == LTTNG_URI_DST);
-       assert(uri2[1].stype == 0);
-       assert(uri2[1].port == 4242);
-       assert(strlen(uri2[1].subdir) == 0);
-       assert(strcmp(uri2[1].dst.ipv4, "127.0.0.1") == 0);
-
-
-       res = uri_compare(uri1, uri1);
-       fprintf(stdout, " [+] %s == %s ", s_uri1, s_uri1);
-       assert(res == 0);
-       PRINT_OK();
-
-       res = uri_compare(uri1, uri2);
-       fprintf(stdout, " [+] %s != %s ", s_uri1, s_uri2);
-       assert(res != 0);
-       PRINT_OK();
-
-       uri_free(uri1);
-       uri_free(uri2);
-}
-
-int main(int argc, char **argv)
-{
-       srand(time(NULL));
-
-       printf("\nStreaming unit tests\n-----------\n");
-
-       /* URI tests */
-       test_uri_parsing();
-       test_uri_cmp();
-
-       return 0;
-}
diff --git a/tests/tools/streaming/uri_switch b/tests/tools/streaming/uri_switch
deleted file mode 100755 (executable)
index 4eb4359..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
-#                      David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-TEST_DESC="Streaming - URI switching"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-BIN_NAME="gen-ust-events"
-SESSION_NAME="stream"
-EVENT_NAME="tp:tptest"
-PID_RELAYD=0
-
-TRACE_PATH=$(mktemp -d)
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/$BIN_NAME" ]; then
-       echo -e "No UST nevents binary detected. Skipping."
-       exit 0
-fi
-
-function lttng_create_session
-{
-       URI=$1
-       # Create session with custom URI
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN create -U $URI $SESSION_NAME >/dev/null 2>&1
-}
-
-function lttng_enable_consumer
-{
-       URI=$1
-       # Create session with custom URI
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u $URI >/dev/null 2>&1
-}
-
-function run_apps
-{
-    # Run 5 times with a 1 second delay
-    COUNT=5
-    APP_DELAY=1000000
-    ./$CURDIR/$BIN_NAME $COUNT $APP_DELAY >/dev/null 2>&1 &
-
-}
-
-function wait_apps
-{
-       echo -n "Waiting for applications to end"
-       while [ -n "$(pidof $BIN_NAME)" ]; do
-               echo -n "."
-               sleep 0.5
-       done
-       echo ""
-}
-
-function test_uri_switch_localhost_folder
-{
-       IPVER=$1
-       echo -e "\n=== Testing switch of localhost folder ($IPVER)\n"
-
-       if [ "$IPVER" == "IPv6" ]; then
-           BASE_URI="net6://localhost"
-       else
-           BASE_URI="net://localhost"
-       fi
-
-       RANDCOUNT=10
-       RAND=""
-       i=1
-
-       lttng_create_session $BASE_URI
-
-       echo -e "Randomizing output folder on $BASE_URI..."
-       while [ "$i" -le $RANDCOUNT ]
-       do
-           RAND=$(randstring 16 0)
-           lttng_enable_consumer "$BASE_URI/$RAND"
-           let "i += 1"
-       done
-
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-       start_lttng_tracing $SESSION_NAME
-       run_apps
-       wait_apps
-       stop_lttng_tracing $SESSION_NAME
-       destroy_lttng_session $SESSION_NAME
-       validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$RAND
-
-       if [ $? -eq 0 ]; then
-       # Only delete if successful
-           rm -rf $TRACE_PATH
-       fi
-}
-
-function test_uri_switch_file_network
-{
-       IPVER=$1
-       echo ""
-       echo -e "=== Testing switch file -> network ($IPVER)"
-
-       TMP_PATH=$(mktemp -d)
-       FILE_URI="file://$TMP_PATH"
-
-       if [ "$IPVER" == "IPv6" ]; then
-           NETWORK_URIS=("net6://localhost" "net6://[::1]")
-       else
-           NETWORK_URIS=("net://localhost" "net://127.0.0.1")
-       fi
-
-       NET_PATHS=("foo/bar" "OohEehOohAhAahTingTangWallaWallaBingBang" ".")
-
-       for NETWORK_URI in ${NETWORK_URIS[@]};
-       do
-           for NET_PATH in ${NET_PATHS[@]};
-           do
-               SESSION_NAME=$(randstring 16 0)
-               echo ""
-               echo "$FILE_URI -> $NETWORK_URI/$NET_PATH"
-
-               lttng_create_session $FILE_URI
-               lttng_enable_consumer "$NETWORK_URI/$NET_PATH"
-               enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-               start_lttng_tracing $SESSION_NAME
-               run_apps
-               wait_apps
-               stop_lttng_tracing $SESSION_NAME
-               destroy_lttng_session $SESSION_NAME
-               validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$NET_PATH
-
-               if [ $? -eq 0 ]; then
-               # Only delete if successful
-                   rm -rf $TRACE_PATH
-               else
-                   break
-               fi
-           done
-       done
-       rm -rf $TMP_PATH
-}
-
-function test_uri_switch_network_file
-{
-IPVER=$1
-       echo ""
-       echo -e "=== Testing switch network ($IPVER) -> file"
-
-       if [ "$IPVER" == "IPv6" ]; then
-           NETWORK_URI="net6://localhost"
-       else
-           NETWORK_URI="net://localhost"
-       fi
-
-       FILE_PATHS=("." "foo/bar" "42")
-
-       for FILE_PATH in ${FILE_PATHS[@]};
-       do
-           TMP_PATH=$(mktemp -d)
-           FILE_URI="file://$TMP_PATH"
-           SESSION_NAME=$(randstring 16 0)
-
-           echo ""
-           echo "$NETWORK_URI -> $FILE_URI/$FILE_PATH"
-
-           lttng_create_session $NETWORK_URI
-           lttng_enable_consumer "$FILE_URI/$FILE_PATH"
-           enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-           start_lttng_tracing $SESSION_NAME
-           run_apps
-           wait_apps
-           stop_lttng_tracing $SESSION_NAME
-           destroy_lttng_session $SESSION_NAME
-           validate_trace $EVENT_NAME $TMP_PATH/$FILE_PATH
-
-           if [ $? -eq 0 ]; then
-                       # Only delete if successful
-                       rm -rf $TMP_PATH
-           else
-                       break
-           fi
-       done
-}
-
-
-start_lttng_sessiond
-
-echo ""
-echo "=== Testing with IPv4"
-start_lttng_relayd "-o $TRACE_PATH"
-test_uri_switch_localhost_folder "IPv4"
-test_uri_switch_file_network "IPv4"
-test_uri_switch_network_file "IPv4"
-stop_lttng_relayd
-
-echo ""
-echo "=== Testing with IPv6"
-start_lttng_relayd "-o $TRACE_PATH -C tcp6://localhost:5342 -D tcp6://localhost:5343"
-test_uri_switch_localhost_folder "IPv6"
-test_uri_switch_file_network "IPv6"
-test_uri_switch_network_file "IPv6"
-stop_lttng_relayd
-
-stop_lttng_sessiond
diff --git a/tests/tools/test_kernel_data_trace.c b/tests/tools/test_kernel_data_trace.c
deleted file mode 100644 (file)
index db2064e..0000000
+++ /dev/null
@@ -1,203 +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 <bin/lttng-sessiond/trace-kernel.h>
-#include <common/defaults.h>
-
-#include "utils.h"
-
-/* This path will NEVER be created in this test */
-#define PATH1 "/tmp/.test-junk-lttng"
-
-#define RANDOM_STRING_LEN      11
-
-/* For lttngerr.h */
-int lttng_opt_quiet = 1;
-int lttng_opt_verbose;
-
-static const char alphanum[] =
-       "0123456789"
-       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-       "abcdefghijklmnopqrstuvwxyz";
-
-static struct ltt_kernel_session *kern;
-static char random_string[RANDOM_STRING_LEN];
-
-/*
- * Return random string of 10 characters.
- * Not thread-safe.
- */
-static char *get_random_string(void)
-{
-       int i;
-
-       for (i = 0; i < RANDOM_STRING_LEN - 1; i++) {
-               random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
-       }
-
-       random_string[RANDOM_STRING_LEN - 1] = '\0';
-
-       return random_string;
-}
-
-static void create_one_kernel_session(void)
-{
-       printf("Create kernel session: ");
-       kern = trace_kernel_create_session(PATH1);
-       assert(kern != NULL);
-       PRINT_OK();
-
-       printf("Validating kernel session: ");
-       assert(kern->fd == -1);
-       assert(kern->metadata_stream_fd == -1);
-       assert(kern->consumer_fds_sent == 0);
-       assert(kern->channel_count == 0);
-       assert(kern->stream_count_global == 0);
-       assert(kern->metadata == NULL);
-       PRINT_OK();
-
-       /* Init list in order to avoid sefaults from cds_list_del */
-       trace_kernel_destroy_session(kern);
-}
-
-static void create_kernel_metadata(void)
-{
-       assert(kern != NULL);
-
-       printf("Create kernel metadata: ");
-       kern->metadata = trace_kernel_create_metadata();
-       assert(kern->metadata != NULL);
-       PRINT_OK();
-
-       printf("Validating kernel session metadata: ");
-       assert(kern->metadata->fd == -1);
-       assert(kern->metadata->conf != NULL);
-       assert(kern->metadata->conf->attr.overwrite
-                       == DEFAULT_CHANNEL_OVERWRITE);
-       assert(kern->metadata->conf->attr.subbuf_size
-                       == default_get_metadata_subbuf_size());
-       assert(kern->metadata->conf->attr.num_subbuf
-                       == DEFAULT_METADATA_SUBBUF_NUM);
-       assert(kern->metadata->conf->attr.switch_timer_interval
-                       == DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER);
-       assert(kern->metadata->conf->attr.read_timer_interval
-                       == DEFAULT_KERNEL_CHANNEL_READ_TIMER);
-       assert(kern->metadata->conf->attr.output
-                       == DEFAULT_KERNEL_CHANNEL_OUTPUT);
-       PRINT_OK();
-
-       trace_kernel_destroy_metadata(kern->metadata);
-}
-
-static void create_kernel_channel(void)
-{
-       struct ltt_kernel_channel *chan;
-       struct lttng_channel attr;
-
-       memset(&attr, 0, sizeof(attr));
-
-       printf("Creating kernel channel: ");
-       chan = trace_kernel_create_channel(&attr);
-       assert(chan != NULL);
-       PRINT_OK();
-
-       printf("Validating kernel channel: ");
-       assert(chan->fd == -1);
-       assert(chan->enabled == 1);
-       assert(chan->stream_count == 0);
-       assert(chan->ctx == NULL);
-       assert(chan->channel->attr.overwrite  == attr.attr.overwrite);
-       PRINT_OK();
-
-       /* Init list in order to avoid sefaults from cds_list_del */
-       CDS_INIT_LIST_HEAD(&chan->list);
-       trace_kernel_destroy_channel(chan);
-}
-
-static void create_kernel_event(void)
-{
-       struct ltt_kernel_event *event;
-       struct lttng_event ev;
-
-       memset(&ev, 0, sizeof(ev));
-       strncpy(ev.name, get_random_string(), LTTNG_KERNEL_SYM_NAME_LEN);
-       ev.type = LTTNG_EVENT_TRACEPOINT;
-       ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
-       printf("Creating kernel event: ");
-       event = trace_kernel_create_event(&ev);
-       assert(event != NULL);
-       PRINT_OK();
-
-       printf("Validating kernel event: ");
-       assert(event->fd == -1);
-       assert(event->enabled == 1);
-       assert(event->event->instrumentation == LTTNG_KERNEL_TRACEPOINT);
-       assert(strlen(event->event->name));
-       PRINT_OK();
-
-       /* Init list in order to avoid sefaults from cds_list_del */
-       CDS_INIT_LIST_HEAD(&event->list);
-       trace_kernel_destroy_event(event);
-}
-
-static void create_kernel_stream(void)
-{
-       struct ltt_kernel_stream *stream;
-
-       printf("Creating kernel stream: ");
-       stream = trace_kernel_create_stream("stream1", 0);
-       assert(stream != NULL);
-       PRINT_OK();
-
-       printf("Validating kernel stream: ");
-       assert(stream->fd == -1);
-       assert(stream->state == 0);
-       PRINT_OK();
-
-       /* Init list in order to avoid sefaults from cds_list_del */
-       CDS_INIT_LIST_HEAD(&stream->list);
-       trace_kernel_destroy_stream(stream);
-}
-
-int main(int argc, char **argv)
-{
-       printf("\nTesting kernel data structures:\n-----------\n");
-
-       create_one_kernel_session();
-
-       create_kernel_metadata();
-       create_kernel_channel();
-
-
-       create_kernel_event();
-
-       create_kernel_stream();
-
-       /* Success */
-       return 0;
-}
diff --git a/tests/tools/test_sessions.c b/tests/tools/test_sessions.c
deleted file mode 100644 (file)
index a6d76c7..0000000
+++ /dev/null
@@ -1,330 +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 <sys/types.h>
-
-#include <bin/lttng-sessiond/session.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/common.h>
-
-#include "utils.h"
-
-#define SESSION1 "test1"
-
-/* This path will NEVER be created in this test */
-#define PATH1 "/tmp/.test-junk-lttng"
-
-#define MAX_SESSIONS 10000
-#define RANDOM_STRING_LEN      11
-
-/*
- * String of 263 caracters. NAME_MAX + "OVERFLOW". If OVERFLOW appears in the
- * session name, we have a problem.
- *
- * NAME_MAX = 255
- */
-#define OVERFLOW_SESSION_NAME \
-       "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" \
-       "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" \
-       "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" \
-       "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc"  \
-       "OVERFLOW"
-
-static struct ltt_session_list *session_list;
-
-/* For lttngerr.h */
-int lttng_opt_quiet = 1;
-int lttng_opt_verbose = 0;
-
-static const char alphanum[] =
-       "0123456789"
-       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-       "abcdefghijklmnopqrstuvwxyz";
-static char random_string[RANDOM_STRING_LEN];
-
-/*
- * Return random string of 10 characters.
- * Not thread-safe.
- */
-static char *get_random_string(void)
-{
-       int i;
-
-       for (i = 0; i < RANDOM_STRING_LEN - 1; i++) {
-               random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
-       }
-
-       random_string[RANDOM_STRING_LEN - 1] = '\0';
-
-       return random_string;
-}
-
-/*
- * Return 0 if session name is found, else -1
- */
-static int find_session_name(char *name)
-{
-       struct ltt_session *iter;
-
-       cds_list_for_each_entry(iter, &session_list->head, list) {
-               if (strcmp(iter->name, name) == 0) {
-                       return 0;
-               }
-       }
-
-       return -1;
-}
-
-static int session_list_count(void)
-{
-       int count = 0;
-       struct ltt_session *iter;
-
-       cds_list_for_each_entry(iter, &session_list->head, list) {
-               count++;
-       }
-       return count;
-}
-
-/*
- * Empty session list manually.
- */
-static void empty_session_list(void)
-{
-       struct ltt_session *iter, *tmp;
-
-       cds_list_for_each_entry_safe(iter, tmp, &session_list->head, list) {
-               cds_list_del(&iter->list);
-               free(iter);
-       }
-
-       /* Session list must be 0 */
-       assert(!session_list_count());
-}
-
-/*
- * Test creation of 1 session
- */
-static int create_one_session(char *name, char *path)
-{
-       int ret;
-
-       ret = session_create(name, path, geteuid(), getegid());
-       if (ret == LTTNG_OK) {
-               /* Validate */
-               ret = find_session_name(name);
-               if (ret < 0) {
-                       /* Session not found by name */
-                       printf("session not found after creation\n");
-                       return -1;
-               } else {
-                       /* Success */
-                       return 0;
-               }
-       } else {
-               if (ret == LTTNG_ERR_EXIST_SESS) {
-                       printf("(session already exists) ");
-               }
-               return -1;
-       }
-
-       return 0;
-}
-
-/*
- * Test deletion of 1 session
- */
-static int destroy_one_session(struct ltt_session *session)
-{
-       int ret;
-
-       ret = session_destroy(session);
-
-       if (ret == LTTNG_OK) {
-               /* Validate */
-               if (session == NULL) {
-                       return 0;
-               }
-               ret = find_session_name(session->name);
-               if (ret < 0) {
-                       /* Success, -1 means that the sesion is NOT found */
-                       return 0;
-               } else {
-                       /* Fail */
-                       return -1;
-               }
-       }
-
-       return 0;
-}
-
-static int fuzzing_create_args(void)
-{
-       int ret;
-
-       ret = create_one_session(NULL, NULL);
-       if (ret > 0) {
-               printf("Session created with (null),(null)\n");
-               return -1;
-       }
-
-       ret = create_one_session(NULL, PATH1);
-       if (ret > 0) {
-               printf("Session created with (null), %s)\n", PATH1);
-               return -1;
-       }
-
-       /* Session list must be 0 */
-       assert(!session_list_count());
-
-       return 0;
-}
-
-/*
- * This test is supposed to fail at the second create call. If so, return 0 for
- * test success, else -1.
- */
-static int two_session_same_name(void)
-{
-       int ret;
-       struct ltt_session *sess;
-
-       ret = create_one_session(SESSION1, PATH1);
-       if (ret < 0) {
-               /* Fail */
-               return -1;
-       }
-
-       sess = session_find_by_name(SESSION1);
-       if (sess) {
-               /* Success */
-               return 0;
-       }
-
-       /* Fail */
-       return -1;
-}
-
-int main(int argc, char **argv)
-{
-       int ret, i;
-       struct ltt_session *iter, *tmp;
-
-       srand(time(NULL));
-
-       printf("\nTesting Sessions:\n-----------\n");
-
-       session_list = session_get_list();
-       if (session_list == NULL) {
-               return -1;
-       }
-
-       printf("Create 1 session %s: ", SESSION1);
-       fflush(stdout);
-       ret = create_one_session(SESSION1, PATH1);
-       if (ret < 0) {
-               return -1;
-       }
-       PRINT_OK();
-
-       printf("Validating created session %s: ", SESSION1);
-       fflush(stdout);
-       tmp = session_find_by_name(SESSION1);
-       if (tmp == NULL) {
-               return -1;
-       }
-       /* Basic init session values */
-       assert(tmp->kernel_session == NULL);
-       assert(strlen(tmp->path));
-       assert(strlen(tmp->name));
-       session_lock(tmp);
-       session_unlock(tmp);
-
-       PRINT_OK();
-
-       printf("Destroy 1 session %s: ", SESSION1);
-       fflush(stdout);
-       ret = destroy_one_session(tmp);
-       if (ret < 0) {
-               return -1;
-       }
-       PRINT_OK();
-
-       printf("Two session with same name: ");
-       fflush(stdout);
-       ret = two_session_same_name();
-       if (ret < 0) {
-               return -1;
-       }
-       PRINT_OK();
-
-       empty_session_list();
-
-       printf("Fuzzing create_session arguments: ");
-       fflush(stdout);
-       ret = fuzzing_create_args();
-       if (ret < 0) {
-               return -1;
-       }
-       PRINT_OK();
-
-       printf("Creating %d sessions: ", MAX_SESSIONS);
-       fflush(stdout);
-       for (i = 0; i < MAX_SESSIONS; i++) {
-               char *tmp_name = get_random_string();
-
-               ret = create_one_session(tmp_name, PATH1);
-               if (ret < 0) {
-                       printf("session %d (name: %s) creation failed\n", i, tmp_name);
-                       return -1;
-               }
-
-               if ((i % 1000) == 0) {
-                       fprintf(stdout, "%d..", i);
-                       fflush(stdout);
-               }
-       }
-       PRINT_OK();
-
-       printf("Destroying %d sessions: ", MAX_SESSIONS);
-       fflush(stdout);
-       for (i = 0; i < MAX_SESSIONS; i++) {
-               cds_list_for_each_entry_safe(iter, tmp, &session_list->head, list) {
-                       ret = destroy_one_session(iter);
-                       if (ret < 0) {
-                               printf("session %d (name: %s) creation failed\n", i, iter->name);
-                               return -1;
-                       }
-               }
-       }
-       PRINT_OK();
-
-       /* Session list must be 0 */
-       assert(!session_list_count());
-
-       /* Success */
-       return 0;
-}
diff --git a/tests/tools/test_ust_data_trace.c b/tests/tools/test_ust_data_trace.c
deleted file mode 100644 (file)
index 0a79345..0000000
+++ /dev/null
@@ -1,204 +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 <bin/lttng-sessiond/lttng-ust-abi.h>
-#include <common/defaults.h>
-#include <bin/lttng-sessiond/trace-ust.h>
-
-#include "utils.h"
-
-/* This path will NEVER be created in this test */
-#define PATH1 "/tmp/.test-junk-lttng"
-
-#define RANDOM_STRING_LEN      11
-
-/* For lttngerr.h */
-int lttng_opt_quiet = 1;
-int lttng_opt_verbose;
-
-static const char alphanum[] =
-       "0123456789"
-       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-       "abcdefghijklmnopqrstuvwxyz";
-static char random_string[RANDOM_STRING_LEN];
-
-static struct ltt_ust_session *usess;
-static struct lttng_domain dom;
-
-/*
- * Return random string of 10 characters.
- * Not thread-safe.
- */
-static char *get_random_string(void)
-{
-       int i;
-
-       for (i = 0; i < RANDOM_STRING_LEN - 1; i++) {
-               random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
-       }
-
-       random_string[RANDOM_STRING_LEN - 1] = '\0';
-
-       return random_string;
-}
-
-static void create_one_ust_session(void)
-{
-       printf("Create UST session: ");
-
-       dom.type = LTTNG_DOMAIN_UST;
-
-       usess = trace_ust_create_session(PATH1, 42);
-       assert(usess != NULL);
-       PRINT_OK();
-
-       printf("Validating UST session: ");
-       assert(usess->id == 42);
-       assert(usess->start_trace == 0);
-       assert(usess->domain_global.channels != NULL);
-       assert(usess->domain_pid != NULL);
-       assert(usess->domain_exec != NULL);
-       assert(usess->uid == 0);
-       assert(usess->gid == 0);
-       PRINT_OK();
-
-       trace_ust_destroy_session(usess);
-}
-
-static void create_ust_metadata(void)
-{
-       struct ltt_ust_metadata *metadata;
-
-       assert(usess != NULL);
-
-       printf("Create UST metadata: ");
-       metadata = trace_ust_create_metadata(PATH1);
-       assert(metadata != NULL);
-       PRINT_OK();
-
-       printf("Validating UST session metadata: ");
-       assert(metadata->handle == -1);
-       assert(strlen(metadata->pathname));
-       assert(metadata->attr.overwrite
-                       == DEFAULT_CHANNEL_OVERWRITE);
-       assert(metadata->attr.subbuf_size
-                       == default_get_metadata_subbuf_size());
-       assert(metadata->attr.num_subbuf
-                       == DEFAULT_METADATA_SUBBUF_NUM);
-       assert(metadata->attr.switch_timer_interval
-                       == DEFAULT_UST_CHANNEL_SWITCH_TIMER);
-       assert(metadata->attr.read_timer_interval
-                       == DEFAULT_UST_CHANNEL_READ_TIMER);
-       assert(metadata->attr.output == LTTNG_UST_MMAP);
-       PRINT_OK();
-
-       trace_ust_destroy_metadata(metadata);
-}
-
-static void create_ust_channel(void)
-{
-       struct ltt_ust_channel *uchan;
-       struct lttng_channel attr;
-
-       memset(&attr, 0, sizeof(attr));
-
-       strncpy(attr.name, "channel0", 8);
-
-       printf("Creating UST channel: ");
-       uchan = trace_ust_create_channel(&attr, PATH1);
-       assert(uchan != NULL);
-       PRINT_OK();
-
-       printf("Validating UST channel: ");
-       assert(uchan->enabled == 0);
-       assert(strcmp(PATH1, uchan->pathname) == 0);
-       assert(strncmp(uchan->name, "channel0", 8) == 0);
-       assert(uchan->name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0');
-       assert(uchan->ctx != NULL);
-       assert(uchan->events != NULL);
-       assert(uchan->attr.overwrite  == attr.attr.overwrite);
-       PRINT_OK();
-
-       trace_ust_destroy_channel(uchan);
-}
-
-static void create_ust_event(void)
-{
-       struct ltt_ust_event *event;
-       struct lttng_event ev;
-
-       memset(&ev, 0, sizeof(ev));
-       strncpy(ev.name, get_random_string(), LTTNG_SYMBOL_NAME_LEN);
-       ev.type = LTTNG_EVENT_TRACEPOINT;
-       ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
-       printf("Creating UST event: ");
-       event = trace_ust_create_event(&ev, NULL);
-       assert(event != NULL);
-       PRINT_OK();
-
-       printf("Validating UST event: ");
-       assert(event->enabled == 0);
-       assert(event->attr.instrumentation == LTTNG_UST_TRACEPOINT);
-       assert(strcmp(event->attr.name, ev.name) == 0);
-       assert(event->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0');
-       PRINT_OK();
-
-       trace_ust_destroy_event(event);
-}
-
-static void create_ust_context(void)
-{
-       struct lttng_event_context ectx;
-       struct ltt_ust_context *uctx;
-
-       ectx.ctx = LTTNG_EVENT_CONTEXT_VTID;
-
-       printf("Creating UST context: ");
-       uctx = trace_ust_create_context(&ectx);
-       assert(uctx != NULL);
-       PRINT_OK();
-
-       printf("Validating UST context: ");
-       assert((int) uctx->ctx.ctx == LTTNG_UST_CONTEXT_VTID);
-       PRINT_OK();
-}
-
-int main(int argc, char **argv)
-{
-       printf("\nTesting UST data structures:\n-----------\n");
-
-       create_one_ust_session();
-       create_ust_metadata();
-       create_ust_channel();
-       create_ust_event();
-       create_ust_context();
-
-       /* Success */
-       return 0;
-}
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
new file mode 100644 (file)
index 0000000..51d7557
--- /dev/null
@@ -0,0 +1,57 @@
+AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests/utils/ -I$(srcdir)
+AM_LDFLAGS =
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+AM_LDFLAGS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+AM_LDFLAGS += -lc
+endif
+
+LIBTAP=$(top_builddir)/tests/utils/tap/libtap.la
+
+LIBCOMMON=$(top_builddir)/src/common/libcommon.la
+LIBSESSIOND_COMM=$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la
+LIBHASHTABLE=$(top_builddir)/src/common/hashtable/libhashtable.la
+
+EXTRA_DIST = run.sh
+
+if HAVE_LIBLTTNG_UST_CTL
+noinst_PROGRAMS = test_uri test_session test_ust_data test_kernel_data
+else
+noinst_PROGRAMS = test_uri test_session        test_kernel_data
+endif
+
+# URI unit tests
+test_uri_SOURCES = test_uri.c
+test_uri_LDADD = $(LIBTAP) $(LIBCOMMON)
+
+# Session unit test
+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
+
+test_session_SOURCES = test_session.c $(SESSIONS)
+test_session_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBSESSIOND_COMM) $(LIBHASHTABLE)
+
+# UST data structures unit test
+if HAVE_LIBLTTNG_UST_CTL
+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
+
+test_ust_data_SOURCES = test_ust_data.c $(UST_DATA_TRACE)
+test_ust_data_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBSESSIOND_COMM) $(LIBHASHTABLE)
+endif
+
+# Kernel data structures unit test
+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
+
+test_kernel_data_SOURCES = test_kernel_data.c $(KERN_DATA_TRACE)
+test_kernel_data_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBSESSIOND_COMM) $(LIBHASHTABLE)
diff --git a/tests/unit/run.sh b/tests/unit/run.sh
new file mode 100755 (executable)
index 0000000..a809e24
--- /dev/null
@@ -0,0 +1,34 @@
+#!/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_uri
+        $DIR/test_session
+       $DIR/test_ust_data
+       $DIR/test_kernel_data )
+
+#### END TESTS HERE ####
+
+opts=("$@")
+run_tests tests[@] opts[@]
diff --git a/tests/unit/test_kernel_data.c b/tests/unit/test_kernel_data.c
new file mode 100644 (file)
index 0000000..13f48f9
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * as published by the Free Software Foundation; only version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define _GNU_SOURCE
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
+
+#include <bin/lttng-sessiond/trace-kernel.h>
+#include <common/defaults.h>
+
+#include <tap/tap.h>
+
+/* This path will NEVER be created in this test */
+#define PATH1 "/tmp/.test-junk-lttng"
+
+#define RANDOM_STRING_LEN      11
+
+/* Number of TAP tests in this file */
+#define NUM_TESTS 10
+
+/* For lttngerr.h */
+int lttng_opt_quiet = 1;
+int lttng_opt_verbose;
+
+static const char alphanum[] =
+       "0123456789"
+       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+       "abcdefghijklmnopqrstuvwxyz";
+
+static struct ltt_kernel_session *kern;
+static char random_string[RANDOM_STRING_LEN];
+
+/*
+ * Return random string of 10 characters.
+ * Not thread-safe.
+ */
+static char *get_random_string(void)
+{
+       int i;
+
+       for (i = 0; i < RANDOM_STRING_LEN - 1; i++) {
+               random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
+       }
+
+       random_string[RANDOM_STRING_LEN - 1] = '\0';
+
+       return random_string;
+}
+
+static void test_create_one_kernel_session(void)
+{
+       kern = trace_kernel_create_session(PATH1);
+       ok(kern != NULL, "Create kernel session");
+
+       ok(kern->fd == -1 &&
+          kern->metadata_stream_fd == -1 &&
+          kern->consumer_fds_sent == 0 &&
+          kern->channel_count == 0 &&
+          kern->stream_count_global == 0 &&
+          kern->metadata == NULL,
+          "Validate kernel session");
+
+       /* Init list in order to avoid sefaults from cds_list_del */
+       trace_kernel_destroy_session(kern);
+}
+
+static void test_create_kernel_metadata(void)
+{
+       assert(kern != NULL);
+
+       kern->metadata = trace_kernel_create_metadata();
+       ok(kern->metadata != NULL, "Create kernel metadata");
+
+       ok(kern->metadata->fd == -1 &&
+          kern->metadata->conf != NULL &&
+          kern->metadata->conf->attr.overwrite
+                       == DEFAULT_CHANNEL_OVERWRITE &&
+          kern->metadata->conf->attr.subbuf_size
+                       == default_get_metadata_subbuf_size() &&
+          kern->metadata->conf->attr.num_subbuf
+                       == DEFAULT_METADATA_SUBBUF_NUM &&
+          kern->metadata->conf->attr.switch_timer_interval
+                       == DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER &&
+          kern->metadata->conf->attr.read_timer_interval
+                       == DEFAULT_KERNEL_CHANNEL_READ_TIMER &&
+          kern->metadata->conf->attr.output
+              == DEFAULT_KERNEL_CHANNEL_OUTPUT,
+          "Validate kernel session metadata");
+
+       trace_kernel_destroy_metadata(kern->metadata);
+}
+
+static void test_create_kernel_channel(void)
+{
+       struct ltt_kernel_channel *chan;
+       struct lttng_channel attr;
+
+       memset(&attr, 0, sizeof(attr));
+
+       chan = trace_kernel_create_channel(&attr);
+       ok(chan != NULL, "Create kernel channel");
+
+       ok(chan->fd == -1 &&
+          chan->enabled == 1 &&
+          chan->stream_count == 0 &&
+          chan->ctx == NULL &&
+          chan->channel->attr.overwrite  == attr.attr.overwrite,
+          "Validate kernel channel");
+
+       /* Init list in order to avoid sefaults from cds_list_del */
+       CDS_INIT_LIST_HEAD(&chan->list);
+       trace_kernel_destroy_channel(chan);
+}
+
+static void test_create_kernel_event(void)
+{
+       struct ltt_kernel_event *event;
+       struct lttng_event ev;
+
+       memset(&ev, 0, sizeof(ev));
+       strncpy(ev.name, get_random_string(), LTTNG_KERNEL_SYM_NAME_LEN);
+       ev.type = LTTNG_EVENT_TRACEPOINT;
+       ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+
+       event = trace_kernel_create_event(&ev);
+       ok(event != NULL, "Create kernel event");
+
+       ok(event->fd == -1 &&
+          event->enabled == 1 &&
+          event->event->instrumentation == LTTNG_KERNEL_TRACEPOINT &&
+          strlen(event->event->name),
+          "Validate kernel event");
+
+       /* Init list in order to avoid sefaults from cds_list_del */
+       CDS_INIT_LIST_HEAD(&event->list);
+       trace_kernel_destroy_event(event);
+}
+
+static void test_create_kernel_stream(void)
+{
+       struct ltt_kernel_stream *stream;
+
+       stream = trace_kernel_create_stream("stream1", 0);
+       ok(stream != NULL, "Create kernel stream");
+
+       ok(stream->fd == -1 &&
+          stream->state == 0,
+          "Validate kernel stream");
+
+       /* Init list in order to avoid sefaults from cds_list_del */
+       CDS_INIT_LIST_HEAD(&stream->list);
+       trace_kernel_destroy_stream(stream);
+}
+
+int main(int argc, char **argv)
+{
+       diag("Kernel data structure unit test");
+
+       plan_tests(NUM_TESTS);
+
+       test_create_one_kernel_session();
+       test_create_kernel_metadata();
+       test_create_kernel_channel();
+       test_create_kernel_event();
+       test_create_kernel_stream();
+
+       /* Success */
+       return 0;
+}
diff --git a/tests/unit/test_session.c b/tests/unit/test_session.c
new file mode 100644 (file)
index 0000000..41c907c
--- /dev/null
@@ -0,0 +1,321 @@
+/*
+ * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * as published by the Free Software Foundation; only version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define _GNU_SOURCE
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
+#include <sys/types.h>
+
+#include <tap/tap.h>
+
+#include <bin/lttng-sessiond/session.h>
+#include <common/sessiond-comm/sessiond-comm.h>
+#include <common/common.h>
+
+#define SESSION1 "test1"
+
+/* This path will NEVER be created in this test */
+#define PATH1 "/tmp/.test-junk-lttng"
+
+#define MAX_SESSIONS 10000
+#define RANDOM_STRING_LEN      11
+
+/* Number of TAP tests in this file */
+#define NUM_TESTS 12
+
+static struct ltt_session_list *session_list;
+
+/* For lttngerr.h */
+int lttng_opt_quiet = 1;
+int lttng_opt_verbose = 0;
+
+static const char alphanum[] =
+       "0123456789"
+       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+       "abcdefghijklmnopqrstuvwxyz";
+static char random_string[RANDOM_STRING_LEN];
+
+/*
+ * Return random string of 10 characters.
+ * Not thread-safe.
+ */
+static char *get_random_string(void)
+{
+       int i;
+
+       for (i = 0; i < RANDOM_STRING_LEN - 1; i++) {
+               random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
+       }
+
+       random_string[RANDOM_STRING_LEN - 1] = '\0';
+
+       return random_string;
+}
+
+/*
+ * Return 0 if session name is found, else -1
+ */
+static int find_session_name(char *name)
+{
+       struct ltt_session *iter;
+
+       cds_list_for_each_entry(iter, &session_list->head, list) {
+               if (strcmp(iter->name, name) == 0) {
+                       return 0;
+               }
+       }
+
+       return -1;
+}
+
+static int session_list_count(void)
+{
+       int count = 0;
+       struct ltt_session *iter;
+
+       cds_list_for_each_entry(iter, &session_list->head, list) {
+               count++;
+       }
+       return count;
+}
+
+/*
+ * Empty session list manually.
+ */
+static void empty_session_list(void)
+{
+       struct ltt_session *iter, *tmp;
+
+       cds_list_for_each_entry_safe(iter, tmp, &session_list->head, list) {
+               cds_list_del(&iter->list);
+               free(iter);
+       }
+
+       /* Session list must be 0 */
+       assert(!session_list_count());
+}
+
+/*
+ * Test creation of 1 session
+ */
+static int create_one_session(char *name, char *path)
+{
+       int ret;
+
+       ret = session_create(name, path, geteuid(), getegid());
+       if (ret == LTTNG_OK) {
+               /* Validate */
+               ret = find_session_name(name);
+               if (ret < 0) {
+                       /* Session not found by name */
+                       printf("session not found after creation\n");
+                       return -1;
+               } else {
+                       /* Success */
+                       return 0;
+               }
+       } else {
+               if (ret == LTTNG_ERR_EXIST_SESS) {
+                       printf("(session already exists) ");
+               }
+               return -1;
+       }
+
+       return 0;
+}
+
+/*
+ * Test deletion of 1 session
+ */
+static int destroy_one_session(struct ltt_session *session)
+{
+       int ret;
+
+       ret = session_destroy(session);
+
+       if (ret == LTTNG_OK) {
+               /* Validate */
+               if (session == NULL) {
+                       return 0;
+               }
+               ret = find_session_name(session->name);
+               if (ret < 0) {
+                       /* Success, -1 means that the sesion is NOT found */
+                       return 0;
+               } else {
+                       /* Fail */
+                       return -1;
+               }
+       }
+
+       return 0;
+}
+
+/*
+ * This test is supposed to fail at the second create call. If so, return 0 for
+ * test success, else -1.
+ */
+static int two_session_same_name(void)
+{
+       int ret;
+       struct ltt_session *sess;
+
+       ret = create_one_session(SESSION1, PATH1);
+       if (ret < 0) {
+               /* Fail */
+               return -1;
+       }
+
+       sess = session_find_by_name(SESSION1);
+       if (sess) {
+               /* Success */
+               return 0;
+       }
+
+       /* Fail */
+       return -1;
+}
+
+void test_session_list(void)
+{
+       session_list = session_get_list();
+       ok(session_list != NULL, "Session list: not NULL");
+}
+
+void test_create_one_session(void)
+{
+       ok(create_one_session(SESSION1, PATH1) == 0,
+          "Create session: %s",
+          SESSION1);
+}
+
+void test_validate_session(void)
+{
+       struct ltt_session *tmp;
+
+       tmp = session_find_by_name(SESSION1);
+
+       ok(tmp != NULL,
+          "Validating session: session found");
+
+       ok(tmp->kernel_session == NULL &&
+          strlen(tmp->path) &&
+          strlen(tmp->name),
+          "Validating session: basic sanity check");
+
+       session_lock(tmp);
+       session_unlock(tmp);
+}
+
+void test_destroy_session(void)
+{
+       struct ltt_session *tmp;
+
+       tmp = session_find_by_name(SESSION1);
+
+       ok(tmp != NULL,
+          "Destroying session: session found");
+
+       ok(destroy_one_session(tmp) == 0,
+          "Destroying session: %s destroyed",
+          SESSION1);
+}
+
+void test_duplicate_session(void)
+{
+       ok(two_session_same_name() == 0,
+          "Duplicate session creation");
+}
+
+void test_bogus_session_param(void)
+{
+       ok(create_one_session(NULL, NULL) < 0,
+          "Create session with bogus param: NULL, NULL should fail");
+
+       ok(create_one_session(NULL, PATH1) < 0,
+          "Create session with bogus param: NULL, %s should fail",
+          PATH1);
+
+       ok(session_list_count() == 0,
+          "Create session with bogus param: session list empty");
+}
+
+void test_large_session_number(void)
+{
+       int ret, i, failed = 0;
+       struct ltt_session *iter, *tmp;
+
+       for (i = 0; i < MAX_SESSIONS; i++) {
+               char *tmp_name = get_random_string();
+               ret = create_one_session(tmp_name, PATH1);
+               if (ret < 0) {
+                       diag("session %d (name: %s) creation failed", i, tmp_name);
+                       ++failed;
+               }
+       }
+
+       ok(failed == 0,
+          "Large sessions number: created %u sessions",
+          MAX_SESSIONS);
+
+       failed = 0;
+
+       for (i = 0; i < MAX_SESSIONS; i++) {
+               cds_list_for_each_entry_safe(iter, tmp, &session_list->head, list) {
+                       ret = destroy_one_session(iter);
+                       if (ret < 0) {
+                               diag("session %d (name: %s) destroy failed", i, iter->name);
+                               ++failed;
+                       }
+               }
+       }
+
+       ok(failed == 0 && session_list_count() == 0,
+          "Large sessions number: destroyed %u sessions",
+          MAX_SESSIONS);
+}
+
+int main(int argc, char **argv)
+{
+       diag("Sessions unit tests");
+
+       plan_tests(NUM_TESTS);
+
+       test_session_list();
+
+       test_create_one_session();
+
+       test_validate_session();
+
+       test_destroy_session();
+
+       test_duplicate_session();
+
+       empty_session_list();
+
+       test_bogus_session_param();
+
+       test_large_session_number();
+
+       return exit_status();
+}
diff --git a/tests/unit/test_uri.c b/tests/unit/test_uri.c
new file mode 100644 (file)
index 0000000..91bd21c
--- /dev/null
@@ -0,0 +1,264 @@
+/*
+ * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by as
+ * published by the Free Software Foundation; only version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <assert.h>
+#include <string.h>
+
+#include <tap/tap.h>
+
+#include <common/uri.h>
+
+/* For lttngerr.h */
+int lttng_opt_quiet = 1;
+int lttng_opt_verbose = 3;
+
+/* Number of TAP tests in this file */
+#define NUM_TESTS 11
+
+void test_uri_parsing(void)
+{
+       ssize_t size;
+       const char *s_uri1;
+       struct lttng_uri *uri = NULL;
+
+       s_uri1 = "net://localhost";
+
+       size = uri_parse(s_uri1, &uri);
+
+       ok(size == 2 &&
+          uri[0].dtype == LTTNG_DST_IPV4 &&
+          uri[0].utype == LTTNG_URI_DST &&
+          uri[0].stype == 0 &&
+          uri[0].port == 0 &&
+          strlen(uri[0].subdir) == 0 &&
+          strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0 &&
+          uri[1].dtype == LTTNG_DST_IPV4 &&
+          uri[1].utype == LTTNG_URI_DST &&
+          uri[1].stype == 0 &&
+          uri[1].port == 0 &&
+          strlen(uri[1].subdir) == 0 &&
+          strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0,
+          "URI set to net://localhost");
+
+       if (uri) {
+               uri_free(uri);
+               uri = NULL;
+       }
+
+       s_uri1 = "net://localhost:8989:4242/my/test/path";
+
+       size = uri_parse(s_uri1, &uri);
+
+       ok(size == 2 &&
+          uri[0].dtype == LTTNG_DST_IPV4 &&
+          uri[0].utype == LTTNG_URI_DST &&
+          uri[0].stype == 0 &&
+          uri[0].port == 8989 &&
+          strcmp(uri[0].subdir, "my/test/path") == 0 &&
+          strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0 &&
+          uri[1].dtype == LTTNG_DST_IPV4 &&
+          uri[1].utype == LTTNG_URI_DST &&
+          uri[1].stype == 0 &&
+          uri[1].port == 4242 &&
+          strcmp(uri[0].subdir, "my/test/path") == 0 &&
+          strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0,
+          "URI set to net://localhost:8989:4242/my/test/path");
+
+       if (uri) {
+               uri_free(uri);
+               uri = NULL;
+       }
+
+       s_uri1 = "net://localhost:8989:4242";
+
+       size = uri_parse(s_uri1, &uri);
+
+       ok(size == 2 &&
+          uri[0].dtype == LTTNG_DST_IPV4 &&
+          uri[0].utype == LTTNG_URI_DST &&
+          uri[0].stype == 0 &&
+          uri[0].port == 8989 &&
+          strlen(uri[1].subdir) == 0 &&
+          strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0 &&
+          uri[1].dtype == LTTNG_DST_IPV4 &&
+          uri[1].utype == LTTNG_URI_DST &&
+          uri[1].stype == 0 &&
+          uri[1].port == 4242 &&
+          strlen(uri[1].subdir) == 0 &&
+          strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0,
+          "URI set to net://localhost:8989:4242");
+
+       if (uri) {
+               uri_free(uri);
+               uri = NULL;
+       }
+
+       s_uri1 = "net6://localhost:8989";
+
+       size = uri_parse(s_uri1, &uri);
+
+       ok(size == 2 &&
+          uri[0].dtype == LTTNG_DST_IPV6 &&
+          uri[0].utype == LTTNG_URI_DST &&
+          uri[0].stype == 0 &&
+          uri[0].port == 8989 &&
+          strlen(uri[1].subdir) == 0 &&
+          strcmp(uri[0].dst.ipv6, "::1") == 0 &&
+          uri[1].dtype == LTTNG_DST_IPV6 &&
+          uri[1].utype == LTTNG_URI_DST &&
+          uri[1].stype == 0 &&
+          uri[1].port == 0 &&
+          strlen(uri[1].subdir) == 0 &&
+          strcmp(uri[0].dst.ipv6, "::1") == 0,
+          "URI set to net6://localhost:8989");
+
+       if (uri) {
+               uri_free(uri);
+               uri = NULL;
+       }
+
+       s_uri1 = "tcp://42.42.42.42/my/test/path";
+
+       size = uri_parse(s_uri1, &uri);
+
+       ok(size == 1 &&
+          uri[0].dtype == LTTNG_DST_IPV4 &&
+          uri[0].utype == LTTNG_URI_DST &&
+          uri[0].stype == 0 &&
+          uri[0].port == 0 &&
+          strcmp(uri[0].subdir, "my/test/path") == 0 &&
+          strcmp(uri[0].dst.ipv4, "42.42.42.42") == 0,
+          "URI set to tcp://42.42.42.42/my/test/path");
+
+       if (uri) {
+               uri_free(uri);
+               uri = NULL;
+       }
+
+       s_uri1 = "tcp6://[fe80::f66d:4ff:fe53:d220]/my/test/path";
+
+       size = uri_parse(s_uri1, &uri);
+
+       ok(size == 1 &&
+          uri[0].dtype == LTTNG_DST_IPV6 &&
+          uri[0].utype == LTTNG_URI_DST &&
+          uri[0].stype == 0 &&
+          uri[0].port == 0 &&
+          strcmp(uri[0].subdir, "my/test/path") == 0 &&
+          strcmp(uri[0].dst.ipv6, "fe80::f66d:4ff:fe53:d220") == 0,
+          "URI set to tcp6://[fe80::f66d:4ff:fe53:d220]/my/test/path");
+
+       if (uri) {
+               uri_free(uri);
+               uri = NULL;
+       }
+
+       s_uri1 = "file:///my/test/path";
+
+       size = uri_parse(s_uri1, &uri);
+
+       ok(size == 1 &&
+          uri[0].dtype == LTTNG_DST_PATH &&
+          uri[0].utype == LTTNG_URI_DST &&
+          uri[0].stype == 0 &&
+          uri[0].port == 0 &&
+          strlen(uri[0].subdir) == 0 &&
+          strcmp(uri[0].dst.path, "/my/test/path") == 0,
+          "URI set to file:///my/test/path");
+
+       if (uri) {
+               uri_free(uri);
+               uri = NULL;
+       }
+
+       /* FIXME: Noisy on stdout */
+       s_uri1 = "file/my/test/path";
+       size = uri_parse(s_uri1, &uri);
+       ok(size == -1, "Bad URI set to file/my/test/path");
+
+       s_uri1 = "net://:8999";
+       size = uri_parse(s_uri1, &uri);
+       ok(size == -1, "Bad URI set to net://:8999");
+}
+
+void test_uri_cmp()
+{
+       struct lttng_uri *uri1, *uri2;
+       const char *s_uri1 = "net://localhost";
+       const char *s_uri2 = "net://localhost:8989:4242";
+       ssize_t size1, size2;
+       int res;
+
+       size1 = uri_parse(s_uri1, &uri1);
+
+       /* Sanity checks */
+       assert(size1 == 2);
+       assert(uri1[0].dtype == LTTNG_DST_IPV4);
+       assert(uri1[0].utype == LTTNG_URI_DST);
+       assert(uri1[0].stype == 0);
+       assert(uri1[0].port == 0);
+       assert(strlen(uri1[0].subdir) == 0);
+       assert(strcmp(uri1[0].dst.ipv4, "127.0.0.1") == 0);
+       assert(uri1[1].dtype == LTTNG_DST_IPV4);
+       assert(uri1[1].utype == LTTNG_URI_DST);
+       assert(uri1[1].stype == 0);
+       assert(uri1[1].port == 0);
+       assert(strlen(uri1[1].subdir) == 0);
+       assert(strcmp(uri1[1].dst.ipv4, "127.0.0.1") == 0);
+
+       size2 = uri_parse(s_uri2, &uri2);
+
+       assert(size2 == 2);
+       assert(uri2[0].dtype == LTTNG_DST_IPV4);
+       assert(uri2[0].utype == LTTNG_URI_DST);
+       assert(uri2[0].stype == 0);
+       assert(uri2[0].port == 8989);
+       assert(strlen(uri2[1].subdir) == 0);
+       assert(strcmp(uri2[0].dst.ipv4, "127.0.0.1") == 0);
+       assert(uri2[1].dtype == LTTNG_DST_IPV4);
+       assert(uri2[1].utype == LTTNG_URI_DST);
+       assert(uri2[1].stype == 0);
+       assert(uri2[1].port == 4242);
+       assert(strlen(uri2[1].subdir) == 0);
+       assert(strcmp(uri2[1].dst.ipv4, "127.0.0.1") == 0);
+
+       res = uri_compare(uri1, uri1);
+
+       ok(res == 0,
+          "URI compare net://localhost == net://localhost");
+
+       res = uri_compare(uri1, uri2);
+
+       ok(res != 0,
+          "URI compare net://localhost != net://localhost:8989:4242");
+
+       uri_free(uri1);
+       uri_free(uri2);
+}
+
+int main(int argc, char **argv)
+{
+       diag("URI unit tests");
+
+       plan_tests(NUM_TESTS);
+
+       test_uri_parsing();
+
+       test_uri_cmp();
+
+       return exit_status();
+}
diff --git a/tests/unit/test_ust_data.c b/tests/unit/test_ust_data.c
new file mode 100644 (file)
index 0000000..0f1c99b
--- /dev/null
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * as published by the Free Software Foundation; only version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define _GNU_SOURCE
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
+
+#include <lttng/lttng.h>
+#include <bin/lttng-sessiond/lttng-ust-abi.h>
+#include <common/defaults.h>
+#include <bin/lttng-sessiond/trace-ust.h>
+
+#include <tap/tap.h>
+
+#include "utils.h"
+
+/* This path will NEVER be created in this test */
+#define PATH1 "/tmp/.test-junk-lttng"
+
+#define RANDOM_STRING_LEN      11
+
+/* Number of TAP tests in this file */
+#define NUM_TESTS 10
+
+/* For lttngerr.h */
+int lttng_opt_quiet = 1;
+int lttng_opt_verbose;
+
+static const char alphanum[] =
+       "0123456789"
+       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+       "abcdefghijklmnopqrstuvwxyz";
+static char random_string[RANDOM_STRING_LEN];
+
+static struct ltt_ust_session *usess;
+static struct lttng_domain dom;
+
+/*
+ * Return random string of 10 characters.
+ * Not thread-safe.
+ */
+static char *get_random_string(void)
+{
+       int i;
+
+       for (i = 0; i < RANDOM_STRING_LEN - 1; i++) {
+               random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
+       }
+
+       random_string[RANDOM_STRING_LEN - 1] = '\0';
+
+       return random_string;
+}
+
+static void test_create_one_ust_session(void)
+{
+       dom.type = LTTNG_DOMAIN_UST;
+
+       usess = trace_ust_create_session(PATH1, 42);
+       ok(usess != NULL, "Create UST session");
+
+       ok(usess->id == 42 &&
+          usess->start_trace == 0 &&
+          usess->domain_global.channels != NULL &&
+          usess->domain_pid != NULL &&
+          usess->domain_exec != NULL &&
+          usess->uid == 0 &&
+          usess->gid == 0,
+          "Validate UST session");
+
+       trace_ust_destroy_session(usess);
+}
+
+static void test_create_ust_metadata(void)
+{
+       struct ltt_ust_metadata *metadata;
+
+       assert(usess != NULL);
+
+       metadata = trace_ust_create_metadata(PATH1);
+       ok(metadata != NULL, "Create UST metadata");
+
+       ok(metadata->handle == -1 &&
+          strlen(metadata->pathname) &&
+          metadata->attr.overwrite
+                       == DEFAULT_CHANNEL_OVERWRITE &&
+          metadata->attr.subbuf_size
+                       == default_get_metadata_subbuf_size() &&
+          metadata->attr.num_subbuf
+                       == DEFAULT_METADATA_SUBBUF_NUM &&
+          metadata->attr.switch_timer_interval
+                       == DEFAULT_UST_CHANNEL_SWITCH_TIMER &&
+          metadata->attr.read_timer_interval
+                       == DEFAULT_UST_CHANNEL_READ_TIMER &&
+          metadata->attr.output == LTTNG_UST_MMAP,
+          "Validate UST session metadata");
+
+       trace_ust_destroy_metadata(metadata);
+}
+
+static void test_create_ust_channel(void)
+{
+       struct ltt_ust_channel *uchan;
+       struct lttng_channel attr;
+
+       memset(&attr, 0, sizeof(attr));
+
+       strncpy(attr.name, "channel0", 8);
+
+       uchan = trace_ust_create_channel(&attr, PATH1);
+       ok(uchan != NULL, "Create UST channel");
+
+       ok(uchan->enabled == 0 &&
+          strcmp(PATH1, uchan->pathname) == 0 &&
+          strncmp(uchan->name, "channel0", 8) == 0 &&
+          uchan->name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0' &&
+          uchan->ctx != NULL &&
+          uchan->events != NULL &&
+          uchan->attr.overwrite  == attr.attr.overwrite,
+          "Validate UST channel");
+
+       trace_ust_destroy_channel(uchan);
+}
+
+static void test_create_ust_event(void)
+{
+       struct ltt_ust_event *event;
+       struct lttng_event ev;
+
+       memset(&ev, 0, sizeof(ev));
+       strncpy(ev.name, get_random_string(), LTTNG_SYMBOL_NAME_LEN);
+       ev.type = LTTNG_EVENT_TRACEPOINT;
+       ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+
+       event = trace_ust_create_event(&ev, NULL);
+
+       ok(event != NULL, "Create UST event");
+
+       ok(event->enabled == 0 &&
+          event->attr.instrumentation == LTTNG_UST_TRACEPOINT &&
+          strcmp(event->attr.name, ev.name) == 0 &&
+          event->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0',
+          "Validate UST event");
+
+       trace_ust_destroy_event(event);
+}
+
+static void test_create_ust_context(void)
+{
+       struct lttng_event_context ectx;
+       struct ltt_ust_context *uctx;
+
+       ectx.ctx = LTTNG_EVENT_CONTEXT_VTID;
+
+       uctx = trace_ust_create_context(&ectx);
+       ok(uctx != NULL, "Create UST context");
+
+       ok((int) uctx->ctx.ctx == LTTNG_UST_CONTEXT_VTID,
+          "Validate UST context");
+}
+
+int main(int argc, char **argv)
+{
+       diag("UST data structures unit test");
+
+       plan_tests(NUM_TESTS);
+
+       test_create_one_ust_session();
+       test_create_ust_metadata();
+       test_create_ust_channel();
+       test_create_ust_event();
+       test_create_ust_context();
+
+       return exit_status();
+}
diff --git a/tests/ust/Makefile.am b/tests/ust/Makefile.am
deleted file mode 100644 (file)
index c598290..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-if HAVE_LIBLTTNG_UST_CTL
-SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \
-                 overlap
-
-AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/tests -I$(top_srcdir)/src -g -Wall 
-AM_LDFLAGS = -lurcu -lurcu-cds
-
-EXTRA_DIST = runall.sh run-ust-global-tests.sh
-
-noinst_PROGRAMS = ust_global_event_basic ust_global_event_wildcard
-
-UTILS=../utils.h
-LIBLTTNG=$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la
-
-SESSIONDSRC=$(top_srcdir)/src/common/sessiond-comm/sessiond-comm.c \
-                $(top_srcdir)/src/common/sessiond-comm/unix.c \
-                $(top_srcdir)/src/common/sessiond-comm/inet.c \
-                $(top_srcdir)/src/common/sessiond-comm/inet6.c
-
-ust_global_event_wildcard_SOURCES = ust_global_event_wildcard.c $(UTILS) \
-               $(SESSIONDSRC)
-ust_global_event_wildcard_LDADD = $(LIBLTTNG)
-
-ust_global_event_basic_SOURCES = ust_global_event_basic.c $(UTILS) \
-               $(SESSIONDSRC)
-ust_global_event_basic_LDADD = $(LIBLTTNG)
-
-endif
diff --git a/tests/ust/before-after/Makefile.am b/tests/ust/before-after/Makefile.am
deleted file mode 100644 (file)
index d197d72..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-AM_CFLAGS = -I$(srcdir) -O2
-AM_LDFLAGS = -llttng-ust
-
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-AM_LDFLAGS += -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-AM_LDFLAGS += -lc
-endif
-
-noinst_PROGRAMS = gen-nevents
-gen_nevents_SOURCES = gen-nevents.c tp.c ust_gen_nevents.h
-gen_nevents_LDADD = -llttng-ust
-
-noinst_SCRIPTS = run
-EXTRA_DIST = run
diff --git a/tests/ust/before-after/gen-nevents.c b/tests/ust/before-after/gen-nevents.c
deleted file mode 100644 (file)
index b2c1992..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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/ust/before-after/run b/tests/ust/before-after/run
deleted file mode 100755 (executable)
index 46b97f4..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-TEST_DESC="UST tracer - Start tracing before and after execution"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-NR_ITER=100
-SESSION_NAME="per-session"
-EVENT_NAME="ust_gen_nevents:tptest"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/gen-nevents" ]; then
-       echo -e "No UST nevents binary detected. Passing."
-       exit 0
-fi
-
-# MUST set TESTDIR before calling those functions
-
-test_before_apps() {
-       local out
-
-       # BEFORE application is spawned
-       create_lttng_session $SESSION_NAME $TRACE_PATH
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-       start_lttng_tracing $SESSION_NAME
-       # Start test
-       echo -n "Starting application... "
-       ./$CURDIR/gen-nevents $NR_ITER
-       echo -n "Ended "
-       print_ok
-       stop_lttng_tracing $SESSION_NAME
-       destroy_lttng_session $SESSION_NAME
-
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
-
-       return $?
-}
-
-test_after_apps() {
-       local out
-
-       echo -n "Starting application... "
-       ./$CURDIR/gen-nevents 100 &
-       print_ok
-
-       # BEFORE application is spawned
-       create_lttng_session $SESSION_NAME $TRACE_PATH
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-       start_lttng_tracing $SESSION_NAME
-
-       # At least hit one event
-       sleep 2
-
-       stop_lttng_tracing $SESSION_NAME
-       destroy_lttng_session $SESSION_NAME
-
-       out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
-       if [ $out -eq 0 ]; then
-               echo -n "No event found. Suppose to have at least one... "
-               print_fail
-               out=1
-       else
-               echo -n "Found $out event(s). Coherent... "
-               print_ok
-               out=0
-       fi
-
-       return $out
-}
-
-# MUST set TESTDIR before calling those functions
-
-start_lttng_sessiond
-
-echo ""
-echo "=== Start application BEFORE tracing was started ==="
-
-TRACE_PATH=$(mktemp -d)
-
-test_before_apps
-out=$?
-if [ $out -ne 0 ]; then
-       stop_lttng_sessiond
-       exit $out
-fi
-
-rm -rf $TRACE_PATH
-
-echo ""
-echo "=== Start application AFTER tracing was started ==="
-
-TRACE_PATH=$(mktemp -d)
-
-test_after_apps
-out=$?
-if [ $out -ne 0 ]; then
-       stop_lttng_sessiond
-       exit $out
-fi
-
-stop_lttng_sessiond
-
-rm -rf $TRACE_PATH
diff --git a/tests/ust/before-after/tp.c b/tests/ust/before-after/tp.c
deleted file mode 100644 (file)
index e291924..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * 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/ust/before-after/ust_gen_nevents.h b/tests/ust/before-after/ust_gen_nevents.h
deleted file mode 100644 (file)
index 8d82ecb..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#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/ust/high-throughput/Makefile.am b/tests/ust/high-throughput/Makefile.am
deleted file mode 100644 (file)
index cff8fe4..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-AM_CFLAGS = -I$(srcdir) -O2
-AM_LDFLAGS = -llttng-ust
-
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-AM_LDFLAGS += -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-AM_LDFLAGS += -lc
-endif
-
-noinst_PROGRAMS = gen-events
-gen_events_SOURCES = main.c tp.c tp.h
-gen_events_LDADD = -llttng-ust
-
-noinst_SCRIPTS = run
-EXTRA_DIST = run
diff --git a/tests/ust/high-throughput/main.c b/tests/ust/high-throughput/main.c
deleted file mode 100644 (file)
index dbd2998..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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/ust/high-throughput/run b/tests/ust/high-throughput/run
deleted file mode 100755 (executable)
index dff5fdd..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-TEST_DESC="UST tracer - Testing high events throughput"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-NR_ITER=20
-BIN_NAME="gen-events"
-SESSION_NAME="high-throughput"
-EVENT_NAME="tp:tptest"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/$BIN_NAME" ]; then
-       echo -e "No UST nevents binary detected. Passing."
-       exit 0
-fi
-
-TRACE_PATH=$(mktemp -d)
-
-# MUST set TESTDIR before calling those functions
-
-start_lttng_sessiond
-
-create_lttng_session $SESSION_NAME $TRACE_PATH
-
-enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-start_lttng_tracing $SESSION_NAME
-
-for i in `seq 1 $NR_ITER`; do
-       ./$CURDIR/$BIN_NAME & >/dev/null 2>&1
-done
-
-echo "Waiting for applications to end"
-while [ -n "$(pidof $BIN_NAME)" ]; do
-       echo -n "."
-       sleep 0.5
-done
-echo ""
-
-stop_lttng_tracing $SESSION_NAME
-destroy_lttng_session $SESSION_NAME
-
-stop_lttng_sessiond
-
-# Validate test
-
-TEMP_FILE=$(mktemp)
-TEMP_FILE_2=$(mktemp)
-
-traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l)
-babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2
-
-cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE
-
-dropped=0
-while read line;
-do
-       let dropped=$dropped+$line
-done < $TEMP_FILE
-
-let total=$dropped+$traced
-let wanted=$NR_ITER*1000000
-
-if [ $wanted -ne $total ]; then
-       echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
-       print_fail
-       out=1
-else
-       echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
-       print_ok
-       out=0
-fi
-
-rm -rf $TRACE_PATH
-rm $TEMP_FILE $TEMP_FILE_2
-
-exit $out
diff --git a/tests/ust/high-throughput/tp.c b/tests/ust/high-throughput/tp.c
deleted file mode 100644 (file)
index 1d6cbda..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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/ust/high-throughput/tp.h b/tests/ust/high-throughput/tp.h
deleted file mode 100644 (file)
index 23d4d25..0000000
+++ /dev/null
@@ -1,61 +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>
- *
- * 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/ust/low-throughput/Makefile.am b/tests/ust/low-throughput/Makefile.am
deleted file mode 100644 (file)
index a1df9f5..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-AM_CFLAGS = -I$(srcdir) -O2
-AM_LDFLAGS = -llttng-ust
-
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-AM_LDFLAGS += -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-AM_LDFLAGS += -lc
-endif
-
-noinst_PROGRAMS = gen-events
-gen_events_SOURCES = main.c tp.c tp.h
-gen_events_LDADD = -llttng-ust -lurcu
-
-noinst_SCRIPTS = run
-EXTRA_DIST = run
diff --git a/tests/ust/low-throughput/main.c b/tests/ust/low-throughput/main.c
deleted file mode 100644 (file)
index 06ab9ef..0000000
+++ /dev/null
@@ -1,81 +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 <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/ust/low-throughput/run b/tests/ust/low-throughput/run
deleted file mode 100755 (executable)
index 26e0749..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-TEST_DESC="UST tracer - Testing low events throughput"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-BIN_NAME="gen-events"
-SESSION_NAME="low-throughput"
-EVENT_NAME="tp:slow"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/$BIN_NAME" ]; then
-       echo -e "No UST nevents binary detected. Passing."
-       exit 0
-fi
-
-TRACE_PATH=$(mktemp -d)
-
-# MUST set TESTDIR before calling those functions
-
-start_lttng_sessiond
-
-create_lttng_session $SESSION_NAME $TRACE_PATH
-
-enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-start_lttng_tracing $SESSION_NAME
-
-# This is going to take 20 minutes
-./$CURDIR/$BIN_NAME >/dev/null 2>&1
-
-stop_lttng_tracing $SESSION_NAME
-destroy_lttng_session $SESSION_NAME
-
-stop_lttng_sessiond
-
-# Validate test
-
-last_val=0
-out=0
-
-babeltrace $TRACE_PATH | while read event;
-do
-       val=$(echo $event | cut -f10 -d" ")
-       val=${val%?}
-       th=$(echo $event | cut -f13 -d " ")
-
-       if [ $th = '"one"' ]; then
-               ((last_val++))
-               # We expect here a continous value from 1 to 20
-               if [ $last_val -ne $val ]; then
-                       echo -n "[-] One minute event failed ($val) "
-                       out=1
-                       break
-               fi
-       elif [ $th = '"ten"' ]; then
-               # Test 10 minutes counter
-               if [ $val -ne 10 ]; then
-                       # Test 20 minutes counter
-                       if [ $val -ne 20 ]; then
-                               echo -n "[-] Ten minutes event failed ($val) "
-                               out=1
-                               break
-                       fi
-               fi
-       elif [ $th = '"twenty"' ]; then
-               # Test 20 minutes counter
-               if [ $val -ne 20 ]; then
-                       echo -n "[-] Twenty minutes event failed ($val) "
-                       out=1
-                       break
-               fi
-       fi
-done
-
-if [ $out -eq 0 ]; then
-       echo -n "Trace is coherent... "
-       print_ok
-else
-       print_fail
-fi
-
-rm -rf $TRACE_PATH
-
-exit $out
diff --git a/tests/ust/low-throughput/tp.c b/tests/ust/low-throughput/tp.c
deleted file mode 100644 (file)
index 1d6cbda..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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/ust/low-throughput/tp.h b/tests/ust/low-throughput/tp.h
deleted file mode 100644 (file)
index 74b908b..0000000
+++ /dev/null
@@ -1,45 +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>
- *
- * 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/ust/multi-session/Makefile.am b/tests/ust/multi-session/Makefile.am
deleted file mode 100644 (file)
index d197d72..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-AM_CFLAGS = -I$(srcdir) -O2
-AM_LDFLAGS = -llttng-ust
-
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-AM_LDFLAGS += -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-AM_LDFLAGS += -lc
-endif
-
-noinst_PROGRAMS = gen-nevents
-gen_nevents_SOURCES = gen-nevents.c tp.c ust_gen_nevents.h
-gen_nevents_LDADD = -llttng-ust
-
-noinst_SCRIPTS = run
-EXTRA_DIST = run
diff --git a/tests/ust/multi-session/gen-nevents.c b/tests/ust/multi-session/gen-nevents.c
deleted file mode 100644 (file)
index 7add252..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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/ust/multi-session/run b/tests/ust/multi-session/run
deleted file mode 100755 (executable)
index 7242fd9..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-TEST_DESC="UST tracer - Multi-session"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-NR_ITER=100
-SESSION_NAME="multi-session"
-EVENT_NAME="ust_gen_nevents:tptest"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/gen-nevents" ]; then
-       echo -e "No UST nevents binary detected. Passing."
-       exit 0
-fi
-
-# MUST set TESTDIR before calling those functions
-
-test_multi_session() {
-       local out
-
-       # BEFORE application is spawned
-       for i in `seq 0 3`; do
-               create_lttng_session "$SESSION_NAME-$i" "$TRACE_PATH/$i"
-               enable_ust_lttng_event "$SESSION_NAME-$i" "$EVENT_NAME$i"
-               start_lttng_tracing "$SESSION_NAME-$i"
-       done
-
-       echo -n "Starting application generating $NR_ITER events... "
-       ./$CURDIR/gen-nevents $NR_ITER &
-       print_ok
-
-       # At least hit one event
-       echo -n "Waiting for events to record "
-       while [ -n "$(pidof gen-nevents)" ]; do
-               echo -n "."
-               sleep 0.1
-       done
-       print_ok
-
-       for i in `seq 0 3`; do
-               stop_lttng_tracing "$SESSION_NAME-$i"
-               destroy_lttng_session "$SESSION_NAME-$i"
-               out=$(babeltrace "$TRACE_PATH/$i" | grep "$EVENT_NAMEi$i" | wc -l)
-               if [ $out -ne $NR_ITER ]; then
-                       echo -n "No event found. Suppose to have at least one... "
-                       print_fail
-                       out=1
-               else
-                       echo -n "Found $out event(s) for $SESSION_NAME-$i. Coherent... "
-                       print_ok
-                       out=0
-               fi
-       done
-
-       return $out
-}
-
-# MUST set TESTDIR before calling those functions
-
-start_lttng_sessiond
-
-TRACE_PATH=$(mktemp -d)
-
-test_multi_session
-out=$?
-if [ $out -ne 0 ]; then
-       stop_lttng_sessiond
-       exit $out
-fi
-
-stop_lttng_sessiond
-
-rm -rf "$TRACE_PATH"
diff --git a/tests/ust/multi-session/tp.c b/tests/ust/multi-session/tp.c
deleted file mode 100644 (file)
index e291924..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * 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/ust/multi-session/ust_gen_nevents.h b/tests/ust/multi-session/ust_gen_nevents.h
deleted file mode 100644 (file)
index cba3994..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#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/ust/nprocesses/Makefile.am b/tests/ust/nprocesses/Makefile.am
deleted file mode 100644 (file)
index b07ae0b..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-AM_CFLAGS = -I$(srcdir) -O2
-AM_LDFLAGS = -llttng-ust
-
-if LTTNG_TOOLS_BUILD_WITH_LIBDL
-AM_LDFLAGS += -ldl
-endif
-if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
-AM_LDFLAGS += -lc
-endif
-
-noinst_PROGRAMS = gen-events-time
-gen_events_time_SOURCES = gen-events-time.c tp.c ust_gen_event.h
-gen_events_time_LDADD = -llttng-ust
-
-noinst_SCRIPTS = run ust-nprocesses
-EXTRA_DIST = run ust-nprocesses
diff --git a/tests/ust/nprocesses/gen-events-time.c b/tests/ust/nprocesses/gen-events-time.c
deleted file mode 100644 (file)
index bc5b68c..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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/ust/nprocesses/run b/tests/ust/nprocesses/run
deleted file mode 100755 (executable)
index f492ed7..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-NR_ITER=100
-TEST_DESC="UST tracer - Generate $NR_ITER process"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-TEST_BIN_NAME="gen-events-time"
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/$TEST_BIN_NAME" ]; then
-       echo -e "No UST $TEST_BIN_NAME binary detected. Passing."
-       exit 0
-fi
-
-# MUST set TESTDIR before calling those functions
-
-start_lttng_sessiond
-
-./$CURDIR/ust-nprocesses $NR_ITER
-
-stop_lttng_sessiond
-
-exit 0
diff --git a/tests/ust/nprocesses/tp.c b/tests/ust/nprocesses/tp.c
deleted file mode 100644 (file)
index 438139e..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * 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/ust/nprocesses/ust-nprocesses b/tests/ust/nprocesses/ust-nprocesses
deleted file mode 100755 (executable)
index 90c0c2e..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-NR_ITER=$1
-TEST_BIN_NAME="gen-events-time"
-SESSION_NAME="ust-nprocesses"
-EVENT_NAME="ust_gen_event:tptest"
-TEST_WAIT_SEC=5
-
-source $TESTDIR/utils.sh
-
-# MUST set TESTDIR before calling those functions
-
-# Start test for 1000 seconds
-
-for i in `seq 1 $NR_ITER`
-do
-       ./$CURDIR/$TEST_BIN_NAME 1000 >/dev/null 2>&1 &
-done
-
-echo -n "Validating registered apps in 3 seconds..."
-
-sleep 3
-
-listing=$($TESTDIR/../src/bin/lttng/$LTTNG_BIN list -u)
-reg_app_count=$(echo -n $listing | sed "s/$TEST_BIN_NAME/$TEST_BIN_NAME\n/g" | grep "$TEST_BIN_NAME" | wc -l)
-if [ "$reg_app_count" -ne "$NR_ITER" ]; then
-       echo -e "$reg_app_count apps listed. Expected $NR_ITER "
-       print_fail
-else
-       print_ok
-fi
-
-TRACE_PATH=$(mktemp -d)
-
-create_lttng_session $SESSION_NAME $TRACE_PATH
-
-enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-start_lttng_tracing $SESSION_NAME
-
-echo "Sleeping $TEST_WAIT_SEC seconds for tracing to start everywhere"
-echo "Warning: this arbitrary time can make the test fail on slower system"
-sleep $TEST_WAIT_SEC
-
-stop_lttng_tracing $SESSION_NAME
-destroy_lttng_session $SESSION_NAME
-
-rm -rf $TRACE_PATH
-
-echo -e -n "Killing all spawned applications..."
-killall -q $TEST_BIN_NAME >/dev/null 2>&1 &
-print_ok
-exit 0
diff --git a/tests/ust/nprocesses/ust_gen_event.h b/tests/ust/nprocesses/ust_gen_event.h
deleted file mode 100644 (file)
index 5bdcb37..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#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/ust/overlap/Makefile.am b/tests/ust/overlap/Makefile.am
deleted file mode 100644 (file)
index 7100034..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-SUBDIRS = demo
-
-noinst_SCRIPTS = run
-EXTRA_DIST = run overlap.sh
diff --git a/tests/ust/overlap/demo/Makefile.am b/tests/ust/overlap/demo/Makefile.am
deleted file mode 100644 (file)
index 68b6e08..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-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/ust/overlap/demo/demo-trace b/tests/ust/overlap/demo/demo-trace
deleted file mode 100755 (executable)
index 88a1be7..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/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/ust/overlap/demo/demo.c b/tests/ust/overlap/demo/demo.c
deleted file mode 100644 (file)
index e2b61c2..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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/ust/overlap/demo/tp.c b/tests/ust/overlap/demo/tp.c
deleted file mode 100644 (file)
index 288ce61..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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/ust/overlap/demo/tp2.c b/tests/ust/overlap/demo/tp2.c
deleted file mode 100644 (file)
index 718c9db..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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/ust/overlap/demo/tp3.c b/tests/ust/overlap/demo/tp3.c
deleted file mode 100644 (file)
index b1babc7..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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/ust/overlap/demo/ust_tests_demo.h b/tests/ust/overlap/demo/ust_tests_demo.h
deleted file mode 100644 (file)
index 3e024b4..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#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/ust/overlap/demo/ust_tests_demo2.h b/tests/ust/overlap/demo/ust_tests_demo2.h
deleted file mode 100644 (file)
index cf4424b..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#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/ust/overlap/demo/ust_tests_demo3.h b/tests/ust/overlap/demo/ust_tests_demo3.h
deleted file mode 100644 (file)
index e58ee86..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#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/ust/overlap/overlap.sh b/tests/ust/overlap/overlap.sh
deleted file mode 100755 (executable)
index ebe6cfd..0000000
+++ /dev/null
@@ -1,693 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-TEST_DESC="UST - Wildcard overlap"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
-SESSION_NAME="wildcard-overlap"
-
-DEMO_EVENT1="ust_tests_demo:starting"
-DEMO_EVENT1_2="ust_tests_demo:done"
-DEMO_EVENT2="ust_tests_demo2:loop"
-DEMO_EVENT3="ust_tests_demo3:done"
-
-NUM_DEMO1_EVENT=1
-NUM_DEMO1_2_EVENT=1
-NUM_DEMO2_EVENT=5
-NUM_DEMO3_EVENT=1
-
-source $TESTDIR/utils.sh
-
-print_test_banner "$TEST_DESC"
-
-if [ ! -x "$CURDIR/demo/demo" ]; then
-       echo -e "No UST nevents binary detected. Passing."
-       exit 0
-fi
-
-# MUST set TESTDIR before calling those functions
-
-run_demo_app()
-{
-       cd $CURDIR/demo
-
-       # Start test
-       echo -n "Starting application... "
-       ./demo-trace >/dev/null 2>&1
-       echo -n "Ended "
-       print_ok
-
-       cd -
-}
-
-# Ease our life a bit ;)
-trace_match_demo1_events()
-{
-       trace_matches "$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
-       trace_matches "$DEMO_EVENT1_2" $NUM_DEMO1_EVENT $TRACE_PATH
-}
-
-# Ease our life a bit ;)
-trace_match_all_demo_events()
-{
-       trace_match_demo1_events
-       trace_matches "$DEMO_EVENT2" $NUM_DEMO2_EVENT $TRACE_PATH
-       trace_matches "$DEMO_EVENT3" $NUM_DEMO3_EVENT $TRACE_PATH
-}
-
-# Ease our life a bit ;)
-trace_match_no_demo_events()
-{
-       trace_matches "$DEMO_EVENT1" 0 $TRACE_PATH
-       trace_matches "$DEMO_EVENT1_2" 0 $TRACE_PATH
-       trace_matches "$DEMO_EVENT2" 0 $TRACE_PATH
-       trace_matches "$DEMO_EVENT3" 0 $TRACE_PATH
-}
-
-# Expect all "demo" events, no duplicate.
-test_enable_simple_wildcard()
-{
-       local event_wild1="us*"
-       local event_wild2="ust*"
-
-       echo ""
-       echo "=== Simple wildcard overlap"
-
-       enable_ust_lttng_event $SESSION_NAME "$event_wild1"
-       enable_ust_lttng_event $SESSION_NAME "$event_wild2"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-
-       return $?
-}
-
-# Expect all "demo" events, no duplicate.
-test_enable_wildcard_filter()
-{
-       local event_wild1="us*"
-       local event_wild2="ust*"
-
-       echo ""
-       echo "=== Wildcard overlap with filter"
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-       return $?
-}
-
-# Expect all "demo" events, no duplicate.
-test_enable_wildcard_filter_2()
-{
-       local event_wild1="us*"
-       local event_wild2="ust*"
-
-       echo ""
-       echo "=== Wildcard overlap with filter 2"
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-       return $?
-}
-
-# Expect all "demo" events, no duplicate.
-test_enable_wildcard_filter_3()
-{
-       local event_wild1="us*"
-       local event_wild2="ust*"
-
-       echo ""
-       echo "=== Wildcard overlap with filter 3"
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-       return $?
-}
-
-# Expected: No events.
-test_enable_wildcard_filter_4()
-{
-       local event_wild1="us*"
-       local event_wild2="ust*"
-
-       echo ""
-       echo "=== Wildcard overlap with filter 4"
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_no_demo_events
-       return $?
-}
-
-# Expect all "demo" events, no duplicate.
-test_enable_wildcard_filter_5()
-{
-       local event_wild1="us*"
-       local event_wild2="$DEMO_EVENT1"
-
-       echo ""
-       echo "=== Wildcard overlap with filter 5"
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-       return $?
-}
-
-# Expect all $DEMO_EVENT1 events, no duplicate.
-test_enable_wildcard_filter_6()
-{
-       local event_wild1="us*"
-       local event_wild2="$DEMO_EVENT1"
-
-       echo ""
-       echo "=== Wildcard overlap with filter 6"
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
-       trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH
-       trace_matches $DEMO_EVENT2 0 $TRACE_PATH
-       trace_matches $DEMO_EVENT3 0 $TRACE_PATH
-       return $?
-}
-
-# Expect all events, no duplicate.
-test_enable_wildcard_filter_7()
-{
-       local event_wild1="us*"
-       local event_wild2="$DEMO_EVENT1"
-
-       echo ""
-       echo "=== Wildcard overlap with filter 7"
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-       return $?
-}
-
-# Expected: No events.
-test_enable_wildcard_filter_8()
-{
-       local event_wild1="us*"
-       local event_wild2="$DEMO_EVENT1"
-
-       echo ""
-       echo "=== Wildcard overlap with filter 8"
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_no_demo_events
-       return $?
-}
-
-# Expect all events.
-test_enable_same_wildcard_filter()
-{
-       local event_wild1="ust*"
-       local event_wild2="ust*"
-
-       echo ""
-       echo "=== Same wildcard overlap with filter"
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-       return $?
-}
-
-# Expect all events.
-test_enable_same_wildcard_filter_2()
-{
-       local event_wild1="ust*"
-       local event_wild2="ust*"
-
-       echo ""
-       echo "=== Same wildcard overlap with filter 2"
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-       if [ $? -eq 1 ]; then
-               echo -n "FAIL is normal. Same event with same filter is denied by the sessiond "
-               print_ok
-       else
-               print_fail
-       fi
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-       return $?
-}
-
-# Expect all events.
-test_enable_same_wildcard_filter_3()
-{
-       local event_wild1="ust*"
-       local event_wild2="ust*"
-
-       echo ""
-       echo "=== Same wildcard overlap with filter 3"
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-       return $?
-}
-
-# Expected: No events.
-test_enable_same_wildcard_filter_4()
-{
-       local event_wild1="ust*"
-       local event_wild2="ust*"
-
-       echo ""
-       echo "=== Same wildcard overlap with filter 4"
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0&&1==0"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_no_demo_events
-       return $?
-}
-
-# Expected: Only $DEMO_EVENT1
-test_enable_same_event_filter()
-{
-       local event_wild1="$DEMO_EVENT1"
-       local event_wild2="$DEMO_EVENT1"
-
-       echo ""
-       echo "=== Enable same event with filter."
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
-       disable_ust_lttng_event $SESSION_NAME "ust*"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
-       trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH
-       trace_matches $DEMO_EVENT2 0 $TRACE_PATH
-       trace_matches $DEMO_EVENT3 0 $TRACE_PATH
-       return $?
-}
-
-# Expected: No events.
-test_disable_same_wildcard_filter()
-{
-       local event_wild1="ust*"
-       local event_wild2="ust*"
-
-       echo ""
-       echo "=== Disable same wildcard with filter."
-
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1"
-       enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
-
-       disable_ust_lttng_event $SESSION_NAME "ust*"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_no_demo_events
-       return $?
-}
-
-# Expect no events
-test_enable_bad_wildcard()
-{
-       # Invalid event
-       local event_wild1="ust_tests_demo"
-       local event_wild2="ust_tests_demo2"
-       local event_wild3="ust_tests_demo3"
-
-       echo ""
-       echo "=== Enable bad wildcard"
-
-       enable_ust_lttng_event $SESSION_NAME "$event_wild1"
-       enable_ust_lttng_event $SESSION_NAME "$event_wild2"
-       enable_ust_lttng_event $SESSION_NAME "$event_wild3"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_no_demo_events
-       return $?
-}
-
-# Expect all "demo" events, no duplicate.
-test_enable_simple_wildcard_2()
-{
-       local event_wild1="us*"
-       local event_wild2="$DEMO_EVENT1"
-
-       echo ""
-       echo "=== Simple wildcard 2"
-
-       enable_ust_lttng_event $SESSION_NAME "$event_wild1"
-       enable_ust_lttng_event $SESSION_NAME "$event_wild2"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-       return $?
-}
-
-# Expected: all CRIT events, + all warning events.
-test_enable_loglevel_overlap()
-{
-       local event_wild1="us*"
-       local event_wild2="ust*"
-
-       echo ""
-       echo "=== Enable loglevel overlap"
-
-       enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING"
-       enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_CRIT"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-       return $?
-}
-
-# Expected: all CRIT events, + all warning events.
-test_enable_loglevel_only_overlap()
-{
-       local event_wild1="us*"
-       local event_wild2="ust*"
-
-       echo ""
-       echo "=== Enable loglevel only overlap"
-
-       enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING"
-       enable_ust_lttng_event_loglevel_only $SESSION_NAME "$event_wild2" "TRACE_CRIT"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-       return $?
-}
-
-# Expected: all events
-test_enable_loglevel_overlap_2()
-{
-       local event_wild1="us*"
-       local event_wild2="$DEMO_EVENT2"
-
-       echo ""
-       echo "=== Enable loglevel overlap 2"
-
-       enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING"
-       enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_CRIT"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-       return $?
-}
-
-# Expected only ust_tests_demo* events.
-test_enable_same_wildcard_loglevels()
-{
-       local event_wild1="ust*"
-       local event_wild2="ust*"
-
-       echo ""
-       echo "=== Enable same wildcard with different loglevels"
-
-       enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_CRIT"
-       enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_WARNING"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_match_all_demo_events
-       return $?
-}
-
-# Expected only ust_tests_demo:starting events.
-test_enable_same_event_loglevels()
-{
-       local event_wild1="$DEMO_EVENT1"
-       local event_wild2="$DEMO_EVENT1"
-
-       echo ""
-       echo "=== Enable same event with different loglevels"
-
-       enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_CRIT"
-       enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_WARNING"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
-       trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH
-       trace_matches $DEMO_EVENT2 0 $TRACE_PATH
-       trace_matches $DEMO_EVENT3 0 $TRACE_PATH
-       return $?
-}
-
-# Expect 0 event
-test_disable_simple_wildcard()
-{
-       local event_wild1="us*"
-       local event_wild2="$DEMO_EVENT1"
-
-       echo ""
-       echo "=== Disable simple wildcard"
-
-       enable_ust_lttng_event $SESSION_NAME "$event_wild1"
-       enable_ust_lttng_event $SESSION_NAME "$event_wild2"
-
-       disable_ust_lttng_event $SESSION_NAME "$event_wild1"
-       disable_ust_lttng_event $SESSION_NAME "$event_wild2"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       # No events are expected.
-       trace_match_no_demo_events
-       return $?
-}
-
-# Expect only "ust_tests_demo" events.
-test_disable_wildcard_overlap()
-{
-       local event_wild1="us*"
-       local event_wild2="$DEMO_EVENT1"
-
-       echo ""
-       echo "=== Disable wildcard overlap"
-
-       enable_ust_lttng_event $SESSION_NAME "$event_wild1"
-       enable_ust_lttng_event $SESSION_NAME "$event_wild2"
-
-       disable_ust_lttng_event $SESSION_NAME "$event_wild1"
-
-       start_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       run_demo_app
-
-       stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1
-
-       # Expect only "ust_tests_demo" events.
-       trace_matches "$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
-       trace_matches "$DEMO_EVENT1_2" 0 $TRACE_PATH
-       trace_matches "$DEMO_EVENT2" 0 $TRACE_PATH
-       trace_matches "$DEMO_EVENT3" 0 $TRACE_PATH
-       return $?
-}
-
-TESTS=(
-       "test_enable_wildcard_filter"
-       "test_enable_wildcard_filter_2"
-       "test_enable_wildcard_filter_3"
-       "test_enable_wildcard_filter_4"
-       "test_enable_wildcard_filter_5"
-       "test_enable_wildcard_filter_6"
-       "test_enable_wildcard_filter_7"
-       "test_enable_wildcard_filter_8"
-       "test_enable_same_wildcard_filter"
-       "test_enable_same_wildcard_filter_2"
-       "test_enable_same_wildcard_filter_3"
-       "test_enable_same_wildcard_filter_4"
-       "test_enable_same_event_filter"
-       "test_enable_loglevel_only_overlap"
-       "test_enable_same_event_loglevels"
-       "test_enable_same_wildcard_loglevels"
-       "test_enable_bad_wildcard"
-       "test_enable_loglevel_overlap_2"
-       "test_enable_simple_wildcard"
-       "test_enable_simple_wildcard_2"
-       "test_enable_loglevel_overlap"
-       "test_disable_simple_wildcard"
-       "test_disable_wildcard_overlap"
-)
-
-TEST_COUNT=${#TESTS[@]}
-i=0
-
-start_lttng_sessiond
-
-while [ "$i" -lt "$TEST_COUNT" ]; do
-
-       TRACE_PATH=$(mktemp -d)
-
-       create_lttng_session $SESSION_NAME $TRACE_PATH >/dev/null 2>&1
-
-       # Execute test
-       ${TESTS[$i]}
-       if [ $? -ne 0 ]; then
-               stop_lttng_sessiond
-               exit 1
-       fi
-
-       destroy_lttng_session $SESSION_NAME >/dev/null 2>&1
-
-       rm -rf $TRACE_PATH
-
-       let "i++"
-done
-
-stop_lttng_sessiond
diff --git a/tests/ust/overlap/run b/tests/ust/overlap/run
deleted file mode 100755 (executable)
index ca8efb3..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-
-DIR=$(dirname $0)
-
-tests=( $DIR/overlap.sh)
-
-exit_code=0
-
-function start_tests ()
-{
-    for bin in ${tests[@]};
-    do
-        ./$bin
-        # Test must return 0 to pass.
-        if [ $? -ne 0 ]; then
-            exit_code=1
-            break
-        fi
-    done
-}
-
-start_tests
-
-exit $exit_code
diff --git a/tests/ust/run-ust-global-tests.sh b/tests/ust/run-ust-global-tests.sh
deleted file mode 100755 (executable)
index e1a54ad..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/bash
-
-SESSIOND_BIN="lttng-sessiond"
-CURDIR=$(dirname $0)
-TESTDIR=$CURDIR/..
-
-source $TESTDIR/utils.sh
-
-tmpdir=`mktemp -d`
-tests=( $CURDIR/ust_global_event_basic $CURDIR/ust_global_event_wildcard )
-exit_code=0
-
-function start_tests ()
-{
-    for bin in ${tests[@]};
-    do
-               if [ ! -e $bin ]; then
-                       echo -e "$bin not found, passing"
-                       continue
-               fi
-
-               start_lttng_sessiond
-
-        ./$bin $tmpdir
-        # Test must return 0 to pass.
-        if [ $? -ne 0 ]; then
-            exit_code=1
-                       stop_lttng_sessiond
-            break
-        fi
-               stop_lttng_sessiond
-    done
-
-       # Cleaning up
-       rm -rf $tmpdir
-}
-
-TEST_DESC="UST tracer - Global domain (LTTNG_DOMAIN_UST)"
-
-print_test_banner "$TEST_DESC"
-
-start_tests
-
-exit $exit_code
diff --git a/tests/ust/runall.sh b/tests/ust/runall.sh
deleted file mode 100755 (executable)
index 01afcec..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-
-DIR=$(dirname $0)
-
-tests=( $DIR/run-ust-global-tests.sh $DIR/nprocesses/run \
-               $DIR/high-throughput/run $DIR/before-after/run \
-               $DIR/multi-session/run $DIR/overlap/run )
-
-# $DIR/low-throughput/run --> DEACTIVATED.
-# Use only for release. This test last 20 minutes
-
-exit_code=0
-
-function start_tests ()
-{
-    for bin in ${tests[@]};
-    do
-        ./$bin
-        # Test must return 0 to pass.
-        if [ $? -ne 0 ]; then
-            exit_code=1
-            break
-        fi
-    done
-}
-
-start_tests
-
-exit $exit_code
diff --git a/tests/ust/ust_global_event_basic.c b/tests/ust/ust_global_event_basic.c
deleted file mode 100644 (file)
index ad14afb..0000000
+++ /dev/null
@@ -1,299 +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, channel2;
-       struct lttng_event ev1, ev2, ev3;
-       struct lttng_event_context context;
-       char *session_name = "ust_global_event_basic";
-       char *session_name2 = "ust_global_event_basic2";
-       int ret = 0;
-
-       memset(&dom, 0, sizeof(dom));
-       memset(&channel, 0, sizeof(channel));
-       memset(&channel2, 0, sizeof(channel2));
-       memset(&ev1, 0, sizeof(ev1));
-       memset(&ev2, 0, sizeof(ev2));
-       memset(&ev3, 0, sizeof(ev3));
-       memset(&context, 0, sizeof(context));
-
-       dom.type = LTTNG_DOMAIN_UST;
-
-       /* Setup channel 1 */
-       strcpy(channel.name, "mychan");
-       channel.attr.overwrite = 0;
-       channel.attr.subbuf_size = 4096;
-       channel.attr.num_subbuf = 4;
-       channel.attr.switch_timer_interval = 0;
-       channel.attr.read_timer_interval = 200;
-       channel.attr.output = LTTNG_EVENT_MMAP;
-
-       /* Setup channel 2 */
-       strcpy(channel2.name, "mychan2");
-       channel2.attr.overwrite = 0;
-       channel2.attr.subbuf_size = 8192;
-       channel2.attr.num_subbuf = 8;
-       channel2.attr.switch_timer_interval = 0;
-       channel2.attr.read_timer_interval = 500;
-       channel2.attr.output = LTTNG_EVENT_MMAP;
-
-       strcpy(ev1.name, "tp1");
-       ev1.type = LTTNG_EVENT_TRACEPOINT;
-       ev1.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
-       strcpy(ev2.name, "ev2");
-       ev2.type = LTTNG_EVENT_TRACEPOINT;
-       ev2.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
-       strcpy(ev3.name, "ev3");
-       ev3.type = LTTNG_EVENT_TRACEPOINT;
-       ev3.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
-       printf("\nTesting tracing UST events:\n");
-       printf("-----------\n");
-
-       if (argc < 2) {
-               printf("Missing session trace path\n");
-               return 1;
-       }
-
-       printf("Creating tracing session (%s): ", argv[1]);
-       if ((ret = lttng_create_session(session_name, argv[1])) < 0) {
-               printf("error creating the session : %s\n", lttng_strerror(ret));
-               goto create_fail;
-       }
-       PRINT_OK();
-
-       printf("Creating tracing session 2 (%s): ", argv[1]);
-       if ((ret = lttng_create_session(session_name2, argv[1])) < 0) {
-               printf("error creating the session : %s\n", lttng_strerror(ret));
-               goto create_fail;
-       }
-       PRINT_OK();
-
-       printf("Creating session handle: ");
-       if ((handle = lttng_create_handle(session_name, &dom)) == NULL) {
-               printf("error creating handle: %s\n", lttng_strerror(ret));
-               goto handle_fail;
-       }
-       PRINT_OK();
-
-       printf("Enabling %s UST channel: ", channel.name);
-       if ((ret = lttng_enable_channel(handle, &channel)) < 0) {
-               printf("error enable channel: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Enabling %s UST channel2: ", channel2.name);
-       if ((ret = lttng_enable_channel(handle, &channel2)) < 0) {
-               printf("error enable channel: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Enabling %s UST event in channel %s: ", ev1.name, channel.name);
-       if ((ret = lttng_enable_event(handle, &ev1, channel.name)) < 0) {
-               printf("error enabling event: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Enabling %s UST event in channel %s: ", ev2.name, channel.name);
-       if ((ret = lttng_enable_event(handle, &ev2, channel.name)) < 0) {
-               printf("error enabling event: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Enabling %s UST event in channel %s: ", ev3.name, channel2.name);
-       if ((ret = lttng_enable_event(handle, &ev3, channel2.name)) < 0) {
-               printf("error enabling event: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       context.ctx = LTTNG_EVENT_CONTEXT_VPID;
-
-       printf("Adding context VPID to UST event %s in channel %s: ", ev1.name,
-                       channel.name);
-       if ((ret = lttng_add_context(handle, &context, ev1.name,
-                                       channel.name)) < 0) {
-               printf("error adding context VPID: %s\n", lttng_strerror(ret));
-               goto context_fail;
-       }
-       PRINT_OK();
-
-       context.ctx = LTTNG_EVENT_CONTEXT_VTID;
-
-       printf("Adding context VTID to UST event %s in channel %s: ", ev1.name,
-                       channel.name);
-       if ((ret = lttng_add_context(handle, &context, ev1.name,
-                                       channel.name)) < 0) {
-               printf("error adding context VTID: %s\n", lttng_strerror(ret));
-               goto context_fail;
-       }
-       PRINT_OK();
-
-       context.ctx = LTTNG_EVENT_CONTEXT_PTHREAD_ID;
-
-       printf("Adding context PTHREAD_ID to UST event %s in channel %s: ",
-                       ev1.name, channel.name);
-       if ((ret = lttng_add_context(handle, &context, ev1.name,
-                                       channel.name)) < 0) {
-               printf("error adding context PTHREAD_ID: %s\n", lttng_strerror(ret));
-               goto context_fail;
-       }
-       PRINT_OK();
-
-       context.ctx = LTTNG_EVENT_CONTEXT_PROCNAME;
-
-       printf("Adding context PROCNAME to UST event %s in channel %s: ",
-                       ev1.name, channel.name);
-       if ((ret = lttng_add_context(handle, &context, ev1.name,
-                                       channel.name)) < 0) {
-               printf("error adding context PROCNAME: %s\n", lttng_strerror(ret));
-               goto context_fail;
-       }
-       PRINT_OK();
-
-       context.ctx = LTTNG_EVENT_CONTEXT_PROCNAME;
-
-       printf("Adding context PROCNAME to UST event %s in channel %s: ",
-                       ev3.name, channel2.name);
-       if ((ret = lttng_add_context(handle, &context, ev3.name,
-                                       channel2.name)) < 0) {
-               printf("error adding context PROCNAME: %s\n", lttng_strerror(ret));
-               goto context_fail;
-       }
-       PRINT_OK();
-
-       printf("Disabling %s UST event: ", ev1.name);
-       if ((ret = lttng_disable_event(handle, ev1.name, channel.name)) < 0) {
-               printf("error enabling event: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Disabling %s UST event: ", ev3.name);
-       if ((ret = lttng_disable_event(handle, ev3.name, channel2.name)) < 0) {
-               printf("error enabling event: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Renabling %s UST event: ", ev1.name);
-       if ((ret = lttng_enable_event(handle, &ev1, channel.name)) < 0) {
-               printf("error enabling event: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Renabling %s UST event: ", ev3.name);
-       if ((ret = lttng_enable_event(handle, &ev3, channel.name)) < 0) {
-               printf("error enabling event: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Disabling channel %s: ", channel2.name);
-       if ((ret = lttng_disable_channel(handle, channel2.name)) < 0) {
-               printf("error disabling channel: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Start tracing: ");
-       if ((ret = lttng_start_tracing(session_name)) < 0) {
-               printf("error starting tracing: %s\n", lttng_strerror(ret));
-               goto start_fail;
-       }
-       PRINT_OK();
-
-       sleep(2);
-
-       printf("Stop tracing: ");
-       if ((ret = lttng_stop_tracing(session_name)) < 0) {
-               printf("error stopping tracing: %s\n", lttng_strerror(ret));
-               goto stop_fail;
-       }
-       PRINT_OK();
-
-       printf("Restart tracing: ");
-       if ((ret = lttng_start_tracing(session_name)) < 0) {
-               printf("error starting tracing: %s\n", lttng_strerror(ret));
-               goto start_fail;
-       }
-       PRINT_OK();
-
-       sleep(2);
-
-       printf("Stop tracing: ");
-       if ((ret = lttng_stop_tracing(session_name)) < 0) {
-               printf("error stopping tracing: %s\n", lttng_strerror(ret));
-               goto stop_fail;
-       }
-       PRINT_OK();
-
-       printf("Destroy tracing session 2: ");
-       if ((ret = lttng_destroy_session(session_name2)) < 0) {
-               printf("error destroying session 2: %s\n", lttng_strerror(ret));
-       }
-       PRINT_OK();
-
-       printf("Destroy tracing session: ");
-       if ((ret = lttng_destroy_session(session_name)) < 0) {
-               printf("error destroying session: %s\n", lttng_strerror(ret));
-       }
-       PRINT_OK();
-
-       return 0;
-
-handle_fail:
-       assert(handle != NULL);
-create_fail:
-       assert(ret != 0);
-
-stop_fail:
-start_fail:
-context_fail:
-enable_fail:
-       lttng_destroy_session(session_name2);
-       lttng_destroy_session(session_name);
-       lttng_destroy_handle(handle);
-
-       return 1;
-}
diff --git a/tests/ust/ust_global_event_wildcard.c b/tests/ust/ust_global_event_wildcard.c
deleted file mode 100644 (file)
index 198a541..0000000
+++ /dev/null
@@ -1,131 +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, ev2;
-       char *channel_name = "channel0";
-       char *channel_name2 = "channel2";
-       char *session_name = "ust_global_all_events_basic";
-       int ret = 0;
-
-       memset(&dom, 0, sizeof(dom));
-       memset(&event, 0, sizeof(event));
-       memset(&ev2, 0, sizeof(ev2));
-
-       dom.type = LTTNG_DOMAIN_UST;
-
-       event.type = LTTNG_EVENT_TRACEPOINT;
-       event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-       strcpy(event.name, "*");
-
-       ev2.type = LTTNG_EVENT_TRACEPOINT;
-       ev2.loglevel_type = LTTNG_EVENT_LOGLEVEL_RANGE;
-       ev2.loglevel = LTTNG_LOGLEVEL_NOTICE;
-       strcpy(ev2.name, "abc*");
-
-       printf("\nTesting tracing all UST events:\n");
-       printf("-----------\n");
-
-       if (argc < 2) {
-               printf("Missing session trace path\n");
-               return 1;
-       }
-
-       printf("Creating tracing session (%s): ", argv[1]);
-       if ((ret = lttng_create_session(session_name, argv[1])) < 0) {
-               printf("error creating the session : %s\n", lttng_strerror(ret));
-               goto create_fail;
-       }
-       PRINT_OK();
-
-       printf("Creating session handle: ");
-       if ((handle = lttng_create_handle(session_name, &dom)) == NULL) {
-               printf("error creating handle: %s\n", lttng_strerror(ret));
-               goto handle_fail;
-       }
-       PRINT_OK();
-
-       printf("Enabling '*' UST events: ");
-       if ((ret = lttng_enable_event(handle, &event, channel_name)) < 0) {
-               printf("error enabling event: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Enabling 'abc*' UST events: ");
-       if ((ret = lttng_enable_event(handle, &ev2, channel_name2)) < 0) {
-               printf("error enabling event: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Start tracing: ");
-       if ((ret = lttng_start_tracing(session_name)) < 0) {
-               printf("error starting tracing: %s\n", lttng_strerror(ret));
-               goto start_fail;
-       }
-       PRINT_OK();
-
-       sleep(2);
-
-       printf("Stop tracing: ");
-       if ((ret = lttng_stop_tracing(session_name)) < 0) {
-               printf("error stopping tracing: %s\n", lttng_strerror(ret));
-               goto stop_fail;
-       }
-       PRINT_OK();
-
-       printf("Destroy tracing session: ");
-       if ((ret = lttng_destroy_session(session_name)) < 0) {
-               printf("error destroying session: %s\n", lttng_strerror(ret));
-       }
-       PRINT_OK();
-
-       return 0;
-
-handle_fail:
-       assert(handle != NULL);
-create_fail:
-       assert(ret != 0);
-
-stop_fail:
-start_fail:
-enable_fail:
-       lttng_destroy_session(session_name);
-       lttng_destroy_handle(handle);
-
-       return 1;
-}
diff --git a/tests/utils.h b/tests/utils.h
deleted file mode 100644 (file)
index 94891c0..0000000
+++ /dev/null
@@ -1,43 +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.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-
-#define BRIGHT 1
-#define GREEN 32
-#define RED 31
-
-#define PRINT_OK()                                                     \
-do {                                                                   \
-       /* Check for color support */                                   \
-       if (isatty(STDOUT_FILENO)) {                                    \
-               printf("%c[%d;%dmOK%c[%dm\n", 0x1B, BRIGHT, GREEN, 0x1B, 0); \
-       } else {                                                        \
-               printf("OK\n");                                 \
-       }                                                               \
-} while (0)
-
-#define PRINT_FAIL() \
-do {                                                                   \
-       /* Check for color support */                                   \
-       if (isatty(STDOUT_FILENO)) {                                    \
-               printf("%c[%d;%dmFAIL%c[%dm\n", 0x1B, BRIGHT, RED, 0x1B, 0); \
-       } else {                                                        \
-               printf("FAIL\n");                                       \
-       }                                                               \
-} while (0)
diff --git a/tests/utils.sh b/tests/utils.sh
deleted file mode 100644 (file)
index 3bcdcc4..0000000
+++ /dev/null
@@ -1,433 +0,0 @@
-#!/src/bin/bash
-#
-# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-
-SESSIOND_BIN="lttng-sessiond"
-RELAYD_BIN="lttng-relayd"
-LTTNG_BIN="lttng"
-BABELTRACE_BIN="babeltrace"
-
-# Minimal kernel version supported for session daemon tests
-KERNEL_MAJOR_VERSION=2
-KERNEL_MINOR_VERSION=6
-KERNEL_PATCHLEVEL_VERSION=27
-
-function print_ok ()
-{
-       # Check if we are a terminal
-       if [ -t 1 ]; then
-               echo -e "\e[1;32mOK\e[0m"
-       else
-               echo -e "OK"
-       fi
-}
-
-function print_fail ()
-{
-       # Check if we are a terminal
-       if [ -t 1 ]; then
-               echo -e "\e[1;31mFAIL\e[0m"
-       else
-               echo -e "FAIL"
-       fi
-}
-
-function print_test_banner ()
-{
-       desc="$1"
-
-       count=$((${#desc}+2))
-       str=$(printf "%${count}s");
-       echo -e "\n"
-       echo -e ${str// /-}
-       echo -e " $desc "
-       echo -e ${str// /-}
-}
-
-function validate_kernel_version ()
-{
-       kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n'))
-       if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
-               return 0
-       fi
-       if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
-               return 0
-       fi
-       if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
-               return 0
-       fi
-       return 1
-}
-
-# Generate a random string 
-#  $1 = number of characters; defaults to 16
-#  $2 = include special characters; 1 = yes, 0 = no; defaults to yes
-function randstring() 
-{
-       [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]"
-       cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-16}
-       echo
-}
-
-function spawn_sessiond ()
-{
-       echo ""
-       echo -n "Starting session daemon... "
-       validate_kernel_version
-       if [ $? -ne 0 ]; then
-               echo -e "\n*** Kernel too old for session daemon tests ***\n"
-               return 2
-       fi
-
-       DIR=$(readlink -f $TESTDIR)
-
-       if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
-               $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
-               #$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --verbose-consumer >>/tmp/sessiond.log 2>&1 &
-               if [ $? -eq 1 ]; then
-                       print_fail
-                       return 1
-               else
-                       print_ok
-               fi
-       fi
-
-       return 0
-}
-
-function lttng_enable_kernel_event
-{
-       sess_name=$1
-       event_name=$2
-
-       if [ -z $event_name ]; then
-               # Enable all event if no event name specified
-               $event_name="-a"
-       fi
-
-       echo -n "Enabling kernel event $event_name for session $sess_name"
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -k >/dev/null 2>&1
-       if [ $? -eq 1 ]; then
-               print_fail
-               return 1
-       else
-               print_ok
-       fi
-}
-
-function start_lttng_relayd
-{
-       local opt=$1
-
-       echo -e -n "Starting lttng-relayd (opt: $opt)... "
-
-       DIR=$(readlink -f $TESTDIR)
-
-       if [ -z $(pidof lt-$RELAYD_BIN) ]; then
-               $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1 &
-               #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
-               if [ $? -eq 1 ]; then
-                       print_fail
-                       return 1
-               else
-                       print_ok
-               fi
-       else
-               print_ok
-       fi
-}
-
-function stop_lttng_relayd
-{
-       PID_RELAYD=`pidof lt-$RELAYD_BIN`
-
-       echo -e -n "Killing lttng-relayd (pid: $PID_RELAYD)... "
-       kill $PID_RELAYD >/dev/null 2>&1
-       if [ $? -eq 1 ]; then
-               print_fail
-               return 1
-       else
-               out=1
-               while [ -n "$out" ]; do
-                       out=$(pidof lt-$RELAYD_BIN)
-                       sleep 0.5
-               done
-               print_ok
-               return 0
-       fi
-}
-
-function start_lttng_sessiond()
-{
-       if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
-               # Env variable requested no session daemon
-               return
-       fi
-
-       spawn_sessiond
-       out=$?
-       if [ $out -eq 2 ]; then
-               # Kernel version is not compatible.
-               exit 0
-       elif [ $out -ne 0 ]; then
-               echo "NOT bad $?"
-               exit 1
-       fi
-
-       # Simply wait for the session daemon bootstrap
-       echo "Waiting for the session daemon to bootstrap (2 secs)"
-       sleep 2
-}
-
-function stop_lttng_sessiond ()
-{
-       if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
-               # Env variable requested no session daemon
-               return
-       fi
-
-       PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
-
-       echo -e -n "Killing session daemon... "
-       kill $PID_SESSIOND >/dev/null 2>&1
-       if [ $? -eq 1 ]; then
-               print_fail
-               return 1
-       else
-               out=1
-               while [ -n "$out" ]; do
-                       out=$(pidof lt-$SESSIOND_BIN)
-                       sleep 0.5
-               done
-               print_ok
-       fi
-}
-
-function create_lttng_session ()
-{
-       sess_name=$1
-       trace_path=$2
-
-       echo -n "Creating lttng session $sess_name in $trace_path "
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -o $trace_path >/dev/null 2>&1
-       if [ $? -eq 1 ]; then
-               print_fail
-               return 1
-       else
-               print_ok
-       fi
-}
-
-function enable_lttng_channel()
-{
-       sess_name=$1
-       channel_name=$2
-
-       echo -n "Enabling lttng channel $channel_name for session $sess_name"
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel $channel_name -s $sess_name >/dev/null 2>&1
-       if [ $? -eq 1 ]; then
-               print_fail
-               return 1
-       else
-               print_ok
-       fi
-}
-
-function disable_lttng_channel()
-{
-       sess_name=$1
-       channel_name=$2
-
-       echo -n "Disabling lttng channel $channel_name for session $sess_name"
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel $channel_name -s $sess_name >/dev/null 2>&1
-       if [ $? -eq 1 ]; then
-               print_fail
-               return 1
-       else
-               print_ok
-       fi
-}
-
-function enable_ust_lttng_event ()
-{
-       sess_name=$1
-       event_name="$2"
-
-       echo -n "Enabling lttng event $event_name for session $sess_name "
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u >/dev/null 2>&1
-       if [ $? -eq 1 ]; then
-               print_fail
-               return 1
-       else
-               print_ok
-       fi
-}
-
-function enable_ust_lttng_event_filter()
-{
-       sess_name="$1"
-       event_name="$2"
-       filter="$3"
-       echo -n "Enabling lttng event with filtering "
-
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --filter "$filter" 2>&1 >/dev/null
-       if [ $? -eq 0 ]; then
-               print_ok
-               return 0
-       else
-               print_fail
-               return 1
-       fi
-}
-
-function enable_ust_lttng_event_loglevel()
-{
-       sess_name="$1"
-       event_name="$2"
-       loglevel="$3"
-       echo -n "Enabling lttng event $event_name with loglevel $loglevel"
-
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel $loglevel 2>&1 >/dev/null
-       if [ $? -eq 0 ]; then
-               print_ok
-               return 0
-       else
-               print_fail
-               return 1
-       fi
-}
-
-function enable_ust_lttng_event_loglevel_only()
-{
-       sess_name="$1"
-       event_name="$2"
-       loglevel="$3"
-       echo -n "Enabling lttng event $event_name with loglevel-only $loglevel"
-
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel-only $loglevel 2>&1 >/dev/null
-       if [ $? -eq 0 ]; then
-               print_ok
-               return 0
-       else
-               print_fail
-               return 1
-       fi
-}
-
-function disable_ust_lttng_event ()
-{
-       sess_name="$1"
-       event_name="$2"
-
-       echo -n "Disabling lttng event $event_name for session $sess_name "
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -u >/dev/null 2>&1
-       if [ $? -eq 1 ]; then
-               print_fail
-               return 1
-       else
-               print_ok
-       fi
-}
-
-function start_lttng_tracing ()
-{
-       sess_name=$1
-
-       echo -n "Start lttng tracing for session $sess_name "
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name >/dev/null 2>&1
-       if [ $? -eq 1 ]; then
-               print_fail
-               return 1
-       else
-               print_ok
-       fi
-}
-
-function stop_lttng_tracing ()
-{
-       sess_name=$1
-
-       echo -n "Stop lttng tracing for session $sess_name "
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name >/dev/null 2>&1
-       if [ $? -eq 1 ]; then
-               print_fail
-               return 1
-       else
-               print_ok
-       fi
-}
-
-function destroy_lttng_session ()
-{
-       sess_name=$1
-
-       echo -n "Destroy lttng session $sess_name "
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $sess_name >/dev/null 2>&1
-       if [ $? -eq 1 ]; then
-               print_fail
-               return 1
-       else
-               print_ok
-       fi
-}
-
-function trace_matches ()
-{
-       event_name=$1
-       nr_iter=$2
-       trace_path=$3
-
-       which $BABELTRACE_BIN >/dev/null
-       if [ $? -eq 1 ]; then
-               echo "Babeltrace binary not found. Skipping trace matches"
-               return 0
-       fi
-
-       echo -n "Looking for $nr_iter $event_name in $trace_path "
-
-       count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
-       if [ "$count" -ne "$nr_iter" ]; then
-               echo -n "$count found in trace "
-               print_fail
-               return 1
-       else
-               echo -n "Trace is coherent "
-               print_ok
-               return 0
-       fi
-}
-
-function validate_trace
-{
-       event_name=$1
-       trace_path=$2
-
-       which $BABELTRACE_BIN >/dev/null
-       if [ $? -eq 1 ]; then
-               echo "Babeltrace binary not found. Skipping trace matches"
-               return 0
-       fi
-
-       echo -n "Validating trace for event $event_name... "
-       traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $event_name | wc -l)
-       if [ $traced -eq 0 ]; then
-               print_fail
-               return 1
-       else
-               print_ok
-               return 0
-       fi
-}
diff --git a/tests/utils/Makefile.am b/tests/utils/Makefile.am
new file mode 100644 (file)
index 0000000..feae65a
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = tap
diff --git a/tests/utils/runner.sh b/tests/utils/runner.sh
new file mode 100644 (file)
index 0000000..8f4932a
--- /dev/null
@@ -0,0 +1,48 @@
+#!/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.
+#
+
+function run_tests
+{
+       declare -a tests=("${!1}")
+       declare -a tests_opts=("${!2}")
+
+       gentap=0
+
+       for test_opt in ${tests_opts[@]};
+       do
+           case "$test_opt" in
+               --generate-tap-files) gentap=1 ;;
+               *) ;;
+           esac
+       done
+
+       for bin in ${tests[@]};
+       do
+               if [ ! -e $bin ]; then
+                       echo -e "$bin not found, skipping."
+                       continue
+               fi
+
+               if [ "$gentap" -eq 1 ]; then
+                       ./$bin > ${bin}.tap 2>&1
+               else
+                       ./$bin
+               fi
+       done
+}
diff --git a/tests/utils/tap/Makefile.am b/tests/utils/tap/Makefile.am
new file mode 100644 (file)
index 0000000..01df68a
--- /dev/null
@@ -0,0 +1,2 @@
+lib_LTLIBRARIES = libtap.la
+libtap_la_SOURCES = tap.c
diff --git a/tests/utils/tap/tap.c b/tests/utils/tap/tap.c
new file mode 100644 (file)
index 0000000..a430951
--- /dev/null
@@ -0,0 +1,427 @@
+/*-
+ * Copyright (c) 2004 Nik Clayton
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#define _GNU_SOURCE
+#include <ctype.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "tap.h"
+
+static int no_plan = 0;
+static int skip_all = 0;
+static int have_plan = 0;
+static unsigned int test_count = 0; /* Number of tests that have been run */
+static unsigned int e_tests = 0; /* Expected number of tests to run */
+static unsigned int failures = 0; /* Number of tests that failed */
+static char *todo_msg = NULL;
+static char *todo_msg_fixed = "libtap malloc issue";
+static int todo = 0;
+static int test_died = 0;
+
+/* Encapsulate the pthread code in a conditional.  In the absence of
+   libpthread the code does nothing */
+#ifdef HAVE_LIBPTHREAD
+#include <pthread.h>
+static pthread_mutex_t M = PTHREAD_MUTEX_INITIALIZER;
+# define LOCK pthread_mutex_lock(&M);
+# define UNLOCK pthread_mutex_unlock(&M);
+#else
+# define LOCK
+# define UNLOCK
+#endif
+
+static void _expected_tests(unsigned int);
+static void _tap_init(void);
+static void _cleanup(void);
+
+/*
+ * Generate a test result.
+ *
+ * ok -- boolean, indicates whether or not the test passed.
+ * test_name -- the name of the test, may be NULL
+ * test_comment -- a comment to print afterwards, may be NULL
+ */
+unsigned int
+_gen_result(int ok, const char *func, char *file, unsigned int line,
+           char *test_name, ...)
+{
+       va_list ap;
+       char *local_test_name = NULL;
+       char *c;
+       int name_is_digits;
+
+       LOCK;
+
+       test_count++;
+
+       /* Start by taking the test name and performing any printf()
+          expansions on it */
+       if(test_name != NULL) {
+               va_start(ap, test_name);
+               vasprintf(&local_test_name, test_name, ap);
+               va_end(ap);
+
+               /* Make sure the test name contains more than digits
+                  and spaces.  Emit an error message and exit if it
+                  does */
+               if(local_test_name) {
+                       name_is_digits = 1;
+                       for(c = local_test_name; *c != '\0'; c++) {
+                               if(!isdigit(*c) && !isspace(*c)) {
+                                       name_is_digits = 0;
+                                       break;
+                               }
+                       }
+
+                       if(name_is_digits) {
+                               diag("    You named your test '%s'.  You shouldn't use numbers for your test names.", local_test_name);
+                               diag("    Very confusing.");
+                       }
+               }
+       }
+
+       if(!ok) {
+               printf("not ");
+               failures++;
+       }
+
+       printf("ok %d", test_count);
+
+       if(test_name != NULL) {
+               printf(" - ");
+
+               /* Print the test name, escaping any '#' characters it
+                  might contain */
+               if(local_test_name != NULL) {
+                       flockfile(stdout);
+                       for(c = local_test_name; *c != '\0'; c++) {
+                               if(*c == '#')
+                                       fputc('\\', stdout);
+                               fputc((int)*c, stdout);
+                       }
+                       funlockfile(stdout);
+               } else {        /* vasprintf() failed, use a fixed message */
+                       printf("%s", todo_msg_fixed);
+               }
+       }
+
+       /* If we're in a todo_start() block then flag the test as being
+          TODO.  todo_msg should contain the message to print at this
+          point.  If it's NULL then asprintf() failed, and we should
+          use the fixed message.
+
+          This is not counted as a failure, so decrement the counter if
+          the test failed. */
+       if(todo) {
+               printf(" # TODO %s", todo_msg ? todo_msg : todo_msg_fixed);
+               if(!ok)
+                       failures--;
+       }
+
+       printf("\n");
+
+       if(!ok) {
+               if(getenv("HARNESS_ACTIVE") != NULL)
+                       fputs("\n", stderr);
+
+               diag("    Failed %stest (%s:%s() at line %d)",
+                    todo ? "(TODO) " : "", file, func, line);
+       }
+       free(local_test_name);
+
+       UNLOCK;
+
+       /* We only care (when testing) that ok is positive, but here we
+          specifically only want to return 1 or 0 */
+       return ok ? 1 : 0;
+}
+
+/*
+ * Initialise the TAP library.  Will only do so once, however many times it's
+ * called.
+ */
+void
+_tap_init(void)
+{
+       static int run_once = 0;
+
+       if(!run_once) {
+               atexit(_cleanup);
+
+               /* stdout needs to be unbuffered so that the output appears
+                  in the same place relative to stderr output as it does
+                  with Test::Harness */
+               setbuf(stdout, 0);
+               run_once = 1;
+       }
+}
+
+/*
+ * Note that there's no plan.
+ */
+int
+plan_no_plan(void)
+{
+
+       LOCK;
+
+       _tap_init();
+
+       if(have_plan != 0) {
+               fprintf(stderr, "You tried to plan twice!\n");
+               test_died = 1;
+               UNLOCK;
+               exit(255);
+       }
+
+       have_plan = 1;
+       no_plan = 1;
+
+       UNLOCK;
+
+       return 1;
+}
+
+/*
+ * Note that the plan is to skip all tests
+ */
+int
+plan_skip_all(char *reason)
+{
+
+       LOCK;
+
+       _tap_init();
+
+       skip_all = 1;
+
+       printf("1..0");
+
+       if(reason != NULL)
+               printf(" # Skip %s", reason);
+
+       printf("\n");
+
+       UNLOCK;
+
+       exit(0);
+}
+
+/*
+ * Note the number of tests that will be run.
+ */
+int
+plan_tests(unsigned int tests)
+{
+
+       LOCK;
+
+       _tap_init();
+
+       if(have_plan != 0) {
+               fprintf(stderr, "You tried to plan twice!\n");
+               test_died = 1;
+               UNLOCK;
+               exit(255);
+       }
+
+       if(tests == 0) {
+               fprintf(stderr, "You said to run 0 tests!  You've got to run something.\n");
+               test_died = 1;
+               UNLOCK;
+               exit(255);
+       }
+
+       have_plan = 1;
+
+       _expected_tests(tests);
+
+       UNLOCK;
+
+       return e_tests;
+}
+
+unsigned int
+diag(char *fmt, ...)
+{
+       va_list ap;
+
+       fputs("# ", stderr);
+
+       va_start(ap, fmt);
+       vfprintf(stderr, fmt, ap);
+       va_end(ap);
+
+       fputs("\n", stderr);
+
+       return 0;
+}
+
+void
+_expected_tests(unsigned int tests)
+{
+
+       printf("1..%d\n", tests);
+       e_tests = tests;
+}
+
+int
+skip(unsigned int n, char *fmt, ...)
+{
+       va_list ap;
+       char *skip_msg;
+
+       LOCK;
+
+       va_start(ap, fmt);
+       asprintf(&skip_msg, fmt, ap);
+       va_end(ap);
+
+       while(n-- > 0) {
+               test_count++;
+               printf("ok %d # skip %s\n", test_count,
+                      skip_msg != NULL ?
+                      skip_msg : "libtap():malloc() failed");
+       }
+
+       free(skip_msg);
+
+       UNLOCK;
+
+       return 1;
+}
+
+void
+todo_start(char *fmt, ...)
+{
+       va_list ap;
+
+       LOCK;
+
+       va_start(ap, fmt);
+       vasprintf(&todo_msg, fmt, ap);
+       va_end(ap);
+
+       todo = 1;
+
+       UNLOCK;
+}
+
+void
+todo_end(void)
+{
+
+       LOCK;
+
+       todo = 0;
+       free(todo_msg);
+
+       UNLOCK;
+}
+
+int
+exit_status(void)
+{
+       int r;
+
+       LOCK;
+
+       /* If there's no plan, just return the number of failures */
+       if(no_plan || !have_plan) {
+               UNLOCK;
+               return failures;
+       }
+
+       /* Ran too many tests?  Return the number of tests that were run
+          that shouldn't have been */
+       if(e_tests < test_count) {
+               r = test_count - e_tests;
+               UNLOCK;
+               return r;
+       }
+
+       /* Return the number of tests that failed + the number of tests
+          that weren't run */
+       r = failures + e_tests - test_count;
+       UNLOCK;
+
+       return r;
+}
+
+/*
+ * Cleanup at the end of the run, produce any final output that might be
+ * required.
+ */
+void
+_cleanup(void)
+{
+
+       LOCK;
+
+       /* If plan_no_plan() wasn't called, and we don't have a plan,
+          and we're not skipping everything, then something happened
+          before we could produce any output */
+       if(!no_plan && !have_plan && !skip_all) {
+               diag("Looks like your test died before it could output anything.");
+               UNLOCK;
+               return;
+       }
+
+       if(test_died) {
+               diag("Looks like your test died just after %d.", test_count);
+               UNLOCK;
+               return;
+       }
+
+
+       /* No plan provided, but now we know how many tests were run, and can
+          print the header at the end */
+       if(!skip_all && (no_plan || !have_plan)) {
+               printf("1..%d\n", test_count);
+       }
+
+       if((have_plan && !no_plan) && e_tests < test_count) {
+               diag("Looks like you planned %d %s but ran %d extra.",
+                    e_tests, e_tests == 1 ? "test" : "tests", test_count - e_tests);
+               UNLOCK;
+               return;
+       }
+
+       if((have_plan || !no_plan) && e_tests > test_count) {
+               diag("Looks like you planned %d %s but only ran %d.",
+                    e_tests, e_tests == 1 ? "test" : "tests", test_count);
+               UNLOCK;
+               return;
+       }
+
+       if(failures)
+               diag("Looks like you failed %d %s of %d.",
+                    failures, failures == 1 ? "test" : "tests", test_count);
+
+       UNLOCK;
+}
diff --git a/tests/utils/tap/tap.h b/tests/utils/tap/tap.h
new file mode 100644 (file)
index 0000000..0f05943
--- /dev/null
@@ -0,0 +1,89 @@
+/*-
+ * Copyright (c) 2004 Nik Clayton
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* '## __VA_ARGS__' is a gcc'ism. C99 doesn't allow the token pasting
+   and requires the caller to add the final comma if they've ommitted
+   the optional arguments */
+#ifdef __GNUC__
+# define ok(e, test, ...) ((e) ?                                       \
+                          _gen_result(1, __func__, __FILE__, __LINE__, \
+                                      test, ## __VA_ARGS__) :          \
+                          _gen_result(0, __func__, __FILE__, __LINE__, \
+                                      test, ## __VA_ARGS__))
+
+# define ok1(e) ((e) ?                                                 \
+                _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
+                _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
+
+# define pass(test, ...) ok(1, test, ## __VA_ARGS__);
+# define fail(test, ...) ok(0, test, ## __VA_ARGS__);
+
+# define skip_start(test, n, fmt, ...)                 \
+       do {                                            \
+               if((test)) {                            \
+                       skip(n, fmt, ## __VA_ARGS__);   \
+                       continue;                       \
+               }
+#elif __STDC_VERSION__ >= 199901L /* __GNUC__ */
+# define ok(e, ...) ((e) ?                                             \
+                    _gen_result(1, __func__, __FILE__, __LINE__,       \
+                                __VA_ARGS__) :                         \
+                    _gen_result(0, __func__, __FILE__, __LINE__,       \
+                                __VA_ARGS__))
+
+# define ok1(e) ((e) ?                                                 \
+                _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
+                _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
+
+# define pass(...) ok(1, __VA_ARGS__);
+# define fail(...) ok(0, __VA_ARGS__);
+
+# define skip_start(test, n, ...)                      \
+       do {                                            \
+               if((test)) {                            \
+                       skip(n,  __VA_ARGS__);          \
+                       continue;                       \
+               }
+#else /* __STDC_VERSION__ */
+# error "Needs gcc or C99 compiler for variadic macros."
+#endif /* __STDC_VERSION__ */
+
+#define skip_end() } while(0);
+
+unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...);
+
+int plan_no_plan(void);
+int plan_skip_all(char *);
+int plan_tests(unsigned int);
+
+unsigned int diag(char *, ...);
+
+int skip(unsigned int, char *, ...);
+
+void todo_start(char *, ...);
+void todo_end(void);
+
+int exit_status(void);
diff --git a/tests/utils/tap/tap.sh b/tests/utils/tap/tap.sh
new file mode 100755 (executable)
index 0000000..24ac1aa
--- /dev/null
@@ -0,0 +1,456 @@
+#!/bin/bash
+#
+# Copyright 2010 Patrick LeBoutillier <patrick.leboutillier@gmail.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, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    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, see <http://www.gnu.org/licenses/>.
+
+
+_version='1.01'
+
+_plan_set=0
+_no_plan=0
+_skip_all=0
+_test_died=0
+_expected_tests=0
+_executed_tests=0
+_failed_tests=0
+TODO=
+
+
+usage(){
+    cat <<'USAGE'
+tap-functions: A TAP-producing BASH library
+
+PLAN:
+  plan_no_plan
+  plan_skip_all [REASON]
+  plan_tests NB_TESTS
+
+TEST:
+  ok RESULT [NAME]
+  okx COMMAND
+  is RESULT EXPECTED [NAME]
+  isnt RESULT EXPECTED [NAME]
+  like RESULT PATTERN [NAME]
+  unlike RESULT PATTERN [NAME]
+  pass [NAME]
+  fail [NAME]
+
+SKIP:
+  skip [CONDITION] [REASON] [NB_TESTS=1]
+
+  skip $feature_not_present "feature not present" 2 || {
+      is $a "a"
+      is $b "b"
+  }
+
+TODO:
+  Specify TODO mode by setting $TODO:
+    TODO="not implemented yet"
+    ok $result "some not implemented test"
+    unset TODO
+
+OTHER:
+  diag MSG
+
+EXAMPLE:
+  #!/bin/bash
+
+  . tap-functions
+
+  plan_tests 7
+
+  me=$USER
+  is $USER $me "I am myself"
+  like $HOME $me "My home is mine"
+  like "`id`" $me "My id matches myself"
+
+  /bin/ls $HOME 1>&2
+  ok $? "/bin/ls $HOME"
+  # Same thing using okx shortcut
+  okx /bin/ls $HOME
+
+  [[ "`id -u`" != "0" ]]
+  i_am_not_root=$?
+  skip $i_am_not_root "Must be root" || {
+    okx ls /root
+  }
+
+  TODO="figure out how to become root..."
+  okx [ "$HOME" == "/root" ]
+  unset TODO
+USAGE
+    exit
+}
+
+opt=
+set_u=
+while getopts ":sx" opt ; do
+    case $_opt in
+        u) set_u=1 ;;
+        *) usage ;;
+    esac
+done
+shift $(( OPTIND - 1 ))
+# Don't allow uninitialized variables if requested
+[[ -n "$set_u" ]] && set -u
+unset opt set_u
+
+# Used to call _cleanup on shell exit
+trap _exit EXIT
+
+
+plan_no_plan(){
+    (( _plan_set != 0 )) && "You tried to plan twice!"
+
+    _plan_set=1
+    _no_plan=1
+
+    return 0
+}
+
+
+plan_skip_all(){
+    local reason=${1:-''}
+
+    (( _plan_set != 0 )) && _die "You tried to plan twice!"
+
+    _print_plan 0 "Skip $reason"
+
+    _skip_all=1
+    _plan_set=1
+    _exit 0
+
+    return 0
+}
+
+plan_tests(){
+    local tests=${1:?}
+
+    (( _plan_set != 0 )) && _die "You tried to plan twice!"
+    (( tests == 0 )) && _die "You said to run 0 tests!  You've got to run something."
+
+    _print_plan $tests
+    _expected_tests=$tests
+    _plan_set=1
+
+    return $tests
+}
+
+
+_print_plan(){
+    local tests=${1:?}
+    local directive=${2:-''}
+
+    echo -n "1..$tests"
+    [[ -n "$directive" ]] && echo -n " # $directive"
+    echo
+}
+
+
+pass(){
+    local name=$1
+    ok 0 "$name"
+}
+
+
+fail(){
+    local name=$1
+    ok 1 "$name"
+}
+
+# This is the workhorse method that actually
+# prints the tests result.
+ok(){
+    local result=${1:?}
+    local name=${2:-''}
+
+    (( _plan_set == 0 )) && _die "You tried to run a test without a plan!  Gotta have a plan."
+
+    _executed_tests=$(( $_executed_tests + 1 ))
+
+    if [[ -n "$name" ]] ; then
+        if _matches "$name" "^[0-9]+$" ; then
+            diag "    You named your test '$name'.  You shouldn't use numbers for your test names."
+            diag "    Very confusing."
+        fi
+    fi
+
+    if (( result != 0 )) ; then
+        echo -n "not "
+        _failed_tests=$(( _failed_tests + 1 ))
+    fi
+    echo -n "ok $_executed_tests"
+
+    if [[ -n "$name" ]] ; then
+        local ename=${name//\#/\\#}
+        echo -n " - $ename"
+    fi
+
+    if [[ -n "$TODO" ]] ; then
+        echo -n " # TODO $TODO" ;
+        if (( result != 0 )) ; then
+            _failed_tests=$(( _failed_tests - 1 ))
+        fi
+    fi
+
+    echo
+    if (( result != 0 )) ; then
+        local file='tap-functions'
+        local func=
+        local line=
+
+        local i=0
+        local bt=$(caller $i)
+        while _matches "$bt" "tap-functions$" ; do
+            i=$(( $i + 1 ))
+            bt=$(caller $i)
+        done
+        local backtrace=
+        eval $(caller $i | (read line func file ; echo "backtrace=\"$file:$func() at line $line.\""))
+
+        local t=
+        [[ -n "$TODO" ]] && t="(TODO) "
+
+        if [[ -n "$name" ]] ; then
+            diag "  Failed ${t}test '$name'"
+            diag "  in $backtrace"
+        else
+            diag "  Failed ${t}test in $backtrace"
+        fi
+    fi
+
+    return $result
+}
+
+
+okx(){
+    local command="$@"
+
+    local line=
+    diag "Output of '$command':"
+    "$@" | while read line ; do
+        diag "$line"
+    done
+    ok ${PIPESTATUS[0]} "$command"
+}
+
+
+_equals(){
+    local result=${1:?}
+    local expected=${2:?}
+
+    if [[ "$result" == "$expected" ]] ; then
+        return 0
+    else
+        return 1
+    fi
+}
+
+
+# Thanks to Aaron Kangas for the patch to allow regexp matching
+# under bash < 3.
+ _bash_major_version=${BASH_VERSION%%.*}
+_matches(){
+    local result=${1:?}
+    local pattern=${2:?}
+
+    if [[ -z "$result" || -z "$pattern" ]] ; then
+        return 1
+    else
+        if (( _bash_major_version >= 3 )) ; then
+            [[ "$result" =~ "$pattern" ]]
+        else
+            echo "$result" | egrep -q "$pattern"
+        fi
+    fi
+}
+
+
+_is_diag(){
+    local result=${1:?}
+    local expected=${2:?}
+
+    diag "         got: '$result'"
+    diag "    expected: '$expected'"
+}
+
+
+is(){
+    local result=${1:?}
+    local expected=${2:?}
+    local name=${3:-''}
+
+    _equals "$result" "$expected"
+    (( $? == 0 ))
+    ok $? "$name"
+    local r=$?
+    (( r != 0 )) && _is_diag "$result" "$expected"
+    return $r
+}
+
+
+isnt(){
+    local result=${1:?}
+    local expected=${2:?}
+    local name=${3:-''}
+
+    _equals "$result" "$expected"
+    (( $? != 0 ))
+    ok $? "$name"
+    local r=$?
+    (( r != 0 )) && _is_diag "$result" "$expected"
+    return $r
+}
+
+
+like(){
+    local result=${1:?}
+    local pattern=${2:?}
+    local name=${3:-''}
+
+    _matches "$result" "$pattern"
+    (( $? == 0 ))
+    ok $? "$name"
+    local r=$?
+    (( r != 0 )) && diag "    '$result' doesn't match '$pattern'"
+    return $r
+}
+
+
+unlike(){
+    local result=${1:?}
+    local pattern=${2:?}
+    local name=${3:-''}
+
+    _matches "$result" "$pattern"
+    (( $? != 0 ))
+    ok $? "$name"
+    local r=$?
+    (( r != 0 )) && diag "    '$result' matches '$pattern'"
+    return $r
+}
+
+
+skip(){
+    local condition=${1:?}
+    local reason=${2:-''}
+    local n=${3:-1}
+
+    if (( condition == 0 )) ; then
+        local i=
+        for (( i=0 ; i<$n ; i++ )) ; do
+            _executed_tests=$(( _executed_tests + 1 ))
+            echo "ok $_executed_tests # skip: $reason"
+        done
+        return 0
+    else
+        return
+    fi
+}
+
+
+diag(){
+    local msg=${1:?}
+
+    if [[ -n "$msg" ]] ; then
+        echo "# $msg"
+    fi
+
+    return 1
+}
+
+
+_die(){
+    local reason=${1:-'<unspecified error>'}
+
+    echo "$reason" >&2
+    _test_died=1
+    _exit 255
+}
+
+
+BAIL_OUT(){
+    local reason=${1:-''}
+
+    echo "Bail out! $reason" >&2
+    _exit 255
+}
+
+
+_cleanup(){
+    local rc=0
+
+    if (( _plan_set == 0 )) ; then
+        diag "Looks like your test died before it could output anything."
+        return $rc
+    fi
+
+    if (( _test_died != 0 )) ; then
+        diag "Looks like your test died just after $_executed_tests."
+        return $rc
+    fi
+
+    if (( _skip_all == 0 && _no_plan != 0 )) ; then
+        _print_plan $_executed_tests
+    fi
+
+    local s=
+    if (( _no_plan == 0 && _expected_tests < _executed_tests )) ; then
+        s= ; (( _expected_tests > 1 )) && s=s
+        local extra=$(( _executed_tests - _expected_tests ))
+        diag "Looks like you planned $_expected_tests test$s but ran $extra extra."
+        rc=1 ;
+    fi
+
+    if (( _no_plan == 0 && _expected_tests > _executed_tests )) ; then
+        s= ; (( _expected_tests > 1 )) && s=s
+        diag "Looks like you planned $_expected_tests test$s but only ran $_executed_tests."
+    fi
+
+    if (( _failed_tests > 0 )) ; then
+        s= ; (( _failed_tests > 1 )) && s=s
+        diag "Looks like you failed $_failed_tests test$s of $_executed_tests."
+    fi
+
+    return $rc
+}
+
+
+_exit_status(){
+    if (( _no_plan != 0 || _plan_set == 0 )) ; then
+        return $_failed_tests
+    fi
+
+    if (( _expected_tests < _executed_tests )) ; then
+        return $(( _executed_tests - _expected_tests  ))
+    fi
+
+    return $(( _failed_tests + ( _expected_tests - _executed_tests )))
+}
+
+
+_exit(){
+    local rc=${1:-''}
+    if [[ -z "$rc" ]] ; then
+        _exit_status
+        rc=$?
+    fi
+
+    _cleanup
+    local alt_rc=$?
+    (( alt_rc != 0 )) && rc=$alt_rc
+    trap - EXIT
+    exit $rc
+}
diff --git a/tests/utils/utils.h b/tests/utils/utils.h
new file mode 100644 (file)
index 0000000..94891c0
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) - 2011 David Goulet <david.goulet@polymtl.ca>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by as
+ * published by the Free Software Foundation; only version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+
+#define BRIGHT 1
+#define GREEN 32
+#define RED 31
+
+#define PRINT_OK()                                                     \
+do {                                                                   \
+       /* Check for color support */                                   \
+       if (isatty(STDOUT_FILENO)) {                                    \
+               printf("%c[%d;%dmOK%c[%dm\n", 0x1B, BRIGHT, GREEN, 0x1B, 0); \
+       } else {                                                        \
+               printf("OK\n");                                 \
+       }                                                               \
+} while (0)
+
+#define PRINT_FAIL() \
+do {                                                                   \
+       /* Check for color support */                                   \
+       if (isatty(STDOUT_FILENO)) {                                    \
+               printf("%c[%d;%dmFAIL%c[%dm\n", 0x1B, BRIGHT, RED, 0x1B, 0); \
+       } else {                                                        \
+               printf("FAIL\n");                                       \
+       }                                                               \
+} while (0)
diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh
new file mode 100644 (file)
index 0000000..6d72a06
--- /dev/null
@@ -0,0 +1,320 @@
+#!/src/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+
+SESSIOND_BIN="lttng-sessiond"
+RELAYD_BIN="lttng-relayd"
+LTTNG_BIN="lttng"
+BABELTRACE_BIN="babeltrace"
+
+# Minimal kernel version supported for session daemon tests
+KERNEL_MAJOR_VERSION=2
+KERNEL_MINOR_VERSION=6
+KERNEL_PATCHLEVEL_VERSION=27
+
+source $TESTDIR/utils/tap/tap.sh
+
+function print_ok ()
+{
+       # Check if we are a terminal
+       if [ -t 1 ]; then
+               echo -e "\e[1;32mOK\e[0m"
+       else
+               echo -e "OK"
+       fi
+}
+
+function print_fail ()
+{
+       # Check if we are a terminal
+       if [ -t 1 ]; then
+               echo -e "\e[1;31mFAIL\e[0m"
+       else
+               echo -e "FAIL"
+       fi
+}
+
+function print_test_banner ()
+{
+       desc="$1"
+       diag "$desc"
+}
+
+function validate_kernel_version ()
+{
+       kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n'))
+       if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
+               return 0
+       fi
+       if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
+               return 0
+       fi
+       if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
+               return 0
+       fi
+       return 1
+}
+
+# Generate a random string
+#  $1 = number of characters; defaults to 16
+#  $2 = include special characters; 1 = yes, 0 = no; defaults to yes
+function randstring()
+{
+       [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]"
+       cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-16}
+       echo
+}
+
+function lttng_enable_kernel_event
+{
+       sess_name=$1
+       event_name=$2
+
+       if [ -z $event_name ]; then
+               # Enable all event if no event name specified
+               event_name="-a"
+       fi
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -k >/dev/null 2>&1
+       ok $? "Enable kernel event $event_name for session $sess_name"
+}
+
+function start_lttng_relayd
+{
+       local opt=$1
+
+       DIR=$(readlink -f $TESTDIR)
+
+       if [ -z $(pidof lt-$RELAYD_BIN) ]; then
+               $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1 &
+               #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
+               if [ $? -eq 1 ]; then
+                       fail "Start lttng-relayd (opt: $opt)"
+                       return 1
+               else
+                       pass "Start lttng-relayd (opt: $opt)"
+               fi
+       else
+               pass "Start lttng-relayd (opt: $opt)"
+       fi
+}
+
+function stop_lttng_relayd
+{
+       PID_RELAYD=`pidof lt-$RELAYD_BIN`
+
+       kill $PID_RELAYD >/dev/null 2>&1
+
+       if [ $? -eq 1 ]; then
+               fail "Kill lttng-relayd (pid: $PID_RELAYD)"
+               return 1
+       else
+               out=1
+               while [ -n "$out" ]; do
+                       out=$(pidof lt-$RELAYD_BIN)
+                       sleep 0.5
+               done
+               pass "Kill lttng-relayd (pid: $PID_RELAYD)"
+               return 0
+       fi
+}
+
+function start_lttng_sessiond()
+{
+       if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
+               # Env variable requested no session daemon
+               return
+       fi
+
+       validate_kernel_version
+       if [ $? -ne 0 ]; then
+           fail "Start session daemon"
+           BAIL_OUT "*** Kernel too old for session daemon tests ***"
+       fi
+
+       DIR=$(readlink -f $TESTDIR)
+
+       if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
+               $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
+               #$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --verbose-consumer >>/tmp/sessiond.log 2>&1 &
+               status=$?
+               # Wait for sessiond to bootstrap
+               sleep 2
+               ok $status "Start session daemon"
+       fi
+}
+
+function stop_lttng_sessiond ()
+{
+       if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
+               # Env variable requested no session daemon
+               return
+       fi
+
+       PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
+
+       kill $PID_SESSIOND >/dev/null 2>&1
+
+       if [ $? -eq 1 ]; then
+               fail "Kill sessions daemon"
+               return 1
+       else
+               out=1
+               while [ -n "$out" ]; do
+                       out=$(pidof lt-$SESSIOND_BIN)
+                       sleep 0.5
+               done
+               pass "Kill session daemon"
+       fi
+}
+
+function create_lttng_session ()
+{
+       sess_name=$1
+       trace_path=$2
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -o $trace_path >/dev/null 2>&1
+       ok $? "Create session $sess_name in $trace_path"
+}
+
+function enable_ust_lttng_channel()
+{
+       sess_name=$1
+       channel_name=$2
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -u $channel_name -s $sess_name >/dev/null 2>&1
+       ok $? "Enable channel $channel_name for session $sess_name"
+}
+
+function disable_ust_lttng_channel()
+{
+       sess_name=$1
+       channel_name=$2
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel -u $channel_name -s $sess_name >/dev/null 2>&1
+       ok $? "Disable channel $channel_name for session $sess_name"
+}
+
+function enable_ust_lttng_event ()
+{
+       sess_name=$1
+       event_name="$2"
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u >/dev/null 2>&1
+       ok $? "Enable event $event_name for session $sess_name"
+}
+
+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" >/dev/null 2>&1
+       ok $? "Enable event $event_name with filtering for session $sess_name"
+}
+
+function enable_ust_lttng_event_loglevel()
+{
+       sess_name="$1"
+       event_name="$2"
+       loglevel="$3"
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel $loglevel >/dev/null 2>&1
+       ok $? "Enable event $event_name with loglevel $loglevel"
+}
+
+function enable_ust_lttng_event_loglevel_only()
+{
+       sess_name="$1"
+       event_name="$2"
+       loglevel="$3"
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel-only $loglevel >/dev/null 2>&1
+       ok $? "Enable event $event_name with loglevel-only $loglevel"
+}
+
+function disable_ust_lttng_event ()
+{
+       sess_name="$1"
+       event_name="$2"
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -u >/dev/null 2>&1
+       ok $? "Disable event $event_name for session $sess_name"
+}
+
+function start_lttng_tracing ()
+{
+       sess_name=$1
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name >/dev/null 2>&1
+       ok $? "Start tracing for session $sess_name"
+}
+
+function stop_lttng_tracing ()
+{
+       sess_name=$1
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name >/dev/null 2>&1
+       ok $? "Stop lttng tracing for session $sess_name"
+}
+
+function destroy_lttng_session ()
+{
+       sess_name=$1
+
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $sess_name >/dev/null 2>&1
+       ok $? "Destroy lttng session $sess_name"
+}
+
+function trace_matches ()
+{
+       event_name=$1
+       nr_iter=$2
+       trace_path=$3
+
+       which $BABELTRACE_BIN >/dev/null
+       skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
+
+       count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
+
+       if [ "$count" -ne "$nr_iter" ]; then
+               fail "Trace match"
+               diag "$count events found in trace"
+       else
+               pass "Trace match"
+       fi
+}
+
+function validate_trace
+{
+       event_name=$1
+       trace_path=$2
+
+       which $BABELTRACE_BIN >/dev/null
+       if [ $? -ne 0 ]; then
+           skip 0 "Babeltrace binary not found. Skipping trace validation"
+       fi
+
+       traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $event_name | wc -l)
+       if [ "$traced" -ne 0 ]; then
+           pass "Validate trace for event $event_name"
+       else
+           fail "Validate trace for event $event_name"
+           diag "Found $traced occurences of $event_name"
+       fi
+}
This page took 0.249341 seconds and 5 git commands to generate.