Tests: utils: add gen-ust-nevents-str util
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 17 Feb 2017 08:53:43 +0000 (03:53 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 5 May 2017 15:30:37 +0000 (11:30 -0400)
This program generates a given number of UST events, each one having
in its payload the next command-line argument string in a cycle:

    gen-ust-nevents-str 10 hello world its me

will generate 10 events with the following strings:

    hello
    world
    its
    me
    hello
    world
    its
    me
    hello
    world

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
tests/utils/testapp/Makefile.am
tests/utils/testapp/gen-ust-nevents-str/Makefile.am [new file with mode: 0644]
tests/utils/testapp/gen-ust-nevents-str/gen-ust-nevents-str.c [new file with mode: 0644]
tests/utils/testapp/gen-ust-nevents-str/tp.c [new file with mode: 0644]
tests/utils/testapp/gen-ust-nevents-str/tp.h [new file with mode: 0644]

index 22533939bf96a7b1473bad6e1f5f45955f4d5f2d..5c12509a4ebd4797c4adf455bf3845cdddd87d8f 100644 (file)
@@ -1083,6 +1083,7 @@ AC_CONFIG_FILES([
        tests/utils/testapp/Makefile
        tests/utils/testapp/gen-ust-events/Makefile
        tests/utils/testapp/gen-ust-nevents/Makefile
+       tests/utils/testapp/gen-ust-nevents-str/Makefile
        tests/utils/testapp/gen-ust-tracef/Makefile
 ])
 
index 0341de42b3879cf4e9a69b134625d9ecf306e2b5..84113a23c3176dd5f975f59f90cae3ce18ff7e62 100644 (file)
@@ -1,2 +1,2 @@
-SUBDIRS = gen-ust-events gen-ust-nevents gen-ust-tracef
+SUBDIRS = gen-ust-events gen-ust-nevents gen-ust-nevents-str gen-ust-tracef
 
diff --git a/tests/utils/testapp/gen-ust-nevents-str/Makefile.am b/tests/utils/testapp/gen-ust-nevents-str/Makefile.am
new file mode 100644 (file)
index 0000000..57f8350
--- /dev/null
@@ -0,0 +1,16 @@
+AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(srcdir) \
+               -I$(top_srcdir)/tests/utils -O2 -g
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+LIBS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+LIBS += -lc
+endif
+
+if HAVE_LIBLTTNG_UST_CTL
+noinst_PROGRAMS = gen-ust-nevents-str
+gen_ust_nevents_str_SOURCES = gen-ust-nevents-str.c tp.c tp.h
+gen_ust_nevents_str_LDADD = -llttng-ust -lurcu-bp \
+               $(top_builddir)/tests/utils/libtestutils.la
+endif
diff --git a/tests/utils/testapp/gen-ust-nevents-str/gen-ust-nevents-str.c b/tests/utils/testapp/gen-ust-nevents-str/gen-ust-nevents-str.c
new file mode 100644 (file)
index 0000000..6d90bfc
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) - 2017 Philippe Proulx <pproulx@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
+ */
+
+#define _LGPL_SOURCE
+#include <stdio.h>
+
+#define TRACEPOINT_DEFINE
+#include "tp.h"
+
+int main(int argc, char **argv)
+{
+       int count;
+       int i;
+       int arg_i;
+
+       if (argc <= 3) {
+               fprintf(stderr, "Usage: %s COUNT STRING [STRING]...\n",
+                       argv[0]);
+               return 1;
+       }
+
+       if (argc >= 2) {
+               count = atoi(argv[1]);
+       }
+
+       if (count < 0) {
+               return 0;
+       }
+
+       for (i = 0, arg_i = 2; i < count; i++) {
+               tracepoint(tp, the_string, i, arg_i, argv[arg_i]);
+
+               arg_i++;
+               if (arg_i == argc) {
+                       arg_i = 2;
+               }
+       }
+
+       return 0;
+}
diff --git a/tests/utils/testapp/gen-ust-nevents-str/tp.c b/tests/utils/testapp/gen-ust-nevents-str/tp.c
new file mode 100644 (file)
index 0000000..a73138b
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) - 2017 Philippe Proulx <pproulx@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
+ */
+
+#define _LGPL_SOURCE
+#define TRACEPOINT_CREATE_PROBES
+#include "tp.h"
diff --git a/tests/utils/testapp/gen-ust-nevents-str/tp.h b/tests/utils/testapp/gen-ust-nevents-str/tp.h
new file mode 100644 (file)
index 0000000..9f9ab95
--- /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
+
+/*
+ * Copyright (C) - 2017 Philippe Proulx <pproulx@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 <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(tp, the_string,
+       TP_ARGS(
+               int, i,
+               int, arg_i,
+               const char *, str
+       ),
+       TP_FIELDS(
+               ctf_integer(int, i, i)
+               ctf_integer(long, arg_i, arg_i)
+               ctf_string(str, str)
+       )
+)
+
+#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>
This page took 0.028678 seconds and 4 git commands to generate.