Add UST test ust-nprocesses
authorDavid Goulet <dgoulet@efficios.com>
Tue, 17 Jan 2012 18:38:48 +0000 (13:38 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 17 Jan 2012 18:38:48 +0000 (13:38 -0500)
Simple to test that launches 100 instrumented applications and validate
that they are all registered to the session daemon.

After that, one event is enabled, tracing starts/stops and finally the
tracing session gets destroyed.

Signed-off-by: David Goulet <dgoulet@efficios.com>
.gitignore
configure.ac
tests/Makefile.am
tests/runall.sh
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_gen_event.h [new file with mode: 0644]

index 9c70e0f58d4e01d7b8d01fb167789b08a3afc68d..afa8505786f06eb70de0cdff01247b8f247101bd 100644 (file)
@@ -43,5 +43,6 @@ 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
 
 benchmark/
index af522eeb0677665d3d0899fc8f7a8c966927743e..433e3ad9102c5756b393b57ed7c90bd5a8179d4c 100644 (file)
@@ -145,6 +145,7 @@ AC_CONFIG_FILES([
        lttng/Makefile
        tests/Makefile
        tests/ust-nevents/Makefile
+       tests/ust-nprocesses/Makefile
        doc/Makefile
 ])
 
index 96d4f6403ec359d2e957a2d57fcea2e3c09e1aa3..27c7c7744658fa73d574fe96d4189ce9a3c8bf07 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = . ust-nevents
+SUBDIRS = . ust-nevents ust-nprocesses
 
 AM_CFLAGS=-I$(top_srcdir)/include -I$(top_srcdir)/libkernelctl \
                  -I$(top_srcdir)/liblttngctl -g -Wall -lurcu -lurcu-cds
index 17be11817f31c69cfa53433835593f15bc1847ca..eadeeb912e6bc07df0fa18d990ed5c6a812ce094 100755 (executable)
@@ -20,7 +20,7 @@
 #### ADD TESTS HERE ####
 
 test_suite=( test_sessions test_kernel_data_trace test_ust_data_trace
-                       lttng/runall.sh ust-nevents/run )
+                       lttng/runall.sh ust-nevents/run ust-nprocesses/run )
 
 #### END TESTS HERE ####
 
diff --git a/tests/ust-nprocesses/Makefile.am b/tests/ust-nprocesses/Makefile.am
new file mode 100644 (file)
index 0000000..e1df41d
--- /dev/null
@@ -0,0 +1,8 @@
+AM_CPPFLAGS = -ldl -I. -O2
+
+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..dcaa379
--- /dev/null
@@ -0,0 +1,67 @@
+#!/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
+TEST_BIN_NAME="gen-events-time"
+SESSION_NAME="ust-nprocesses"
+EVENT_NAME="ust_gen_event:tptest"
+TRACE_PATH=$(mktemp -d)
+TEST_WAIT_SEC=3
+
+source $TESTDIR/utils.sh
+
+echo -e "\n-------------------------------------"
+echo -e "UST tracer - Generate $NR_ITER process"
+echo -e "---------------------------------------"
+
+# MUST set TESTDIR before calling those functions
+
+# Start test for 1000 seconds
+
+for i in `seq 1 $NR_ITER`
+do
+       ./$(dirname $0)/$TEST_BIN_NAME 1000 >/dev/null 2>&1 &
+done
+
+echo -n "Validating registered apps: "
+
+listing=$($TESTDIR/../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
+
+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"
+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
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_gen_event.h b/tests/ust-nprocesses/ust_gen_event.h
new file mode 100644 (file)
index 0000000..df53ccc
--- /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
This page took 0.030445 seconds and 4 git commands to generate.