Add high-throughput test
authorDavid Goulet <dgoulet@efficios.com>
Tue, 27 Mar 2012 20:04:27 +0000 (16:04 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 27 Mar 2012 21:43:00 +0000 (17:43 -0400)
This tests high number of events being recorded with multiple concurrent
instrumented applications.

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

index ac0b2f43346cb6219c2d521ee80f1471299892e7..b63da96a36a43e2818f0a9d1e468947055c1516e 100644 (file)
@@ -45,5 +45,6 @@ ust_global_all_events_basic
 ust_global_event_basic
 gen-nevents
 gen-events-time
+gen-events
 
 benchmark/
index f8518c568f62a63ead9d7c008fd7381c1ef942c2..b2dbe42682b8c4850f9dd898a6193439e5cd9567 100644 (file)
@@ -199,6 +199,7 @@ AC_CONFIG_FILES([
        tests/ust/Makefile
        tests/ust/nevents/Makefile
        tests/ust/nprocesses/Makefile
+       tests/ust/high-throughput/Makefile
 ])
 
 AC_OUTPUT
index bb9748afc2b2bc89a20f08808a316f5e7a272bb4..80e76491d1edc38ab12cef26efa5546d9f978530 100644 (file)
@@ -46,4 +46,10 @@ Tests = \
     'desc': "Test multiple events during tracing",
     'success': 0, 'enabled': True
     },
+    {
+    'bin': "ust/high-throughput/run", 'daemon': True, 'kern': False,
+    'name': "UST tracer - Testing high events throughput",
+    'desc': "Test multiple large number of events with concurrent application",
+    'success': 0, 'enabled': True
+    },
 ]
index 822e33c51f10f59329e715974ca0c43dcf592f72..300ebf15e10fb0623d00e483ea1691dab8bd3766 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = nevents nprocesses
+SUBDIRS = nevents nprocesses high-throughput
 
 AM_CFLAGS = -g -Wall -I../
 AM_LDFLAGS = -lurcu -lurcu-cds
diff --git a/tests/ust/high-throughput/Makefile.am b/tests/ust/high-throughput/Makefile.am
new file mode 100644 (file)
index 0000000..01d5ad2
--- /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-events
+gen_events_SOURCES = main.c tp.c tp.h
+gen_events_LDADD = -llttng-ust
+
+noinst_SCRIPTS = run
+EXTRA_DIST = run
diff --git a/tests/ust/high-throughput/main.c b/tests/ust/high-throughput/main.c
new file mode 100644 (file)
index 0000000..dbd2998
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2009  Pierre-Marc Fournier
+ * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@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 <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
+
+#define TRACEPOINT_DEFINE
+#include "tp.h"
+
+void inthandler(int sig)
+{
+}
+
+int init_int_handler(void)
+{
+       int result;
+       struct sigaction act;
+
+       memset(&act, 0, sizeof(act));
+       result = sigemptyset(&act.sa_mask);
+       if (result == -1) {
+               perror("sigemptyset");
+               return -1;
+       }
+
+       act.sa_handler = inthandler;
+       act.sa_flags = SA_RESTART;
+
+       /* Only defer ourselves. Also, try to restart interrupted
+        * syscalls to disturb the traced program as little as possible.
+        */
+       result = sigaction(SIGUSR1, &act, NULL);
+       if (result == -1) {
+               perror("sigaction");
+               return -1;
+       }
+
+       return 0;
+}
+
+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;
+       int delay = 0;
+
+       init_int_handler();
+
+       if (argc == 2)
+               delay = atoi(argv[1]);
+
+       sleep(delay);
+
+       for (i = 0; i < 1000000; i++) {
+               netint = htonl(i);
+               tracepoint(tp, tptest, i, netint, values, text,
+                               strlen(text), dbl, flt);
+       }
+
+       return 0;
+}
diff --git a/tests/ust/high-throughput/run b/tests/ust/high-throughput/run
new file mode 100755 (executable)
index 0000000..bc30c83
--- /dev/null
@@ -0,0 +1,91 @@
+#!/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=20
+BIN_NAME="gen-events"
+SESSION_NAME="high-throughput"
+EVENT_NAME="tp:tptest"
+
+source $TESTDIR/utils.sh
+
+echo -e "\n-------------------------------------------"
+echo -e "UST tracer - Testing high events throughput"
+echo -e "-------------------------------------------"
+
+if [ ! -e "$CURDIR/$BIN_NAME" ]; then
+       echo -e "No UST nevents binary detected. Passing."
+       exit 0
+fi
+
+TRACE_PATH=$(mktemp -d)
+
+# MUST set TESTDIR before calling those functions
+
+start_sessiond
+
+create_lttng_session $SESSION_NAME $TRACE_PATH
+
+enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+start_tracing $SESSION_NAME
+
+for i in `seq 1 $NR_ITER`; do
+       ./$CURDIR/$BIN_NAME & >/dev/null 2>&1
+done
+
+echo "Waiting for all tracing to settle"
+sleep 5
+
+stop_tracing $SESSION_NAME
+destroy_lttng_session $SESSION_NAME
+
+stop_sessiond
+
+# Validate test
+
+TEMP_FILE=$(mktemp)
+TEMP_FILE_2=$(mktemp)
+
+traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l)
+babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2
+
+cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE
+
+dropped=0
+while read line;
+do
+       let dropped=$dropped+$line
+done < $TEMP_FILE
+
+let total=$dropped+$traced
+let wanted=$NR_ITER*1000000
+
+if [ $wanted -ne $total ]; then
+       echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
+       echo -e "\e[1;31mFAILED\e[0m"
+       out=1
+else
+       echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
+       echo -e "\e[1;32mOK\e[0m"
+       out=0
+fi
+
+rm -rf $TRACE_PATH
+rm $TEMP_FILE $TEMP_FILE_2
+
+exit $out
diff --git a/tests/ust/high-throughput/tp.c b/tests/ust/high-throughput/tp.c
new file mode 100644 (file)
index 0000000..1d6cbda
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * tp.c
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "tp.h"
diff --git a/tests/ust/high-throughput/tp.h b/tests/ust/high-throughput/tp.h
new file mode 100644 (file)
index 0000000..23d4d25
--- /dev/null
@@ -0,0 +1,61 @@
+#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>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#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)
+       )
+)
+
+TRACEPOINT_EVENT(tp, tptest_sighandler,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+#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
index 78182cb92684aa6b7c74865dd42ef3334b6068a1..514680b7a25fb60f8fa138eb03b25d8cab3e1743 100755 (executable)
@@ -2,7 +2,8 @@
 
 DIR=$(dirname $0)
 
-tests=( $DIR/run-ust-global-tests.sh $DIR/nevents/run $DIR/nprocesses/run )
+tests=( $DIR/run-ust-global-tests.sh $DIR/nevents/run $DIR/nprocesses/run \
+               $DIR/high-throughput/run )
 exit_code=0
 
 function start_tests ()
This page took 0.031656 seconds and 4 git commands to generate.