Improve tests and change tests/ directory layout
authorDavid Goulet <dgoulet@efficios.com>
Tue, 6 Mar 2012 21:59:55 +0000 (16:59 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 27 Mar 2012 19:34:59 +0000 (15:34 -0400)
Add run-report.py and test_list.py files which are an extended test framework
providing memory and CPU sampling of the session daemon during the tests.

Tests are now divided on a per package basis. The kernel/ directory contains
integration tests for lttng-modules (kernel tracer). ust/ directory contains
tests for lttng-ust and tools/ directory has the unit tests of lttng-tools
itself which does not test tracer integration.

First patch aimed at improving test coverage of the lttng 2.0 toolchain and
provide the python framework for more detailled analysis.

Use make check to run them all or use run-report.py and select which tests to
run in test_list.py.

Signed-off-by: David Goulet <dgoulet@efficios.com>
55 files changed:
.gitignore
configure.ac
tests/Makefile.am
tests/kernel/Makefile.am [new file with mode: 0644]
tests/kernel/kernel_all_events_basic.c [new file with mode: 0644]
tests/kernel/kernel_event_basic.c [new file with mode: 0644]
tests/kernel/run-kernel-tests.sh [new file with mode: 0755]
tests/kernel/runall.sh [new file with mode: 0755]
tests/lttng/kernel_all_events_basic.c [deleted file]
tests/lttng/kernel_event_basic.c [deleted file]
tests/lttng/run-kernel-tests.sh [deleted file]
tests/lttng/run-ust-global-tests.sh [deleted file]
tests/lttng/runall.sh [deleted file]
tests/lttng/ust_global_all_events_basic.c [deleted file]
tests/lttng/ust_global_event_basic.c [deleted file]
tests/run-report.py [new file with mode: 0755]
tests/runall.sh
tests/test_kernel_data_trace.c [deleted file]
tests/test_list.py [new file with mode: 0644]
tests/test_sessions.c [deleted file]
tests/test_ust_data_trace.c [deleted file]
tests/tools/Makefile.am [new file with mode: 0644]
tests/tools/runall.sh [new file with mode: 0755]
tests/tools/test_kernel_data_trace.c [new file with mode: 0644]
tests/tools/test_sessions.c [new file with mode: 0644]
tests/tools/test_ust_data_trace.c [new file with mode: 0644]
tests/ust-nevents/Makefile.am [deleted file]
tests/ust-nevents/gen-nevents.c [deleted file]
tests/ust-nevents/run [deleted file]
tests/ust-nevents/tp.c [deleted file]
tests/ust-nevents/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_gen_event.h [deleted file]
tests/ust/Makefile.am [new file with mode: 0644]
tests/ust/nevents/Makefile.am [new file with mode: 0644]
tests/ust/nevents/gen-nevents.c [new file with mode: 0644]
tests/ust/nevents/run [new file with mode: 0755]
tests/ust/nevents/tp.c [new file with mode: 0644]
tests/ust/nevents/ust-nevents [new file with mode: 0755]
tests/ust/nevents/ust_gen_nevents.h [new file with mode: 0644]
tests/ust/nprocesses/Makefile.am [new file with mode: 0644]
tests/ust/nprocesses/gen-events-time.c [new file with mode: 0644]
tests/ust/nprocesses/run [new file with mode: 0755]
tests/ust/nprocesses/tp.c [new file with mode: 0644]
tests/ust/nprocesses/ust-nprocesses [new file with mode: 0755]
tests/ust/nprocesses/ust_gen_event.h [new file with mode: 0644]
tests/ust/run-ust-global-tests.sh [new file with mode: 0755]
tests/ust/runall.sh [new file with mode: 0755]
tests/ust/ust_global_all_events_basic.c [new file with mode: 0644]
tests/ust/ust_global_event_basic.c [new file with mode: 0644]
tests/utils.h
tests/utils.sh

index 0eacb03bb3cadf1245e14f455afe5af67a61b746..ac0b2f43346cb6219c2d521ee80f1471299892e7 100644 (file)
@@ -3,6 +3,7 @@
 *.swp
 *.o
 *.swo
 *.swp
 *.o
 *.swo
+*.pyc
 Makefile
 .libs/
 .deps/
 Makefile
 .libs/
 .deps/
@@ -34,14 +35,15 @@ src/bin/lttng-sessiond/lttng-sessiond
 src/bin/lttng/lttng
 src/bin/lttng-consumerd/lttng-consumerd
 
 src/bin/lttng/lttng
 src/bin/lttng-consumerd/lttng-consumerd
 
-tests/test_sessions
-tests/test_kernel_data_trace
-tests/test_ust_data_trace
-tests/kernel_all_events_basic
-tests/kernel_event_basic
-tests/ust_global_all_events_basic
-tests/ust_global_event_basic
-tests/ust-nevents/gen-nevents
-tests/ust-nprocesses/gen-events-time
+# Tests
+test_sessions
+test_kernel_data_trace
+test_ust_data_trace
+kernel_all_events_basic
+kernel_event_basic
+ust_global_all_events_basic
+ust_global_event_basic
+gen-nevents
+gen-events-time
 
 benchmark/
 
 benchmark/
index 5808c7914a250d66f80af8e9dcd5d8cfeb624d2e..f8518c568f62a63ead9d7c008fd7381c1ef942c2 100644 (file)
@@ -194,8 +194,11 @@ AC_CONFIG_FILES([
        src/bin/lttng-sessiond/Makefile
        src/bin/lttng/Makefile
        tests/Makefile
        src/bin/lttng-sessiond/Makefile
        src/bin/lttng/Makefile
        tests/Makefile
-       tests/ust-nevents/Makefile
-       tests/ust-nprocesses/Makefile
+       tests/kernel/Makefile
+       tests/tools/Makefile
+       tests/ust/Makefile
+       tests/ust/nevents/Makefile
+       tests/ust/nprocesses/Makefile
 ])
 
 AC_OUTPUT
 ])
 
 AC_OUTPUT
index 8dd05a4f0cfb646fdf6cc590a7229fdddeaa3df5..27570566b509c093d542ff266710aa5beae4d848 100644 (file)
@@ -1,43 +1,12 @@
-SUBDIRS = .
+SUBDIRS = . tools kernel
 
 AM_CFLAGS = -g -Wall
 AM_LDFLAGS = -lurcu -lurcu-cds
 
 
 AM_CFLAGS = -g -Wall
 AM_LDFLAGS = -lurcu -lurcu-cds
 
