Add multi-session test for UST
authorDavid Goulet <dgoulet@efficios.com>
Thu, 12 Apr 2012 18:22:55 +0000 (14:22 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Thu, 12 Apr 2012 18:22:55 +0000 (14:22 -0400)
Signed-off-by: David Goulet <dgoulet@efficios.com>
configure.ac
tests/test_list.py
tests/ust/Makefile.am
tests/ust/multi-session/Makefile.am [new file with mode: 0644]
tests/ust/multi-session/gen-nevents.c [new file with mode: 0644]
tests/ust/multi-session/run [new file with mode: 0755]
tests/ust/multi-session/tp.c [new file with mode: 0644]
tests/ust/multi-session/ust_gen_nevents.h [new file with mode: 0644]
tests/ust/runall.sh

index 9527af2842fe838cb2dea1b7706a9738d65ea788..dbd461ec4e58668a1ba9d1cd71dd584d6cd76dfd 100644 (file)
@@ -201,6 +201,7 @@ AC_CONFIG_FILES([
        tests/ust/high-throughput/Makefile
        tests/ust/low-throughput/Makefile
        tests/ust/before-after/Makefile
        tests/ust/high-throughput/Makefile
        tests/ust/low-throughput/Makefile
        tests/ust/before-after/Makefile
+       tests/ust/multi-session/Makefile
 ])
 
 AC_OUTPUT
 ])
 
 AC_OUTPUT
index 238164a3fdcbeda15c051c879c4bbabaf8e2efd1..069429dfb7db1a502af7638528d441a5f8d0538a 100644 (file)
@@ -53,11 +53,11 @@ Tests = \
     'success': 0, 'enabled': True
     },
     {
     'success': 0, 'enabled': True
     },
     {
+    # Deactivated. This test last 20 minutes...
     'bin': "ust/low-throughput/run", 'daemon': True, 'kern': False,
     'name': "UST tracer - Testing high events throughput",
     'desc': "Test low throughput of events",
     'success': 0, 'enabled': False
     'bin': "ust/low-throughput/run", 'daemon': True, 'kern': False,
     'name': "UST tracer - Testing high events throughput",
     'desc': "Test low throughput of events",
     'success': 0, 'enabled': False
-    # Deactivated. This test last 20 minutes...
     },
     {
     'bin': "ust/before-after/run", 'daemon': True, 'kern': False,
     },
     {
     'bin': "ust/before-after/run", 'daemon': True, 'kern': False,
@@ -65,4 +65,10 @@ Tests = \
     'desc': "Test tracing before and after app execution",
     'success': 0, 'enabled': True
     },
     'desc': "Test tracing before and after app execution",
     'success': 0, 'enabled': True
     },
+    {
+    'bin': "ust/multi-session/run", 'daemon': True, 'kern': False,
+    'name': "UST tracer - Multi-session",
+    'desc': "Test tracing with 4 sessions for one application",
+    'success': 0, 'enabled': True
+    },
 ]
 ]
index 7c7bcba41a813c99189e8336e924830248f05fbe..0479e1c5b9bc6e37e9d4d008199d16bf6a30afe5 100644 (file)
@@ -1,5 +1,5 @@
 if HAVE_LIBLTTNG_UST_CTL
 if HAVE_LIBLTTNG_UST_CTL
-SUBDIRS = nprocesses high-throughput low-throughput before-after
+SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session
 
 AM_CFLAGS = -g -Wall -I../
 AM_LDFLAGS = -lurcu -lurcu-cds
 
 AM_CFLAGS = -g -Wall -I../
 AM_LDFLAGS = -lurcu -lurcu-cds
