Add low-throughput test
authorDavid Goulet <dgoulet@efficios.com>
Mon, 2 Apr 2012 15:57:23 +0000 (11:57 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 2 Apr 2012 15:57:23 +0000 (11:57 -0400)
Test during 20 minutes events at each minute, 10 minutes and 20 minutes.
It validates the event order with an incremental counter.

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

index b2dbe42682b8c4850f9dd898a6193439e5cd9567..d28dab8769c70f571a8c12a8df915c2320adcfd1 100644 (file)
@@ -200,6 +200,7 @@ AC_CONFIG_FILES([
        tests/ust/nevents/Makefile
        tests/ust/nprocesses/Makefile
        tests/ust/high-throughput/Makefile
+       tests/ust/low-throughput/Makefile
 ])
 
 AC_OUTPUT
index 80e76491d1edc38ab12cef26efa5546d9f978530..375e07320e8408fffe3ea960e4861cd4992d9e41 100644 (file)
@@ -52,4 +52,11 @@ Tests = \
     'desc': "Test multiple large number of events with concurrent application",
     'success': 0, 'enabled': True
     },
+    {
+    'bin': "ust/low-throughput/run", 'daemon': True, 'kern': False,
+    'name': "UST tracer - Testing high events throughput",
+    'desc': "Test low throughput of events",
+    'success': 0, 'enabled': False
+    # Deactivated. This test last 20 minutes...
+    },
 ]
diff --git a/tests/ust/low-throughput/Makefile.am b/tests/ust/low-throughput/Makefile.am
new file mode 100644 (file)
index 0000000..aefdf53
--- /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 -lurcu
+
+noinst_SCRIPTS = run
+EXTRA_DIST = run
diff --git a/tests/ust/low-throughput/main.c b/tests/ust/low-throughput/main.c
new file mode 100644 (file)
index 0000000..c8802e7
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * 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 <poll.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define TRACEPOINT_DEFINE
+#include "tp.h"
+
+/*
+ * Thread recording a tracepoint every minute for 20 minutes.
+ */
+static void *th_event_minute(void *data)
+{
+       int i;
+
+       /* Loop for 20 minutes */
+       for (i = 1; i < 21; i++) {
+               /* Sleep 60 seconds */
+               poll(NULL, 0, 60000);
+
+               /* 20 minutes tracepoint */
+               if ((i % 20) == 0) {
+                       tracepoint(tp, slow, i, "twenty");
+                       printf("Twenty: %d\n", i);
+               }
+
+               /* 10 minutes tracepoint */
+               if ((i % 10) == 0) {
+                       tracepoint(tp, slow, i, "ten");
+                       printf("Ten: %d\n", i);
+               }
+
+               /* 1 minute tracepoint */
+               tracepoint(tp, slow, i, "one");
+               printf("One: %d\n", i);
+       }
+
+       return NULL;
+}
+
+/*
+ * main
+ */
+int main(int argc, char **argv)
+{
+       int ret;
+       void *status;
+       pthread_t thread;
+
+       ret = pthread_create(&thread, NULL, th_event_minute, NULL);
+       if (ret != 0) {
+               perror("pthread_create event minute");
+               goto error;
+       }
+
+       ret = pthread_join(thread, &status);
+       if (ret != 0) {
+               perror("pthread_join");
+               goto error;
+       }
+
+       return 0;
+
+error:
+       return 1;
+}
diff --git a/tests/ust/low-throughput/run b/tests/ust/low-throughput/run
new file mode 100755 (executable)
index 0000000..8beaf60
--- /dev/null
@@ -0,0 +1,102 @@
+#!/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-events"
+SESSION_NAME="low-throughput"
+EVENT_NAME="tp:slow"
+
+source $TESTDIR/utils.sh
+
+echo -e "\n-------------------------------------------"
+echo -e "UST tracer - Testing low 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
+
+# This is going to take 20 minutes
+./$CURDIR/$BIN_NAME >/dev/null 2>&1
+
+stop_tracing $SESSION_NAME
+destroy_lttng_session $SESSION_NAME
+
+stop_sessiond
+
+# Validate test
+
+last_val=0
+out=0
+
+babeltrace $TRACE_PATH | while read event;
+do
+       val=$(echo $event | cut -f10 -d" ")
+       val=${val%?}
+       th=$(echo $event | cut -f13 -d " ")
+
+       if [ $th = '"one"' ]; then
+               ((last_val++))
+               # We expect here a continous value from 1 to 20
+               if [ $last_val -ne $val ]; then
+                       echo -n "[-] One minute event failed ($val) "
+                       out=1
+                       break
+               fi
+       elif [ $th = '"ten"' ]; then
+               # Test 10 minutes counter
+               if [ $val -ne 10 ]; then
+                       # Test 20 minutes counter
+                       if [ $val -ne 20 ]; then
+                               echo -n "[-] Ten minutes event failed ($val) "
+                               out=1
+                               break
+                       fi
+               fi
+       elif [ $th = '"twenty"' ]; then
+               # Test 20 minutes counter
+               if [ $val -ne 20 ]; then
+                       echo -n "[-] Twenty minutes event failed ($val) "
+                       out=1
+                       break
+               fi
+       fi
+done
+
+if [ $out -eq 0 ]; then
+       echo -n "Trace is coherent... "
+       echo -e "\e[1;32mOK\e[0m"
+else
+       echo -e "\e[1;31mFAILED\e[0m"
+fi
+
+rm -rf $TRACE_PATH
+
+exit $out
diff --git a/tests/ust/low-throughput/tp.c b/tests/ust/low-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/low-throughput/tp.h b/tests/ust/low-throughput/tp.h
new file mode 100644 (file)
index 0000000..74b908b
--- /dev/null
@@ -0,0 +1,45 @@
+#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, slow,
+       TP_ARGS(unsigned int, c, char *, thread_name),
+       TP_FIELDS(
+               ctf_integer(unsigned int, counter, c)
+               ctf_string(th_name, thread_name)
+       )
+)
+
+#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 514680b7a25fb60f8fa138eb03b25d8cab3e1743..f47246fceaf07b7241b4222cdbd1c8a7ca828a7f 100755 (executable)
@@ -4,6 +4,10 @@ DIR=$(dirname $0)
 
 tests=( $DIR/run-ust-global-tests.sh $DIR/nevents/run $DIR/nprocesses/run \
                $DIR/high-throughput/run )
+
+# $DIR/low-throughput/run --> DEACTIVATED.
+# Use only for release. This test last 20 minutes
+
 exit_code=0
 
 function start_tests ()
This page took 0.045266 seconds and 4 git commands to generate.