tests/kernel_event_basic
tests/ust_global_all_events_basic
tests/ust_global_event_basic
+tests/ust-nevents/gen-nevents
benchmark/
lttng-sessiond/Makefile
lttng/Makefile
tests/Makefile
+ tests/ust-nevents/Makefile
doc/Makefile
])
+SUBDIRS = . ust-nevents
+
AM_CFLAGS=-I$(top_srcdir)/include -I$(top_srcdir)/libkernelctl \
-I$(top_srcdir)/liblttngctl -g -Wall -lurcu -lurcu-cds
struct lttng_domain dom;
struct lttng_event event;
char *channel_name = "channel0";
+ char *session_name = "kernel_all_events_basic";
int ret = 0;
dom.type = LTTNG_DOMAIN_KERNEL;
}
printf("Creating tracing session (%s): ", argv[1]);
- if ((ret = lttng_create_session("test", argv[1])) < 0) {
+ 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("test", &dom)) == NULL) {
+ if ((handle = lttng_create_handle(session_name, &dom)) == NULL) {
printf("error creating handle: %s\n", lttng_strerror(ret));
goto handle_fail;
}
PRINT_OK();
printf("Start tracing: ");
- if ((ret = lttng_start_tracing("test")) < 0) {
+ if ((ret = lttng_start_tracing(session_name)) < 0) {
printf("error starting tracing: %s\n", lttng_strerror(ret));
goto start_fail;
}
sleep(2);
printf("Stop tracing: ");
- if ((ret = lttng_stop_tracing("test")) < 0) {
+ 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("test")) < 0) {
+ if ((ret = lttng_destroy_session(session_name)) < 0) {
printf("error destroying session: %s\n", lttng_strerror(ret));
}
PRINT_OK();
stop_fail:
start_fail:
enable_fail:
- lttng_destroy_session("test");
+ lttng_destroy_session(session_name);
lttng_destroy_handle(handle);
return 1;
int ret = 0;
- char *session_name = "kernel_event";
+ char *session_name = "kernel_event_basic";
dom.type = LTTNG_DOMAIN_KERNEL;
#!/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=1
break
fi
- # Cleaning up
- rm -rf $tmpdir
done
+
+ # Cleaning up
+ rm -rf $tmpdir
}
function check_lttng_modules ()
check_lttng_modules
-if [ -z $(pidof $SESSIOND_BIN) ]; then
- echo -n "Starting session daemon... "
- ../lttng-sessiond/$SESSIOND_BIN --daemonize --quiet
- if [ $? -eq 1 ]; then
- echo -e '\e[1;31mFAILED\e[0m'
- rm -rf $tmpdir
- exit 1
- else
- echo -e "\e[1;32mOK\e[0m"
- fi
-fi
-
-PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
-
# Simply wait for the session daemon bootstrap
sleep 1
start_tests
-echo -e -n "\nKilling session daemon... "
-kill $PID_SESSIOND >/dev/null 2>&1
-if [ $? -eq 1 ]; then
- echo -e '\e[1;31mFAILED\e[0m'
-else
- echo -e "\e[1;32mOK\e[0m"
-fi
-
exit $exit_code
#!/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=1
break
fi
- # Cleaning up
- rm -rf $tmpdir
done
+
+ # Cleaning up
+ rm -rf $tmpdir
}
echo -e "\n-------------------------------------------"
-echo -e "UST tracer - GLOBAL DOMAIN (LTTNG_DOMAIN_UST)"
+echo -e "UST tracer - Global domain (LTTNG_DOMAIN_UST)"
echo -e "---------------------------------------------"
-if [ -z $(pidof $SESSIOND_BIN) ]; then
- echo -n "Starting session daemon... "
- ../lttng-sessiond/$SESSIOND_BIN --daemonize --quiet
- if [ $? -eq 1 ]; then
- echo -e '\e[1;31mFAILED\e[0m'
- rm -rf $tmpdir
- exit 1
- else
- echo -e "\e[1;32mOK\e[0m"
- fi
-fi
-
PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
# Simply wait for the session daemon bootstrap
start_tests
-echo -e -n "\nKilling session daemon... "
-kill $PID_SESSIOND >/dev/null 2>&1
-if [ $? -eq 1 ]; then
- echo -e '\e[1;31mFAILED\e[0m'
-else
- echo -e "\e[1;32mOK\e[0m"
-fi
-
exit $exit_code
struct lttng_domain dom;
struct lttng_event event;
char *channel_name = "channel0";
+ char *session_name = "ust_global_all_events_basic";
int ret = 0;
dom.type = LTTNG_DOMAIN_UST;
}
printf("Creating tracing session (%s): ", argv[1]);
- if ((ret = lttng_create_session("test", argv[1])) < 0) {
+ 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("test", &dom)) == NULL) {
+ if ((handle = lttng_create_handle(session_name, &dom)) == NULL) {
printf("error creating handle: %s\n", lttng_strerror(ret));
goto handle_fail;
}
PRINT_OK();
printf("Start tracing: ");
- if ((ret = lttng_start_tracing("test")) < 0) {
+ if ((ret = lttng_start_tracing(session_name)) < 0) {
printf("error starting tracing: %s\n", lttng_strerror(ret));
goto start_fail;
}
sleep(2);
printf("Stop tracing: ");
- if ((ret = lttng_stop_tracing("test")) < 0) {
+ 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("test")) < 0) {
+ if ((ret = lttng_destroy_session(session_name)) < 0) {
printf("error destroying session: %s\n", lttng_strerror(ret));
}
PRINT_OK();
stop_fail:
start_fail:
enable_fail:
- lttng_destroy_session("test");
+ lttng_destroy_session(session_name);
lttng_destroy_handle(handle);
return 1;
int ret = 0;
- char *session_name = "ust_event_basic";
+ char *session_name = "ust_global_event_basic";
dom.type = LTTNG_DOMAIN_UST;
#### ADD TESTS HERE ####
-test_suite=( test_sessions test_kernel_data_trace test_ust_data_trace lttng/runall.sh )
+test_suite=( test_sessions test_kernel_data_trace test_ust_data_trace
+ lttng/runall.sh ust-nevents/run )
#### END TESTS HERE ####
+TESTDIR=$(dirname $0)
+
+source $TESTDIR/utils.sh
+
+start_sessiond
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+
for bin in ${test_suite[@]};
do
./$bin
if [ $? -ne 0 ]; then
echo -e '\e[1;31mFAIL\e[0m'
echo ""
+ stop_sessiond
exit 1
fi
done
echo ""
+stop_sessiond
exit 0
--- /dev/null
+/*
+ * 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 "lttng-sessiond/lttng-ust-abi.h"
+#include "lttng-share.h"
+#include "lttng-sessiond/trace-ust.h"
+#include "utils.h"
+
+/* This path will NEVER be created in this test */
+#define PATH1 "/tmp/.test-junk-lttng"
+
+/* For lttngerr.h */
+int opt_quiet = 1;
+int opt_verbose = 0;
+
+static const char alphanum[] =
+ "0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz";
+
+static struct ltt_ust_session *usess;
+static struct lttng_domain dom;
+
+/*
+ * Return random string of 10 characters.
+ */
+static char *get_random_string(void)
+{
+ int i;
+ char *str = malloc(11);
+
+ for (i = 0; i < 10; i++) {
+ str[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
+ }
+
+ str[10] = '\0';
+
+ return str;
+}
+
+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;
+
+ 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;
+
+ strncpy(ev.name, get_random_string(), LTTNG_SYMBOL_NAME_LEN);
+ ev.type = LTTNG_EVENT_TRACEPOINT;
+
+ 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 ctx;
+ struct ltt_ust_context *uctx;
+
+ printf("Creating UST context: ");
+ uctx = trace_ust_create_context(&ctx);
+ assert(uctx != NULL);
+ PRINT_OK();
+
+ printf("Validating UST context: ");
+ assert(ctx.ctx == uctx->ctx.ctx);
+ 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;
+}
--- /dev/null
+AM_CPPFLAGS = -llttng-ust -ldl -I. -O2
+
+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
--- /dev/null
+/*
+ * 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;
+}
--- /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
+
+TESTDIR=$(dirname $0)/..
+NR_ITER=100
+SESSION_NAME="ust-nevents"
+EVENT_NAME="ust_gen_nevents:tptest"
+TRACE_PATH=$(mktemp -d)
+
+source $TESTDIR/utils.sh
+
+echo -e "\n-----------------------------------"
+echo -e "UST tracer - Generate $NR_ITER events"
+echo -e "-------------------------------------"
+
+# 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
+./$(dirname $0)/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
--- /dev/null
+/*
+ * 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"
--- /dev/null
+#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
--- /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
+
+SESSIOND_BIN="lttng-sessiond"
+LTTNG_BIN="lttng"
+BABELTRACE_BIN="babeltrace"
+
+function start_sessiond ()
+{
+ if [ -z $(pidof $SESSIOND_BIN) ]; then
+ echo -n "Starting session daemon... "
+ $TESTDIR/../lttng-sessiond/$SESSIOND_BIN --daemonize --quiet
+ if [ $? -eq 1 ]; then
+ echo -e "\e[1;31mFAILED\e[0m"
+ return 1
+ else
+ echo -e "\e[1;32mOK\e[0m"
+ fi
+ fi
+}
+
+function stop_sessiond ()
+{
+ PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
+
+ echo -e -n "Killing session daemon... "
+ kill $PID_SESSIOND >/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 create_lttng_session ()
+{
+ sess_name=$1
+ trace_path=$2
+
+ echo -n "Creating lttng session $SESSION_NAME in $TRACE_PATH "
+ $TESTDIR/../lttng/$LTTNG_BIN create $sess_name -o $trace_path >/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"
+ #echo $out | grep "written in" | cut -d' ' -f6
+ fi
+}
+
+function enable_ust_lttng_event ()
+{
+ sess_name=$1
+ event_name=$2
+
+ echo -n "Enabling lttng event $event_name for session $sess_name "
+ $TESTDIR/../lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u >/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 start_tracing ()
+{
+ sess_name=$1
+
+ echo -n "Start lttng tracing for session $sess_name "
+ $TESTDIR/../lttng/$LTTNG_BIN start $sess_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 stop_tracing ()
+{
+ sess_name=$1
+
+ echo -n "Stop lttng tracing for session $sess_name "
+ $TESTDIR/../lttng/$LTTNG_BIN stop $sess_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 destroy_lttng_session ()
+{
+ sess_name=$1
+
+ echo -n "Destroy lttng session $sess_name "
+ $TESTDIR/../lttng/$LTTNG_BIN destroy $sess_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 trace_matches ()
+{
+ event_name=$1
+ nr_iter=$2
+ trace_path=$3
+
+ echo -n "Looking for $nr_iter $event_name in $trace_path "
+
+ count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
+ if [ "$count" -ne "$nr_iter" ]; then
+ echo -e "$count found in trace \e[1;31mFAILED\e[0m"
+ return 1
+ else
+ echo -e "Trace is coherent \e[1;32mOK\e[0m"
+ return 0
+ fi
+}