-EXTRA_DIST = runall.sh utils.sh lttng/runall.sh lttng/run-kernel-tests.sh
-
-noinst_PROGRAMS = test_sessions test_kernel_data_trace \
-                                 kernel_all_events_basic kernel_event_basic
-
-UTILS=utils.h
-SESSIONS=$(top_srcdir)/src/bin/lttng-sessiond/session.c
-KERN_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-kernel.c
-LIBLTTNG=$(top_srcdir)/src/lib/lttng-ctl/lttng-ctl.c \
-                $(top_srcdir)/src/common/sessiond-comm/sessiond-comm.c
-
-test_sessions_SOURCES = test_sessions.c $(UTILS) $(SESSIONS)
-test_sessions_LDADD = $(top_builddir)/src/common/libcommon.la \
-                                         $(top_builddir)/src/common/hashtable/libhashtable.la
-
-test_kernel_data_trace_SOURCES = test_kernel_data_trace.c $(UTILS) $(KERN_DATA_TRACE)
-
-kernel_all_events_basic_SOURCES = lttng/kernel_all_events_basic.c $(UTILS) $(LIBLTTNG)
-
-kernel_event_basic_SOURCES = lttng/kernel_event_basic.c $(UTILS) $(LIBLTTNG)
+EXTRA_DIST = run-report.py test_list.py utils.sh utils.h
 
 if HAVE_LIBLTTNG_UST_CTL
 
 if HAVE_LIBLTTNG_UST_CTL
-SUBDIRS += ust-nevents ust-nprocesses
-EXTRA_DIST += lttng/run-ust-global-tests.sh
-noinst_PROGRAMS += ust_global_event_basic ust_global_all_events_basic test_ust_data_trace
-
-UST_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-ust.c
-
-test_ust_data_trace_SOURCES = test_ust_data_trace.c $(UTILS) $(UST_DATA_TRACE)
-test_ust_data_trace_LDADD = $(top_builddir)/src/common/libcommon.la \
-                                                       $(top_builddir)/src/common/hashtable/libhashtable.la
-
-ust_global_all_events_basic_SOURCES = lttng/ust_global_all_events_basic.c $(UTILS) $(LIBLTTNG)
-
-ust_global_event_basic_SOURCES = lttng/ust_global_event_basic.c $(UTILS) $(LIBLTTNG)
+SUBDIRS += ust
 endif # HAVE_LIBLTTNG_UST_CTL
 
 check-am:
 endif # HAVE_LIBLTTNG_UST_CTL
 
 check-am:
diff --git a/tests/kernel/Makefile.am b/tests/kernel/Makefile.am
new file mode 100644 (file)
index 0000000..50e7719
--- /dev/null
@@ -0,0 +1,15 @@
+AM_CFLAGS = -g -Wall -I../
+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_srcdir)/src/lib/lttng-ctl/lttng-ctl.c \
+                $(top_srcdir)/src/common/sessiond-comm/sessiond-comm.c
+
+
+kernel_all_events_basic_SOURCES = kernel_all_events_basic.c $(UTILS) $(LIBLTTNG)
+
+kernel_event_basic_SOURCES = kernel_event_basic.c $(UTILS) $(LIBLTTNG)
diff --git a/tests/kernel/kernel_all_events_basic.c b/tests/kernel/kernel_all_events_basic.c
new file mode 100644 (file)
index 0000000..2e56e6a
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * 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;
+
+create_fail:
+       assert(ret != 0);
+handle_fail:
+       assert(handle != NULL);
+
+stop_fail:
+start_fail:
+enable_fail:
+       lttng_destroy_session(session_name);
+       lttng_destroy_handle(handle);
+
+       return 1;
+}
diff --git a/tests/kernel/kernel_event_basic.c b/tests/kernel/kernel_event_basic.c
new file mode 100644 (file)
index 0000000..a7d7dfa
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ * 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;
+
+create_fail:
+       assert(ret != 0);
+handle_fail:
+       assert(handle != NULL);
+
+stop_fail:
+start_fail:
+enable_fail:
+       lttng_destroy_session(session_name);
+       lttng_destroy_handle(handle);
+
+       return 1;
+}
diff --git a/tests/kernel/run-kernel-tests.sh b/tests/kernel/run-kernel-tests.sh
new file mode 100755 (executable)
index 0000000..2881c42
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+SESSIOND_BIN="lttng-sessiond"
+TESTDIR=$(dirname $0)/..
+
+source $TESTDIR/utils.sh
+
+tmpdir=`mktemp -d`
+tests=( kernel_event_basic kernel_all_events_basic )
+exit_code=0
+
+function start_tests ()
+{
+    for bin in ${tests[@]};
+    do
+               start_sessiond
+
+        ./$bin $tmpdir
+        # Test must return 0 to pass.
+        if [ $? -ne 0 ]; then
+            exit_code=1
+                       stop_sessiond
+            break
+        fi
+               stop_sessiond
+    done
+
+       # Cleaning up
+       rm -rf $tmpdir
+}
+
+function check_lttng_modules ()
+{
+       local out=`modprobe -l | 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
+}
+
+echo -e "\n---------------------"
+echo -e "Testing Kernel tracer"
+echo -e "---------------------"
+
+# Detect lttng-modules installed
+check_lttng_modules
+
+start_tests
+
+exit $exit_code
diff --git a/tests/kernel/runall.sh b/tests/kernel/runall.sh
new file mode 100755 (executable)
index 0000000..2b76e53
--- /dev/null
@@ -0,0 +1,23 @@
+#!/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/lttng/kernel_all_events_basic.c b/tests/lttng/kernel_all_events_basic.c
deleted file mode 100644 (file)
index 6964a6f..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;
-
-create_fail:
-       assert(ret != 0);
-handle_fail:
-       assert(handle != NULL);
-
-stop_fail:
-start_fail:
-enable_fail:
-       lttng_destroy_session(session_name);
-       lttng_destroy_handle(handle);
-
-       return 1;
-}
diff --git a/tests/lttng/kernel_event_basic.c b/tests/lttng/kernel_event_basic.c
deleted file mode 100644 (file)
index 0af797c..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;
-
-create_fail:
-       assert(ret != 0);
-handle_fail:
-       assert(handle != NULL);
-
-stop_fail:
-start_fail:
-enable_fail:
-       lttng_destroy_session(session_name);
-       lttng_destroy_handle(handle);
-
-       return 1;
-}
diff --git a/tests/lttng/run-kernel-tests.sh b/tests/lttng/run-kernel-tests.sh
deleted file mode 100755 (executable)
index d5a4138..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/bash
-
-SESSIOND_BIN="lttng-sessiond"
-TESTDIR=$(dirname $0)/..
-
-source $TESTDIR/utils.sh
-
-tmpdir=`mktemp -d`
-tests=( kernel_event_basic kernel_all_events_basic )
-exit_code=0
-
-function start_tests ()
-{
-    for bin in ${tests[@]};
-    do
-        ./$bin $tmpdir
-        # Test must return 0 to pass.
-        if [ $? -ne 0 ]; then
-            exit_code=1
-            break
-        fi
-    done
-
-       # Cleaning up
-       rm -rf $tmpdir
-}
-
-function check_lttng_modules ()
-{
-       local out=`modprobe -l | 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
-}
-
-echo -e "\n--------------------------------------------------"
-echo -e "Kernel tracer - Testing lttng client (liblttngctl)"
-echo -e "--------------------------------------------------"
-
-# Detect lttng-modules installed
-
-check_lttng_modules
-
-# Simply wait for the session daemon bootstrap
-sleep 1
-
-start_tests
-
-exit $exit_code
diff --git a/tests/lttng/run-ust-global-tests.sh b/tests/lttng/run-ust-global-tests.sh
deleted file mode 100755 (executable)
index a99ff43..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/bash
-
-SESSIOND_BIN="lttng-sessiond"
-TESTDIR=$(dirname $0)/..
-
-source $TESTDIR/utils.sh
-
-tmpdir=`mktemp -d`
-tests=( ust_global_event_basic ust_global_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
-
-        ./$bin $tmpdir
-        # Test must return 0 to pass.
-        if [ $? -ne 0 ]; then
-            exit_code=1
-            break
-        fi
-    done
-
-       # Cleaning up
-       rm -rf $tmpdir
-}
-
-echo -e "\n-------------------------------------------"
-echo -e "UST tracer - Global domain (LTTNG_DOMAIN_UST)"
-echo -e "---------------------------------------------"
-
-PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
-
-# Simply wait for the session daemon bootstrap
-sleep 1
-
-start_tests
-
-exit $exit_code
diff --git a/tests/lttng/runall.sh b/tests/lttng/runall.sh
deleted file mode 100755 (executable)
index c5446c9..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-
-tests=( lttng/run-kernel-tests.sh lttng/run-ust-global-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/lttng/ust_global_all_events_basic.c b/tests/lttng/ust_global_all_events_basic.c
deleted file mode 100644 (file)
index 03363a8..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * as published by the Free Software Foundation; only version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#define _GNU_SOURCE
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
-
-#include <lttng/lttng.h>
-
-#include "../utils.h"
-
-int lttng_opt_quiet;
-
-int main(int argc, char **argv)
-{
-       struct lttng_handle *handle = NULL;
-       struct lttng_domain dom;
-       struct lttng_event event;
-       char *channel_name = "channel0";
-       char *session_name = "ust_global_all_events_basic";
-       int ret = 0;
-
-       memset(&dom, 0, sizeof(dom));
-       memset(&event, 0, sizeof(event));
-       dom.type = LTTNG_DOMAIN_UST;
-       event.type = LTTNG_EVENT_TRACEPOINT;
-       event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
-       printf("\nTesting tracing all UST events:\n");
-       printf("-----------\n");
-
-       if (argc < 2) {
-               printf("Missing session trace path\n");
-               return 1;
-       }
-
-       printf("Creating tracing session (%s): ", argv[1]);
-       if ((ret = lttng_create_session(session_name, argv[1])) < 0) {
-               printf("error creating the session : %s\n", lttng_strerror(ret));
-               goto create_fail;
-       }
-       PRINT_OK();
-
-       printf("Creating session handle: ");
-       if ((handle = lttng_create_handle(session_name, &dom)) == NULL) {
-               printf("error creating handle: %s\n", lttng_strerror(ret));
-               goto handle_fail;
-       }
-       PRINT_OK();
-
-       printf("Enabling all UST events: ");
-       if ((ret = lttng_enable_event(handle, &event, channel_name)) < 0) {
-               printf("error enabling event: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Start tracing: ");
-       if ((ret = lttng_start_tracing(session_name)) < 0) {
-               printf("error starting tracing: %s\n", lttng_strerror(ret));
-               goto start_fail;
-       }
-       PRINT_OK();
-
-       sleep(2);
-
-       printf("Stop tracing: ");
-       if ((ret = lttng_stop_tracing(session_name)) < 0) {
-               printf("error stopping tracing: %s\n", lttng_strerror(ret));
-               goto stop_fail;
-       }
-       PRINT_OK();
-
-       printf("Destroy tracing session: ");
-       if ((ret = lttng_destroy_session(session_name)) < 0) {
-               printf("error destroying session: %s\n", lttng_strerror(ret));
-       }
-       PRINT_OK();
-
-       return 0;
-
-create_fail:
-       assert(ret != 0);
-handle_fail:
-       assert(handle != NULL);
-
-stop_fail:
-start_fail:
-enable_fail:
-       lttng_destroy_session(session_name);
-       lttng_destroy_handle(handle);
-
-       return 1;
-}
diff --git a/tests/lttng/ust_global_event_basic.c b/tests/lttng/ust_global_event_basic.c
deleted file mode 100644 (file)
index 24dcec5..0000000
+++ /dev/null
@@ -1,200 +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 ev1, ev2, ev3;
-       char *session_name = "ust_global_event_basic";
-       int ret = 0;
-
-       memset(&dom, 0, sizeof(dom));
-       memset(&channel, 0, sizeof(channel));
-       memset(&ev1, 0, sizeof(ev1));
-       memset(&ev2, 0, sizeof(ev2));
-       memset(&ev3, 0, sizeof(ev3));
-
-       dom.type = LTTNG_DOMAIN_UST;
-       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;
-
-       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 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 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("Enabling %s UST event: ", ev2.name);
-       if ((ret = lttng_enable_event(handle, &ev2, channel.name)) < 0) {
-               printf("error enabling event: %s\n", lttng_strerror(ret));
-               goto enable_fail;
-       }
-       PRINT_OK();
-
-       printf("Enabling %s UST event: ", ev3.name);
-       if ((ret = lttng_enable_event(handle, &ev3, channel.name)) < 0) {
-               printf("error enabling event: %s\n", lttng_strerror(ret));
-               goto enable_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, channel.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("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: ");
-       if ((ret = lttng_destroy_session(session_name)) < 0) {
-               printf("error destroying session: %s\n", lttng_strerror(ret));
-       }
-       PRINT_OK();
-
-       return 0;
-
-create_fail:
-       assert(ret != 0);
-handle_fail:
-       assert(handle != NULL);
-
-stop_fail:
-start_fail:
-enable_fail:
-       lttng_destroy_session(session_name);
-       lttng_destroy_handle(handle);
-
-       return 1;
-}
diff --git a/tests/run-report.py b/tests/run-report.py
new file mode 100755 (executable)
index 0000000..0b67027
--- /dev/null
@@ -0,0 +1,416 @@
+#!/usr/bin/env python
+
+import os, sys
+import subprocess
+import threading
+import Queue
+import time
+
+from signal import signal, SIGTERM, SIGINT
+
+SESSIOND_BIN_NAME = "lttng-sessiond"
+SESSIOND_BIN_PATH = "src/bin/lttng-sessiond/.libs/"
+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 word in words:
+        index = word.find('%')
+        # Add the value to the dictionnary
+        top_dict[word[index + 1:]] = float(word[:index])
+
+    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):
+        threading.Thread.__init__(self)
+        self.path = path
+        self.name = name
+
+    def run(self):
+        bin_path_name = os.path.join(self.path, self.name)
+
+        env = os.environ
+        env['TEST_NO_SESSIOND'] = '1'
+
+        test = subprocess.Popen([bin_path_name], env=env)
+        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)
+
+    if not os.path.isfile(bin_path):
+        print "Error: No session daemon binary found. Compiled?"
+        return 0
+
+    try:
+        sdaemon_proc = subprocess.Popen([bin_path, "-d"], shell=False,
+                stderr = subprocess.PIPE)
+    except OSError, e:
+        print e
+        return 0
+
+    return get_pid(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"
+        return 0
+
+    # No session daemon needed
+    if not test['daemon']:
+        print PRINT_ARROW + " No session daemon needed"
+        ret = start_test(test['bin'])
+        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)
+
+    tw = TestWorker(".", test['bin'])
+    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)
index 5e1c0f537a8113a337237513e3977710b7a66760..0adbb2e4bb709863b4a4207db7a607602449fb6f 100755 (executable)
 
 #### ADD TESTS HERE ####
 
 
 #### ADD TESTS HERE ####
 