diff --git a/tests/ust/multi-session/Makefile.am b/tests/ust/multi-session/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/multi-session/gen-nevents.c b/tests/ust/multi-session/gen-nevents.c
new file mode 100644 (file)
index 0000000..7add252
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) - 2009 Pierre-Marc Fournier
+ * Copyright (C) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_gen_nevents.h"
+
+int main(int argc, char **argv)
+{
+       int i, nr_iter = 100;
+       long value = 42;
+
+       if (argc == 2) {
+               nr_iter = atoi(argv[1]);
+       }
+
+       for (i = 0; i < nr_iter; i++) {
+               tracepoint(ust_gen_nevents, tptest0, i, value);
+               tracepoint(ust_gen_nevents, tptest1, i, value);
+               tracepoint(ust_gen_nevents, tptest2, i, value);
+               tracepoint(ust_gen_nevents, tptest3, i, value);
+       }
+
+       return 0;
+}
diff --git a/tests/ust/multi-session/run b/tests/ust/multi-session/run
new file mode 100755 (executable)
index 0000000..f6dab7c
--- /dev/null
@@ -0,0 +1,92 @@
+#!/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../..
+NR_ITER=100
+SESSION_NAME="multi-session"
+EVENT_NAME="ust_gen_nevents:tptest"
+
+source $TESTDIR/utils.sh
+
+echo -e "\n--------------------------"
+echo -e "UST tracer - Multi-session"
+echo -e "--------------------------"
+
+if [ ! -x "$CURDIR/gen-nevents" ]; then
+       echo -e "No UST nevents binary detected. Passing."
+       exit 0
+fi
+
+# MUST set TESTDIR before calling those functions
+
+test_multi_session() {
+       local out
+
+       # BEFORE application is spawned
+       for i in `seq 0 3`; do
+               create_lttng_session "$SESSION_NAME-$i" "$TRACE_PATH/$i"
+               enable_ust_lttng_event "$SESSION_NAME-$i" "$EVENT_NAME$i"
+               start_tracing "$SESSION_NAME-$i"
+       done
+
+       echo -n "Starting application generating $NR_ITER events... "
+       ./$CURDIR/gen-nevents $NR_ITER &
+       echo -e "\e[1;32mOK\e[0m"
+
+       # At least hit one event
+       echo -n "Waiting for events to record "
+       while [ -n "$(pidof gen-nevents)" ]; do
+               echo -n "."
+               sleep 0.1
+       done
+       echo -e "\e[1;32m OK\e[0m"
+
+       for i in `seq 0 3`; do
+               stop_tracing "$SESSION_NAME-$i"
+               destroy_lttng_session "$SESSION_NAME-$i"
+               out=$(babeltrace "$TRACE_PATH/$i" | grep "$EVENT_NAMEi$i" | wc -l)
+               if [ $out -ne $NR_ITER ]; then
+                       echo -n "No event found. Suppose to have at least one... "
+                       echo -e "\e[1;31mFAILED\e[0m"
+                       out=1
+               else
+                       echo -n "Found $out event(s) for $SESSION_NAME-$i. Coherent... "
+                       echo -e "\e[1;32mOK\e[0m"
+                       out=0
+               fi
+       done
+
+       return $out
+}
+
+# MUST set TESTDIR before calling those functions
+
+start_sessiond
+
+TRACE_PATH=$(mktemp -d)
+
+test_multi_session
+out=$?
+if [ $out -ne 0 ]; then
+       stop_sessiond
+       exit $out
+fi
+
+stop_sessiond
+
+rm -rf "$TRACE_PATH"
diff --git a/tests/ust/multi-session/tp.c b/tests/ust/multi-session/tp.c
new file mode 100644 (file)
index 0000000..e291924
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
+ * IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program for any purpose,
+ * provided the above notices are retained on all copies.  Permission to modify
+ * the code and to distribute modified code is granted, provided the above
+ * notices are retained, and a notice that the code was modified is included
+ * with the above copyright notice.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_gen_nevents.h"
diff --git a/tests/ust/multi-session/ust_gen_nevents.h b/tests/ust/multi-session/ust_gen_nevents.h
new file mode 100644 (file)
index 0000000..cba3994
--- /dev/null
@@ -0,0 +1,68 @@
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_gen_nevents
+
+#if !defined(_TRACEPOINT_UST_GEN_NEVENTS_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_GEN_NEVENTS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose,  provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(ust_gen_nevents, tptest0,
+       TP_ARGS(int, anint, long, value),
+       TP_FIELDS(
+               ctf_integer(int, intfield, anint)
+               ctf_integer(long, longfield, value)
+       )
+)
+
+TRACEPOINT_EVENT(ust_gen_nevents, tptest1,
+       TP_ARGS(int, anint, long, value),
+       TP_FIELDS(
+               ctf_integer(int, intfield, anint)
+               ctf_integer(long, longfield, value)
+       )
+)
+
+TRACEPOINT_EVENT(ust_gen_nevents, tptest2,
+       TP_ARGS(int, anint, long, value),
+       TP_FIELDS(
+               ctf_integer(int, intfield, anint)
+               ctf_integer(long, longfield, value)
+       )
+)
+
+TRACEPOINT_EVENT(ust_gen_nevents, tptest3,
+       TP_ARGS(int, anint, long, value),
+       TP_FIELDS(
+               ctf_integer(int, intfield, anint)
+               ctf_integer(long, longfield, value)
+       )
+)
+
+#endif /* _TRACEPOINT_UST_GEN_NEVENTS_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./ust_gen_nevents.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus 
+}
+#endif
index 01f1410be94aa6b51d927744beb72095685e01ec..0f63f838a9952a9ac25c406a2b132e687cb30507 100755 (executable)
@@ -3,7 +3,8 @@
 DIR=$(dirname $0)
 
 tests=( $DIR/run-ust-global-tests.sh $DIR/nprocesses/run \
 DIR=$(dirname $0)
 
 tests=( $DIR/run-ust-global-tests.sh $DIR/nprocesses/run \
-               $DIR/high-throughput/run $DIR/before-after/run )
+               $DIR/high-throughput/run $DIR/before-after/run \
+               $DIR/multi-session/run )
 
 # $DIR/low-throughput/run --> DEACTIVATED.
 # Use only for release. This test last 20 minutes
 
 # $DIR/low-throughput/run --> DEACTIVATED.
 # Use only for release. This test last 20 minutes
This page took 0.03457 seconds and 4 git commands to generate.