gen-nevents
gen-events-time
gen-events
+gen-ust-events
benchmark/
tests/Makefile
tests/kernel/Makefile
tests/tools/Makefile
+ tests/tools/streaming/Makefile
tests/ust/Makefile
tests/ust/nprocesses/Makefile
tests/ust/high-throughput/Makefile
'desc': "Test UST data structures and methods.",
'success': 0, 'enabled': True
},
+ {
+ 'bin': "tools/streaming/run-ust", 'daemon': True, 'kern': False,
+ 'name': "UST network streaming",
+ 'desc': "Test user space tracing network streaming support",
+ 'success': 0, 'enabled': True
+ },
+ {
+ 'bin': "tools/streaming/run-kernel", 'daemon': True, 'kern': True,
+ 'name': "Kernel network streaming",
+ 'desc': "Test kernel tracing network streaming support",
+ 'success': 0, 'enabled': True
+ },
#### KERNEL ####
{
+SUBDIR = . streaming
+
AM_CFLAGS = -g -Wall -I../
AM_LDFLAGS = -lurcu -lurcu-cds
DIR=$(dirname $0)
-tests=( $DIR/test_kernel_data_trace $DIR/test_sessions $DIR/test_ust_data_trace )
+tests=( $DIR/test_kernel_data_trace $DIR/test_sessions $DIR/test_ust_data_trace \
+ $DIR/streaming/run )
exit_code=0
function start_tests ()
--- /dev/null
+AM_CFLAGS = -I. -O2
+AM_LDFLAGS =
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+AM_LDFLAGS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+AM_LDFLAGS += -lc
+endif
+
+if HAVE_LIBLTTNG_UST_CTL
+noinst_PROGRAMS = gen-ust-events
+gen_ust_events_SOURCES = gen-ust-events.c tp.c tp.h
+gen_ust_events_LDADD = -llttng-ust
+endif
+
+noinst_SCRIPTS = run
+EXTRA_DIST = run
--- /dev/null
+/*
+ * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <arpa/inet.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define TRACEPOINT_DEFINE
+#include "tp.h"
+
+int main(int argc, char **argv)
+{
+ int i, netint;
+ long values[] = { 1, 2, 3 };
+ char text[10] = "test";
+ double dbl = 2.0;
+ float flt = 2222.0;
+ /* Generate 30 events. */
+ unsigned int nr_iter = 100;
+ useconds_t nr_usec = 0;
+
+ if (argc >= 2) {
+ nr_iter = atoi(argv[1]);
+ }
+
+ if (argc == 3) {
+ /* By default, don't wait unless user specifies. */
+ nr_usec = atoi(argv[2]);
+ }
+
+ for (i = 0; i < nr_iter; i++) {
+ netint = htonl(i);
+ tracepoint(tp, tptest, i, netint, values, text, strlen(text), dbl,
+ flt);
+ usleep(nr_usec);
+ }
+
+ return 0;
+}
--- /dev/null
+#!/bin/bash
+
+DIR=$(dirname $0)
+
+tests=( $DIR/run-kernel $DIR/run-ust )
+exit_code=0
+
+function start_tests ()
+{
+ for bin in ${tests[@]};
+ do
+ if [ ! -e $bin ]; then
+ echo -e "$bin not found, passing"
+ continue
+ fi
+
+ ./$bin
+ # Test must return 0 to pass.
+ if [ $? -ne 0 ]; then
+ exit_code=1
+ break
+ fi
+ done
+}
+
+start_tests
+
+exit $exit_code
--- /dev/null
+#!/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/../..
+EVENT_NAME="sched_switch"
+PID_RELAYD=0
+SESSION_NAME=""
+
+source $TESTDIR/utils.sh
+
+echo -e "\n---------------------------"
+echo -e " Streaming - Kernel tracing "
+echo -e "----------------------------"
+
+if [ "$(id -u)" != "0" ]; then
+ echo "This test must be running as root. Aborting"
+ # Exit status 0 so the tests can continue
+ exit 0
+fi
+
+# LTTng kernel modules check
+out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
+if [ -z "$out" ]; then
+ echo "LTTng modules not detected. Aborting kernel tests!"
+ echo ""
+ # Exit status 0 so the tests can continue
+ exit 0
+fi
+
+function lttng_create_session
+{
+ echo -n "Creating session $SESSION_NAME... "
+ # Create session with default path
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ echo -e '\e[1;31mFAILED\e[0m'
+ return 1
+ else
+ echo -e "\e[1;32mOK\e[0m"
+ fi
+}
+
+function lttng_enable_consumer_localhost
+{
+ echo -n "Enabling network consumer... "
+ # Create session with default path
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -k net://localhost >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ echo -e '\e[1;31mFAILED\e[0m'
+ return 1
+ else
+ echo -e "\e[1;32mOK\e[0m"
+ fi
+}
+
+function test_kernel_before_start ()
+{
+ echo -e "\n=== Testing kernel streaming with event enable BEFORE start\n"
+ lttng_create_session
+ lttng_enable_consumer_localhost
+ lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
+ start_tracing $SESSION_NAME
+ # Give a second
+ sleep 1
+ stop_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+}
+
+function test_kernel_after_start ()
+{
+ echo -e "\n=== Testing kernel streaming with event enable AFTER start\n"
+ lttng_create_session
+ lttng_enable_consumer_localhost
+ start_tracing $SESSION_NAME
+ lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
+ # Give a second
+ sleep 1
+ stop_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+}
+
+start_sessiond
+lttng_start_relayd
+
+tests=( test_kernel_before_start test_kernel_after_start )
+
+for fct_test in ${tests[@]};
+do
+ SESSION_NAME=$(randstring 16 0)
+ ${fct_test}
+
+ # Validate test
+ validate_trace $EVENT_NAME ~/lttng-traces/$HOSTNAME/$SESSION_NAME*
+ if [ $? -eq 0 ]; then
+ # Only delete if successful
+ rm -rf ~/lttng-traces/$HOSTNAME/$SESSION_NAME*
+ rm -rf ~/lttng-traces/$SESSION_NAME*
+ else
+ break
+ fi
+done
+
+echo ""
+stop_sessiond
+lttng_stop_relayd
+
+
+exit $out
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../..
+BIN_NAME="gen-ust-events"
+SESSION_NAME="stream"
+EVENT_NAME="tp:tptest"
+PID_RELAYD=0
+
+source $TESTDIR/utils.sh
+
+echo -e "\n-------------------------------"
+echo -e " Streaming - User space tracing "
+echo -e "--------------------------------"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+ echo -e "No UST nevents binary detected. Passing."
+ exit 0
+fi
+
+function lttng_create_session
+{
+ # Create session with default path
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME >/dev/null 2>&1
+}
+
+function lttng_enable_consumer
+{
+ # Create session with default path
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u net://localhost/test >/dev/null 2>&1
+}
+
+function wait_apps
+{
+ echo -n "Waiting for applications to end"
+ while [ -n "$(pidof $BIN_NAME)" ]; do
+ echo -n "."
+ sleep 0.5
+ done
+ echo ""
+}
+
+# MUST set TESTDIR before calling those functions
+
+function test_ust_before_start ()
+{
+ echo -e "\n=== Testing UST streaming BEFORE tracing starts\n"
+ lttng_create_session
+ lttng_enable_consumer
+ enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+
+ # Run 5 times with a 1 second delay
+ ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 &
+
+ start_tracing $SESSION_NAME
+
+ wait_apps
+ stop_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+}
+
+function test_ust_after_start ()
+{
+ echo -e "\n=== Testing UST streaming AFTER tracing starts\n"
+ lttng_create_session
+ lttng_enable_consumer
+ enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+ start_tracing $SESSION_NAME
+
+ # Run 5 times with a 1 second delay
+ ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 &
+
+ wait_apps
+ stop_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+}
+
+start_sessiond
+lttng_start_relayd
+
+tests=( test_ust_before_start test_ust_after_start )
+
+for fct_test in ${tests[@]};
+do
+ SESSION_NAME=$(randstring 16 0)
+ ${fct_test}
+
+ # Validate test
+ validate_trace $EVENT_NAME ~/lttng-traces/$HOSTNAME/$SESSION_NAME*
+ if [ $? -eq 0 ]; then
+ # Only delete if successful
+ rm -rf ~/lttng-traces/$HOSTNAME/$SESSION_NAME*
+ rm -rf ~/lttng-traces/$SESSION_NAME*
+ else
+ break
+ fi
+done
+
+echo ""
+stop_sessiond
+lttng_stop_relayd
+
+exit $out
--- /dev/null
+/*
+ * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
+ * IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program for any purpose,
+ * provided the above notices are retained on all copies. Permission to modify
+ * the code and to distribute modified code is granted, provided the above
+ * notices are retained, and a notice that the code was modified is included
+ * with the above copyright notice.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "tp.h"
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER tp
+
+#if !defined(_TRACEPOINT_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_TP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(tp, tptest,
+ TP_ARGS(int, anint, int, netint, long *, values,
+ char *, text, size_t, textlen,
+ double, doublearg, float, floatarg),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer_hex(int, intfield2, anint)
+ ctf_integer(long, longfield, anint)
+ ctf_integer_network(int, netintfield, netint)
+ ctf_integer_network_hex(int, netintfieldhex, netint)
+ ctf_array(long, arrfield1, values, 3)
+ ctf_array_text(char, arrfield2, text, 10)
+ ctf_sequence(char, seqfield1, text, size_t, textlen)
+ ctf_sequence_text(char, seqfield2, text, size_t, textlen)
+ ctf_string(stringfield, text)
+ ctf_float(float, floatfield, floatarg)
+ ctf_float(double, doublefield, doublearg)
+ )
+)
+
+#endif /* _TRACEPOINT_TP_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./tp.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
SESSIOND_BIN="lttng-sessiond"
+RELAYD_BIN="lttng-relayd"
LTTNG_BIN="lttng"
BABELTRACE_BIN="babeltrace"
return 1
}
+# Generate a random string
+# $1 = number of characters; defaults to 16
+# $2 = include special characters; 1 = yes, 0 = no; defaults to yes
+function randstring()
+{
+ [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]"
+ cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-16}
+ echo
+}
+
function spawn_sessiond ()
{
echo ""
return 0
}
+function lttng_enable_kernel_event
+{
+ sess_name=$1
+ event_name=$2
+
+ if [ -z $event_name ]; then
+ # Enable all event if no event name specified
+ $event_name="-a"
+ fi
+
+ echo -n "Enabling kernel event $event_name for session $sess_name"
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -k >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ echo -e '\e[1;31mFAILED\e[0m'
+ return 1
+ else
+ echo -e "\e[1;32mOK\e[0m"
+ fi
+}
+
+function lttng_start_relayd
+{
+ echo -e -n "Starting lttng-relayd... "
+ DIR=$(readlink -f $TESTDIR)
+
+ if [ -z $(pidof lt-$RELAYD_BIN) ]; then
+ $DIR/../src/bin/lttng-relayd/$RELAYD_BIN >/dev/null 2>&1 &
+ if [ $? -eq 1 ]; then
+ echo -e "\e[1;31mFAILED\e[0m"
+ return 1
+ else
+ echo -e "\e[1;32mOK\e[0m"
+ fi
+ else
+ echo -e "\e[1;32mOK\e[0m"
+ fi
+}
+
+function lttng_stop_relayd
+{
+ PID_RELAYD=`pidof lt-$RELAYD_BIN`
+
+ echo -e -n "Killing lttng-relayd (pid: $PID_RELAYD)... "
+ kill $PID_RELAYD >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ echo -e "\e[1;31mFAILED\e[0m"
+ return 1
+ else
+ out=1
+ while [ -n "$out" ]; do
+ out=$(pidof lt-$RELAYD_BIN)
+ sleep 0.5
+ done
+ echo -e "\e[1;32mOK\e[0m"
+ return 0
+ fi
+}
+
function start_sessiond()
{
if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
return 0
fi
}
+
+function validate_trace
+{
+ event_name=$1
+ trace_path=$2
+
+ which $BABELTRACE_BIN >/dev/null
+ if [ $? -eq 1 ]; then
+ echo "Babeltrace binary not found. Skipping trace matches"
+ return 0
+ fi
+
+ echo -n "Validating trace for event $event_name... "
+ traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $event_name | wc -l)
+ if [ $traced -eq 0 ]; then
+ echo -e "\e[1;31mFAILED\e[0m"
+ return 1
+ else
+ echo -e "\e[1;32mOK\e[0m"
+ return 0
+ fi
+}