-# A spawned session daemon is needed for those tests
-test_with_sessiond=( lttng/runall.sh ust-nevents/run ust-nprocesses/run )
-
-# No session daemon needed
-test_no_sessiond=( test_sessions test_kernel_data_trace test_ust_data_trace )
+tests=( kernel/runall.sh ust/runall.sh tools/runall.sh )
 
 #### END TESTS HERE ####
 
 
 #### END TESTS HERE ####
 
@@ -31,35 +27,9 @@ TESTDIR=$(dirname $0)
 
 source $TESTDIR/utils.sh
 
 
 source $TESTDIR/utils.sh
 
-## NO Session daemon ##
-for bin in ${test_no_sessiond[@]};
-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
-
-# With session daemon
-start_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
-
-for bin in ${test_with_sessiond[@]};
+## lttng-tools unit tests ##
+# No session daemon needed
+for bin in ${tests[@]};
 do
        if [ ! -e $bin ]; then
                echo -e "$bin not found, passing"
 do
        if [ ! -e $bin ]; then
                echo -e "$bin not found, passing"
@@ -71,11 +41,9 @@ do
        if [ $? -ne 0 ]; then
                echo -e '\e[1;31mFAIL\e[0m'
                echo ""
        if [ $? -ne 0 ]; then
                echo -e '\e[1;31mFAIL\e[0m'
                echo ""
-               stop_sessiond
                exit 1
        fi
 done
 
                exit 1
        fi
 done
 
-echo ""
-stop_sessiond
+# All passed
 exit 0
 exit 0
