Add before-after test
authorDavid Goulet <dgoulet@efficios.com>
Mon, 2 Apr 2012 18:44:55 +0000 (14:44 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 2 Apr 2012 18:48:33 +0000 (14:48 -0400)
Test tracing before and after application execution.

Signed-off-by: David Goulet <dgoulet@efficios.com>
configure.ac
tests/test_list.py
tests/ust/Makefile.am
tests/ust/before-after/Makefile.am [new file with mode: 0644]
tests/ust/before-after/gen-nevents.c [new file with mode: 0644]
tests/ust/before-after/run [new file with mode: 0755]
tests/ust/before-after/tp.c [new file with mode: 0644]
tests/ust/before-after/ust_gen_nevents.h [new file with mode: 0644]
tests/ust/runall.sh

index d28dab8769c70f571a8c12a8df915c2320adcfd1..4e058510c40da1141ea0051bae5f24a42a74d3df 100644 (file)
@@ -201,6 +201,7 @@ AC_CONFIG_FILES([
        tests/ust/nprocesses/Makefile
        tests/ust/high-throughput/Makefile
        tests/ust/low-throughput/Makefile
+       tests/ust/before-after/Makefile
 ])
 
 AC_OUTPUT
index 375e07320e8408fffe3ea960e4861cd4992d9e41..238164a3fdcbeda15c051c879c4bbabaf8e2efd1 100644 (file)
@@ -59,4 +59,10 @@ Tests = \
     'success': 0, 'enabled': False
     # Deactivated. This test last 20 minutes...
     },
+    {
+    'bin': "ust/before-after/run", 'daemon': True, 'kern': False,
+    'name': "UST tracer - Tracing before and after app execution",
+    'desc': "Test tracing before and after app execution",
+    'success': 0, 'enabled': True
+    },
 ]
index 79f67cc06b73b54285fc95654dd02232c63d8805..1c8295cccf57ae59ece60ddcd6ef2db17a2e3708 100644 (file)
@@ -1,5 +1,5 @@
 if HAVE_LIBLTTNG_UST_CTL
-SUBDIRS = nevents nprocesses high-throughput
+SUBDIRS = nevents nprocesses high-throughput low-throughput before-after
 
 AM_CFLAGS = -g -Wall -I../
 AM_LDFLAGS = -lurcu -lurcu-cds
diff --git a/tests/ust/before-after/Makefile.am b/tests/ust/before-after/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/before-after/gen-nevents.c b/tests/ust/before-after/gen-nevents.c
new file mode 100644 (file)
index 0000000..b2c1992
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) - 2009 Pierre-Marc Fournier
+ * Copyright (C) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_gen_nevents.h"
+
+int main(int argc, char **argv)
+{
+       int i, netint;
+       long values[] = { 1, 2, 3 };
+       char text[10] = "test";
+       double dbl = 2.0;
+       float flt = 2222.0;
+       unsigned int nr_iter = 100;
+
+       if (argc == 2) {
+               nr_iter = atoi(argv[1]);
+       }
+
+       for (i = 0; i < nr_iter; i++) {
+               netint = htonl(i);
+               tracepoint(ust_gen_nevents, tptest, i, netint, values, text,
+                               strlen(text), dbl, flt);
+               usleep(100000);
+       }
+
+       return 0;
+}
diff --git a/tests/ust/before-after/run b/tests/ust/before-after/run
new file mode 100755 (executable)
index 0000000..9b16528
--- /dev/null
@@ -0,0 +1,120 @@
+#!/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="per-session"
+EVENT_NAME="ust_gen_nevents:tptest"
+
+source $TESTDIR/utils.sh
+
+echo -e "\n----------------------------------------------------"
+echo -e "UST tracer - Star tracing before and after execution"
+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_before_apps() {
+       local out
+
+       # BEFORE application is spawned
+       create_lttng_session $SESSION_NAME $TRACE_PATH
+       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+       start_tracing $SESSION_NAME
+       # Start test
+       echo -n "Starting application... "
+       ./$CURDIR/gen-nevents $NR_ITER
+       echo -e "Ended \e[1;32mOK\e[0m"
+       stop_tracing $SESSION_NAME
+       destroy_lttng_session $SESSION_NAME
+
+       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+
+       return $?
+}
+
+test_after_apps() {
+       local out
+
+       echo -n "Starting application... "
+       ./$CURDIR/gen-nevents 100 &
+       echo -e "\e[1;32mOK\e[0m"
+
+       # BEFORE application is spawned
+       create_lttng_session $SESSION_NAME $TRACE_PATH
+       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+       start_tracing $SESSION_NAME
+
+       # At least hit one event
+       sleep 2
+
+       stop_tracing $SESSION_NAME
+       destroy_lttng_session $SESSION_NAME
+
+       out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
+       if [ $out -eq 0 ]; then
+               echo -n "No event found. Suppose to have at least one... "
+               echo -e "\e[1;31mFAILED\e[0m"
+               out=1
+       else
+               echo -n "Found $out event(s). Coherent... "
+               echo -e "\e[1;32mOK\e[0m"
+               out=0
+       fi
+
+       return $out
+}
+
+# MUST set TESTDIR before calling those functions
+
+start_sessiond
+
+echo ""
+echo "=== Start application BEFORE tracing was started ==="
+
+TRACE_PATH=$(mktemp -d)
+
+test_before_apps
+out=$?
+if [ $out -ne 0 ]; then
+       stop_sessiond
+       exit $out
+fi
+
+rm -rf $TRACE_PATH
+
+echo ""
+echo "=== Start application AFTER tracing was started ==="
+
+TRACE_PATH=$(mktemp -d)
+
+test_after_apps
+out=$?
+if [ $out -ne 0 ]; then
+       stop_sessiond
+       exit $out
+fi
+
+stop_sessiond
+
+rm -rf $TRACE_PATH
diff --git a/tests/ust/before-after/tp.c b/tests/ust/before-after/tp.c
new file mode 100644 (file)
index 0000000..e291924
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
+ * IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program for any purpose,
+ * provided the above notices are retained on all copies.  Permission to modify
+ * the code and to distribute modified code is granted, provided the above
+ * notices are retained, and a notice that the code was modified is included
+ * with the above copyright notice.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_gen_nevents.h"
diff --git a/tests/ust/before-after/ust_gen_nevents.h b/tests/ust/before-after/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
index f47246fceaf07b7241b4222cdbd1c8a7ca828a7f..4aee65a9993e8c35a0d3ecda5f263d1294a9724f 100755 (executable)
@@ -3,7 +3,7 @@
 DIR=$(dirname $0)
 
 tests=( $DIR/run-ust-global-tests.sh $DIR/nevents/run $DIR/nprocesses/run \
-               $DIR/high-throughput/run )
+               $DIR/high-throughput/run $DIR/before-after/run )
 
 # $DIR/low-throughput/run --> DEACTIVATED.
 # Use only for release. This test last 20 minutes
This page took 0.043158 seconds and 4 git commands to generate.