Tests: Cleanup and move gen-ust-events testapp under utils
authorChristian Babeux <christian.babeux@efficios.com>
Mon, 13 May 2013 22:30:51 +0000 (18:30 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 14 May 2013 14:18:34 +0000 (10:18 -0400)
This will improve the maintainability and stop the copying madness going
on in each test needing a UST sample application.

Application under test should go in tests/utils/testapp/<testapp_name>/.

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
configure.ac
tests/utils/Makefile.am
tests/utils/testapp/Makefile.am [new file with mode: 0644]
tests/utils/testapp/gen-ust-events/Makefile.am [new file with mode: 0644]
tests/utils/testapp/gen-ust-events/gen-ust-events.c [new file with mode: 0644]
tests/utils/testapp/gen-ust-events/tp.c [new file with mode: 0644]
tests/utils/testapp/gen-ust-events/tp.h [new file with mode: 0644]

index 02cea73f8d649157363018524761bf3e2c1ddf92..6f19e570b8f008c2aa3d3529bf10c1926d1236b4 100644 (file)
@@ -350,6 +350,8 @@ AC_CONFIG_FILES([
        tests/unit/Makefile
        tests/utils/Makefile
        tests/utils/tap/Makefile
+       tests/utils/testapp/Makefile
+       tests/utils/testapp/gen-ust-events/Makefile
 ])
 
 AC_OUTPUT
index 25c6e04c17088964e894f1e253e801bed522537c..e0de483ea7212ae1004034fb86189eb5d6e09db8 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = tap
+SUBDIRS = tap testapp
 
 EXTRA_DIST = utils.sh test_utils.py
 dist_noinst_SCRIPTS = utils.sh test_utils.py
diff --git a/tests/utils/testapp/Makefile.am b/tests/utils/testapp/Makefile.am
new file mode 100644 (file)
index 0000000..8b631ee
--- /dev/null
@@ -0,0 +1,2 @@
+SUBDIRS = gen-ust-events
+
diff --git a/tests/utils/testapp/gen-ust-events/Makefile.am b/tests/utils/testapp/gen-ust-events/Makefile.am
new file mode 100644 (file)
index 0000000..1be5835
--- /dev/null
@@ -0,0 +1,15 @@
+AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(srcdir) -O2 -g
+AM_LDFLAGS =
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+AM_LDFLAGS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+AM_LDFLAGS += -lc
+endif
+
+if HAVE_LIBLTTNG_UST_CTL
+noinst_PROGRAMS = gen-ust-events
+gen_ust_events_SOURCES = gen-ust-events.c tp.c tp.h
+gen_ust_events_LDADD = -llttng-ust
+endif
diff --git a/tests/utils/testapp/gen-ust-events/gen-ust-events.c b/tests/utils/testapp/gen-ust-events/gen-ust-events.c
new file mode 100644 (file)
index 0000000..edf40ee
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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 <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 "tp.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;
+       useconds_t nr_usec = 0;
+
+       if (argc >= 2) {
+               nr_iter = atoi(argv[1]);
+       }
+
+       if (argc == 3) {
+               /* By default, don't wait unless user specifies. */
+               nr_usec = atoi(argv[2]);
+       }
+
+       for (i = 0; i < nr_iter; i++) {
+               netint = htonl(i);
+               tracepoint(tp, tptest, i, netint, values, text, strlen(text),
+                          dbl, flt);
+               usleep(nr_usec);
+       }
+
+       return 0;
+}
diff --git a/tests/utils/testapp/gen-ust-events/tp.c b/tests/utils/testapp/gen-ust-events/tp.c
new file mode 100644 (file)
index 0000000..a09561d
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * 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 "tp.h"
diff --git a/tests/utils/testapp/gen-ust-events/tp.h b/tests/utils/testapp/gen-ust-events/tp.h
new file mode 100644 (file)
index 0000000..6ffbc32
--- /dev/null
@@ -0,0 +1,56 @@
+#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>
+ *
+ * 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(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)
+       )
+)
+
+#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
This page took 0.030822 seconds and 5 git commands to generate.