diff --git a/tests/test_kernel_data_trace.c b/tests/test_kernel_data_trace.c
deleted file mode 100644 (file)
index 6d7f291..0000000
+++ /dev/null
@@ -1,208 +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);
-       assert(kern->consumer_fd == -1);
-       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(PATH1);
-       assert(kern->metadata != NULL);
-       PRINT_OK();
-
-       printf("Validating kernel session metadata: ");
-       assert(kern->metadata->fd == -1);
-       assert(strlen(kern->metadata->pathname));
-       assert(kern->metadata->conf != NULL);
-       assert(kern->metadata->conf->attr.overwrite
-                       == DEFAULT_CHANNEL_OVERWRITE);
-       assert(kern->metadata->conf->attr.subbuf_size
-                       == DEFAULT_METADATA_SUBBUF_SIZE);
-       assert(kern->metadata->conf->attr.num_subbuf
-                       == DEFAULT_METADATA_SUBBUF_NUM);
-       assert(kern->metadata->conf->attr.switch_timer_interval
-                       == DEFAULT_CHANNEL_SWITCH_TIMER);
-       assert(kern->metadata->conf->attr.read_timer_interval
-                       == DEFAULT_CHANNEL_READ_TIMER);
-       assert(kern->metadata->conf->attr.output
-                       == DEFAULT_KERNEL_CHANNEL_OUTPUT);
-       PRINT_OK();
-
-       trace_kernel_destroy_metadata(kern->metadata);
-}
-
-static void create_kernel_channel(void)
-{
-       struct ltt_kernel_channel *chan;
-       struct lttng_channel attr;
-
-       memset(&attr, 0, sizeof(attr));
-
-       printf("Creating kernel channel: ");
-       chan = trace_kernel_create_channel(&attr, PATH1);
-       assert(chan != NULL);
-       PRINT_OK();
-
-       printf("Validating kernel channel: ");
-       assert(chan->fd == -1);
-       assert(chan->enabled == 1);
-       assert(strcmp(PATH1, chan->pathname) == 0);
-       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->ctx == NULL);
-       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();
-       assert(stream != NULL);
-       PRINT_OK();
-
-       printf("Validating kernel stream: ");
-       assert(stream->fd == -1);
-       assert(stream->pathname == NULL);
-       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/test_list.py b/tests/test_list.py
new file mode 100644 (file)
index 0000000..bb9748a
--- /dev/null
@@ -0,0 +1,49 @@
+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
+    },
+
+    #### KERNEL ####
+    {
+    '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 ####
+    {
+    '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/nevents/run", 'daemon': True, 'kern': False,
+    'name': "UST tracer - Generate multiple events",
+    'desc': "Test multiple events during tracing",
+    'success': 0, 'enabled': True
+    },
+]
diff --git a/tests/test_sessions.c b/tests/test_sessions.c
deleted file mode 100644 (file)
index e555935..0000000
+++ /dev/null
@@ -1,348 +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 "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;
-}
-
-/*
- * 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);
-               session_list->count--;
-               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 == LTTCOMM_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 == LTTCOMM_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 == LTTCOMM_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;
-       }
-
-       ret = create_one_session(SESSION1, NULL);
-       if (ret > 0) {
-               printf("Session created with %s, (null)\n", SESSION1);
-               return -1;
-       }
-
-       /* Session list must be 0 */
-       assert(!session_list->count);
-
-       return 0;
-}
-
-static int fuzzing_destroy_args(void)
-{
-       int ret;
-
-       ret = destroy_one_session(NULL);
-       if (ret > 0) {
-               printf("Session destroyed with (null)\n");
-               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;
-
-       ret = create_one_session(SESSION1, PATH1);
-       if (ret < 0) {
-               /* Fail */
-               return -1;
-       }
-
-       ret = create_one_session(SESSION1, PATH1);
-       if (ret < 0) {
-               /* 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("Fuzzing destroy_session argument: ");
-       fflush(stdout);
-       ret = fuzzing_destroy_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/test_ust_data_trace.c b/tests/test_ust_data_trace.c
deleted file mode 100644 (file)
index 459520d..0000000
+++ /dev/null
@@ -1,205 +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, &dom);
-       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_METADATA_SUBBUF_SIZE);
-       assert(metadata->attr.num_subbuf
-                       == DEFAULT_METADATA_SUBBUF_NUM);
-       assert(metadata->attr.switch_timer_interval
-                       == DEFAULT_CHANNEL_SWITCH_TIMER);
-       assert(metadata->attr.read_timer_interval
-                       == DEFAULT_CHANNEL_READ_TIMER);
-       assert(metadata->attr.output == LTTNG_UST_MMAP);
-       PRINT_OK();
-
-       trace_ust_destroy_metadata(metadata);
-}
-
-static void create_ust_channel(void)
-{
-       struct ltt_ust_channel *uchan;
-       struct lttng_channel attr;
-
-       memset(&attr, 0, sizeof(attr));
-
-       strncpy(attr.name, "channel0", 8);
-
-       printf("Creating UST channel: ");
-       uchan = trace_ust_create_channel(&attr, PATH1);
-       assert(uchan != NULL);
-       PRINT_OK();
-
-       printf("Validating UST channel: ");
-       assert(uchan->enabled == 0);
-       assert(strcmp(PATH1, uchan->pathname) == 0);
-       assert(strncmp(uchan->name, "channel0", 8) == 0);
-       assert(uchan->name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0');
-       assert(uchan->ctx != NULL);
-       assert(uchan->events != NULL);
-       assert(uchan->attr.overwrite  == attr.attr.overwrite);
-       PRINT_OK();
-
-       trace_ust_destroy_channel(uchan);
-}
-
-static void create_ust_event(void)
-{
-       struct ltt_ust_event *event;
-       struct lttng_event ev;
-
-       memset(&ev, 0, sizeof(ev));
-       strncpy(ev.name, get_random_string(), LTTNG_SYMBOL_NAME_LEN);
-       ev.type = LTTNG_EVENT_TRACEPOINT;
-       ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
-
-       printf("Creating UST event: ");
-       event = trace_ust_create_event(&ev);
-       assert(event != NULL);
-       PRINT_OK();
-
-       printf("Validating UST event: ");
-       assert(event->enabled == 0);
-       assert(event->ctx != NULL);
-       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/tools/Makefile.am b/tests/tools/Makefile.am
new file mode 100644 (file)
index 0000000..d138680
--- /dev/null
@@ -0,0 +1,24 @@
+AM_CFLAGS = -g -Wall -I../
+AM_LDFLAGS = -lurcu -lurcu-cds
+
+EXTRA_DIST = runall.sh
+
+noinst_PROGRAMS = test_sessions test_kernel_data_trace test_ust_data_trace
+
+UTILS=utils.h
+SESSIONS=$(top_srcdir)/src/bin/lttng-sessiond/session.c
+KERN_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-kernel.c
+UST_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-ust.c
+COMMON=$(top_builddir)/src/common/libcommon.la
+HASHTABLE=$(top_builddir)/src/common/hashtable/libhashtable.la
+
+# Tracing sessions unit tests
+test_sessions_SOURCES = test_sessions.c $(UTILS) $(SESSIONS)
+test_sessions_LDADD = $(COMMON) $(HASHTABLE)
+
+# Kernel trace data unit tests
+test_kernel_data_trace_SOURCES = test_kernel_data_trace.c $(UTILS) $(KERN_DATA_TRACE)
+
+# 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)
diff --git a/tests/tools/runall.sh b/tests/tools/runall.sh
new file mode 100755 (executable)
index 0000000..5fdbda6
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+DIR=$(dirname $0)
+
+tests=( $DIR/test_kernel_data_trace $DIR/test_sessions $DIR/test_ust_data_trace )
+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/tools/test_kernel_data_trace.c b/tests/tools/test_kernel_data_trace.c
new file mode 100644 (file)
index 0000000..6d7f291
--- /dev/null
@@ -0,0 +1,208 @@
+/*
+ * 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);
+       assert(kern->consumer_fd == -1);
+       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(PATH1);
+       assert(kern->metadata != NULL);
+       PRINT_OK();
+
+       printf("Validating kernel session metadata: ");
+       assert(kern->metadata->fd == -1);
+       assert(strlen(kern->metadata->pathname));
+       assert(kern->metadata->conf != NULL);
+       assert(kern->metadata->conf->attr.overwrite
+                       == DEFAULT_CHANNEL_OVERWRITE);
+       assert(kern->metadata->conf->attr.subbuf_size
+                       == DEFAULT_METADATA_SUBBUF_SIZE);
+       assert(kern->metadata->conf->attr.num_subbuf
+                       == DEFAULT_METADATA_SUBBUF_NUM);
+       assert(kern->metadata->conf->attr.switch_timer_interval
+                       == DEFAULT_CHANNEL_SWITCH_TIMER);
+       assert(kern->metadata->conf->attr.read_timer_interval
+                       == DEFAULT_CHANNEL_READ_TIMER);
+       assert(kern->metadata->conf->attr.output
+                       == DEFAULT_KERNEL_CHANNEL_OUTPUT);
+       PRINT_OK();
+
+       trace_kernel_destroy_metadata(kern->metadata);
+}
+
+static void create_kernel_channel(void)
+{
+       struct ltt_kernel_channel *chan;
+       struct lttng_channel attr;
+
+       memset(&attr, 0, sizeof(attr));
+
+       printf("Creating kernel channel: ");
+       chan = trace_kernel_create_channel(&attr, PATH1);
+       assert(chan != NULL);
+       PRINT_OK();
+
+       printf("Validating kernel channel: ");
+       assert(chan->fd == -1);
+       assert(chan->enabled == 1);
+       assert(strcmp(PATH1, chan->pathname) == 0);
+       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->ctx == NULL);
+       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();
+       assert(stream != NULL);
+       PRINT_OK();
+
+       printf("Validating kernel stream: ");
+       assert(stream->fd == -1);
+       assert(stream->pathname == NULL);
+       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
new file mode 100644 (file)
index 0000000..e555935
--- /dev/null
@@ -0,0 +1,348 @@
+/*
+ * 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 "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;
+}
+
+/*
+ * 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);
+               session_list->count--;
+               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 == LTTCOMM_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 == LTTCOMM_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 == LTTCOMM_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;
+       }
+
+       ret = create_one_session(SESSION1, NULL);
+       if (ret > 0) {
+               printf("Session created with %s, (null)\n", SESSION1);
+               return -1;
+       }
+
+       /* Session list must be 0 */
+       assert(!session_list->count);
+
+       return 0;
+}
+
+static int fuzzing_destroy_args(void)
+{
+       int ret;
+
+       ret = destroy_one_session(NULL);
+       if (ret > 0) {
+               printf("Session destroyed with (null)\n");
+               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;
+
+       ret = create_one_session(SESSION1, PATH1);
+       if (ret < 0) {
+               /* Fail */
+               return -1;
+       }
+
+       ret = create_one_session(SESSION1, PATH1);
+       if (ret < 0) {
+               /* 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("Fuzzing destroy_session argument: ");
+       fflush(stdout);
+       ret = fuzzing_destroy_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
new file mode 100644 (file)
index 0000000..459520d
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * 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, &dom);
+       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_METADATA_SUBBUF_SIZE);
+       assert(metadata->attr.num_subbuf
+                       == DEFAULT_METADATA_SUBBUF_NUM);
+       assert(metadata->attr.switch_timer_interval
+                       == DEFAULT_CHANNEL_SWITCH_TIMER);
+       assert(metadata->attr.read_timer_interval
+                       == DEFAULT_CHANNEL_READ_TIMER);
+       assert(metadata->attr.output == LTTNG_UST_MMAP);
+       PRINT_OK();
+
+       trace_ust_destroy_metadata(metadata);
+}
+
+static void create_ust_channel(void)
+{
+       struct ltt_ust_channel *uchan;
+       struct lttng_channel attr;
+
+       memset(&attr, 0, sizeof(attr));
+
+       strncpy(attr.name, "channel0", 8);
+
+       printf("Creating UST channel: ");
+       uchan = trace_ust_create_channel(&attr, PATH1);
+       assert(uchan != NULL);
+       PRINT_OK();
+
+       printf("Validating UST channel: ");
+       assert(uchan->enabled == 0);
+       assert(strcmp(PATH1, uchan->pathname) == 0);
+       assert(strncmp(uchan->name, "channel0", 8) == 0);
+       assert(uchan->name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0');
+       assert(uchan->ctx != NULL);
+       assert(uchan->events != NULL);
+       assert(uchan->attr.overwrite  == attr.attr.overwrite);
+       PRINT_OK();
+
+       trace_ust_destroy_channel(uchan);
+}
+
+static void create_ust_event(void)
+{
+       struct ltt_ust_event *event;
+       struct lttng_event ev;
+
+       memset(&ev, 0, sizeof(ev));
+       strncpy(ev.name, get_random_string(), LTTNG_SYMBOL_NAME_LEN);
+       ev.type = LTTNG_EVENT_TRACEPOINT;
+       ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+
+       printf("Creating UST event: ");
+       event = trace_ust_create_event(&ev);
+       assert(event != NULL);
+       PRINT_OK();
+
+       printf("Validating UST event: ");
+       assert(event->enabled == 0);
+       assert(event->ctx != NULL);
+       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/ust-nevents/Makefile.am b/tests/ust-nevents/Makefile.am
deleted file mode 100644 (file)
index 29652dc..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-AM_CFLAGS = -I. -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-nevents/gen-nevents.c b/tests/ust-nevents/gen-nevents.c
deleted file mode 100644 (file)
index 03aa6c6..0000000
+++ /dev/null
@@ -1,55 +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);
-       }
-
-       return 0;
-}
diff --git a/tests/ust-nevents/run b/tests/ust-nevents/run
deleted file mode 100755 (executable)
index 301b70d..0000000
+++ /dev/null
@@ -1,52 +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=100
-SESSION_NAME="ust-nevents"
-EVENT_NAME="ust_gen_nevents:tptest"
-
-source $TESTDIR/utils.sh
-
-echo -e "\n-----------------------------------"
-echo -e "UST tracer - Generate $NR_ITER events"
-echo -e "-------------------------------------"
-
-if [ ! -e "$CURDIR/gen-nevents" ]; then
-       echo -e "No UST nevents binary detected. Passing."
-       exit 0
-fi
-
-TRACE_PATH=$(mktemp -d)
-
-# MUST set TESTDIR before calling those functions
-
-create_lttng_session $SESSION_NAME $TRACE_PATH
-
-enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-start_tracing $SESSION_NAME
-
-# Start test
-./$CURDIR/gen-nevents $NR_ITER
-
-stop_tracing $SESSION_NAME
-destroy_lttng_session $SESSION_NAME
-
-trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
-
-rm -rf $TRACE_PATH
diff --git a/tests/ust-nevents/tp.c b/tests/ust-nevents/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-nevents/ust_gen_nevents.h b/tests/ust-nevents/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-nprocesses/Makefile.am b/tests/ust-nprocesses/Makefile.am
deleted file mode 100644 (file)
index d3fdcbd..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-AM_CFLAGS = -I. -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
-EXTRA_DIST = run
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 cab42ef..0000000
+++ /dev/null
@@ -1,77 +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=100
-TEST_BIN_NAME="gen-events-time"
-SESSION_NAME="ust-nprocesses"
-EVENT_NAME="ust_gen_event:tptest"
-TEST_WAIT_SEC=5
-
-source $TESTDIR/utils.sh
-
-echo -e "\n-------------------------------------"
-echo -e "UST tracer - Generate $NR_ITER process"
-echo -e "---------------------------------------"
-
-if [ ! -e "$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 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 \e[1;31mFAILED\e[0m"
-else
-       echo -e "\e[1;32mOK\e[0m"
-fi
-
-TRACE_PATH=$(mktemp -d)
-
-create_lttng_session $SESSION_NAME $TRACE_PATH
-
-enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
-start_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_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 &
-echo -e "\e[1;32mOK\e[0m"
-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_gen_event.h b/tests/ust-nprocesses/ust_gen_event.h
deleted file mode 100644 (file)
index df53ccc..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/Makefile.am b/tests/ust/Makefile.am
new file mode 100644 (file)
index 0000000..822e33c
--- /dev/null
@@ -0,0 +1,16 @@
+SUBDIRS = nevents nprocesses
+
+AM_CFLAGS = -g -Wall -I../
+AM_LDFLAGS = -lurcu -lurcu-cds
+
+EXTRA_DIST = runall.sh utils.sh run-ust-global-tests.sh
+
+noinst_PROGRAMS = ust_global_event_basic ust_global_all_events_basic
+
+UTILS=utils.h
+LIBLTTNG=$(top_srcdir)/src/lib/lttng-ctl/lttng-ctl.c \
+                $(top_srcdir)/src/common/sessiond-comm/sessiond-comm.c
+
+ust_global_all_events_basic_SOURCES = ust_global_all_events_basic.c $(UTILS) $(LIBLTTNG)
+
+ust_global_event_basic_SOURCES = ust_global_event_basic.c $(UTILS) $(LIBLTTNG)
diff --git a/tests/ust/nevents/Makefile.am b/tests/ust/nevents/Makefile.am
new file mode 100644 (file)
index 0000000..29652dc
--- /dev/null
@@ -0,0 +1,16 @@
+AM_CFLAGS = -I. -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/nevents/gen-nevents.c b/tests/ust/nevents/gen-nevents.c
new file mode 100644 (file)
index 0000000..03aa6c6
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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);
+       }
+
+       return 0;
+}
diff --git a/tests/ust/nevents/run b/tests/ust/nevents/run
new file mode 100755 (executable)
index 0000000..946e8b2
--- /dev/null
@@ -0,0 +1,41 @@
+#!/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=100
+
+source $TESTDIR/utils.sh
+
+echo -e "\n-----------------------------------"
+echo -e "UST tracer - Generate $NR_ITER events"
+echo -e "-------------------------------------"
+
+if [ ! -e "$CURDIR/gen-nevents" ]; then
+       echo -e "No UST nevents binary detected. Passing."
+       exit 0
+fi
+
+# MUST set TESTDIR before calling those functions
+
+start_sessiond
+
+./$CURDIR/ust-nevents $NR_ITER
+
+stop_sessiond
+
+rm -rf $TRACE_PATH
diff --git a/tests/ust/nevents/tp.c b/tests/ust/nevents/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/ust/nevents/ust-nevents b/tests/ust/nevents/ust-nevents
new file mode 100755 (executable)
index 0000000..eed4dcb
--- /dev/null
@@ -0,0 +1,43 @@
+#!/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
+SESSION_NAME="ust-nevents"
+EVENT_NAME="ust_gen_nevents:tptest"
+
+source $TESTDIR/utils.sh
+
+TRACE_PATH=$(mktemp -d)
+
+# MUST set TESTDIR before calling those functions
+
+create_lttng_session $SESSION_NAME $TRACE_PATH
+
+enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+start_tracing $SESSION_NAME
+
+# Start test
+./$CURDIR/gen-nevents $NR_ITER
+
+stop_tracing $SESSION_NAME
+destroy_lttng_session $SESSION_NAME
+
+trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+
+rm -rf $TRACE_PATH
diff --git a/tests/ust/nevents/ust_gen_nevents.h b/tests/ust/nevents/ust_gen_nevents.h
new file mode 100644 (file)
index 0000000..8d82ecb
--- /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/ust/nprocesses/Makefile.am b/tests/ust/nprocesses/Makefile.am
new file mode 100644 (file)
index 0000000..d3fdcbd
--- /dev/null
@@ -0,0 +1,16 @@
+AM_CFLAGS = -I. -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
+EXTRA_DIST = run
diff --git a/tests/ust/nprocesses/gen-events-time.c b/tests/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/ust/nprocesses/run b/tests/ust/nprocesses/run
new file mode 100755 (executable)
index 0000000..d2f6d55
--- /dev/null
@@ -0,0 +1,41 @@
+#!/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=100
+
+source $TESTDIR/utils.sh
+
+echo -e "\n-------------------------------------"
+echo -e "UST tracer - Generate $NR_ITER process"
+echo -e "---------------------------------------"
+
+if [ ! -e "$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_sessiond
+
+./$CURDIR/ust-nprocesses $NR_ITER
+
+stop_sessiond
+
+exit 0
diff --git a/tests/ust/nprocesses/tp.c b/tests/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/ust/nprocesses/ust-nprocesses b/tests/ust/nprocesses/ust-nprocesses
new file mode 100755 (executable)
index 0000000..eab6d39
--- /dev/null
@@ -0,0 +1,68 @@
+#!/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 \e[1;31mFAILED\e[0m"
+else
+       echo -e "\e[1;32mOK\e[0m"
+fi
+
+TRACE_PATH=$(mktemp -d)
+
+create_lttng_session $SESSION_NAME $TRACE_PATH
+
+enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+start_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_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 &
+echo -e "\e[1;32mOK\e[0m"
+exit 0
diff --git a/tests/ust/nprocesses/ust_gen_event.h b/tests/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/ust/run-ust-global-tests.sh b/tests/ust/run-ust-global-tests.sh
new file mode 100755 (executable)
index 0000000..96c1f9e
--- /dev/null
@@ -0,0 +1,44 @@
+#!/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_all_events_basic )
+exit_code=0
+
+function start_tests ()
+{
+    for bin in ${tests[@]};
+    do
+               if [ ! -e $bin ]; then
+                       echo -e "$bin not found, passing"
+                       continue
+               fi
+
+               start_sessiond
+
+        ./$bin $tmpdir
+        # Test must return 0 to pass.
+        if [ $? -ne 0 ]; then
+            exit_code=1
+                       stop_sessiond
+            break
+        fi
+               stop_sessiond
+    done
+
+       # Cleaning up
+       rm -rf $tmpdir
+}
+
+echo -e "\n-------------------------------------------"
+echo -e "UST tracer - Global domain (LTTNG_DOMAIN_UST)"
+echo -e "---------------------------------------------"
+
+start_tests
+
+exit $exit_code
diff --git a/tests/ust/runall.sh b/tests/ust/runall.sh
new file mode 100755 (executable)
index 0000000..78182cb
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+DIR=$(dirname $0)
+
+tests=( $DIR/run-ust-global-tests.sh $DIR/nevents/run $DIR/nprocesses/run )
+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_all_events_basic.c b/tests/ust/ust_global_all_events_basic.c
new file mode 100644 (file)
index 0000000..3ae786e
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * as published by the Free Software Foundation; only version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define _GNU_SOURCE
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
+
+#include <lttng/lttng.h>
+
+#include "utils.h"
+
+int lttng_opt_quiet;
+
+int main(int argc, char **argv)
+{
+       struct lttng_handle *handle = NULL;
+       struct lttng_domain dom;
+       struct lttng_event event;
+       char *channel_name = "channel0";
+       char *session_name = "ust_global_all_events_basic";
+       int ret = 0;
+
+       memset(&dom, 0, sizeof(dom));
+       memset(&event, 0, sizeof(event));
+       dom.type = LTTNG_DOMAIN_UST;
+       event.type = LTTNG_EVENT_TRACEPOINT;
+       event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+
+       printf("\nTesting tracing all UST events:\n");
+       printf("-----------\n");
+
+       if (argc < 2) {
+               printf("Missing session trace path\n");
+               return 1;
+       }
+
+       printf("Creating tracing session (%s): ", argv[1]);
+       if ((ret = lttng_create_session(session_name, argv[1])) < 0) {
+               printf("error creating the session : %s\n", lttng_strerror(ret));
+               goto create_fail;
+       }
+       PRINT_OK();
+
+       printf("Creating session handle: ");
+       if ((handle = lttng_create_handle(session_name, &dom)) == NULL) {
+               printf("error creating handle: %s\n", lttng_strerror(ret));
+               goto handle_fail;
+       }
+       PRINT_OK();
+
+       printf("Enabling all UST events: ");
+       if ((ret = lttng_enable_event(handle, &event, channel_name)) < 0) {
+               printf("error enabling event: %s\n", lttng_strerror(ret));
+               goto enable_fail;
+       }
+       PRINT_OK();
+
+       printf("Start tracing: ");
+       if ((ret = lttng_start_tracing(session_name)) < 0) {
+               printf("error starting tracing: %s\n", lttng_strerror(ret));
+               goto start_fail;
+       }
+       PRINT_OK();
+
+       sleep(2);
+
+       printf("Stop tracing: ");
+       if ((ret = lttng_stop_tracing(session_name)) < 0) {
+               printf("error stopping tracing: %s\n", lttng_strerror(ret));
+               goto stop_fail;
+       }
+       PRINT_OK();
+
+       printf("Destroy tracing session: ");
+       if ((ret = lttng_destroy_session(session_name)) < 0) {
+               printf("error destroying session: %s\n", lttng_strerror(ret));
+       }
+       PRINT_OK();
+
+       return 0;
+
+create_fail:
+       assert(ret != 0);
+handle_fail:
+       assert(handle != NULL);
+
+stop_fail:
+start_fail:
+enable_fail:
+       lttng_destroy_session(session_name);
+       lttng_destroy_handle(handle);
+
+       return 1;
+}
diff --git a/tests/ust/ust_global_event_basic.c b/tests/ust/ust_global_event_basic.c
new file mode 100644 (file)
index 0000000..24dcec5
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * 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 ev1, ev2, ev3;
+       char *session_name = "ust_global_event_basic";
+       int ret = 0;
+
+       memset(&dom, 0, sizeof(dom));
+       memset(&channel, 0, sizeof(channel));
+       memset(&ev1, 0, sizeof(ev1));
+       memset(&ev2, 0, sizeof(ev2));
+       memset(&ev3, 0, sizeof(ev3));
+
+       dom.type = LTTNG_DOMAIN_UST;
+       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;
+
+       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 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 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("Enabling %s UST event: ", ev2.name);
+       if ((ret = lttng_enable_event(handle, &ev2, channel.name)) < 0) {
+               printf("error enabling event: %s\n", lttng_strerror(ret));
+               goto enable_fail;
+       }
+       PRINT_OK();
+
+       printf("Enabling %s UST event: ", ev3.name);
+       if ((ret = lttng_enable_event(handle, &ev3, channel.name)) < 0) {
+               printf("error enabling event: %s\n", lttng_strerror(ret));
+               goto enable_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, channel.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("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: ");
+       if ((ret = lttng_destroy_session(session_name)) < 0) {
+               printf("error destroying session: %s\n", lttng_strerror(ret));
+       }
+       PRINT_OK();
+
+       return 0;
+
+create_fail:
+       assert(ret != 0);
+handle_fail:
+       assert(handle != NULL);
+
+stop_fail:
+start_fail:
+enable_fail:
+       lttng_destroy_session(session_name);
+       lttng_destroy_handle(handle);
+
+       return 1;
+}
index 52893b207f12bd1af51a851febc508159d16b319..7650865dd57c64411840db21541454ecf5774967 100644 (file)
@@ -1,19 +1,18 @@
 /*
 /*
- * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
+ * 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 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.
+ * 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.
+ * 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 <stdio.h>
index 55bc9e9d5a41adf559840f41a0bab677c25894db..f0a2e25dd7fde160e603f57f8b16b65c1fae6428 100644 (file)
@@ -24,6 +24,8 @@ KERNEL_MAJOR_VERSION=2
 KERNEL_MINOR_VERSION=6
 KERNEL_PATCHLEVEL_VERSION=27
 
 KERNEL_MINOR_VERSION=6
 KERNEL_PATCHLEVEL_VERSION=27
 
+alias realpath='readlink -f'
+
 function validate_kernel_version ()
 {
        kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n'))
 function validate_kernel_version ()
 {
        kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n'))
@@ -39,7 +41,7 @@ function validate_kernel_version ()
        return 1
 }
 
        return 1
 }
 
-function start_sessiond ()
+function spawn_sessiond ()
 {
        echo ""
        echo -n "Starting session daemon... "
 {
        echo ""
        echo -n "Starting session daemon... "
@@ -49,8 +51,10 @@ function start_sessiond ()
                return 2
        fi
 
                return 2
        fi
 
+       DIR=$(realpath $TESTDIR)
+
        if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
        if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
-               $TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --daemonize --quiet --consumerd32-path="$(pwd)/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$(pwd)/../src/bin/lttng-consumerd/lttng-consumerd"
+               $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"
                if [ $? -eq 1 ]; then
                        echo -e "\e[1;31mFAILED\e[0m"
                        return 1
                if [ $? -eq 1 ]; then
                        echo -e "\e[1;31mFAILED\e[0m"
                        return 1
@@ -62,8 +66,35 @@ function start_sessiond ()
        return 0
 }
 
        return 0
 }
 
+function start_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_sessiond ()
 {
 function stop_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... "
        PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
 
        echo -e -n "Killing session daemon... "
This page took 0.086593 seconds and 4 git commands to generate.